The friendly Operating System for the Internet of Things
msp430fxyz/include/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 
19 #ifndef CPU_PERIPH_H
20 #define CPU_PERIPH_H
21 
22 #include "cpu.h"
23 #include "msp430_regs.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
33 #define HAVE_GPIO_T
34 typedef uint16_t gpio_t;
40 #define GPIO_UNDEF (0xffff)
41 
46 #define GPIO_PIN(x, y) ((gpio_t)(((x & 0xff) << 8) | (1 << (y & 0xff))))
47 
51 #define SPI_HWCS(x) (SPI_CS_UNDEF)
52 
53 #ifndef DOXYGEN
54 
58 #define HAVE_GPIO_FLANK_T
59 typedef enum {
60  GPIO_FALLING = 0xff,
61  GPIO_RISING = 0x00,
62  GPIO_BOTH = 0xab
63 } gpio_flank_t;
69 #define HAVE_SPI_MODE_T
70 #ifndef SPI_USE_USCI
71 typedef enum {
72  SPI_MODE_0 = (USART_TCTL_CKPH),
73  SPI_MODE_1 = 0,
74  SPI_MODE_2 = (USART_TCTL_CKPL | USART_TCTL_CKPH),
75  SPI_MODE_3 = (USART_TCTL_CKPL)
76 } spi_mode_t;
77 #else
78 typedef enum {
79  SPI_MODE_0 = (USCI_SPI_CTL0_CKPH),
80  SPI_MODE_1 = 0,
81  SPI_MODE_2 = (USCI_SPI_CTL0_CKPL | USCI_SPI_CTL0_CKPH),
82  SPI_MODE_3 = (USCI_SPI_CTL0_CKPL)
83 } spi_mode_t;
84 #endif
85 
90 #define HAVE_SPI_CLK_T
91 typedef enum {
92  SPI_CLK_100KHZ = 100000,
93  SPI_CLK_400KHZ = 400000,
94  SPI_CLK_1MHZ = 1000000,
95  SPI_CLK_5MHZ = 5000000,
96  SPI_CLK_10MHZ = 0,
97 } spi_clk_t;
99 #endif /* ndef DOXYGEN */
100 
104 enum {
105  P1 = 1,
106  P2 = 2,
107  P3 = 3,
108  P4 = 4,
109  P5 = 5,
110  P6 = 6,
111 };
112 
119 void gpio_periph_mode(gpio_t pin, bool enable);
120 
125 #define PERIPH_SPI_NEEDS_INIT_CS
126 #define PERIPH_SPI_NEEDS_TRANSFER_BYTE
127 #define PERIPH_SPI_NEEDS_TRANSFER_REG
128 #define PERIPH_SPI_NEEDS_TRANSFER_REGS
129 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* CPU_PERIPH_H */
136 
emit interrupt on rising flank
Definition: gpio.h:114
emit interrupt on both flanks
Definition: gpio.h:115
gpio_flank_t
Definition of possible active flanks for external interrupt mode.
Definition: gpio.h:112
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:69
Cortex CMSIS style definition of MSP430 registers.
emit interrupt on falling flank
Definition: gpio.h:113
void gpio_periph_mode(gpio_t pin, bool enable)
Enable or disable a pin to be used by peripheral modules.