Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/msp430: rework MSP430 x1xx periph drivers #19835

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions boards/msb-430/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C" {
* @brief Clock configuration
*/
static const msp430_clock_params_t clock_params = {
.target_dco_frequency = 7372800U,
.target_dco_frequency = MHZ(8),
.lfxt1_frequency = 32768,
.main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK,
.submain_clock_source = SUBMAIN_CLOCK_SOURCE_DCOCLK,
Expand All @@ -49,35 +49,30 @@ static const msp430_clock_params_t clock_params = {
* @name UART configuration
* @{
*/
#define UART_NUMOF (1U)
static const uart_conf_t uart_config[] = {
{
.uart = &usart1_as_uart,
},
};

#define UART0_RX_ISR (USART1RX_VECTOR) /**< RX IRQ vector of UART 0 */
#define UART0_TX_ISR (USART1TX_VECTOR) /**< TX IRQ vector of UART 0 */

#define UART_BASE (&USART_1)
#define UART_SFR (&USART_1_SFR)
#define UART_IE_RX_BIT (1 << 4)
#define UART_IE_TX_BIT (1 << 5)
#define UART_ME_BITS (0x30)
#define UART_PORT (&PORT_3)
#define UART_RX_PIN (1 << 6)
#define UART_TX_PIN (1 << 7)
#define UART_RX_ISR (USART1RX_VECTOR)
#define UART_TX_ISR (USART1TX_VECTOR)
#define UART_NUMOF ARRAY_SIZE(uart_config)
/** @} */

/**
* @name SPI configuration
* @{
*/
#define SPI_NUMOF (1U)
static const spi_conf_t spi_config[] = {
{
/* beware of resource conflict with UART */
.spi = &usart1_as_spi,
},
};

/* SPI configuration */
#define SPI_BASE (&USART_1)
#define SPI_SFR (&USART_1_SFR)
#define SPI_IE_RX_BIT (1 << 6)
#define SPI_IE_TX_BIT (1 << 7)
#define SPI_ME_BIT (1 << 6)
#define SPI_PIN_MISO GPIO_PIN(P5, 2)
#define SPI_PIN_MOSI GPIO_PIN(P5, 1)
#define SPI_PIN_CLK GPIO_PIN(P5, 3)
#define SPI_NUMOF ARRAY_SIZE(spi_config)
/** @} */

#ifdef __cplusplus
Expand Down
36 changes: 15 additions & 21 deletions boards/msb-430h/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,29 @@ static const msp430_clock_params_t clock_params = {
* @name UART configuration
* @{
*/
#define UART_NUMOF (1U)
static const uart_conf_t uart_config[] = {
{
.uart = &usart1_as_uart,
},
};

#define UART0_RX_ISR (USART1RX_VECTOR) /**< RX IRQ vector of UART 0 */
#define UART0_TX_ISR (USART1TX_VECTOR) /**< TX IRQ vector of UART 0 */

#define UART_BASE (&USART_1)
#define UART_SFR (&USART_1_SFR)
#define UART_IE_RX_BIT (1 << 4)
#define UART_IE_TX_BIT (1 << 5)
#define UART_ME_BITS (0x30)
#define UART_PORT (&PORT_3)
#define UART_RX_PIN (1 << 6)
#define UART_TX_PIN (1 << 7)
#define UART_RX_ISR (USART1RX_VECTOR)
#define UART_TX_ISR (USART1TX_VECTOR)
#define UART_NUMOF ARRAY_SIZE(uart_config)
/** @} */

/**
* @name SPI configuration
* @{
*/
#define SPI_NUMOF (1U)
static const spi_conf_t spi_config[] = {
{
.spi = &usart0_as_spi,
},
};

/* SPI configuration */
#define SPI_BASE (&USART_0)
#define SPI_SFR (&USART_0_SFR)
#define SPI_IE_RX_BIT (1 << 6)
#define SPI_IE_TX_BIT (1 << 7)
#define SPI_ME_BIT (1 << 6)
#define SPI_PIN_MISO GPIO_PIN(P3, 2)
#define SPI_PIN_MOSI GPIO_PIN(P3, 1)
#define SPI_PIN_CLK GPIO_PIN(P3, 3)
#define SPI_NUMOF ARRAY_SIZE(spi_config)
/** @} */

#ifdef __cplusplus
Expand Down
7 changes: 7 additions & 0 deletions boards/olimex-msp430-h1611/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# UART @ 115200 Bd is not reliable with a CPU clock of ~ 5 MHz, occasionally
# chars get lost. Adding an 8 MHz crystal or an external resistor so that the
# DCO can reach 8 MHz does yield the speed bump needed for a more reliable
# UART connection @ 115200 Bd
BAUD ?= 9600

# When freshly plugged in the Olimex MSP430-JTAG-Tiny debugger provides a
# ttyACM interface, which is only available until the first flashing. A
# `make term` or even a `make flash term` may pick the JTAG debugger instead
Expand All @@ -16,3 +22,4 @@ TTY_SELECT_CMD := $(RIOTTOOLS)/usb-serial/ttys.py \
--format path serial

include $(RIOTBOARD)/common/msp430/Makefile.include
CFLAGS += -DSTDIO_UART_BAUDRATE=$(BAUD)
40 changes: 19 additions & 21 deletions boards/olimex-msp430-h1611/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ extern "C" {
* @brief Clock configuration
*/
static const msp430_clock_params_t clock_params = {
/* Without an external resistor, the DCO frequency typically tops out
* at something like 5 MHz. However, the DCO calibration just picks the
* closet possible value, in this case it will go for the highest frequency
* the silicon at hand can run at. */
.target_dco_frequency = MHZ(8),
.lfxt1_frequency = 32768,
.main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK,
Expand All @@ -48,35 +52,29 @@ static const msp430_clock_params_t clock_params = {
* @name UART configuration
* @{
*/
#define UART_NUMOF (1U)
static const uart_conf_t uart_config[] = {
{
.uart = &usart1_as_uart,
},
};

#define UART0_RX_ISR (USART1RX_VECTOR) /**< RX IRQ vector of UART 0 */
#define UART0_TX_ISR (USART1TX_VECTOR) /**< TX IRQ vector of UART 0 */

#define UART_BASE (&USART_1)
#define UART_SFR (&USART_1_SFR)
#define UART_IE_RX_BIT (1 << 4)
#define UART_IE_TX_BIT (1 << 5)
#define UART_ME_BITS (0x30)
#define UART_PORT (&PORT_3)
#define UART_RX_PIN (1 << 6)
#define UART_TX_PIN (1 << 7)
#define UART_RX_ISR (USART1RX_VECTOR)
#define UART_TX_ISR (USART1TX_VECTOR)
#define UART_NUMOF ARRAY_SIZE(uart_config)
/** @} */

/**
* @name SPI configuration
* @{
*/
#define SPI_NUMOF (1U)
static const spi_conf_t spi_config[] = {
{
.spi = &usart0_as_spi,
},
};

/* SPI configuration */
#define SPI_BASE (&USART_0)
#define SPI_SFR (&USART_0_SFR)
#define SPI_IE_RX_BIT (1 << 6)
#define SPI_IE_TX_BIT (1 << 7)
#define SPI_ME_BIT (1 << 6)
#define SPI_PIN_MISO GPIO_PIN(P3, 2)
#define SPI_PIN_MOSI GPIO_PIN(P3, 1)
#define SPI_PIN_CLK GPIO_PIN(P3, 3)
#define SPI_NUMOF ARRAY_SIZE(spi_config)
/** @} */

#ifdef __cplusplus
Expand Down
35 changes: 15 additions & 20 deletions boards/telosb/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,29 @@ static const msp430_clock_params_t clock_params = {
* @name UART configuration
* @{
*/
#define UART_NUMOF (1U)
static const uart_conf_t uart_config[] = {
{
.uart = &usart1_as_uart,
},
};

#define UART0_RX_ISR (USART1RX_VECTOR) /**< RX IRQ vector of UART 0 */
#define UART0_TX_ISR (USART1TX_VECTOR) /**< TX IRQ vector of UART 0 */

#define UART_BASE (&USART_1)
#define UART_SFR (&USART_1_SFR)
#define UART_IE_RX_BIT (1 << 4)
#define UART_IE_TX_BIT (1 << 5)
#define UART_ME_BITS (0x30)
#define UART_PORT (&PORT_3)
#define UART_RX_PIN (1 << 6)
#define UART_TX_PIN (1 << 7)
#define UART_RX_ISR (USART1RX_VECTOR)
#define UART_TX_ISR (USART1TX_VECTOR)
#define UART_NUMOF ARRAY_SIZE(uart_config)
/** @} */

/**
* @name SPI configuration
* @{
*/
#define SPI_NUMOF (1U)
static const spi_conf_t spi_config[] = {
{
.spi = &usart0_as_spi,
},
};

#define SPI_BASE (&USART_0)
#define SPI_SFR (&USART_0_SFR)
#define SPI_IE_RX_BIT (1 << 6)
#define SPI_IE_TX_BIT (1 << 7)
#define SPI_ME_BIT (1 << 6)
#define SPI_PIN_MISO GPIO_PIN(P3, 2)
#define SPI_PIN_MOSI GPIO_PIN(P3, 1)
#define SPI_PIN_CLK GPIO_PIN(P3, 3)
#define SPI_NUMOF ARRAY_SIZE(spi_config)
/** @} */

#ifdef __cplusplus
Expand Down
Loading
Loading