X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fkernel%2Fao.h;h=b3f780f5c7609797c15c895e90b0fa965dcf1a44;hb=b0ea39f7eb18aa73160b0b848a9000892f43c0e7;hp=bf4b18396a65e89c946aee34a3f4de70c652dcd2;hpb=bdf0671cb36daca741c4842a37a3fc71744a63a2;p=fw%2Faltos diff --git a/src/kernel/ao.h b/src/kernel/ao.h index bf4b1839..b3f780f5 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -40,6 +40,11 @@ extern char ao_getchar(void); #define HAS_TASK 1 #endif +#ifndef AO_GPIO_TYPE +#define AO_GPIO_TYPE void * +#endif + +typedef AO_GPIO_TYPE ao_gpio_t; typedef AO_PORT_TYPE ao_port_t; #ifndef AO_TICK_TYPE @@ -113,6 +118,7 @@ extern volatile AO_TICK_TYPE ao_tick_count; #endif #define AO_MS_TO_TICKS(ms) ((ms) / (1000 / AO_HERTZ)) #define AO_SEC_TO_TICKS(s) ((AO_TICK_TYPE) (s) * AO_HERTZ) +#define AO_NS_TO_TICKS(ns) ((ns) / (1000000000L / AO_HERTZ)) /* Returns the current time in ticks */ AO_TICK_TYPE @@ -390,6 +396,7 @@ ao_spi_slave(void); extern uint8_t ao_gps_new; extern AO_TICK_TYPE ao_gps_tick; +extern AO_TICK_TYPE ao_gps_utc_tick; extern uint8_t ao_gps_mutex; extern struct ao_telemetry_location ao_gps_data; extern struct ao_telemetry_satellite ao_gps_tracking_data; @@ -531,7 +538,7 @@ struct ao_telemetry_tiny_recv { * for reporting RSSI. So, now we use these values everywhere */ #define AO_RSSI_FROM_RADIO(radio) ((int16_t) ((int8_t) (radio) >> 1) - 74) -#define AO_RADIO_FROM_RSSI(rssi) (((int8_t) (rssi) + 74) << 1) +#define AO_RADIO_FROM_RSSI(rssi) ((uint8_t) (((rssi) + 74) << 1)) /* * ao_radio_recv tacks on rssi and status bytes @@ -828,15 +835,15 @@ struct ao_fifo { char fifo[AO_FIFO_SIZE]; }; -#define ao_fifo_insert(f,c) do { \ - (f).fifo[(f).insert] = (c); \ - (f).insert = ((f).insert + 1) & (AO_FIFO_SIZE-1); \ -} while(0) +#define ao_fifo_insert(f,c) do { \ + (f).fifo[(f).insert] = (char) (c); \ + (f).insert = ((f).insert + 1) & (AO_FIFO_SIZE-1); \ + } while(0) -#define ao_fifo_remove(f,c) do {\ - c = (f).fifo[(f).remove]; \ - (f).remove = ((f).remove + 1) & (AO_FIFO_SIZE-1); \ -} while(0) +#define ao_fifo_remove(f,c) do { \ + c = (f).fifo[(f).remove]; \ + (f).remove = ((f).remove + 1) & (AO_FIFO_SIZE-1); \ + } while(0) #define ao_fifo_full(f) ((((f).insert + 1) & (AO_FIFO_SIZE-1)) == (f).remove) #define ao_fifo_mostly(f) ((((f).insert - (f).remove) & (AO_FIFO_SIZE-1)) >= (AO_FIFO_SIZE * 3 / 4))