mirror of https://github.com/ARMmbed/mbed-os.git
commit
fd6ceda960
|
@ -75,7 +75,7 @@ typedef enum {
|
|||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
PWM_I = (int)HRTIM1_BASE,
|
||||
PWM_I = (int)HRTIM1_BASE,
|
||||
PWM_1 = (int)TIM1_BASE,
|
||||
PWM_2 = (int)TIM2_BASE,
|
||||
PWM_3 = (int)TIM3_BASE,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -102,11 +102,11 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
|||
|
||||
/*!< Supply configuration update enable */
|
||||
// HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
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;
|
||||
|
@ -190,11 +189,11 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
|
||||
/*!< Supply configuration update enable */
|
||||
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
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;
|
||||
|
@ -216,7 +215,7 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
|
||||
/* Select PLL as system clock source and configure bus clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
|
||||
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
|
||||
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
|
||||
|
|
|
@ -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) {
|
||||
|
@ -100,7 +99,7 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
|||
}
|
||||
|
||||
int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
||||
uint32_t size)
|
||||
uint32_t size)
|
||||
{
|
||||
uint32_t StartAddress = 0;
|
||||
int32_t status = 0;
|
||||
|
@ -163,49 +162,34 @@ uint32_t flash_get_size(const flash_t *obj)
|
|||
*/
|
||||
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)))
|
||||
{
|
||||
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)))
|
||||
{
|
||||
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)))
|
||||
{
|
||||
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)))
|
||||
{
|
||||
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)))
|
||||
{
|
||||
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)))
|
||||
{
|
||||
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)))
|
||||
{
|
||||
sector = FLASH_SECTOR_6;
|
||||
}
|
||||
else
|
||||
{
|
||||
sector = FLASH_SECTOR_7;
|
||||
}
|
||||
uint32_t sector = 0;
|
||||
|
||||
return sector;
|
||||
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))) {
|
||||
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))) {
|
||||
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))) {
|
||||
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))) {
|
||||
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))) {
|
||||
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))) {
|
||||
sector = FLASH_SECTOR_6;
|
||||
} else {
|
||||
sector = FLASH_SECTOR_7;
|
||||
}
|
||||
|
||||
return sector;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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) {
|
||||
|
@ -131,7 +131,7 @@ static void uart8_irq(void)
|
|||
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
|
||||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
|
||||
|
||||
irq_handler = handler;
|
||||
serial_irq_ids[obj_s->index] = id;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ void serial_break_set(serial_t *obj)
|
|||
* LOCAL HELPER FUNCTIONS
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
/**
|
||||
* Configure the TX buffer for an asynchronous write serial transaction
|
||||
*
|
||||
* @param obj The serial object.
|
||||
|
@ -290,7 +290,7 @@ static void serial_tx_buffer_set(serial_t *obj, void *tx, int tx_length, uint8_t
|
|||
obj->tx_buff.length = tx_length;
|
||||
obj->tx_buff.pos = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure the RX buffer for an asynchronous write serial transaction
|
||||
*
|
||||
|
@ -312,7 +312,7 @@ static void serial_rx_buffer_set(serial_t *obj, void *rx, int rx_length, uint8_t
|
|||
obj->rx_buff.pos = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Configure events
|
||||
*
|
||||
* @param obj The serial object
|
||||
|
@ -320,9 +320,9 @@ static void serial_rx_buffer_set(serial_t *obj, void *rx, int rx_length, uint8_t
|
|||
* @param enable Set to non-zero to enable events, or zero to disable them
|
||||
*/
|
||||
static void serial_enable_event(serial_t *obj, int event, uint8_t enable)
|
||||
{
|
||||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
|
||||
|
||||
// Shouldn't have to enable interrupt here, just need to keep track of the requested events.
|
||||
if (enable) {
|
||||
obj_s->events |= event;
|
||||
|
@ -394,7 +394,7 @@ static IRQn_Type serial_get_irq_n(UARTName uart_name)
|
|||
* MBED API FUNCTIONS
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
/**
|
||||
* Begin asynchronous TX transfer. The used buffer is specified in the serial
|
||||
* object, tx_buff
|
||||
*
|
||||
|
@ -408,16 +408,16 @@ static IRQn_Type serial_get_irq_n(UARTName uart_name)
|
|||
* @return Returns number of data transfered, or 0 otherwise
|
||||
*/
|
||||
int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint)
|
||||
{
|
||||
{
|
||||
// TODO: DMA usage is currently ignored
|
||||
(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;
|
||||
|
@ -425,11 +425,11 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
|
|||
|
||||
// Set up buffer
|
||||
serial_tx_buffer_set(obj, (void *)tx, tx_length, tx_width);
|
||||
|
||||
|
||||
// Set up events
|
||||
serial_enable_event(obj, SERIAL_EVENT_TX_ALL, 0); // Clear all events
|
||||
serial_enable_event(obj, event, 1); // Set only the wanted events
|
||||
|
||||
|
||||
// Enable interrupt
|
||||
IRQn_Type irq_n = serial_get_irq_n(obj_s->uart);
|
||||
NVIC_ClearPendingIRQ(irq_n);
|
||||
|
@ -439,14 +439,14 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
return tx_length;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Begin asynchronous RX transfer (enable interrupt for data collecting)
|
||||
* The used buffer is specified in the serial object, rx_buff
|
||||
*
|
||||
|
@ -467,18 +467,18 @@ 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);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
serial_enable_event(obj, SERIAL_EVENT_RX_ALL, 0);
|
||||
serial_enable_event(obj, event, 1);
|
||||
|
||||
|
||||
// set CharMatch
|
||||
obj->char_match = char_match;
|
||||
|
||||
|
||||
serial_rx_buffer_set(obj, rx, rx_length, rx_width);
|
||||
|
||||
IRQn_Type irq_n = serial_get_irq_n(obj_s->uart);
|
||||
|
@ -488,8 +488,8 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
|
|||
NVIC_SetVector(irq_n, (uint32_t)handler);
|
||||
NVIC_EnableIRQ(irq_n);
|
||||
|
||||
// following HAL function will enable the RXNE interrupt + error interrupts
|
||||
HAL_UART_Receive_IT(huart, (uint8_t*)rx, rx_length);
|
||||
// following HAL function will enable the RXNE interrupt + error interrupts
|
||||
HAL_UART_Receive_IT(huart, (uint8_t *)rx, rx_length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -501,7 +501,7 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
|
|||
uint8_t serial_tx_active(serial_t *obj)
|
||||
{
|
||||
MBED_ASSERT(obj);
|
||||
|
||||
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
|
@ -517,7 +517,7 @@ uint8_t serial_tx_active(serial_t *obj)
|
|||
uint8_t serial_rx_active(serial_t *obj)
|
||||
{
|
||||
MBED_ASSERT(obj);
|
||||
|
||||
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
|
@ -557,49 +557,49 @@ int serial_irq_handler_asynch(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle error events
|
||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_PE) != RESET) {
|
||||
if (__HAL_UART_GET_IT(huart, UART_IT_PE) != RESET) {
|
||||
return_event |= (SERIAL_EVENT_RX_PARITY_ERROR & obj_s->events);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_FE) != RESET) {
|
||||
if (__HAL_UART_GET_IT(huart, UART_IT_FE) != RESET) {
|
||||
return_event |= (SERIAL_EVENT_RX_FRAMING_ERROR & obj_s->events);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE) != RESET) {
|
||||
if (__HAL_UART_GET_IT(huart, UART_IT_ORE) != RESET) {
|
||||
return_event |= (SERIAL_EVENT_RX_OVERRUN_ERROR & obj_s->events);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HAL_UART_IRQHandler(huart);
|
||||
|
||||
|
||||
// Abort if an error occurs
|
||||
if ((return_event & SERIAL_EVENT_RX_PARITY_ERROR) ||
|
||||
(return_event & SERIAL_EVENT_RX_FRAMING_ERROR) ||
|
||||
(return_event & SERIAL_EVENT_RX_OVERRUN_ERROR)) {
|
||||
(return_event & SERIAL_EVENT_RX_FRAMING_ERROR) ||
|
||||
(return_event & SERIAL_EVENT_RX_OVERRUN_ERROR)) {
|
||||
return return_event;
|
||||
}
|
||||
|
||||
|
||||
//RX PART
|
||||
if (huart->RxXferSize != 0) {
|
||||
obj->rx_buff.pos = huart->RxXferSize - huart->RxXferCount;
|
||||
|
@ -607,7 +607,7 @@ int serial_irq_handler_asynch(serial_t *obj)
|
|||
if ((huart->RxXferCount == 0) && (obj->rx_buff.pos >= (obj->rx_buff.length - 1))) {
|
||||
return_event |= (SERIAL_EVENT_RX_COMPLETE & obj_s->events);
|
||||
}
|
||||
|
||||
|
||||
// Check if char_match is present
|
||||
if (obj_s->events & SERIAL_EVENT_RX_CHARACTER_MATCH) {
|
||||
if (buf != NULL) {
|
||||
|
@ -621,11 +621,11 @@ int serial_irq_handler_asynch(serial_t *obj)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return return_event;
|
||||
|
||||
return return_event;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Abort the ongoing TX transaction. It disables the enabled interupt for TX and
|
||||
* flush TX hardware buffer if TX FIFO is used
|
||||
*
|
||||
|
@ -635,17 +635,17 @@ void serial_tx_abort_asynch(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
|
||||
__HAL_UART_DISABLE_IT(huart, UART_IT_TC);
|
||||
__HAL_UART_DISABLE_IT(huart, UART_IT_TXE);
|
||||
|
||||
|
||||
// clear flags
|
||||
__HAL_UART_CLEAR_IT(huart, UART_FLAG_TC);
|
||||
|
||||
// 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;
|
||||
|
@ -662,23 +662,23 @@ void serial_rx_abort_asynch(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
|
||||
// disable interrupts
|
||||
__HAL_UART_DISABLE_IT(huart, UART_IT_RXNE);
|
||||
__HAL_UART_DISABLE_IT(huart, UART_IT_PE);
|
||||
__HAL_UART_DISABLE_IT(huart, UART_IT_ERR);
|
||||
|
||||
|
||||
// clear flags
|
||||
volatile uint32_t tmpval __attribute__((unused)) = huart->Instance->RDR; // Clear RXNE
|
||||
__HAL_UART_CLEAR_IT(huart, UART_CLEAR_PEF);
|
||||
__HAL_UART_CLEAR_IT(huart, UART_CLEAR_FEF);
|
||||
__HAL_UART_CLEAR_IT(huart, UART_CLEAR_NEF);
|
||||
__HAL_UART_CLEAR_IT(huart, UART_CLEAR_OREF);
|
||||
|
||||
|
||||
// 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,9 +708,9 @@ 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;
|
||||
obj_s->hw_flow_ctl = UART_HWCONTROL_NONE;
|
||||
}
|
||||
if (type == FlowControlRTS) {
|
||||
// Enable RTS
|
||||
|
@ -740,7 +740,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
|
|||
// Enable the pin for RTS function
|
||||
pinmap_pinout(rxflow, PinMap_UART_RTS);
|
||||
}
|
||||
|
||||
|
||||
init_uart(obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,35 +40,36 @@
|
|||
#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;
|
||||
int spi_hz = 0;
|
||||
|
||||
/* Get source clock depending on SPI instance */
|
||||
/* Get source clock depending on SPI instance */
|
||||
switch ((int)spiobj->spi) {
|
||||
case SPI_1:
|
||||
case SPI_2:
|
||||
case SPI_3:
|
||||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI123_CLKSOURCE);
|
||||
break;
|
||||
case SPI_4:
|
||||
case SPI_5:
|
||||
case SPI_4:
|
||||
case SPI_5:
|
||||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI45_CLKSOURCE);
|
||||
break;
|
||||
case SPI_6:
|
||||
case SPI_6:
|
||||
spi_hz = LL_RCC_GetSPIClockFreq(LL_RCC_SPI6_CLKSOURCE);
|
||||
break;
|
||||
default:
|
||||
error("CLK: SPI instance not set");
|
||||
default:
|
||||
error("CLK: SPI instance not set");
|
||||
break;
|
||||
}
|
||||
if (spi_hz == LL_RCC_PERIPH_FREQUENCY_NO) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -590,17 +590,17 @@ int i2c_stop(i2c_t *obj)
|
|||
#endif
|
||||
// Disable reload mode
|
||||
handle->Instance->CR2 &= (uint32_t)~I2C_CR2_RELOAD;
|
||||
|
||||
|
||||
// Ensure the transmission is started before sending a stop
|
||||
if ((handle->Instance->CR2 & (uint32_t)I2C_CR2_RD_WRN) == 0) {
|
||||
timeout = FLAG_TIMEOUT;
|
||||
while (!__HAL_I2C_GET_FLAG(handle, I2C_FLAG_TXIS)) {
|
||||
if ((timeout--) == 0) {
|
||||
return I2C_ERROR_BUS_BUSY;
|
||||
}
|
||||
}
|
||||
timeout = FLAG_TIMEOUT;
|
||||
while (!__HAL_I2C_GET_FLAG(handle, I2C_FLAG_TXIS)) {
|
||||
if ((timeout--) == 0) {
|
||||
return I2C_ERROR_BUS_BUSY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Generate the STOP condition
|
||||
handle->Instance->CR2 |= I2C_CR2_STOP;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
/* hence 2^(31+1), then FLASH_SIZE_DEFAULT = 1<<31 */
|
||||
#define QSPI_FLASH_SIZE_DEFAULT 0x80000000
|
||||
|
||||
void qspi_prepare_command(const qspi_command_t *command, QSPI_CommandTypeDef *st_command)
|
||||
void qspi_prepare_command(const qspi_command_t *command, QSPI_CommandTypeDef *st_command)
|
||||
{
|
||||
// TODO: shift these around to get more dynamic mapping
|
||||
switch (command->instruction.bus_width) {
|
||||
|
@ -134,7 +134,7 @@ void qspi_prepare_command(const qspi_command_t *command, QSPI_CommandTypeDef *st
|
|||
qspi_status_t qspi_init(qspi_t *obj, PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName ssel, uint32_t hz, uint8_t mode)
|
||||
{
|
||||
// Enable interface clock for QSPI
|
||||
__HAL_RCC_QSPI_CLK_ENABLE();
|
||||
__HAL_RCC_QSPI_CLK_ENABLE();
|
||||
|
||||
// Reset QSPI
|
||||
__HAL_RCC_QSPI_FORCE_RESET();
|
||||
|
@ -170,7 +170,7 @@ qspi_status_t qspi_init(qspi_t *obj, PinName io0, PinName io1, PinName io2, PinN
|
|||
QSPIName qspi_data_third = (QSPIName)pinmap_merge(qspiclkname, qspisselname);
|
||||
|
||||
if (qspi_data_first != qspi_data_second || qspi_data_second != qspi_data_third ||
|
||||
qspi_data_first != qspi_data_third) {
|
||||
qspi_data_first != qspi_data_third) {
|
||||
return QSPI_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -300,7 +297,7 @@ qspi_status_t qspi_command_transfer(qspi_t *obj, const qspi_command_t *command,
|
|||
qspi_prepare_command(command, &st_command);
|
||||
|
||||
st_command.NbData = 1;
|
||||
st_command.DataMode = QSPI_DATA_NONE; /* Instruction only */
|
||||
st_command.DataMode = QSPI_DATA_NONE; /* Instruction only */
|
||||
if (HAL_QSPI_Command(&obj->handle, &st_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
|
||||
status = QSPI_STATUS_ERROR;
|
||||
return status;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ int spi_master_write(spi_t *obj, int value)
|
|||
|
||||
#if TARGET_STM32H7
|
||||
/* Wait for RXP or end of Transfer */
|
||||
while (!LL_SPI_IsActiveFlag_RXP(SPI_INST(obj)));
|
||||
while (!LL_SPI_IsActiveFlag_RXP(SPI_INST(obj)));
|
||||
#else /* TARGET_STM32H7 */
|
||||
/* Wait for RXNE flag before reading */
|
||||
while (!LL_SPI_IsActiveFlag_RXNE(SPI_INST(obj)));
|
||||
|
|
Loading…
Reference in New Issue