X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Flpc%2Fao_arch.h;h=59f3a7eee4983a94fee99c4bf19d716725010811;hb=09a3c086dae1cce43c843626a1c624b4e2ad8d04;hp=c638aa22b9658846a0a4319daec94b377706b6d4;hpb=2108da105ed9c915fc09d1251dc655bf11203d79;p=fw%2Faltos diff --git a/src/lpc/ao_arch.h b/src/lpc/ao_arch.h index c638aa22..59f3a7ee 100644 --- a/src/lpc/ao_arch.h +++ b/src/lpc/ao_arch.h @@ -29,6 +29,7 @@ #define AO_STACK_SIZE 512 #endif +#define AO_GPIO_TYPE uint8_t #define AO_PORT_TYPE uint32_t #define AO_LED_TYPE AO_PORT_TYPE @@ -103,18 +104,28 @@ ao_serial_init(void); /* SPI definitions */ -#define AO_SPI_SPEED_12MHz 4 -#define AO_SPI_SPEED_8MHz 6 -#define AO_SPI_SPEED_6MHz 8 -#define AO_SPI_SPEED_4MHz 12 -#define AO_SPI_SPEED_2MHz 24 -#define AO_SPI_SPEED_1MHz 48 -#define AO_SPI_SPEED_500kHz 96 -#define AO_SPI_SPEED_250kHz 192 -#define AO_SPI_SPEED_125kHz 384 -#define AO_SPI_SPEED_62500Hz 768 - -#define AO_SPI_SPEED_FAST AO_SPI_SPEED_12MHz +#define _AO_SPI_SPEED_12MHz 4 +#define _AO_SPI_SPEED_8MHz 6 +#define _AO_SPI_SPEED_6MHz 8 +#define _AO_SPI_SPEED_4MHz 12 +#define _AO_SPI_SPEED_2MHz 24 +#define _AO_SPI_SPEED_1MHz 48 +#define _AO_SPI_SPEED_500kHz 96 +#define _AO_SPI_SPEED_250kHz 192 +#define _AO_SPI_SPEED_125kHz 384 +#define _AO_SPI_SPEED_62500Hz 768 + +static inline uint32_t +ao_spi_speed(uint32_t hz) +{ + if (hz >= 4000000) return _AO_SPI_SPEED_4MHz; + if (hz >= 2000000) return _AO_SPI_SPEED_2MHz; + if (hz >= 1000000) return _AO_SPI_SPEED_1MHz; + if (hz >= 500000) return _AO_SPI_SPEED_500kHz; + if (hz >= 250000) return _AO_SPI_SPEED_250kHz; + if (hz >= 125000) return _AO_SPI_SPEED_125kHz; + return _AO_SPI_SPEED_62500Hz; +} #define AO_BOOT_APPLICATION_BASE ((uint32_t *) 0x00001000) #define AO_BOOT_APPLICATION_BOUND ((uint32_t *) (0x00000000 + 32 * 1024))