compat with 072hub

dac
Ondřej Hruška 7 years ago
parent 76d1cd3a24
commit 274f2be6e0
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      FreeRTOSConfig.h
  2. 12
      USB/usbd_conf.c
  3. 2
      platform/debug_uart.c
  4. 27
      platform/plat_compat.h
  5. 14
      platform/platform.c
  6. 2
      units/i2c/_i2c_init.c
  7. 2
      units/i2c/_i2c_settings.c
  8. 34
      units/spi/_spi_init.c
  9. 6
      units/spi/_spi_settings.c
  10. 2
      units/usart/_usart_init.c
  11. 2
      units/usart/_usart_settings.c

@ -151,7 +151,7 @@ to exclude the API function. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#elif defined(GEX_PLAT_F072_DISCOVERY)
#elif defined(STM32F072xB)
// This is for F072
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 3
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 1

@ -84,13 +84,13 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
__HAL_RCC_USB_CLK_ENABLE();
/* Peripheral interrupt init */
#if defined(GEX_PLAT_F103_BLUEPILL)
#if GEX_PLAT_F103_BLUEPILL
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
#elif defined(GEX_PLAT_F072_DISCOVERY)
#elif STM32F072xB
HAL_NVIC_SetPriority(USB_IRQn, 3, 0);
HAL_NVIC_EnableIRQ(USB_IRQn);
#elif defined(GEX_PLAT_F303_DISCOVERY)
#elif GEX_PLAT_F303_DISCOVERY
// Pins need to be configured here
/**USB GPIO Configuration
@ -149,11 +149,11 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
__HAL_RCC_USB_CLK_DISABLE();
/* Peripheral interrupt Deinit*/
#if defined(GEX_PLAT_F103_BLUEPILL)
#if GEX_PLAT_F103_BLUEPILL
HAL_NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn);
#elif defined(GEX_PLAT_F072_DISCOVERY)
#elif STM32F072xB
HAL_NVIC_DisableIRQ(USB_IRQn);
#elif defined(GEX_PLAT_F303_DISCOVERY)
#elif GEX_PLAT_F303_DISCOVERY
HAL_NVIC_DisableIRQ(USB_LP_CAN_RX0_IRQn);
#else
#error "BAD PLATFORM"

@ -12,7 +12,7 @@
#define DEBUG_USART_BAUD 115200
#if GEX_PLAT_F072_DISCOVERY
#if GEX_PLAT_F072_DISCOVERY || GEX_PLAT_F072_HUB
#define DEBUG_USART USART1
#define DEBUG_USART_RSC R_USART1

@ -70,6 +70,7 @@
// PLAT_LOCK_BTN - use a lock button instead of a lock jumper (push to toggle)
// PLAT_LOCK_1CLOSED - lock jumper is active (closed / button pressed) in logical 1
// PLAT_NO_AFNUM - legacy platform without numbered AF alternatives
// PLAT_FULL_XTAL - use two-wire xtal attachment
#if defined(GEX_PLAT_F103_BLUEPILL)
@ -124,10 +125,8 @@
#define STATUS_LED_PORT 'C'
#define STATUS_LED_PIN 13
#elif defined(GEX_PLAT_F072_DISCOVERY)
#elif defined(STM32F072xB)
// platform name for the version string
#define GEX_PLATFORM "STM32F072-Discovery"
#define PLAT_AHB_MHZ 48
#define PLAT_APB1_MHZ 48
@ -162,6 +161,10 @@
// Number of GPIO ports A,B,C...
#define PORTS_COUNT 6
#if defined(GEX_PLAT_F072_DISCOVERY)
// platform name for the version string
#define GEX_PLATFORM "STM32F072-Discovery"
// Lock jumper config
#define LOCK_JUMPER_PORT 'A'
#define LOCK_JUMPER_PIN 0
@ -171,6 +174,24 @@
// Status LED config
#define STATUS_LED_PORT 'C'
#define STATUS_LED_PIN 6 // RED LED "UP"
#elif defined(GEX_PLAT_F072_HUB)
// platform name for the version string
#define GEX_PLATFORM "STM32F072-HUB"
#define PLAT_FULL_XTAL 1
// Lock jumper config
#define LOCK_JUMPER_PORT 'D'
#define LOCK_JUMPER_PIN 2
#define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
#define PLAT_LOCK_1CLOSED 0 // toggle button active in log. 1
// Status LED config
#define STATUS_LED_PORT 'A'
#define STATUS_LED_PIN 15 // RED LED "UP"
#else
#error Bad platform
#endif
#elif defined(GEX_PLAT_F303_DISCOVERY)

