Blame view

RIOT/cpu/msp430fxyz/include/periph_cpu.h 3.39 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
  /*
   * Copyright (C) 2015 Freie Universitรคt Berlin
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  /**
   * @ingroup         cpu_msp430fxyz
   * @{
   *
   * @file
   * @brief           CPU specific definitions for internal peripheral handling
   *
   * @author          Hauke Petersen <hauke.petersen@fu-berlin.de>
   */
  
  #ifndef PERIPH_CPU_H
  #define PERIPH_CPU_H
  
  #include "cpu.h"
  #include "msp430_regs.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /**
   * @brief   Define a custom type for GPIO pins
   * @{
   */
  #define HAVE_GPIO_T
  typedef uint16_t gpio_t;
  /** @} */
  
  /**
   * @brief   Definition of a fitting UNDEF value
   */
  #define GPIO_UNDEF          (0xffff)
  
  /**
   * @brief   Mandatory function for defining a GPIO pins
   * @{
   */
  #define GPIO_PIN(x, y)      ((gpio_t)(((x & 0xff) << 8) | (1 << (y & 0xff))))
  
  /**
   * @brief   No support for HW chip select...
   */
  #define SPI_HWCS(x)         (SPI_CS_UNDEF)
  
  #ifndef DOXYGEN
  /**
   * @brief   Override flank selection values
   * @{
   */
  #define HAVE_GPIO_FLANK_T
  typedef enum {
      GPIO_FALLING = 0xff,        /**< emit interrupt on falling flank */
      GPIO_RISING  = 0x00,        /**< emit interrupt on rising flank */
      GPIO_BOTH    = 0xab         /**< not supported -> random value*/
  } gpio_flank_t;
  /** @} */
  
  /**
   * @brief   Override SPI mode selection values
   */
  #define HAVE_SPI_MODE_T
  #ifndef SPI_USE_USCI
  typedef enum {
      SPI_MODE_0 = (USART_TCTL_CKPH),                         /**< CPOL=0, CPHA=0 */
      SPI_MODE_1 = 0,                                         /**< CPOL=0, CPHA=1 */
      SPI_MODE_2 = (USART_TCTL_CKPL | USART_TCTL_CKPH),       /**< CPOL=1, CPHA=0 */
      SPI_MODE_3 = (USART_TCTL_CKPL)                          /**< CPOL=1, CPHA=1 */
  } spi_mode_t;
  #else
  typedef enum {
      SPI_MODE_0 = (USCI_SPI_CTL0_CKPH),                      /**< CPOL=0, CPHA=0 */
      SPI_MODE_1 = 0,                                         /**< CPOL=0, CPHA=1 */
      SPI_MODE_2 = (USCI_SPI_CTL0_CKPL | USCI_SPI_CTL0_CKPH), /**< CPOL=1, CPHA=0 */
      SPI_MODE_3 = (USCI_SPI_CTL0_CKPL)                       /**< CPOL=1, CPHA=1 */
  } spi_mode_t;
  #endif
  /** @} */
  
  /**
   * @brief   Override SPI clock speed selection values
   */
  #define HAVE_SPI_CLK_T
  typedef enum {
      SPI_CLK_100KHZ = 100000,    /**< 100KHz */
      SPI_CLK_400KHZ = 400000,    /**< 400KHz */
      SPI_CLK_1MHZ   = 1000000,   /**< 1MHz */
      SPI_CLK_5MHZ   = 5000000,   /**< 5MHz */
      SPI_CLK_10MHZ  = 0,         /**< not supported */
  } spi_clk_t;
  /** @} */
  #endif /* ndef DOXYGEN */
  
  /**
   * @brief   Available ports on MSP430 platforms
   */
  enum {
      P1 = 1,                 /**< PORT 1 */
      P2 = 2,                 /**< PORT 2 */
      P3 = 3,                 /**< PORT 3 */
      P4 = 4,                 /**< PORT 4 */
      P5 = 5,                 /**< PORT 5 */
      P6 = 6,                 /**< PORT 6 */
  };
  
  /**
   * @brief   Enable or disable a pin to be used by peripheral modules
   *
   * @param[in] pin       pin to (de-)select
   * @param[in] enable    true for enabling peripheral use, false for disabling it
   */
  void gpio_periph_mode(gpio_t pin, bool enable);
  
  /**
   * @brief declare needed generic SPI functions
   * @{
   */
  #define PERIPH_SPI_NEEDS_INIT_CS
  #define PERIPH_SPI_NEEDS_TRANSFER_BYTE
  #define PERIPH_SPI_NEEDS_TRANSFER_REG
  #define PERIPH_SPI_NEEDS_TRANSFER_REGS
  /** @} */
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* PERIPH_CPU_H */
  /** @} */