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

Cortex CMSIS style definition of MSP430 registers. More...

Detailed Description

Cortex CMSIS style definition of MSP430 registers.

Todo:
This file is incomplete, not all registers are listed. Further There are probably some inconsistencies throughout the MSP430 family which need to be addressed.
Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file msp430_regs.h.

#include <stdint.h>
#include <stddef.h>
#include "msp430_regs_common.h"
+ Include dependency graph for msp430_regs.h:

Go to the source code of this file.

Data Structures

struct  msp430_usci_a_t
 Universal Serial Control Interface Type A (USCI_A) Registers. More...
 
struct  msp430_usci_b_t
 Universal Serial Control Interface Type B (USCI_B) Registers. More...
 

Functions

static msp430_usci_b_tmsp430_usci_b_from_usci_a (msp430_usci_a_t *usci_a)
 "Convert" a USCI A into an USCI B interface
 
#define MSP430_USCI_A_B_OFFSET   3U
 Offset of the USCI B registers in an USCI A peripheral.
 
#define MSP430_USCI_B_FROM_USCI_A(usci_a)    ((msp430_usci_b_t *)((uintptr_t)(usci_a) + MSP430_USCI_A_B_OFFSET))
 "Convert" an USCI A to an USCI B
 

USCI clock selection

The vendor header files expose clock configurations with hard to read names.

So we provide alias with better names

#define UCSSEL_UCLKI   UCSSEL_0
 Clock USCI using CLKI (n/a in SPI mode)
 
#define UCSSEL_ACLK   UCSSEL_1
 Clock USCI using auxiliary clock.
 
#define UCSSEL_SMCLK   UCSSEL_2
 Clock USCI using sub-system master clock.
 
#define UCSSEL_Pos   6
 Position of the UCSSEL field in the USCI CTL1 register.
 

USCI Modulation Control fields

The vendor header files provides bitmasks for each of the possible values from 0..7.

But rather than creating a look up table, we can just shift the number in place, if there only would be a UCRBS_SHIFT macro.

#define UCBRS_MASK   UCBRS_7
 Bitmask to retrieve the UCRBS field of the USCI modulation control register.
 
#define UCBRS_Pos   1
 Position of the UCRBS field in the UCAxMCTL register.
 

Typing of base register objects

msp430_usci_a_t USCI_A0
 USCI_A0 register map.
 
msp430_usci_a_t USCI_A1
 USCI_A1 register map.
 
msp430_usci_b_t USCI_B0
 USCI_B0 register map.
 
msp430_usci_b_t USCI_B1
 USCI_B1 register map.
 

Macro Definition Documentation

◆ MSP430_USCI_A_B_OFFSET

#define MSP430_USCI_A_B_OFFSET   3U

Offset of the USCI B registers in an USCI A peripheral.

USCI A peripheral contains the USCI B peripheral registers, but has a few USCI A specific register in front. Adding this offset to the USCI A base address results in the base address of the shared registers.

See also
MSP430_USCI_B_FROM_USCI_A

Definition at line 44 of file msp430_regs.h.

◆ MSP430_USCI_B_FROM_USCI_A

#define MSP430_USCI_B_FROM_USCI_A (   usci_a)     ((msp430_usci_b_t *)((uintptr_t)(usci_a) + MSP430_USCI_A_B_OFFSET))

"Convert" an USCI A to an USCI B

This returns the pointer to the part of the USCI A registers that matches the USCI B register layout, so that an USCI A can be treated as if it is an USCI B.

This can be used instead of msp430_usci_b_from_usci_a when needing a constant initializer. Otherwise msp430_usci_b_from_usci_a is preferred as it includes type checks this macro doesn't.

Definition at line 57 of file msp430_regs.h.

◆ UCBRS_MASK

#define UCBRS_MASK   UCBRS_7

Bitmask to retrieve the UCRBS field of the USCI modulation control register.

Definition at line 119 of file msp430_regs.h.

◆ UCBRS_Pos

#define UCBRS_Pos   1

Position of the UCRBS field in the UCAxMCTL register.

Definition at line 122 of file msp430_regs.h.

◆ UCSSEL_ACLK

#define UCSSEL_ACLK   UCSSEL_1

Clock USCI using auxiliary clock.

Definition at line 100 of file msp430_regs.h.

◆ UCSSEL_Pos

#define UCSSEL_Pos   6

Position of the UCSSEL field in the USCI CTL1 register.

Definition at line 104 of file msp430_regs.h.

◆ UCSSEL_SMCLK

#define UCSSEL_SMCLK   UCSSEL_2

Clock USCI using sub-system master clock.

Definition at line 101 of file msp430_regs.h.

◆ UCSSEL_UCLKI

#define UCSSEL_UCLKI   UCSSEL_0

Clock USCI using CLKI (n/a in SPI mode)

Definition at line 99 of file msp430_regs.h.

Function Documentation

◆ msp430_usci_b_from_usci_a()

static msp430_usci_b_t * msp430_usci_b_from_usci_a ( msp430_usci_a_t usci_a)
inlinestatic

"Convert" a USCI A into an USCI B interface

The USCI peripheral come in two flavors: USCI A and USCI B with the following feature set. When comparing the memory map USCI B is a subset of USCI A registers, which conveniently have the same offsets. It is therefore possible to address USCI A registers as if it was a USCI B interface when operated in SPI mode. This makes implementation of SPI easier.

Name UART SPI I2C IrDA
USCI A
USCI B

Definition at line 145 of file msp430_regs.h.

Variable Documentation

◆ USCI_A0

msp430_usci_a_t USCI_A0
extern

USCI_A0 register map.

Provided by linker

◆ USCI_A1

msp430_usci_a_t USCI_A1
extern

USCI_A1 register map.

Provided by linker

◆ USCI_B0

msp430_usci_b_t USCI_B0
extern

USCI_B0 register map.

Provided by linker

◆ USCI_B1

msp430_usci_b_t USCI_B1
extern

USCI_B1 register map.

Provided by linker