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 
21 #ifndef PERIPH_CPU_H
22 #define PERIPH_CPU_H
23 
24 #include "cpu.h"
25 #include "msp430_regs.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #define HAVE_GPIO_T
36 typedef uint16_t gpio_t;
42 #define GPIO_UNDEF (0xffff)
43 
48 #define GPIO_PIN(x, y) ((gpio_t)(((x & 0xff) << 8) | (1 << (y & 0xff))))
49 
53 #define SPI_HWCS(x) (SPI_CS_UNDEF)
54 
55 #ifndef DOXYGEN
56 
60 #define HAVE_GPIO_FLANK_T
61 typedef enum {
62  GPIO_FALLING = 0xff,
63  GPIO_RISING = 0x00,
64  GPIO_BOTH = 0xab
65 } gpio_flank_t;
71 #define HAVE_SPI_MODE_T
72 #ifndef SPI_USE_USCI
73 typedef enum {
74  SPI_MODE_0 = (USART_TCTL_CKPH),
75  SPI_MODE_1 = 0,
76  SPI_MODE_2 = (USART_TCTL_CKPL | USART_TCTL_CKPH),
77  SPI_MODE_3 = (USART_TCTL_CKPL)
78 } spi_mode_t;
79 #else
80 typedef enum {
81  SPI_MODE_0 = (USCI_SPI_CTL0_CKPH),
82  SPI_MODE_1 = 0,
83  SPI_MODE_2 = (USCI_SPI_CTL0_CKPL | USCI_SPI_CTL0_CKPH),
84  SPI_MODE_3 = (USCI_SPI_CTL0_CKPL)
85 } spi_mode_t;
86 #endif
87 
92 #define HAVE_SPI_CLK_T
93 typedef enum {
94  SPI_CLK_100KHZ = 100000,
95  SPI_CLK_400KHZ = 400000,
96  SPI_CLK_1MHZ = 1000000,
97  SPI_CLK_5MHZ = 5000000,
98  SPI_CLK_10MHZ = 0,
99 } spi_clk_t;
101 #endif /* ndef DOXYGEN */
102 
106 enum {
107  P1 = 1,
108  P2 = 2,
109  P3 = 3,
110  P4 = 4,
111  P5 = 5,
112  P6 = 6,
113 };
114 
121 void gpio_periph_mode(gpio_t pin, bool enable);
122 
127 #define PERIPH_SPI_NEEDS_INIT_CS
128 #define PERIPH_SPI_NEEDS_TRANSFER_BYTE
129 #define PERIPH_SPI_NEEDS_TRANSFER_REG
130 #define PERIPH_SPI_NEEDS_TRANSFER_REGS
131 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* PERIPH_CPU_H */
138 
emit interrupt on rising flank
emit interrupt on both flanks
void gpio_periph_mode(gpio_t pin, bool enable)
Enable or disable a pin to be used by peripheral modules.
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:69
Cortex CMSIS style definition of MSP430 registers.
emit interrupt on falling flank