8 #ifndef BRTOS_DEVICE_H_
9 #define BRTOS_DEVICE_H_
16 #include "OSDevConfig.h"
26 Device_Types_t device_type;
27 unsigned long base_address;
32 typedef const void *Device_Descriptor_t;
35 typedef size_t (*Device_Control_write_t)(Device_Descriptor_t
const device,
const void *pvBuffer,
const size_t xBytes );
36 typedef size_t (*Device_Control_read_t)(Device_Descriptor_t
const device,
void *pvBuffer,
const size_t xBytes );
37 typedef size_t (*Device_Control_set_t)(Device_Descriptor_t
const device, uint32_t ulRequest, uint32_t value );
38 typedef size_t (*Device_Control_get_t)(Device_Descriptor_t
const device, uint32_t ulRequest);
41 typedef struct device_api_t_{
42 Device_Control_write_t write;
43 Device_Control_read_t read;
44 Device_Control_set_t set;
45 Device_Control_get_t
get;
57 const device_api_t *api;
70 #ifndef OS_UART_DEVICE
71 #define OSOpenUART(x,y)
77 #define OSOpenSPI(x,y)
83 #define OSOpenI2C(x,y)
88 #ifndef OS_GPIO_DEVICE
89 #define OSOpenGPIO(x,y)
102 #define OSGPIOWrite(x,y,z) OSDevWrite(x, (const void *)(y), z)
103 #define OSGPIORead(x,y) OSDevRead(x, y, 0)
106 #define INF_TIMEOUT 0
108 #define NO_TIMEOUT (ostick_t)(MAX_TIMER - 1)
112 CTRL_ACQUIRE_READ_MUTEX = 10,
113 CTRL_ACQUIRE_WRITE_MUTEX,
114 CTRL_RELEASE_WRITE_MUTEX,
115 CTRL_RELEASE_READ_MUTEX
142 typedef struct uart_config_t_{
145 uart_stop_t stop_bits;
146 uart_irq_t polling_irq;
160 #define GPIO_PIN_0 0x00000001
161 #define GPIO_PIN_1 0x00000002
162 #define GPIO_PIN_2 0x00000004
163 #define GPIO_PIN_3 0x00000008
164 #define GPIO_PIN_4 0x00000010
165 #define GPIO_PIN_5 0x00000020
166 #define GPIO_PIN_6 0x00000040
167 #define GPIO_PIN_7 0x00000080
168 #define GPIO_PIN_8 0x00000100
169 #define GPIO_PIN_9 0x00000200
170 #define GPIO_PIN_10 0x00000400
171 #define GPIO_PIN_11 0x00000800
172 #define GPIO_PIN_12 0x00001000
173 #define GPIO_PIN_13 0x00002000
174 #define GPIO_PIN_14 0x00004000
175 #define GPIO_PIN_15 0x00008000
176 #define GPIO_PIN_16 0x00010000
177 #define GPIO_PIN_17 0x00020000
178 #define GPIO_PIN_18 0x00040000
179 #define GPIO_PIN_19 0x00080000
180 #define GPIO_PIN_20 0x00100000
181 #define GPIO_PIN_21 0x00200000
182 #define GPIO_PIN_22 0x00400000
183 #define GPIO_PIN_23 0x00800000
184 #define GPIO_PIN_24 0x01000000
185 #define GPIO_PIN_25 0x02000000
186 #define GPIO_PIN_26 0x04000000
187 #define GPIO_PIN_27 0x08000000
188 #define GPIO_PIN_28 0x10000000
189 #define GPIO_PIN_29 0x20000000
190 #define GPIO_PIN_30 0x40000000
191 #define GPIO_PIN_31 0x80000000
194 typedef struct gpio_config_t_{
195 unsigned long used_pins_in;
196 unsigned long used_pins_out;
198 unsigned long irq_pins;
201 typedef struct mux_gpio_config_t_{
204 unsigned long pin_number;
210 #ifndef PWM_MODE_EDGE_ALIGNED1
211 #define PWM_MODE_EDGE_ALIGNED1 0x00000000
217 #ifndef PWM_MODE_EDGE_ALIGNED2
218 #define PWM_MODE_EDGE_ALIGNED2 0x00000001
224 #ifndef PWM_MODE_CENTER_ALIGNED1
225 #define PWM_MODE_CENTER_ALIGNED1 0x00000002
231 #ifndef PWM_MODE_CENTER_ALIGNED2
232 #define PWM_MODE_CENTER_ALIGNED2 0x00000003
235 typedef struct pwm_config_t_{
Static device information (In ROM) Per driver instance.
Definition: device.h:24
BRTOS kernel main defines, functions prototypes and structs declaration.
Runtime device structure (In memory) Per driver instance.
Definition: device.h:54