Loading...
Searching...
No Matches
periph_cpu.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
20
21#include <stdbool.h>
22
23#include "periph_cpu_common.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
33#define HAVE_SPI_MODE_T
42typedef enum {
43 SPI_MODE_0 = (UCCKPH),
45 SPI_MODE_2 = (UCCKPL | UCCKPH),
46 SPI_MODE_3 = (UCCKPL)
48
49
54#define HAVE_SPI_CLK_T
58typedef enum {
59 SPI_CLK_100KHZ = 100000,
60 SPI_CLK_400KHZ = 400000,
61 SPI_CLK_1MHZ = 1000000,
62 SPI_CLK_5MHZ = 5000000,
64} spi_clk_t;
65
66
71#define PERIPH_SPI_NEEDS_INIT_CS
72#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
73#define PERIPH_SPI_NEEDS_TRANSFER_REG
74#define PERIPH_SPI_NEEDS_TRANSFER_REGS
76
82typedef enum {
83#ifdef __MSP430_HAS_USCI_AB0__
84 MSP430_USCI_ID_A0,
85 MSP430_USCI_ID_B0,
86#endif
87#ifdef __MSP430_HAS_USCI_AB1__
88 MSP430_USCI_ID_A1,
89 MSP430_USCI_ID_B1,
90#endif
93
108
117
121typedef struct {
123 uint8_t br0;
124 uint8_t br1;
125 uint8_t mctl;
127
138
153
157typedef struct {
160
177
181typedef struct {
183} spi_conf_t;
184
189
194
213 const msp430_usci_conf_t *conf);
214
221
235
240
245
250
255
260
265
266#ifdef __cplusplus
267}
268#endif
269
#define REG8
Register types.
spi_clk_t
Definition periph_cpu.h:351
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
Definition periph_cpu.h:356
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
Definition periph_cpu.h:355
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
Definition periph_cpu.h:353
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
Definition periph_cpu.h:354
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
Definition periph_cpu.h:352
#define UCSSEL_ACLK
Clock USCI using auxiliary clock.
#define UCSSEL_SMCLK
Clock USCI using sub-system master clock.
#define UCSSEL_UCLKI
Clock USCI using CLKI (n/a in SPI mode)
msp430_port_p7_p8_t PORT_8
Register map of GPIO PORT 8.
const msp430_usci_spi_params_t usci_b1_as_spi
MSP430 F2xx/G2xx USCI B1 in SPI configuration.
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.
const msp430_usci_spi_params_t usci_a1_as_spi
MSP430 F2xx/G2xx USCI A1 in SPI configuration.
msp430_port_p7_p8_t PORT_7
Register map of GPIO PORT 7.
const msp430_usci_spi_params_t usci_b0_as_spi
MSP430 F2xx/G2xx USCI B0 in SPI configuration.
const msp430_usci_uart_params_t usci_a1_as_uart
MSP430 F2xx/G2xx USCI A1 in UART configuration.
msp430_usci_clk_t
MSP430 F2xx/G2xx USCI clock source.
Definition periph_cpu.h:112
@ USCI_CLK_SUBMAIN
sub-system master clock source
Definition periph_cpu.h:115
@ USCI_CLK_AUX
auxiliary clock source
Definition periph_cpu.h:114
@ USCI_CLK_UCLKI
UCLKI clock source (not supported yet)
Definition periph_cpu.h:113
const msp430_usci_spi_params_t usci_a0_as_spi
MSP430 F2xx/G2xx USCI A0 in SPI configuration.
const msp430_usci_uart_params_t usci_a0_as_uart
MSP430 F2xx/G2xx USCI A0 in UART configuration.
spi_mode_t
Support SPI modes.
Definition periph_cpu.h:42
@ SPI_MODE_0
CPOL=0, CPHA=0.
Definition periph_cpu.h:43
@ SPI_MODE_2
CPOL=1, CPHA=0.
Definition periph_cpu.h:45
@ SPI_MODE_1
CPOL=0, CPHA=1.
Definition periph_cpu.h:44
@ SPI_MODE_3
CPOL=1, CPHA=1.
Definition periph_cpu.h:46
msp430_usci_prescaler_t msp430_usci_prescale(uint32_t target_hz)
Calculate prescaler settings for the given target frequency.
msp430_usci_id_t
Identifiers for USCI instances.
Definition periph_cpu.h:82
@ MSP430_USCI_ID_NUMOF
Number of USCI IDs (also: number of USCI instances)
Definition periph_cpu.h:91
GPIO Port 7/8 (different register layout than Ports 1-6)
Definition msp430_regs.h:74
Universal Serial Control Interface Type B (USCI_B) Registers.
MSP430 F2xx/G2xx USCI configuration registers.
Definition periph_cpu.h:134
uint8_t ctl0
USCI control register 0.
Definition periph_cpu.h:136
msp430_usci_prescaler_t prescaler
Prescaler configuration.
Definition periph_cpu.h:135
MSP430 F2xx/G2xx USCI configuration.
Definition periph_cpu.h:99
REG8 * interrupt_enable
The interrupt enable register matching the USCI.
Definition periph_cpu.h:102
msp430_usci_b_t * dev
The USCI device to use.
Definition periph_cpu.h:100
REG8 * interrupt_flag
The interrupt flag register matching the USCI.
Definition periph_cpu.h:103
uint8_t rx_irq_mask
The bitmask to enable the TX IRQ for this USCI.
Definition periph_cpu.h:105
msp430_usci_id_t id
ID of the USCI.
Definition periph_cpu.h:106
uint8_t tx_irq_mask
The bitmask to enable the TX IRQ for this USCI.
Definition periph_cpu.h:104
MSP430 F2xx/G2xx USCI prescaler configuration.
Definition periph_cpu.h:121
uint8_t br0
What to write in the BR0 register.
Definition periph_cpu.h:123
msp430_usci_clk_t clk_source
Clock source to use.
Definition periph_cpu.h:122
uint8_t br1
What to write in the BR1 register.
Definition periph_cpu.h:124
uint8_t mctl
USCI modulation control register.
Definition periph_cpu.h:125
MSP430 F2xx/G2xx SPI configuration, CPU level.
Definition periph_cpu.h:171
gpio_t mosi
COPI (MOSI) pin.
Definition periph_cpu.h:174
gpio_t miso
CIPO (MISO) pin.
Definition periph_cpu.h:173
msp430_usci_params_t usci_params
The USCI parameters.
Definition periph_cpu.h:172
MSP430 F2xx/G2xx UART configuration, CPU level.
Definition periph_cpu.h:148
msp430_usci_params_t usci_params
The USCI params.
Definition periph_cpu.h:149
SPI device configuration.
Definition periph_cpu.h:336
const msp430_usci_spi_params_t * spi
The SPI configuration to use.
Definition periph_cpu.h:182
UART device configuration.
Definition periph_cpu.h:217
const msp430_usci_uart_params_t * uart
The UART configuration to use.
Definition periph_cpu.h:158