Embedded Wireless Framework
ewf_platform_bare_metal.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_platform_bare_metal__h__included__
10 #define __ewf_platform_bare_metal__h__included__
11 
12 #include "ewf_platform.h"
13 
14 #ifndef EWF_PLATFORM_BARE_METAL
15 #error EWF_PLATFORM_BARE_METAL must be defined before including this file
16 #endif
17 
18 #include <stdint.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #ifndef EWF_PLATFORM_TICKS_PER_SECOND
26 #define EWF_PLATFORM_TICKS_PER_SECOND (1000)
27 #endif
28 
29 #ifndef EWF_PLATFORM_BUSY_WAIT
37 #define EWF_PLATFORM_BUSY_WAIT(count) \
38 do { \
39  static volatile uint32_t i, j, x; \
40  for (i = 0, x = 0; i < count; i++) \
41  for (j = 0; j < 1024; j++) \
42  x += i + j; \
43 } while(0)
44 #endif
45 
46 #if defined(__CORTEX_M) /* Generic Cortex-M CMSIS*/
47 
48 #define EWF_PLATFORM_INTERRUPT_DISABLE() __disable_irq()
49 #define EWF_PLATFORM_INTERRUPT_ENABLE() __enable_irq()
50 
51 #define EWF_PLATFORM_INTERRUPT_STATE_TYPE uint32_t
52 
53 #define EWF_PLATFORM_INTERRUPT_STATE_TYPE_GET() __get_PRIMASK()
54 #define EWF_PLATFORM_INTERRUPT_STATE_TYPE_SET(state) __set_PRIMASK(state)
55 
56 #elif defined(__IAR_SYSTEMS_ICC__) /* Generic IAR */
57 
58 #define EWF_PLATFORM_INTERRUPT_DISABLE() __disable_interrupt()
59 #define EWF_PLATFORM_INTERRUPT_ENABLE() __enable_interrupt()
60 
61 #define EWF_PLATFORM_INTERRUPT_STATE_TYPE __istate_t
62 
63 #define EWF_PLATFORM_INTERRUPT_STATE_TYPE_GET() __get_interrupt_state()
64 #define EWF_PLATFORM_INTERRUPT_STATE_TYPE_SET(state) __set_interrupt_state(state)
65 
66 #else
67 
68 // Insert other bare metal implementations here
69 #error "Bare metal platform not implemented! (yet)"
70 
71 #endif
72 
74 {
75  void* data;
76  uint32_t item_size;
77  volatile uint32_t queue_size;
78  volatile uint32_t tail_index;
79  volatile uint32_t used_count;
80 };
81 
89 #define EWF_PLATFORM_QUEUE_STATIC_DECLARE(queue_ptr, queue_name_symb, item_type, item_count) \
90 do { \
91 static uint8_t ewf_platform_queue__buffer__##queue_name_symb[sizeof(item_type) * item_count]; \
92 static ewf_platform_queue ewf_platform_queue__##queue_name_symb = {0}; \
93 ewf_platform_queue__##queue_name_symb.data = ewf_platform_queue__buffer__##queue_name_symb; \
94 ewf_platform_queue__##queue_name_symb.item_size = sizeof(item_type); \
95 ewf_platform_queue__##queue_name_symb.queue_size = item_count; \
96 ewf_platform_queue__##queue_name_symb.tail_index = 0; \
97 ewf_platform_queue__##queue_name_symb.used_count = 0; \
98 queue_ptr = &(ewf_platform_queue__##queue_name_symb); \
99 } while(0)
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* __ewf_platform_bare_metal__h__included__ */
The Embedded Wireless Framework Software Platform API.
The platform queue structure.
Definition: ewf_platform_bare_metal.h:74