- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there an API provided to support critical sections on the CYW920721?
I want to share some variables between threads and the interrupt callback context. I don't know if the interrupt callback is running in a thread or ISR. In either case, from what I've seen in the documentation the threading is preemptive, so my question is does the Modus Bluetooth SDK support critical sections where all interrupts are temporarily disabled?
I think this is needed to prevent race-conditions in the use of shared variables.
What are the functions for enabling/disabling global interrupts?
Thanks
Solved! Go to Solution.
- Labels:
-
ModusToolbox Bluetooth SDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @bt_fw_eng ,
1. To disable the callback, you need to pass NULL to the call back registering function
wiced_hal_puart_register_interrupt(NULL).
To re-enable the callback function:
wiced_hal_puart_reset_puart_interrupt();
wiced_hal_puart_register_interrupt(puart_rx_interrupt_callback);
2. Disabling the callback function will not disable the PUART from receiving data in to the RX FIFO.
3. The RX FIFO of PUART is 256 bytes. You can find this information in the device datasheet.
If you don't want to disable interrupts, you could simply implement a lock variable (mutex) to ensure that such race conditions don't happen. If the lock variable is set, you can't access the shared variable.
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @bt_fw_eng,
We do not have APIs to disable global interrupts or to enter critical sections.
Can you please let us know which peripheral interrupt you are referring to here? Is it possible for you to disable the callback of only that interrupt so that you can prevent it from executing when you are modifying that variable in the task?
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm referring to the Peripheral UART. Your reply raises the following questions.
1. How do you disable the PUART receive callback?
2. Will disabling the callback also disable the PUART receiving data?
3. What is the size in bytes of the PUART receive FIFO?
Thanks,
bt_fw_eng
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @bt_fw_eng ,
1. To disable the callback, you need to pass NULL to the call back registering function
wiced_hal_puart_register_interrupt(NULL).
To re-enable the callback function:
wiced_hal_puart_reset_puart_interrupt();
wiced_hal_puart_register_interrupt(puart_rx_interrupt_callback);
2. Disabling the callback function will not disable the PUART from receiving data in to the RX FIFO.
3. The RX FIFO of PUART is 256 bytes. You can find this information in the device datasheet.
If you don't want to disable interrupts, you could simply implement a lock variable (mutex) to ensure that such race conditions don't happen. If the lock variable is set, you can't access the shared variable.
Bragadeesh