@ -75,7 +75,7 @@ void plat_init_resources(void)
// BOOT pin(s)
rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
}
#elif defined(GEX_PLAT_F072_DISCOVERY)
#elif defined(STM32F072xB)
// Platform STM32F073RBT
// Additional GPIO ports
@ -122,13 +122,17 @@ void plat_init_resources(void)
// Claim resources not available due to board layout or internal usage
{
// HAL timebase
rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
rv |= rsc_claim(&UNIT_SYSTEM, R_TIM17);
// HSE crystal
rv |= rsc_claim(&UNIT_SYSTEM, R_PF0);
//rv |= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode
#if PLAT_FULL_XTAL
rv |= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode
#endif
// SWD
rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
// rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
// rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
// USB
rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);

@ -62,7 +62,7 @@ error_t UI2C_init(Unit *unit)
uint32_t af_i2c;
uint32_t timing; // magic constant from CubeMX
#if GEX_PLAT_F072_DISCOVERY
#if STM32F072xB
// scl - 6 or 8 for I2C1, 10 for I2C2
// sda - 7 or 9 for I2C1, 11 for I2C2
if (priv->periph_num == 1) {

@ -77,7 +77,7 @@ void UI2C_writeIni(Unit *unit, IniWriter *iw)
iw_entry_d(iw, "device", priv->periph_num);
iw_comment(iw, "Pin mappings (SCL,SDA)");
#if GEX_PLAT_F072_DISCOVERY
#if STM32F072xB
iw_comment(iw, " I2C1: (0) B6,B7 (1) B8,B9");
iw_comment(iw, " I2C2: (0) B10,B11 (1) B13,B14");
#elif GEX_PLAT_F103_BLUEPILL

@ -63,7 +63,7 @@ error_t USPI_init(Unit *unit)
uint32_t af_spi;
// TODO
#if GEX_PLAT_F072_DISCOVERY
#if STM32F072xB
// SPI1 - many options
// sck, miso, mosi, af
@ -83,14 +83,14 @@ error_t USPI_init(Unit *unit)
pin_miso = 4;
pin_mosi = 5;
}
else if (priv->remap == 2) {
// large packages only
spi_portname = 'E';
af_spi = LL_GPIO_AF_1;
pin_sck = 13;
pin_miso = 14;
pin_mosi = 15;
}
// else if (priv->remap == 2) {
// // large packages only
// spi_portname = 'E';
// af_spi = LL_GPIO_AF_1;
// pin_sck = 13;
// pin_miso = 14;
// pin_mosi = 15;
// }
else {
return E_BAD_CONFIG;
}
@ -104,14 +104,14 @@ error_t USPI_init(Unit *unit)
pin_miso = 14;
pin_mosi = 15;
}
else if (priv->remap == 1) {
// NOTE: the's also a incomplete remap in PB and PC
spi_portname = 'D';
af_spi = LL_GPIO_AF_0;
pin_sck = 1;
pin_miso = 3;
pin_mosi = 4;
}
// else if (priv->remap == 1) {
// // NOTE: there's also an incomplete remap in PB and PC
// spi_portname = 'D';
// af_spi = LL_GPIO_AF_0;
// pin_sck = 1;
// pin_miso = 3;
// pin_mosi = 4;
// }
else {
return E_BAD_CONFIG;
}

@ -102,9 +102,9 @@ void USPI_writeIni(Unit *unit, IniWriter *iw)
// TODO show a legend for peripherals and remaps
iw_comment(iw, "Pin mappings (SCK,MISO,MOSI)");
#if GEX_PLAT_F072_DISCOVERY
iw_comment(iw, " SPI1: (0) A5,A6,A7 (1) B3,B4,B5 (2) E13,E14,E15");
iw_comment(iw, " SPI2: (0) B13,B14,B15 (1) D1,D3,D4");
#if STM32F072xB
iw_comment(iw, " SPI1: (0) A5,A6,A7 (1) B3,B4,B5"); // (2) E13,E14,E15
iw_comment(iw, " SPI2: (0) B13,B14,B15"); // (1) D1,D3,D4
#elif GEX_PLAT_F103_BLUEPILL
#error "NO IMPL"
#elif GEX_PLAT_F303_DISCOVERY

@ -111,7 +111,7 @@ static inline error_t UUSART_configPins(Unit *unit)
want_rts_pin(priv)
};
#if GEX_PLAT_F072_DISCOVERY
#if STM32F072xB
const struct PinAF *mappings = NULL;

@ -159,7 +159,7 @@ void UUSART_writeIni(Unit *unit, IniWriter *iw)
iw_entry_d(iw, "device", priv->periph_num);
iw_comment(iw, "Pin mappings (TX,RX,CK,CTS,RTS/DE)");
#if GEX_PLAT_F072_DISCOVERY
#if STM32F072xB
iw_comment(iw, " USART1: (0) A9,A10,A8,A11,A12 (1) B6,B7,A8,A11,A12");
iw_comment(iw, " USART2: (0) A2,A3,A4,A0,A1 (1) A14,A15,A4,A0,A1");
iw_comment(iw, " USART3: (0) B10,B11,B12,B13,B14");

Loading…
Cancel
Save