mirror of https://github.com/ARMmbed/mbed-os.git
commit
fd6ceda960
|
@ -251,13 +251,13 @@ MBED_WEAK const PinMap PinMap_UART_TX[] = {
|
|||
{PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to RMII_MDIO
|
||||
{PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_VBUS
|
||||
{PA_9_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_VBUS
|
||||
{PA_9_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_VBUS
|
||||
{PA_12, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // Connected to USB_DP
|
||||
{PA_15, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)},
|
||||
{PB_4, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)},
|
||||
{PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_6_ALT0, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
|
||||
{PB_6_ALT1, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)},
|
||||
{PB_6_ALT1, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)},
|
||||
{PB_9, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PB_13, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, // Connected to RMII_TXD1
|
||||
|
@ -281,12 +281,12 @@ MBED_WEAK const PinMap PinMap_UART_RX[] = {
|
|||
{PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_8, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // Connected to USB_SOF [TP1]
|
||||
{PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_ID
|
||||
{PA_10_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_ID
|
||||
{PA_10_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_ID
|
||||
{PA_11, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // Connected to USB_DM
|
||||
{PB_3, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // Connected to SWO
|
||||
{PB_5, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
|
||||
{PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to LD2 [Blue]
|
||||
{PB_7_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, // Connected to LD2 [Blue]
|
||||
{PB_7_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, // Connected to LD2 [Blue]
|
||||
{PB_8, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PB_12, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
|
||||
|
@ -308,7 +308,7 @@ MBED_WEAK const PinMap PinMap_UART_RX[] = {
|
|||
MBED_WEAK const PinMap PinMap_UART_RTS[] = {
|
||||
{PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to RMII_REF_CLK
|
||||
{PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_DP
|
||||
{PA_12_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_DP
|
||||
{PA_12_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_DP
|
||||
{PA_15, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to LD3 [Red]
|
||||
{PB_14_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to LD3 [Red]
|
||||
|
@ -324,7 +324,7 @@ MBED_WEAK const PinMap PinMap_UART_RTS[] = {
|
|||
};
|
||||
|
||||
MBED_WEAK const PinMap PinMap_UART_CTS[] = {
|
||||
{PA_11, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_DM
|
||||
{PA_11, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // Connected to USB_DM
|
||||
{PB_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PB_15, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PC_9, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
|
||||
|
|
|
@ -291,7 +291,7 @@ typedef enum {
|
|||
SPI_CS = D10,
|
||||
PWM_OUT = D9,
|
||||
|
||||
/**** USB pins ****/
|
||||
/**** USB pins ****/
|
||||
USB_OTG_FS_DM = PA_11,
|
||||
USB_OTG_FS_DP = PA_12,
|
||||
USB_OTG_FS_ID = PA_10,
|
||||
|
@ -315,7 +315,7 @@ typedef enum {
|
|||
USB_OTG_HS_ULPI_STP = PC_0,
|
||||
USB_OTG_HS_VBUS = PB_13,
|
||||
|
||||
/**** ETHERNET pins ****/
|
||||
/**** ETHERNET pins ****/
|
||||
ETH_COL = PA_3,
|
||||
ETH_CRS = PA_0,
|
||||
ETH_CRS_DV = PA_7,
|
||||
|
@ -345,13 +345,13 @@ typedef enum {
|
|||
ETH_TX_ER = PB_2,
|
||||
ETH_TX_ER_ALT0 = PA_9,
|
||||
|
||||
/**** OSCILLATOR pins ****/
|
||||
/**** OSCILLATOR pins ****/
|
||||
RCC_OSC32_IN = PC_14,
|
||||
RCC_OSC32_OUT = PC_15,
|
||||
RCC_OSC_IN = PH_0,
|
||||
RCC_OSC_OUT = PH_1,
|
||||
|
||||
/**** DEBUG pins ****/
|
||||
/**** DEBUG pins ****/
|
||||
SYS_JTCK_SWCLK = PA_14,
|
||||
SYS_JTDI = PA_15,
|
||||
SYS_JTDO_SWO = PB_3,
|
||||
|
|
|
@ -106,7 +106,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
|||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
|
||||
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
|
||||
|
||||
// NEEDED ???
|
||||
/* Select CSI as system clock source to allow modification of the PLL configuration */
|
||||
|
@ -121,8 +121,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
|||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
|
||||
if (bypass) {
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
}
|
||||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
||||
|
@ -194,7 +193,7 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
|
||||
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
|
||||
|
||||
// Enable HSI oscillator and activate PLL with HSI as source
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_CSI;
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
#include "stm32h7xx_hal.h"
|
||||
#include "PeripheralPins.h"
|
||||
|
||||
void analogout_init(dac_t *obj, PinName pin) {
|
||||
void analogout_init(dac_t *obj, PinName pin)
|
||||
{
|
||||
DAC_ChannelConfTypeDef sConfig = {0};
|
||||
|
||||
// Get the peripheral name (DAC_1, ...) from the pin and assign it to the object
|
||||
|
@ -73,7 +74,7 @@ void analogout_init(dac_t *obj, PinName pin) {
|
|||
obj->handle.Instance = DAC1;
|
||||
obj->handle.State = HAL_DAC_STATE_RESET;
|
||||
|
||||
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
|
||||
if (HAL_DAC_Init(&obj->handle) != HAL_OK) {
|
||||
error("HAL_DAC_Init failed");
|
||||
}
|
||||
|
||||
|
@ -87,7 +88,8 @@ void analogout_init(dac_t *obj, PinName pin) {
|
|||
analogout_write_u16(obj, 0);
|
||||
}
|
||||
|
||||
void analogout_free(dac_t *obj) {
|
||||
void analogout_free(dac_t *obj)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ struct serial_s {
|
|||
PinName pin_rts;
|
||||
PinName pin_cts;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
struct i2c_s {
|
||||
/* The 1st 2 members I2CName i2c
|
||||
|
|
|
@ -85,8 +85,7 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
|||
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) {
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
EraseInitStruct.Banks = FLASH_BANK_2;
|
||||
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) {
|
||||
|
@ -165,43 +164,28 @@ static uint32_t GetSector(uint32_t Address)
|
|||
{
|
||||
uint32_t sector = 0;
|
||||
|
||||
if(((Address < ADDR_FLASH_SECTOR_1_BANK1) && (Address >= ADDR_FLASH_SECTOR_0_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_1_BANK2) && (Address >= ADDR_FLASH_SECTOR_0_BANK2)))
|
||||
{
|
||||
if (((Address < ADDR_FLASH_SECTOR_1_BANK1) && (Address >= ADDR_FLASH_SECTOR_0_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_1_BANK2) && (Address >= ADDR_FLASH_SECTOR_0_BANK2))) {
|
||||
sector = FLASH_SECTOR_0;
|
||||
}
|
||||
else if(((Address < ADDR_FLASH_SECTOR_2_BANK1) && (Address >= ADDR_FLASH_SECTOR_1_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_2_BANK2) && (Address >= ADDR_FLASH_SECTOR_1_BANK2)))
|
||||
{
|
||||
} else if (((Address < ADDR_FLASH_SECTOR_2_BANK1) && (Address >= ADDR_FLASH_SECTOR_1_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_2_BANK2) && (Address >= ADDR_FLASH_SECTOR_1_BANK2))) {
|
||||
sector = FLASH_SECTOR_1;
|
||||
}
|
||||
else if(((Address < ADDR_FLASH_SECTOR_3_BANK1) && (Address >= ADDR_FLASH_SECTOR_2_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_3_BANK2) && (Address >= ADDR_FLASH_SECTOR_2_BANK2)))
|
||||
{
|
||||
} else if (((Address < ADDR_FLASH_SECTOR_3_BANK1) && (Address >= ADDR_FLASH_SECTOR_2_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_3_BANK2) && (Address >= ADDR_FLASH_SECTOR_2_BANK2))) {
|
||||
sector = FLASH_SECTOR_2;
|
||||
}
|
||||
else if(((Address < ADDR_FLASH_SECTOR_4_BANK1) && (Address >= ADDR_FLASH_SECTOR_3_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_4_BANK2) && (Address >= ADDR_FLASH_SECTOR_3_BANK2)))
|
||||
{
|
||||
} else if (((Address < ADDR_FLASH_SECTOR_4_BANK1) && (Address >= ADDR_FLASH_SECTOR_3_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_4_BANK2) && (Address >= ADDR_FLASH_SECTOR_3_BANK2))) {
|
||||
sector = FLASH_SECTOR_3;
|
||||
}
|
||||
else if(((Address < ADDR_FLASH_SECTOR_5_BANK1) && (Address >= ADDR_FLASH_SECTOR_4_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_5_BANK2) && (Address >= ADDR_FLASH_SECTOR_4_BANK2)))
|
||||
{
|
||||
} else if (((Address < ADDR_FLASH_SECTOR_5_BANK1) && (Address >= ADDR_FLASH_SECTOR_4_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_5_BANK2) && (Address >= ADDR_FLASH_SECTOR_4_BANK2))) {
|
||||
sector = FLASH_SECTOR_4;
|
||||
}
|
||||
else if(((Address < ADDR_FLASH_SECTOR_6_BANK1) && (Address >= ADDR_FLASH_SECTOR_5_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_6_BANK2) && (Address >= ADDR_FLASH_SECTOR_5_BANK2)))
|
||||
{
|
||||
} else if (((Address < ADDR_FLASH_SECTOR_6_BANK1) && (Address >= ADDR_FLASH_SECTOR_5_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_6_BANK2) && (Address >= ADDR_FLASH_SECTOR_5_BANK2))) {
|
||||
sector = FLASH_SECTOR_5;
|
||||
}
|
||||
else if(((Address < ADDR_FLASH_SECTOR_7_BANK1) && (Address >= ADDR_FLASH_SECTOR_6_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_7_BANK2) && (Address >= ADDR_FLASH_SECTOR_6_BANK2)))
|
||||
{
|
||||
} else if (((Address < ADDR_FLASH_SECTOR_7_BANK1) && (Address >= ADDR_FLASH_SECTOR_6_BANK1)) || \
|
||||
((Address < ADDR_FLASH_SECTOR_7_BANK2) && (Address >= ADDR_FLASH_SECTOR_6_BANK2))) {
|
||||
sector = FLASH_SECTOR_6;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sector = FLASH_SECTOR_7;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,14 +56,15 @@ static inline void stm_pin_PullConfig(GPIO_TypeDef *gpio, uint32_t ll_pin, uint3
|
|||
}
|
||||
}
|
||||
|
||||
static inline void stm_pin_SetAFPin( GPIO_TypeDef *gpio, PinName pin, uint32_t afnum)
|
||||
static inline void stm_pin_SetAFPin(GPIO_TypeDef *gpio, PinName pin, uint32_t afnum)
|
||||
{
|
||||
uint32_t ll_pin = ll_pin_defines[STM_PIN(pin)];
|
||||
|
||||
if (STM_PIN(pin) > 7)
|
||||
if (STM_PIN(pin) > 7) {
|
||||
LL_GPIO_SetAFPin_8_15(gpio, ll_pin, afnum);
|
||||
else
|
||||
} else {
|
||||
LL_GPIO_SetAFPin_0_7(gpio, ll_pin, afnum);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
|
||||
#ifdef DEVICE_PWMOUT
|
||||
|
||||
const pwm_apb_map_t pwm_apb_map_table[] =
|
||||
{
|
||||
const pwm_apb_map_t pwm_apb_map_table[] = {
|
||||
#if defined(TIM2_BASE)
|
||||
{PWM_2, PWMOUT_ON_APB1},
|
||||
#endif
|
||||
|
|
|
@ -50,7 +50,7 @@ static void uart_irq(UARTName uart_name)
|
|||
int8_t id = get_uart_index(uart_name);
|
||||
|
||||
if (id >= 0) {
|
||||
UART_HandleTypeDef * huart = &uart_handlers[id];
|
||||
UART_HandleTypeDef *huart = &uart_handlers[id];
|
||||
if (serial_irq_ids[id] != 0) {
|
||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_TXE) != RESET) {
|
||||
if (__HAL_UART_GET_IT(huart, UART_IT_TXE) != RESET) {
|
||||
|
@ -413,11 +413,11 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
|
|||
(void) hint;
|
||||
|
||||
// Check buffer is ok
|
||||
MBED_ASSERT(tx != (void*)0);
|
||||
MBED_ASSERT(tx != (void *)0);
|
||||
MBED_ASSERT(tx_width == 8); // support only 8b width
|
||||
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef * huart = &uart_handlers[obj_s->index];
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
if (tx_length == 0) {
|
||||
return 0;
|
||||
|
@ -439,7 +439,7 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
|
|||
NVIC_EnableIRQ(irq_n);
|
||||
|
||||
// the following function will enable UART_IT_TXE and error interrupts
|
||||
if (HAL_UART_Transmit_IT(huart, (uint8_t*)tx, tx_length) != HAL_OK) {
|
||||
if (HAL_UART_Transmit_IT(huart, (uint8_t *)tx, tx_length) != HAL_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
|
|||
|
||||
/* Sanity check arguments */
|
||||
MBED_ASSERT(obj);
|
||||
MBED_ASSERT(rx != (void*)0);
|
||||
MBED_ASSERT(rx != (void *)0);
|
||||
MBED_ASSERT(rx_width == 8); // support only 8b width
|
||||
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
|
@ -489,7 +489,7 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
|
|||
NVIC_EnableIRQ(irq_n);
|
||||
|
||||
// following HAL function will enable the RXNE interrupt + error interrupts
|
||||
HAL_UART_Receive_IT(huart, (uint8_t*)rx, rx_length);
|
||||
HAL_UART_Receive_IT(huart, (uint8_t *)rx, rx_length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -559,14 +559,14 @@ int serial_irq_handler_asynch(serial_t *obj)
|
|||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
volatile int return_event = 0;
|
||||
uint8_t *buf = (uint8_t*)(obj->rx_buff.buffer);
|
||||
uint8_t *buf = (uint8_t *)(obj->rx_buff.buffer);
|
||||
uint8_t i = 0;
|
||||
|
||||
// TX PART:
|
||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_TC) != RESET) {
|
||||
if (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_TC) != RESET) {
|
||||
// Return event SERIAL_EVENT_TX_COMPLETE if requested
|
||||
if ((obj_s->events & SERIAL_EVENT_TX_COMPLETE ) != 0) {
|
||||
if ((obj_s->events & SERIAL_EVENT_TX_COMPLETE) != 0) {
|
||||
return_event |= (SERIAL_EVENT_TX_COMPLETE & obj_s->events);
|
||||
}
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ void serial_tx_abort_asynch(serial_t *obj)
|
|||
// reset states
|
||||
huart->TxXferCount = 0;
|
||||
// update handle state
|
||||
if(huart->gState == HAL_UART_STATE_BUSY_TX_RX) {
|
||||
if (huart->gState == HAL_UART_STATE_BUSY_TX_RX) {
|
||||
huart->gState = HAL_UART_STATE_BUSY_RX;
|
||||
} else {
|
||||
huart->gState = HAL_UART_STATE_READY;
|
||||
|
@ -678,7 +678,7 @@ void serial_rx_abort_asynch(serial_t *obj)
|
|||
// reset states
|
||||
huart->RxXferCount = 0;
|
||||
// update handle state
|
||||
if(huart->RxState == HAL_UART_STATE_BUSY_TX_RX) {
|
||||
if (huart->RxState == HAL_UART_STATE_BUSY_TX_RX) {
|
||||
huart->RxState = HAL_UART_STATE_BUSY_TX;
|
||||
} else {
|
||||
huart->RxState = HAL_UART_STATE_READY;
|
||||
|
@ -708,7 +708,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
|
|||
obj_s->uart = (UARTName)pinmap_merge(uart_cts, uart_rts);
|
||||
MBED_ASSERT(obj_s->uart != (UARTName)NC);
|
||||
|
||||
if(type == FlowControlNone) {
|
||||
if (type == FlowControlNone) {
|
||||
// Disable hardware flow control
|
||||
obj_s->hw_flow_ctl = UART_HWCONTROL_NONE;
|
||||
}
|
||||
|
|
|
@ -40,16 +40,17 @@
|
|||
#include "spi_device.h"
|
||||
|
||||
#if DEVICE_SPI_ASYNCH
|
||||
#define SPI_S(obj) (( struct spi_s *)(&(obj->spi)))
|
||||
#define SPI_S(obj) (( struct spi_s *)(&(obj->spi)))
|
||||
#else
|
||||
#define SPI_S(obj) (( struct spi_s *)(obj))
|
||||
#define SPI_S(obj) (( struct spi_s *)(obj))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Only the frequency is managed in the family specific part
|
||||
* the rest of SPI management is common to all STM32 families
|
||||
*/
|
||||
int spi_get_clock_freq(spi_t *obj) {
|
||||
int spi_get_clock_freq(spi_t *obj)
|
||||
{
|
||||
struct spi_s *spiobj = SPI_S(obj);
|
||||
int spi_hz = 0;
|
||||
|
||||
|
|
|
@ -221,19 +221,19 @@ MBED_WEAK const PinMap PinMap_PWM[] = {
|
|||
MBED_WEAK const PinMap PinMap_UART_TX[] = {
|
||||
{PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_2_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PA_2_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_VBUS
|
||||
{PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PB_11, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_1, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_11, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_1, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_4, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_10_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PC_12, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
|
||||
{PD_5, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to STDIO_UART_TX
|
||||
{PG_7, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_TX
|
||||
{PG_7, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_TX
|
||||
{PG_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
@ -241,20 +241,20 @@ MBED_WEAK const PinMap PinMap_UART_TX[] = {
|
|||
MBED_WEAK const PinMap PinMap_UART_RX[] = {
|
||||
{PA_1, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_3_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PA_3_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_ID
|
||||
{PA_15, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART2)},
|
||||
{PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to LD2 [Blue]
|
||||
{PB_10, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_10, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_5, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_11_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PD_2, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
|
||||
{PD_6, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to STDIO_UART_RX
|
||||
{PG_8, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_RX
|
||||
{PG_8, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_RX
|
||||
{PG_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
@ -265,15 +265,15 @@ MBED_WEAK const PinMap PinMap_UART_RTS[] = {
|
|||
{PA_15, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PA_15_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PB_1, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PB_1_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_1_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_3, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_4, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
|
||||
{PB_12, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_12, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to LD3 [Red]
|
||||
{PD_2, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PD_4, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PD_12, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PG_6, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to USB_OverCurrent [STMPS2151STR_FAULT]
|
||||
{PG_6, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to USB_OverCurrent [STMPS2151STR_FAULT]
|
||||
{PG_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
@ -281,16 +281,16 @@ MBED_WEAK const PinMap PinMap_UART_RTS[] = {
|
|||
MBED_WEAK const PinMap PinMap_UART_CTS[] = {
|
||||
{PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_6, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PA_6_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PA_6_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_DM
|
||||
{PB_4, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_5, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
|
||||
{PB_7, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to LD2 [Blue]
|
||||
{PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PB_13_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_13_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PD_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PD_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PG_5, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to USB_PowerSwitchOn [STMPS2151STR_EN]
|
||||
{PG_5, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to USB_PowerSwitchOn [STMPS2151STR_EN]
|
||||
{PG_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
|
|
@ -281,7 +281,7 @@ typedef enum {
|
|||
SPI_CS = D10,
|
||||
PWM_OUT = D9,
|
||||
|
||||
/**** USB pins ****/
|
||||
/**** USB pins ****/
|
||||
USB_OTG_FS_DM = PA_11,
|
||||
USB_OTG_FS_DP = PA_12,
|
||||
USB_OTG_FS_ID = PA_10,
|
||||
|
@ -291,13 +291,13 @@ typedef enum {
|
|||
USB_OTG_FS_SOF_ALT0 = PA_14,
|
||||
USB_OTG_FS_VBUS = PA_9,
|
||||
|
||||
/**** OSCILLATOR pins ****/
|
||||
/**** OSCILLATOR pins ****/
|
||||
RCC_OSC32_IN = PC_14,
|
||||
RCC_OSC32_OUT = PC_15,
|
||||
RCC_OSC_IN = PH_0,
|
||||
RCC_OSC_OUT = PH_1,
|
||||
|
||||
/**** DEBUG pins ****/
|
||||
/**** DEBUG pins ****/
|
||||
SYS_JTCK_SWCLK = PA_14,
|
||||
SYS_JTDI = PA_15,
|
||||
SYS_JTDO_SWO = PB_3,
|
||||
|
|
|
@ -51,8 +51,7 @@ uint32_t HAL_GetTick()
|
|||
new_time = ticker_read_us(get_us_ticker_data()) + prev_time;
|
||||
prev_time = 0; // Use this time only once
|
||||
return (new_time / 1000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new_time = us_ticker_read();
|
||||
elapsed_time += (new_time - prev_time) & 0xFFFF; // Only use the lower 16 bits
|
||||
prev_time = new_time;
|
||||
|
@ -61,8 +60,7 @@ uint32_t HAL_GetTick()
|
|||
#else // 32-bit timer
|
||||
if (mbed_sdk_inited) {
|
||||
return (ticker_read_us(get_us_ticker_data()) / 1000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return (us_ticker_read() / 1000);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -197,7 +197,7 @@ qspi_status_t qspi_init(qspi_t *obj, PinName io0, PinName io1, PinName io2, PinN
|
|||
|
||||
qspi_status_t qspi_free(qspi_t *obj)
|
||||
{
|
||||
if(HAL_QSPI_DeInit(&obj->handle) != HAL_OK) {
|
||||
if (HAL_QSPI_DeInit(&obj->handle) != HAL_OK) {
|
||||
return QSPI_STATUS_ERROR;
|
||||
}
|
||||
|
||||
|
@ -234,8 +234,7 @@ qspi_status_t qspi_frequency(qspi_t *obj, int hz)
|
|||
int div = HAL_RCC_GetHCLKFreq() / hz;
|
||||
if (div > 255) {
|
||||
div = 255;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ((HAL_RCC_GetHCLKFreq() % hz) == 0) {
|
||||
div = div - 1;
|
||||
}
|
||||
|
@ -260,8 +259,7 @@ qspi_status_t qspi_write(qspi_t *obj, const qspi_command_t *command, const void
|
|||
|
||||
if (HAL_QSPI_Command(&obj->handle, &st_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
|
||||
status = QSPI_STATUS_ERROR;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (HAL_QSPI_Transmit(&obj->handle, (uint8_t *)data, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
|
||||
status = QSPI_STATUS_ERROR;
|
||||
}
|
||||
|
@ -280,8 +278,7 @@ qspi_status_t qspi_read(qspi_t *obj, const qspi_command_t *command, void *data,
|
|||
|
||||
if (HAL_QSPI_Command(&obj->handle, &st_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
|
||||
status = QSPI_STATUS_ERROR;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (HAL_QSPI_Receive(&obj->handle, data, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
|
||||
status = QSPI_STATUS_ERROR;
|
||||
}
|
||||
|
|
|
@ -668,7 +668,8 @@ int8_t get_uart_index(UARTName uart_name)
|
|||
.* Returns 1 if there is at least 1 serial instance with an on-going transfer
|
||||
* and 0 otherwise.
|
||||
*/
|
||||
int serial_is_tx_ongoing(void) {
|
||||
int serial_is_tx_ongoing(void)
|
||||
{
|
||||
int TxOngoing = 0;
|
||||
|
||||
#if defined(USART1_BASE)
|
||||
|
@ -766,7 +767,8 @@ int serial_is_tx_ongoing(void) {
|
|||
|
||||
#else
|
||||
|
||||
int serial_is_tx_ongoing(void) {
|
||||
int serial_is_tx_ongoing(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue