Loading...
Searching...
No Matches
periph_cpu.h File Reference

CPU specific definitions for internal peripheral handling. More...

Detailed Description

CPU specific definitions for internal peripheral handling.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file periph_cpu.h.

#include <stdbool.h>
#include "periph_cpu_common.h"
+ Include dependency graph for periph_cpu.h:

Go to the source code of this file.

Data Structures

struct  msp430_usci_params_t
 MSP430 F2xx/G2xx USCI configuration. More...
 
struct  msp430_usci_prescaler_t
 MSP430 F2xx/G2xx USCI prescaler configuration. More...
 
struct  msp430_usci_conf_t
 MSP430 F2xx/G2xx USCI configuration registers. More...
 
struct  msp430_usci_uart_params_t
 MSP430 F2xx/G2xx UART configuration, CPU level. More...
 
struct  uart_conf_t
 UART device configuration. More...
 
struct  msp430_usci_spi_params_t
 MSP430 F2xx/G2xx SPI configuration, CPU level. More...
 
struct  spi_conf_t
 SPI device configuration. More...
 

Enumerations

enum  msp430_usci_id_t { MSP430_USCI_ID_NUMOF }
 Identifiers for USCI instances. More...
 
enum  msp430_usci_clk_t { USCI_CLK_UCLKI = UCSSEL_UCLKI , USCI_CLK_AUX = UCSSEL_ACLK , USCI_CLK_SUBMAIN = UCSSEL_SMCLK }
 MSP430 F2xx/G2xx USCI clock source. More...
 

Functions

void msp430_usci_acquire (const msp430_usci_params_t *params, const msp430_usci_conf_t *conf)
 Acquire and initialize USCI for use a SPI/UART peripheral.
 
void msp430_usci_release (const msp430_usci_params_t *params)
 Release an USCI, so that it can be used to provide other peripherals.
 
msp430_usci_prescaler_t msp430_usci_prescale (uint32_t target_hz)
 Calculate prescaler settings for the given target frequency.
 

Variables

const msp430_usci_uart_params_t usci_a0_as_uart
 MSP430 F2xx/G2xx USCI A0 in UART configuration.
 
const msp430_usci_uart_params_t usci_a1_as_uart
 MSP430 F2xx/G2xx USCI A1 in UART configuration.
 
const msp430_usci_spi_params_t usci_a0_as_spi
 MSP430 F2xx/G2xx USCI A0 in SPI configuration.
 
const msp430_usci_spi_params_t usci_a1_as_spi
 MSP430 F2xx/G2xx USCI A1 in SPI configuration.
 
const msp430_usci_spi_params_t usci_b0_as_spi
 MSP430 F2xx/G2xx USCI B0 in SPI configuration.
 
const msp430_usci_spi_params_t usci_b1_as_spi
 MSP430 F2xx/G2xx USCI B1 in SPI configuration.
 

Override SPI mode selection values

#define HAVE_SPI_MODE_T
 MSP430 F2xx/G2xx has a custom spi_mode_t.
 
enum  spi_mode_t { SPI_MODE_0 = (UCCKPH) , SPI_MODE_1 = 0 , SPI_MODE_2 = (UCCKPL | UCCKPH) , SPI_MODE_3 = (UCCKPL) }
 Support SPI modes. More...
 

Override SPI clock speed selection values

#define HAVE_SPI_CLK_T
 MSP430 F2xx/G2xx has a custom spi_clock_t.
 
enum  spi_clk_t {
  SPI_CLK_100KHZ = 100000 , SPI_CLK_400KHZ = 400000 , SPI_CLK_1MHZ = 1000000 , SPI_CLK_5MHZ = 5000000 ,
  SPI_CLK_10MHZ = SPI_CLK_5MHZ
}
 Support SPI clock frequencies. More...
 

declare needed generic SPI functions

#define PERIPH_SPI_NEEDS_INIT_CS
 use shared spi_init_cs()
 
#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
 use shared spi_transfer_byte()
 
#define PERIPH_SPI_NEEDS_TRANSFER_REG
 use shared spi_transfer_reg()
 
#define PERIPH_SPI_NEEDS_TRANSFER_REGS
 use shared spi_transfer_regs()
 

Macro Definition Documentation

◆ HAVE_SPI_CLK_T

#define HAVE_SPI_CLK_T

MSP430 F2xx/G2xx has a custom spi_clock_t.

Definition at line 55 of file periph_cpu.h.

