updated plat compat

sipo
Ondřej Hruška 7 years ago
parent dcf0037b83
commit 6f561bc191
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 24
      platform/plat_compat.h
  2. 11
      units/neopixel/ws2812.c

@ -41,8 +41,6 @@
#define TF_PARSER_TIMEOUT_TICKS 100 // Timeout for receiving & parsing a frame #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 #define BULK_LST_TIMEOUT_MS 200 // timeout for the bulk transaction to expire
// -------- Platform specific includes and defines --------- // -------- Platform specific includes and defines ---------
/// Feature flags: /// Feature flags:
@ -57,6 +55,7 @@
// platform name for the version string // platform name for the version string
#define GEX_PLATFORM "STM32F103-Bluepill" #define GEX_PLATFORM "STM32F103-Bluepill"
#define PLAT_AHB_CLOCK 72e6
// feature flags // feature flags
#define PLAT_FLASHBANKS 1 #define PLAT_FLASHBANKS 1
@ -95,9 +94,9 @@
// Number of GPIO ports A,B,C... // Number of GPIO ports A,B,C...
#define PORTS_COUNT 5 #define PORTS_COUNT 5
// Lock jumper config // Lock jumper config - re-use BOOT1, closed = LOW
#define LOCK_JUMPER_PORT 'C' #define LOCK_JUMPER_PORT 'B'
#define LOCK_JUMPER_PIN 14 #define LOCK_JUMPER_PIN 2
// Status LED config // Status LED config
#define STATUS_LED_PORT 'C' #define STATUS_LED_PORT 'C'
@ -107,6 +106,7 @@
// platform name for the version string // platform name for the version string
#define GEX_PLATFORM "STM32F072-Discovery" #define GEX_PLATFORM "STM32F072-Discovery"
#define PLAT_AHB_CLOCK 48e6
#include <stm32f0xx.h> #include <stm32f0xx.h>
#include <stm32f0xx_ll_adc.h> #include <stm32f0xx_ll_adc.h>
@ -153,6 +153,7 @@
// platform name for the version string // platform name for the version string
#define GEX_PLATFORM "STM32F303-Discovery" #define GEX_PLATFORM "STM32F303-Discovery"
#define PLAT_AHB_CLOCK 72e6
#include <stm32f3xx.h> #include <stm32f3xx.h>
#include <stm32f3xx_hal.h> #include <stm32f3xx_hal.h>
@ -189,8 +190,10 @@
#define PORTS_COUNT 6 #define PORTS_COUNT 6
// Lock jumper config // Lock jumper config
#define LOCK_JUMPER_PORT 'F' #define LOCK_JUMPER_PORT 'A'
#define LOCK_JUMPER_PIN 1 // OSC OUT, not used in BYPASS mode (receiving clock from the ST-Link MCO) #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 // Status LED config
#define STATUS_LED_PORT 'E' #define STATUS_LED_PORT 'E'
@ -200,6 +203,7 @@
// platform name for the version string // platform name for the version string
#define GEX_PLATFORM "STM32F407-Discovery" #define GEX_PLATFORM "STM32F407-Discovery"
#define PLAT_AHB_CLOCK 168e6
#define PLAT_USB_PHYCLOCK 1 #define PLAT_USB_PHYCLOCK 1
#define PLAT_USB_OTGFS 1 #define PLAT_USB_OTGFS 1
@ -239,8 +243,10 @@
#define PORTS_COUNT 6 #define PORTS_COUNT 6
// Lock jumper config // Lock jumper config
#define LOCK_JUMPER_PORT 'C' #define LOCK_JUMPER_PORT 'A'
#define LOCK_JUMPER_PIN 14 // completely random choice here... TBD #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 // Status LED config
#define STATUS_LED_PORT 'D' // orange #define STATUS_LED_PORT 'D' // orange

@ -1,6 +1,9 @@
#include "platform.h" #include "platform.h"
#include "ws2812.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)) static //inline __attribute__((always_inline))
void ws2812_byte(GPIO_TypeDef *port, uint32_t ll_pin, uint8_t b) 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 // duty cycle determines bit value
if (b & 0x80) { if (b & 0x80) {
__delay_cycles(20); __delay_cycles(PLAT_NEOPIXEL_LONG);
//for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop"); //for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop");
LL_GPIO_ResetOutputPin(port, ll_pin); LL_GPIO_ResetOutputPin(port, ll_pin);
//for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop"); //for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop");
__delay_cycles(10); __delay_cycles(PLAT_NEOPIXEL_SHORT);
} else { } else {
__delay_cycles(10); __delay_cycles(PLAT_NEOPIXEL_SHORT);
//for(uint32_t _i = 0; _i < 5; _i++) asm volatile("nop"); //for(uint32_t _i = 0; _i < 5; _i++) asm volatile("nop");
LL_GPIO_ResetOutputPin(port, ll_pin); 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"); //for(uint32_t _i = 0; _i < 10; _i++) asm volatile("nop");
} }

Loading…
Cancel
Save