From 6f561bc19160ea63ac4a4a303975aa97f74d1ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 2 Jan 2018 19:57:40 +0100 Subject: [PATCH] updated plat compat --- platform/plat_compat.h | 26 ++++++++++++++++---------- units/neopixel/ws2812.c | 11 +++++++---- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/platform/plat_compat.h b/platform/plat_compat.h index 36f3f19..551e100 100644 --- a/platform/plat_compat.h +++ b/platform/plat_compat.h @@ -41,8 +41,6 @@ #define TF_PARSER_TIMEOUT_TICKS 100 // Timeout for receiving & parsing a frame #define BULK_LST_TIMEOUT_MS 200 // timeout for the bulk transaction to expire - - // -------- Platform specific includes and defines --------- /// Feature flags: @@ -57,6 +55,7 @@ // platform name for the version string #define GEX_PLATFORM "STM32F103-Bluepill" + #define PLAT_AHB_CLOCK 72e6 // feature flags #define PLAT_FLASHBANKS 1 @@ -95,9 +94,9 @@ // Number of GPIO ports A,B,C... #define PORTS_COUNT 5 - // Lock jumper config - #define LOCK_JUMPER_PORT 'C' - #define LOCK_JUMPER_PIN 14 + // Lock jumper config - re-use BOOT1, closed = LOW + #define LOCK_JUMPER_PORT 'B' + #define LOCK_JUMPER_PIN 2 // Status LED config #define STATUS_LED_PORT 'C' @@ -107,6 +106,7 @@ // platform name for the version string #define GEX_PLATFORM "STM32F072-Discovery" + #define PLAT_AHB_CLOCK 48e6 #include #include @@ -153,6 +153,7 @@ // platform name for the version string #define GEX_PLATFORM "STM32F303-Discovery" + #define PLAT_AHB_CLOCK 72e6 #include #include @@ -189,8 +190,10 @@ #define PORTS_COUNT 6 // Lock jumper config - #define LOCK_JUMPER_PORT 'F' - #define LOCK_JUMPER_PIN 1 // OSC OUT, not used in BYPASS mode (receiving clock from the ST-Link MCO) + #define LOCK_JUMPER_PORT 'A' + #define LOCK_JUMPER_PIN 0 + #define PLAT_LOCK_BTN 1 // toggle button instead of a jumper + #define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1 // Status LED config #define STATUS_LED_PORT 'E' @@ -198,8 +201,9 @@ #elif defined(GEX_PLAT_F407_DISCOVERY) -// platform name for the version string + // platform name for the version string #define GEX_PLATFORM "STM32F407-Discovery" + #define PLAT_AHB_CLOCK 168e6 #define PLAT_USB_PHYCLOCK 1 #define PLAT_USB_OTGFS 1 @@ -239,8 +243,10 @@ #define PORTS_COUNT 6 // Lock jumper config - #define LOCK_JUMPER_PORT 'C' - #define LOCK_JUMPER_PIN 14 // completely random choice here... TBD + #define LOCK_JUMPER_PORT 'A' + #define LOCK_JUMPER_PIN 0 + #define PLAT_LOCK_BTN 1 // toggle button instead of a jumper + #define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1 // Status LED config #define STATUS_LED_PORT 'D' // orange diff --git a/units/neopixel/ws2812.c b/units/neopixel/ws2812.c index 6c764d0..9ecea62 100644 --- a/units/neopixel/ws2812.c +++ b/units/neopixel/ws2812.c @@ -1,6 +1,9 @@ #include "platform.h" #include "ws2812.h" +#define PLAT_NEOPIXEL_SHORT (uint32_t)(800e-9*PLAT_AHB_CLOCK) +#define PLAT_NEOPIXEL_LONG (uint32_t)(400e-9*PLAT_AHB_CLOCK) + static //inline __attribute__((always_inline)) void ws2812_byte(GPIO_TypeDef *port, uint32_t ll_pin, uint8_t b) { @@ -9,16 +12,16 @@ void ws2812_byte(GPIO_TypeDef *port, uint32_t ll_pin, uint8_t b) // duty cycle determines bit value if (b & 0x80) { - __delay_cycles(20); + __delay_cycles(PLAT_NEOPIXEL_LONG); //for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop"); LL_GPIO_ResetOutputPin(port, ll_pin); //for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop"); - __delay_cycles(10); + __delay_cycles(PLAT_NEOPIXEL_SHORT); } else { - __delay_cycles(10); + __delay_cycles(PLAT_NEOPIXEL_SHORT); //for(uint32_t _i = 0; _i < 5; _i++) asm volatile("nop"); LL_GPIO_ResetOutputPin(port, ll_pin); - __delay_cycles(20); + __delay_cycles(PLAT_NEOPIXEL_LONG); //for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop"); }