Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

Messaging Framework Issue - Posting messages in IRQ

$
0
0

Hi.  I am brand new to the Synergy platform and am trying to learn some of the basics.  Working with the messaging framework I am having a problem and am hoping someone can provide some insight.  I can acquire buffers, post, process and release as expected, but when I try to post a message from an external interrupt callback function it breaks.

I started this exploration with the messaging framework demo: an-r11an0096eu0102-synergy-message-fw-mod-guide

After getting a hang of it, I wrote my own basic message posting code here:

/* Acquire a buffer for ONCE for messages since handle_message() does not release the buffer */
err = g_sf_message.p_api->bufferAcquire(g_sf_message.p_ctrl, &p_buffer, &g_acquire_cfg, 300);

while (SSP_SUCCESS != err){}

while (1)
{

/* Load message data */

p_buffer->event_b.class_instance = 0;
p_buffer->event_b.class_code = (uint32_t) SF_MESSAGE_EVENT_CLASS_LED1;
p_buffer->event_b.code = toggle_state(&g_led_state[0], SF_MESSAGE_EVENT_LED1_ON, SF_MESSAGE_EVENT_LED1_OFF);

/* Send a message */
err = g_sf_message.p_api->post(g_sf_message.p_ctrl, (sf_message_header_t *) p_buffer, &g_post_cfg, &g_err_post, 300);
while (SSP_SUCCESS != err){}
tx_thread_sleep(10);
}

 

This works as expected and in this example flashes LED1 only.

Now, I wanted to make a switch event on external IRQ perform this same function by posting the LED event message.

 

Changing the thread code to the following:

/* Acquire a buffer for ONCE for messages since handle_message() does not release the buffer */
err = g_sf_message.p_api->bufferAcquire(g_sf_message.p_ctrl, &p_buffer, &g_acquire_cfg, 300);

while (SSP_SUCCESS != err){}

while (1)
{

tx_thread_sleep(10);
}

 

 

and adding this switch callback function for my external irq event:

 

void switch_callback(external_irq_callback_args_t * p_args)
{

ssp_err_t err;

p_buffer->event_b.class_instance = 0;
p_buffer->event_b.class_code = (uint32_t) SF_MESSAGE_EVENT_CLASS_LED1;
p_buffer->event_b.code = toggle_state(&g_led_state[0], SF_MESSAGE_EVENT_LED1_ON, SF_MESSAGE_EVENT_LED1_OFF);

/* Send a message */
err = g_sf_message.p_api->post(g_sf_message.p_ctrl, (sf_message_header_t *) p_buffer, &g_post_cfg, &g_err_post, 300);
while (SSP_SUCCESS != err){}

}

 

This doesn't work.  The post call returns SSP_ERR_INTERNAL.  Anyone have a suggestion?  Thanks!


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>