◆ HAVE_SPI_MODE_T

#define HAVE_SPI_MODE_T

MSP430 F2xx/G2xx has a custom spi_mode_t.

Definition at line 34 of file periph_cpu.h.

◆ PERIPH_SPI_NEEDS_INIT_CS

#define PERIPH_SPI_NEEDS_INIT_CS

use shared spi_init_cs()

Definition at line 72 of file periph_cpu.h.

◆ PERIPH_SPI_NEEDS_TRANSFER_BYTE

#define PERIPH_SPI_NEEDS_TRANSFER_BYTE

use shared spi_transfer_byte()

Definition at line 73 of file periph_cpu.h.

◆ PERIPH_SPI_NEEDS_TRANSFER_REG

#define PERIPH_SPI_NEEDS_TRANSFER_REG

use shared spi_transfer_reg()

Definition at line 74 of file periph_cpu.h.

◆ PERIPH_SPI_NEEDS_TRANSFER_REGS

#define PERIPH_SPI_NEEDS_TRANSFER_REGS

use shared spi_transfer_regs()

Definition at line 75 of file periph_cpu.h.

Enumeration Type Documentation

◆ msp430_usci_clk_t

MSP430 F2xx/G2xx USCI clock source.

Enumerator
USCI_CLK_UCLKI 

UCLKI clock source (not supported yet)

USCI_CLK_AUX 

auxiliary clock source

USCI_CLK_SUBMAIN 

sub-system master clock source

Definition at line 113 of file periph_cpu.h.

◆ msp430_usci_id_t

Identifiers for USCI instances.

This assigns the four USCI instances (A0, B0, A1, B1) numbers from 0 to 3.

Enumerator
MSP430_USCI_ID_NUMOF 

Number of USCI IDs (also: number of USCI instances)

Definition at line 83 of file periph_cpu.h.

◆ spi_clk_t

enum spi_clk_t

Support SPI clock frequencies.

Enumerator
SPI_CLK_100KHZ 

100 kHz

SPI_CLK_400KHZ 

400 kHz

SPI_CLK_1MHZ 

1 MHz

SPI_CLK_5MHZ 

5 MHz

SPI_CLK_10MHZ 

10 MHz not supported, falling back to 5 MHz

Definition at line 59 of file periph_cpu.h.

◆ spi_mode_t

enum spi_mode_t

Support SPI modes.

Field Name Description
UCCKPH Clock phase select 0 = capture on second edge, 1 = capture on first
UCCKPL Clock polarity select 0 = clock is idle-low, 1 = clock is high idle-high
Enumerator
SPI_MODE_0 

CPOL=0, CPHA=0.

SPI_MODE_1 

CPOL=0, CPHA=1.

SPI_MODE_2 

CPOL=1, CPHA=0.

SPI_MODE_3 

CPOL=1, CPHA=1.

Definition at line 43 of file periph_cpu.h.

Function Documentation

◆ msp430_usci_acquire()

void msp430_usci_acquire ( const msp430_usci_params_t params,
const msp430_usci_conf_t conf 
)

Acquire and initialize USCI for use a SPI/UART peripheral.

Parameters
paramsParameter identifying the USCI to use
confConfiguration to initialize the USCI with
Note
The USCI will be acquired and configured as specified in conf. However, it will still be held in software reset and all interrupts will be masked and all interrupt flags be cleared.
Warning
You cannot enable IRQs while the USCI is still held under reset.

As currently only for UART USCI IRQs are actually needed, the ISR is implemented in the UART driver. If the SPI or I2C driver would start to make use of IRQs (other than polling for the IRQ flag to be set), the ISRs would need to be moved to the USCI driver and call into the UART/SPI/I2C driver, depending on what driver has currently acquired the USCI.

◆ msp430_usci_prescale()

msp430_usci_prescaler_t msp430_usci_prescale ( uint32_t  target_hz)

Calculate prescaler settings for the given target frequency.

Parameters
target_hzThe clock frequency (in Hz) to generated with the prescaler
Returns
The calculated prescaler settings
Note
This will select the auxiliary clock source for well known UART symbol rates up to 9600 Bd, if that is running at 32,768 Hz. Otherwise the submain clock source is selected.

◆ msp430_usci_release()

void msp430_usci_release ( const msp430_usci_params_t params)

Release an USCI, so that it can be used to provide other peripherals.

This will also put the USCI in low power mode.