.suc_pin_tx = MCU_GPIO_PORTD(8), /* PD8 */ .suc_pin_rx = MCU_GPIO_PORTD(9), /* PD9 */ .suc_pin_rts = -1, .suc_pin_cts = -1, .suc_pin_af = GPIO_AF7_USART3, .suc_irqn = USART3_IRQn } }; #endif #if MYNEWT_VAL(I2C_0) static struct stm32_hal_i2c_cfg i2c_cfg0 = { .hic_i2c = I2C1, .hic_rcc_reg = &RCC->APB1ENR, .hic_rcc_dev = RCC_APB1ENR_I2C1EN, .hic_pin_sda = MCU_GPIO_PORTB(9), /* PB9 */ .hic_pin_scl = MCU_GPIO_PORTB(8), /* PB8 */ .hic_pin_af = GPIO_AF4_I2C1, .hic_10bit = 0, .hic_speed = 100000 /* 100kHz */ }; #endif #if MYNEWT_VAL(SPI_0_MASTER) /* * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line * and is handled outside the SPI routines. */ static const struct stm32_hal_spi_cfg os_bsp_spi0m_cfg = { .sck_pin = MCU_GPIO_PORTB(3), .mosi_pin = MCU_GPIO_PORTB(5),
&U3CTSR, &U4RXR, &U5RXR, &SS2R, &OCFAR } }; static const uint8_t output_pins[4][16] = { { MCU_GPIO_PORTD(2), MCU_GPIO_PORTG(8), MCU_GPIO_PORTF(4), MCU_GPIO_PORTD(10), MCU_GPIO_PORTF(1), MCU_GPIO_PORTB(9), MCU_GPIO_PORTB(10), MCU_GPIO_PORTC(14), MCU_GPIO_PORTB(5), MCU_GPIO_UNDEF, MCU_GPIO_UNDEF, MCU_GPIO_UNDEF, MCU_GPIO_UNDEF, MCU_GPIO_UNDEF, MCU_GPIO_UNDEF, MCU_GPIO_UNDEF }, { MCU_GPIO_PORTD(3), MCU_GPIO_PORTG(7), MCU_GPIO_PORTF(5),
#define STM32F4_ADC3_DEFAULT_CONFIG {\ .sac_chan_count = 16,\ .sac_chans = (struct adc_chan_config [16]){{0},{0},{0},{0},STM32F4_ADC3_DEFAULT_SAC},\ .sac_adc_handle = &adc3_handle,\ } struct stm32f4_adc_dev_cfg adc3_config = STM32F4_ADC3_DEFAULT_CONFIG; #endif #if MYNEWT_VAL(I2C_0) static struct stm32f4_hal_i2c_cfg i2c_cfg0 = { .hic_i2c = I2C1, .hic_rcc_reg = &RCC->APB1ENR, .hic_rcc_dev = RCC_APB1ENR_I2C1EN, .hic_pin_sda = MCU_GPIO_PORTB(9), /* PB9 */ .hic_pin_scl = MCU_GPIO_PORTB(8), /* PB8 */ .hic_pin_af = GPIO_AF4_I2C1, .hic_10bit = 0, .hic_speed = 100000 /* 100kHz */ }; #endif #if MYNEWT_VAL(SPI_0_SLAVE) || MYNEWT_VAL(SPI_0_MASTER) struct stm32f4_hal_spi_cfg spi0_cfg = { .ss_pin = MCU_GPIO_PORTA(4), /* PA4 */ .sck_pin = MCU_GPIO_PORTA(5), /* PA5 */ .miso_pin = MCU_GPIO_PORTA(6), /* PA6 */ .mosi_pin = MCU_GPIO_PORTB(5), /* PB5 */ .irq_prio = 2 };
.irq_prio = 2, }; #endif #if MYNEWT_VAL(I2C_0) /* * The PB8 and PB9 pins are connected through jumpers in the board to * both ADC_IN and I2C pins. To enable I2C functionality SB147/SB157 need * to be removed (they are the default connections) and SB138/SB143 need * to be shorted. */ static struct stm32_hal_i2c_cfg i2c_cfg0 = { .hic_i2c = I2C1, .hic_rcc_reg = &RCC->APB1ENR, .hic_rcc_dev = RCC_APB1ENR_I2C1EN, .hic_pin_sda = MCU_GPIO_PORTB(9), /* D14 on CN7 */ .hic_pin_scl = MCU_GPIO_PORTB(8), /* D15 on CN7 */ .hic_pin_af = GPIO_AF4_I2C1, .hic_10bit = 0, .hic_timingr = 0x30420F13, /* 100KHz at 16MHz of SysCoreClock */ }; #endif #if MYNEWT_VAL(ETH_0) static const struct stm32_eth_cfg eth_cfg = { /* * PORTA * PA1 - ETH_RMII_REF_CLK * PA2 - ETH_RMII_MDIO * PA7 - ETH_RMII_CRS_DV */
#include <mcu/stm32l1_bsp.h> #include "mcu/stm32l1xx_mynewt_hal.h" #include "mcu/stm32_hal.h" #include "hal/hal_i2c.h" #include "bsp/bsp.h" #if MYNEWT_VAL(UART_0) static struct uart_dev hal_uart0; static const struct stm32_uart_cfg uart_cfg[UART_CNT] = { [0] = { .suc_uart = USART3, .suc_rcc_reg = &RCC->APB1ENR, .suc_rcc_dev = RCC_APB1ENR_USART3EN, .suc_pin_tx = MCU_GPIO_PORTB(10), .suc_pin_rx = MCU_GPIO_PORTB(11), .suc_pin_rts = -1, .suc_pin_cts = -1, .suc_pin_af = GPIO_AF7_USART3, .suc_irqn = USART3_IRQn } }; #endif #if MYNEWT_VAL(I2C_0) static struct stm32_hal_i2c_cfg i2c_cfg0 = { .hic_i2c = I2C1, .hic_rcc_reg = &RCC->APB1ENR, .hic_rcc_dev = RCC_APB1ENR_I2C1EN, .hic_pin_sda = MCU_GPIO_PORTB(9),