Another short time hack. This one is for test the behavior of the spi module. Probably an Oscilloscope is required to check the wave.

Dependencies:   mbed

/media/uploads/Rhyme/test_spi.jpg

Another short time hack of mine. To check Mr. J's problem, I needed a way to control SPI in a short time. This is an aid for testing SPI module with an Oscilloscope.

You can specify, frequency, bits, mode and number of loops to let the spi write or read.

For FRDM-KL25Z MOSI: PTD2 MISO: PTD3 SCLK:PTD1

Please set "local echo on" in your terminal program.

某JさんのSPIトラブルの様子を確認するのに、作った簡単なSPIテストプログラムです。 オシロスコープでSPIの挙動を見るためのユティリティです。

FRDM-KL25Zの場合、MOSI(PTD2), MISO(PTD3), SCLK(PTD1) で使っています。

ターミナルプログラムのローカルエコーを有効にしてご使用ください。

SPIモジュールの設定(周波数、ビット、モード、そして読み書きのループ回数を設定できます。)

Committer:
Rhyme
Date:
Wed Jun 01 07:42:55 2016 +0000
Revision:
3:ec7a94b41102
MSS supported platforms added. Tested with FRDM-K64F with mbed lib 119

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 3:ec7a94b41102 1 #ifndef _MSS_H_
Rhyme 3:ec7a94b41102 2 #define _MSS_H_
Rhyme 3:ec7a94b41102 3
Rhyme 3:ec7a94b41102 4 #if defined (TARGET_KL25Z)
Rhyme 3:ec7a94b41102 5 /* I2C */
Rhyme 3:ec7a94b41102 6 #define PIN_SCL PTE1
Rhyme 3:ec7a94b41102 7 #define PIN_SDA PTE0
Rhyme 3:ec7a94b41102 8 /* SPI */
Rhyme 3:ec7a94b41102 9 #define PIN_SCK PTD1
Rhyme 3:ec7a94b41102 10 #define PIN_MISO PTD3
Rhyme 3:ec7a94b41102 11 #define PIN_MOSI PTD2
Rhyme 3:ec7a94b41102 12 #define PIN_CS0 PTD0
Rhyme 3:ec7a94b41102 13 /* Interrupt */
Rhyme 3:ec7a94b41102 14 #define PIN_INT0 PTD5
Rhyme 3:ec7a94b41102 15 #define PIN_INT1 PTA13
Rhyme 3:ec7a94b41102 16 #define PIN_INT2 PTC9 /* This pin does not support interrupt */
Rhyme 3:ec7a94b41102 17 #define PIN_INT3 PTC8 /* This pin does not support interrupt */
Rhyme 3:ec7a94b41102 18 #define PIN_INT4 PTA5
Rhyme 3:ec7a94b41102 19 #define PIN_INT5 PTA4
Rhyme 3:ec7a94b41102 20 /* Analog Input */
Rhyme 3:ec7a94b41102 21 #define PIN_AN0 PTB0
Rhyme 3:ec7a94b41102 22 #define PIN_AN1 PTB1
Rhyme 3:ec7a94b41102 23 #define PIN_AN2 PTB2
Rhyme 3:ec7a94b41102 24 #define PIN_AN3 PTB3
Rhyme 3:ec7a94b41102 25 #define PIN_AN4 PTC2
Rhyme 3:ec7a94b41102 26 #define PIN_AN5 PTC1
Rhyme 3:ec7a94b41102 27 #define BOARD_NAME "FRDM-KL25Z"
Rhyme 3:ec7a94b41102 28
Rhyme 3:ec7a94b41102 29 #elif defined (TARGET_KL46Z)
Rhyme 3:ec7a94b41102 30 /* I2C */
Rhyme 3:ec7a94b41102 31 #define PIN_SCL PTE1
Rhyme 3:ec7a94b41102 32 #define PIN_SDA PTE0
Rhyme 3:ec7a94b41102 33 /* SPI */
Rhyme 3:ec7a94b41102 34 #define PIN_SCK PTD5
Rhyme 3:ec7a94b41102 35 #define PIN_MISO PTD7
Rhyme 3:ec7a94b41102 36 #define PIN_MOSI PTD6
Rhyme 3:ec7a94b41102 37 #define PIN_CS0 PTD4
Rhyme 3:ec7a94b41102 38 /* Interrupt */
Rhyme 3:ec7a94b41102 39 #define PIN_INT0 PTD2
Rhyme 3:ec7a94b41102 40 #define PIN_INT1 PTA13
Rhyme 3:ec7a94b41102 41 #define PIN_INT2 PTC9 /* This pin does not support interrupt */
Rhyme 3:ec7a94b41102 42 #define PIN_INT3 PTC8 /* This pin does not support interrupt */
Rhyme 3:ec7a94b41102 43 #define PIN_INT4 PTA5
Rhyme 3:ec7a94b41102 44 #define PIN_INT5 PTA4
Rhyme 3:ec7a94b41102 45 /* Analog Input */
Rhyme 3:ec7a94b41102 46 #define PIN_AN0 PTB0
Rhyme 3:ec7a94b41102 47 #define PIN_AN1 PTB1
Rhyme 3:ec7a94b41102 48 #define PIN_AN2 PTB2
Rhyme 3:ec7a94b41102 49 #define PIN_AN3 PTB3
Rhyme 3:ec7a94b41102 50 #define PIN_AN4 PTC2
Rhyme 3:ec7a94b41102 51 #define PIN_AN5 PTC1
Rhyme 3:ec7a94b41102 52 #define BOARD_NAME "FRDM-KL46Z"
Rhyme 3:ec7a94b41102 53
Rhyme 3:ec7a94b41102 54 #elif defined (TARGET_K64F)
Rhyme 3:ec7a94b41102 55 /* I2C */
Rhyme 3:ec7a94b41102 56 #define PIN_SCL PTE24
Rhyme 3:ec7a94b41102 57 #define PIN_SDA PTE25
Rhyme 3:ec7a94b41102 58 /* SPI */
Rhyme 3:ec7a94b41102 59 #define PIN_SCK PTD1
Rhyme 3:ec7a94b41102 60 #define PIN_MISO PTD3
Rhyme 3:ec7a94b41102 61 #define PIN_MOSI PTD2
Rhyme 3:ec7a94b41102 62 #define PIN_CS0 PTD0
Rhyme 3:ec7a94b41102 63 /* Interrupt */
Rhyme 3:ec7a94b41102 64 #define PIN_INT0 PTC4
Rhyme 3:ec7a94b41102 65 #define PIN_INT1 PTA0
Rhyme 3:ec7a94b41102 66 #define PIN_INT2 PTC3
Rhyme 3:ec7a94b41102 67 #define PIN_INT3 PTC2
Rhyme 3:ec7a94b41102 68 #define PIN_INT4 PTA2
Rhyme 3:ec7a94b41102 69 #define PIN_INT5 PTB23
Rhyme 3:ec7a94b41102 70 /* Analog Input */
Rhyme 3:ec7a94b41102 71 #define PIN_AN0 PTB2
Rhyme 3:ec7a94b41102 72 #define PIN_AN1 PTB3
Rhyme 3:ec7a94b41102 73 #define PIN_AN2 PTB10
Rhyme 3:ec7a94b41102 74 #define PIN_AN3 PTB11
Rhyme 3:ec7a94b41102 75 #define PIN_AN4 PTC11
Rhyme 3:ec7a94b41102 76 #define PIN_AN5 PTC10
Rhyme 3:ec7a94b41102 77 #define BOARD_NAME "FRDM-K64Z"
Rhyme 3:ec7a94b41102 78
Rhyme 3:ec7a94b41102 79 /**
Rhyme 3:ec7a94b41102 80 * NOTE: On FRDM-K22F
Rhyme 3:ec7a94b41102 81 * Both I2C and UART are assigned to
Rhyme 3:ec7a94b41102 82 * the same pins PTE1/PTE0.
Rhyme 3:ec7a94b41102 83 * So MSS does not work as is.
Rhyme 3:ec7a94b41102 84 */
Rhyme 3:ec7a94b41102 85 #elif defined (TARGET_K22F)
Rhyme 3:ec7a94b41102 86 /* I2C */
Rhyme 3:ec7a94b41102 87 #define PIN_SCL PTE1
Rhyme 3:ec7a94b41102 88 #define PIN_SDA PTE0
Rhyme 3:ec7a94b41102 89 /* SPI */
Rhyme 3:ec7a94b41102 90 #define PIN_SCK PTD5
Rhyme 3:ec7a94b41102 91 #define PIN_MISO PTD7
Rhyme 3:ec7a94b41102 92 #define PIN_MOSI PTD6
Rhyme 3:ec7a94b41102 93 #define PIN_CS0 PTD4
Rhyme 3:ec7a94b41102 94 /* Interrupt */
Rhyme 3:ec7a94b41102 95 #define PIN_INT0 PTA1
Rhyme 3:ec7a94b41102 96 #define PIN_INT1 PTB19
Rhyme 3:ec7a94b41102 97 #define PIN_INT2 PTC6
Rhyme 3:ec7a94b41102 98 #define PIN_INT3 PTC3
Rhyme 3:ec7a94b41102 99 #define PIN_INT4 PTB18
Rhyme 3:ec7a94b41102 100 #define PIN_INT5 PTA4
Rhyme 3:ec7a94b41102 101 /* Analog Input */
Rhyme 3:ec7a94b41102 102 #define PIN_AN0 PTB0
Rhyme 3:ec7a94b41102 103 #define PIN_AN1 PTB1
Rhyme 3:ec7a94b41102 104 #define PIN_AN2 PTC1
Rhyme 3:ec7a94b41102 105 #define PIN_AN3 PTC2
Rhyme 3:ec7a94b41102 106 #define PIN_AN4 PTB3
Rhyme 3:ec7a94b41102 107 #define PIN_AN5 PTB2
Rhyme 3:ec7a94b41102 108 #define BOARD_NAME "FRDM-K22F"
Rhyme 3:ec7a94b41102 109
Rhyme 3:ec7a94b41102 110 #elif defined (TARGET_KL05Z)
Rhyme 3:ec7a94b41102 111 /* I2C */
Rhyme 3:ec7a94b41102 112 #define PIN_SCL PTB3
Rhyme 3:ec7a94b41102 113 #define PIN_SDA PTB4
Rhyme 3:ec7a94b41102 114 /* SPI */
Rhyme 3:ec7a94b41102 115 #define PIN_SCK PTB0
Rhyme 3:ec7a94b41102 116 #define PIN_MISO PTA6
Rhyme 3:ec7a94b41102 117 #define PIN_MOSI PTA7
Rhyme 3:ec7a94b41102 118 #define PIN_CS0 PTA5
Rhyme 3:ec7a94b41102 119 /* Interrupt */
Rhyme 3:ec7a94b41102 120 #define PIN_INT0 PTB11
Rhyme 3:ec7a94b41102 121 #define PIN_INT1 PTB10
Rhyme 3:ec7a94b41102 122 #define PIN_INT2 PTB7
Rhyme 3:ec7a94b41102 123 #define PIN_INT3 PTB6
Rhyme 3:ec7a94b41102 124 #define PIN_INT4 PTA12
Rhyme 3:ec7a94b41102 125 #define PIN_INT5 PTA10
Rhyme 3:ec7a94b41102 126 /* Analog Input */
Rhyme 3:ec7a94b41102 127 #define PIN_AN0 PTB8
Rhyme 3:ec7a94b41102 128 #define PIN_AN1 PTB9
Rhyme 3:ec7a94b41102 129 #define PIN_AN2 PTA8
Rhyme 3:ec7a94b41102 130 #define PIN_AN3 PTA0
Rhyme 3:ec7a94b41102 131 #define PIN_AN4 PTA9
Rhyme 3:ec7a94b41102 132 #define PIN_AN5 PTB13
Rhyme 3:ec7a94b41102 133 #define BOARD_NAME "FRDM-KL05Z"
Rhyme 3:ec7a94b41102 134
Rhyme 3:ec7a94b41102 135 #elif defined (TARGET_F411RE)
Rhyme 3:ec7a94b41102 136 /* I2C */
Rhyme 3:ec7a94b41102 137 #define PIN_SCL PB_8
Rhyme 3:ec7a94b41102 138 #define PIN_SDA PB_9
Rhyme 3:ec7a94b41102 139 /* SPI */
Rhyme 3:ec7a94b41102 140 #define PIN_SCK PA_5
Rhyme 3:ec7a94b41102 141 #define PIN_MISO PA_6
Rhyme 3:ec7a94b41102 142 #define PIN_MOSI PA_7
Rhyme 3:ec7a94b41102 143 #define PIN_CS0 PB_6
Rhyme 3:ec7a94b41102 144 /* Interrupt */
Rhyme 3:ec7a94b41102 145 #define PIN_INT0 PC_7
Rhyme 3:ec7a94b41102 146 #define PIN_INT1 PA_9
Rhyme 3:ec7a94b41102 147 #define PIN_INT2 PA_8
Rhyme 3:ec7a94b41102 148 #define PIN_INT3 PB_10
Rhyme 3:ec7a94b41102 149 #define PIN_INT4 PB_4
Rhyme 3:ec7a94b41102 150 #define PIN_INT5 PB_5
Rhyme 3:ec7a94b41102 151 /* Analog In */
Rhyme 3:ec7a94b41102 152 #define PIN_AN0 PA_0
Rhyme 3:ec7a94b41102 153 #define PIN_AN1 PA_1
Rhyme 3:ec7a94b41102 154 #define PIN_AN2 PA_4
Rhyme 3:ec7a94b41102 155 #define PIN_AN3 PB_0
Rhyme 3:ec7a94b41102 156 #define PIN_AN4 PC_1
Rhyme 3:ec7a94b41102 157 #define PIN_AN5 PC_0
Rhyme 3:ec7a94b41102 158 #define BOARD_NAME "NUCLEO-F411RE"
Rhyme 3:ec7a94b41102 159
Rhyme 3:ec7a94b41102 160 #elif defined (TARGET_LPC812)
Rhyme 3:ec7a94b41102 161 /* I2C */
Rhyme 3:ec7a94b41102 162 #define PIN_SCL P0_11
Rhyme 3:ec7a94b41102 163 #define PIN_SDA P0_10
Rhyme 3:ec7a94b41102 164 /* SPI */
Rhyme 3:ec7a94b41102 165 #define PIN_SCK P0_12
Rhyme 3:ec7a94b41102 166 #define PIN_MISO P0_15
Rhyme 3:ec7a94b41102 167 #define PIN_MOSI P0_14
Rhyme 3:ec7a94b41102 168 #define PIN_CS0 P0_13
Rhyme 3:ec7a94b41102 169 /* Interrupt */
Rhyme 3:ec7a94b41102 170 #define PIN_INT0 P0_16
Rhyme 3:ec7a94b41102 171 #define PIN_INT1 P0_17
Rhyme 3:ec7a94b41102 172 #define PIN_INT2 P0_7
Rhyme 3:ec7a94b41102 173 #define PIN_INT3 XP_4
Rhyme 3:ec7a94b41102 174 #define PIN_INT4 XP_5
Rhyme 3:ec7a94b41102 175 #define PIN_INT5 P0_9
Rhyme 3:ec7a94b41102 176 /* Analog In */
Rhyme 3:ec7a94b41102 177 #define PIN_AN0 A0
Rhyme 3:ec7a94b41102 178 #define PIN_AN1 A1
Rhyme 3:ec7a94b41102 179 #define PIN_AN2 A2
Rhyme 3:ec7a94b41102 180 #define PIN_AN3 A3
Rhyme 3:ec7a94b41102 181 #define PIN_AN4 A4
Rhyme 3:ec7a94b41102 182 #define PIN_AN5 A5
Rhyme 3:ec7a94b41102 183 /* MSS on board LEDs */
Rhyme 3:ec7a94b41102 184 #define LED_D1 P0_12
Rhyme 3:ec7a94b41102 185 #define LED_D2 P0_15
Rhyme 3:ec7a94b41102 186 #define LED_D3 P0_14
Rhyme 3:ec7a94b41102 187 #define LED_D4 P0_13
Rhyme 3:ec7a94b41102 188 #define LED_D5 P0_8
Rhyme 3:ec7a94b41102 189 #define LED_D6 P0_6
Rhyme 3:ec7a94b41102 190 #define LED_D7 P0_4
Rhyme 3:ec7a94b41102 191 #define LED_D8 P0_0
Rhyme 3:ec7a94b41102 192 #define BOARD_NAME "NXP_LPC800MAX"
Rhyme 3:ec7a94b41102 193
Rhyme 3:ec7a94b41102 194 #else
Rhyme 3:ec7a94b41102 195 #error TARGET NOT DEFINED
Rhyme 3:ec7a94b41102 196 /* I2C */
Rhyme 3:ec7a94b41102 197 #define PIN_SCL D15
Rhyme 3:ec7a94b41102 198 #define PIN_SDA D14
Rhyme 3:ec7a94b41102 199 /* SPI */
Rhyme 3:ec7a94b41102 200 #define PIN_SCK D13
Rhyme 3:ec7a94b41102 201 #define PIN_MISO D12
Rhyme 3:ec7a94b41102 202 #define PIN_MOSI D11
Rhyme 3:ec7a94b41102 203 #define PIN_CS0 D10
Rhyme 3:ec7a94b41102 204 /* Interrupt */
Rhyme 3:ec7a94b41102 205 #define PIN_INT0 D9
Rhyme 3:ec7a94b41102 206 #define PIN_INT1 D8
Rhyme 3:ec7a94b41102 207 #define PIN_INT2 D7
Rhyme 3:ec7a94b41102 208 #define PIN_INT3 D6
Rhyme 3:ec7a94b41102 209 #define PIN_INT4 D5
Rhyme 3:ec7a94b41102 210 #define PIN_INT5 D4
Rhyme 3:ec7a94b41102 211 /* Analog In */
Rhyme 3:ec7a94b41102 212 #define PIN_AN0 A0
Rhyme 3:ec7a94b41102 213 #define PIN_AN1 A1
Rhyme 3:ec7a94b41102 214 #define PIN_AN2 A2
Rhyme 3:ec7a94b41102 215 #define PIN_AN3 A3
Rhyme 3:ec7a94b41102 216 #define PIN_AN4 A4
Rhyme 3:ec7a94b41102 217 #define PIN_AN5 A5
Rhyme 3:ec7a94b41102 218 /* MSS on board LEDs */
Rhyme 3:ec7a94b41102 219 #define LED_D1 D13
Rhyme 3:ec7a94b41102 220 #define LED_D2 D12
Rhyme 3:ec7a94b41102 221 #define LED_D3 D11
Rhyme 3:ec7a94b41102 222 #define LED_D4 D10
Rhyme 3:ec7a94b41102 223 #define LED_D5 D3
Rhyme 3:ec7a94b41102 224 #define LED_D6 D2
Rhyme 3:ec7a94b41102 225 #define LED_D7 D1
Rhyme 3:ec7a94b41102 226 #define LED_D8 D0
Rhyme 3:ec7a94b41102 227
Rhyme 3:ec7a94b41102 228 #endif
Rhyme 3:ec7a94b41102 229
Rhyme 3:ec7a94b41102 230 #endif /* _MSS_H_ */