#include "sender1_thread.h"
#include "blinky_thread.h"
extern bsp_leds_t leds;

/* Sender1 Thread entry function */
void sender1_thread_entry(void)
{
    uint32_t count=0;     //to get mutex count
    uint32_t msg[2] = {0xAA,0x55};
    while (1)
    {
        tx_mutex_info_get(&g_mutex0,TX_NULL,&count,TX_NULL,TX_NULL,TX_NULL,TX_NULL);
        // RED LED indicates blocking
        if(count) {
            g_ioport.p_api->pinWrite(leds.p_leds[1], IOPORT_LEVEL_LOW);
        } else {
            g_ioport.p_api->pinWrite(leds.p_leds[1], IOPORT_LEVEL_HIGH);
        }
        tx_mutex_get(&g_mutex0,TX_WAIT_FOREVER);
        g_ioport.p_api->pinWrite(leds.p_leds[2], IOPORT_LEVEL_LOW);
        tx_queue_send(&g_queue0,msg,TX_WAIT_FOREVER);
        tx_thread_sleep(40);
        tx_mutex_put(&g_mutex0);
        g_ioport.p_api->pinWrite(leds.p_leds[2], IOPORT_LEVEL_HIGH);

        tx_thread_sleep(50);
    }
}
