MSS
/
testI2C
Simple I2C test program. open/close/read/write supported.
MSS.h@2:218e22a54982, 2016-04-05 (annotated)
- Committer:
- Rhyme
- Date:
- Tue Apr 05 06:53:27 2016 +0000
- Revision:
- 2:218e22a54982
- Parent:
- 0:1a2637f8e2dd
condition check for read/write and bus scan added;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:1a2637f8e2dd | 1 | #ifndef _MSS_H_ |
Rhyme | 0:1a2637f8e2dd | 2 | #define _MSS_H_ |
Rhyme | 0:1a2637f8e2dd | 3 | |
Rhyme | 0:1a2637f8e2dd | 4 | #if defined (TARGET_KL25Z) |
Rhyme | 0:1a2637f8e2dd | 5 | /* I2C */ |
Rhyme | 0:1a2637f8e2dd | 6 | #define PIN_SCL PTE1 |
Rhyme | 0:1a2637f8e2dd | 7 | #define PIN_SDA PTE0 |
Rhyme | 0:1a2637f8e2dd | 8 | /* SPI */ |
Rhyme | 0:1a2637f8e2dd | 9 | #define PIN_SCK PTD1 |
Rhyme | 0:1a2637f8e2dd | 10 | #define PIN_MISO PTD3 |
Rhyme | 0:1a2637f8e2dd | 11 | #define PIN_MOSI PTD2 |
Rhyme | 0:1a2637f8e2dd | 12 | #define PIN_CS0 PTD0 |
Rhyme | 0:1a2637f8e2dd | 13 | /* Interrupt */ |
Rhyme | 0:1a2637f8e2dd | 14 | #define PIN_INT0 PTD5 |
Rhyme | 0:1a2637f8e2dd | 15 | #define PIN_INT1 PTA13 |
Rhyme | 0:1a2637f8e2dd | 16 | #define PIN_INT2 PTC9 /* This pin does not support interrupt */ |
Rhyme | 0:1a2637f8e2dd | 17 | #define PIN_INT3 PTC8 /* This pin does not support interrupt */ |
Rhyme | 0:1a2637f8e2dd | 18 | #define PIN_INT4 PTA5 |
Rhyme | 0:1a2637f8e2dd | 19 | #define PIN_INT5 PTA4 |
Rhyme | 0:1a2637f8e2dd | 20 | /* Analog Input */ |
Rhyme | 0:1a2637f8e2dd | 21 | #define PIN_AN0 PTB0 |
Rhyme | 0:1a2637f8e2dd | 22 | #define PIN_AN1 PTB1 |
Rhyme | 0:1a2637f8e2dd | 23 | #define PIN_AN2 PTB2 |
Rhyme | 0:1a2637f8e2dd | 24 | #define PIN_AN3 PTB3 |
Rhyme | 0:1a2637f8e2dd | 25 | #define PIN_AN4 PTC2 |
Rhyme | 0:1a2637f8e2dd | 26 | #define PIN_AN5 PTC1 |
Rhyme | 0:1a2637f8e2dd | 27 | #define BOARD_NAME "FRDM-KL25Z" |
Rhyme | 0:1a2637f8e2dd | 28 | |
Rhyme | 0:1a2637f8e2dd | 29 | #elif defined (TARGET_KL46Z) |
Rhyme | 0:1a2637f8e2dd | 30 | /* I2C */ |
Rhyme | 0:1a2637f8e2dd | 31 | #define PIN_SCL PTE1 |
Rhyme | 0:1a2637f8e2dd | 32 | #define PIN_SDA PTE0 |
Rhyme | 0:1a2637f8e2dd | 33 | /* SPI */ |
Rhyme | 0:1a2637f8e2dd | 34 | #define PIN_SCK PTD5 |
Rhyme | 0:1a2637f8e2dd | 35 | #define PIN_MISO PTD7 |
Rhyme | 0:1a2637f8e2dd | 36 | #define PIN_MOSI PTD6 |
Rhyme | 0:1a2637f8e2dd | 37 | #define PIN_CS0 PTD4 |
Rhyme | 0:1a2637f8e2dd | 38 | /* Interrupt */ |
Rhyme | 0:1a2637f8e2dd | 39 | #define PIN_INT0 PTD2 |
Rhyme | 0:1a2637f8e2dd | 40 | #define PIN_INT1 PTA13 |
Rhyme | 0:1a2637f8e2dd | 41 | #define PIN_INT2 PTC9 /* This pin does not support interrupt */ |
Rhyme | 0:1a2637f8e2dd | 42 | #define PIN_INT3 PTC8 /* This pin does not support interrupt */ |
Rhyme | 0:1a2637f8e2dd | 43 | #define PIN_INT4 PTA5 |
Rhyme | 0:1a2637f8e2dd | 44 | #define PIN_INT5 PTA4 |
Rhyme | 0:1a2637f8e2dd | 45 | /* Analog Input */ |
Rhyme | 0:1a2637f8e2dd | 46 | #define PIN_AN0 PTB0 |
Rhyme | 0:1a2637f8e2dd | 47 | #define PIN_AN1 PTB1 |
Rhyme | 0:1a2637f8e2dd | 48 | #define PIN_AN2 PTB2 |
Rhyme | 0:1a2637f8e2dd | 49 | #define PIN_AN3 PTB3 |
Rhyme | 0:1a2637f8e2dd | 50 | #define PIN_AN4 PTC2 |
Rhyme | 0:1a2637f8e2dd | 51 | #define PIN_AN5 PTC1 |
Rhyme | 0:1a2637f8e2dd | 52 | #define BOARD_NAME "FRDM-KL46Z" |
Rhyme | 0:1a2637f8e2dd | 53 | |
Rhyme | 0:1a2637f8e2dd | 54 | #elif defined (TARGET_K64F) |
Rhyme | 0:1a2637f8e2dd | 55 | /* I2C */ |
Rhyme | 0:1a2637f8e2dd | 56 | #define PIN_SCL PTE24 |
Rhyme | 0:1a2637f8e2dd | 57 | #define PIN_SDA PTE25 |
Rhyme | 0:1a2637f8e2dd | 58 | /* SPI */ |
Rhyme | 0:1a2637f8e2dd | 59 | #define PIN_SCK PTD1 |
Rhyme | 0:1a2637f8e2dd | 60 | #define PIN_MISO PTD3 |
Rhyme | 0:1a2637f8e2dd | 61 | #define PIN_MOSI PTD2 |
Rhyme | 0:1a2637f8e2dd | 62 | #define PIN_CS0 PTD0 |
Rhyme | 0:1a2637f8e2dd | 63 | /* Interrupt */ |
Rhyme | 0:1a2637f8e2dd | 64 | #define PIN_INT0 PTC4 |
Rhyme | 0:1a2637f8e2dd | 65 | #define PIN_INT1 PTA0 |
Rhyme | 0:1a2637f8e2dd | 66 | #define PIN_INT2 PTC3 |
Rhyme | 0:1a2637f8e2dd | 67 | #define PIN_INT3 PTC2 |
Rhyme | 0:1a2637f8e2dd | 68 | #define PIN_INT4 PTA2 |
Rhyme | 0:1a2637f8e2dd | 69 | #define PIN_INT5 PTB23 |
Rhyme | 0:1a2637f8e2dd | 70 | /* Analog Input */ |
Rhyme | 0:1a2637f8e2dd | 71 | #define PIN_AN0 PTB2 |
Rhyme | 0:1a2637f8e2dd | 72 | #define PIN_AN1 PTB3 |
Rhyme | 0:1a2637f8e2dd | 73 | #define PIN_AN2 PTB10 |
Rhyme | 0:1a2637f8e2dd | 74 | #define PIN_AN3 PTB11 |
Rhyme | 0:1a2637f8e2dd | 75 | #define PIN_AN4 PTC11 |
Rhyme | 0:1a2637f8e2dd | 76 | #define PIN_AN5 PTC10 |
Rhyme | 0:1a2637f8e2dd | 77 | #define BOARD_NAME "FRDM-K64Z" |
Rhyme | 0:1a2637f8e2dd | 78 | |
Rhyme | 0:1a2637f8e2dd | 79 | /** |
Rhyme | 0:1a2637f8e2dd | 80 | * NOTE: On FRDM-K22F |
Rhyme | 0:1a2637f8e2dd | 81 | * Both I2C and UART are assigned to |
Rhyme | 0:1a2637f8e2dd | 82 | * the same pins PTE1/PTE0. |
Rhyme | 0:1a2637f8e2dd | 83 | * So MSS does not work as is. |
Rhyme | 0:1a2637f8e2dd | 84 | */ |
Rhyme | 0:1a2637f8e2dd | 85 | #elif defined (TARGET_K22F) |
Rhyme | 0:1a2637f8e2dd | 86 | /* I2C */ |
Rhyme | 0:1a2637f8e2dd | 87 | #define PIN_SCL PTE1 |
Rhyme | 0:1a2637f8e2dd | 88 | #define PIN_SDA PTE0 |
Rhyme | 0:1a2637f8e2dd | 89 | /* SPI */ |
Rhyme | 0:1a2637f8e2dd | 90 | #define PIN_SCK PTD5 |
Rhyme | 0:1a2637f8e2dd | 91 | #define PIN_MISO PTD7 |
Rhyme | 0:1a2637f8e2dd | 92 | #define PIN_MOSI PTD6 |
Rhyme | 0:1a2637f8e2dd | 93 | #define PIN_CS0 PTD4 |
Rhyme | 0:1a2637f8e2dd | 94 | /* Interrupt */ |
Rhyme | 0:1a2637f8e2dd | 95 | #define PIN_INT0 PTA1 |
Rhyme | 0:1a2637f8e2dd | 96 | #define PIN_INT1 PTB19 |
Rhyme | 0:1a2637f8e2dd | 97 | #define PIN_INT2 PTC6 |
Rhyme | 0:1a2637f8e2dd | 98 | #define PIN_INT3 PTC3 |
Rhyme | 0:1a2637f8e2dd | 99 | #define PIN_INT4 PTB18 |
Rhyme | 0:1a2637f8e2dd | 100 | #define PIN_INT5 PTA4 |
Rhyme | 0:1a2637f8e2dd | 101 | /* Analog Input */ |
Rhyme | 0:1a2637f8e2dd | 102 | #define PIN_AN0 PTB0 |
Rhyme | 0:1a2637f8e2dd | 103 | #define PIN_AN1 PTB1 |
Rhyme | 0:1a2637f8e2dd | 104 | #define PIN_AN2 PTC1 |
Rhyme | 0:1a2637f8e2dd | 105 | #define PIN_AN3 PTC2 |
Rhyme | 0:1a2637f8e2dd | 106 | #define PIN_AN4 PTB3 |
Rhyme | 0:1a2637f8e2dd | 107 | #define PIN_AN5 PTB2 |
Rhyme | 0:1a2637f8e2dd | 108 | #define BOARD_NAME "FRDM-K22F" |
Rhyme | 0:1a2637f8e2dd | 109 | |
Rhyme | 0:1a2637f8e2dd | 110 | #elif defined (TARGET_KL05Z) |
Rhyme | 0:1a2637f8e2dd | 111 | /* I2C */ |
Rhyme | 0:1a2637f8e2dd | 112 | #define PIN_SCL PTB3 |
Rhyme | 0:1a2637f8e2dd | 113 | #define PIN_SDA PTB4 |
Rhyme | 0:1a2637f8e2dd | 114 | /* SPI */ |
Rhyme | 0:1a2637f8e2dd | 115 | #define PIN_SCK PTB0 |
Rhyme | 0:1a2637f8e2dd | 116 | #define PIN_MISO PTA6 |
Rhyme | 0:1a2637f8e2dd | 117 | #define PIN_MOSI PTA7 |
Rhyme | 0:1a2637f8e2dd | 118 | #define PIN_CS0 PTA5 |
Rhyme | 0:1a2637f8e2dd | 119 | /* Interrupt */ |
Rhyme | 0:1a2637f8e2dd | 120 | #define PIN_INT0 PTB11 |
Rhyme | 0:1a2637f8e2dd | 121 | #define PIN_INT1 PTB10 |
Rhyme | 0:1a2637f8e2dd | 122 | #define PIN_INT2 PTB7 |
Rhyme | 0:1a2637f8e2dd | 123 | #define PIN_INT3 PTB6 |
Rhyme | 0:1a2637f8e2dd | 124 | #define PIN_INT4 PTA12 |
Rhyme | 0:1a2637f8e2dd | 125 | #define PIN_INT5 PTA10 |
Rhyme | 0:1a2637f8e2dd | 126 | /* Analog Input */ |
Rhyme | 0:1a2637f8e2dd | 127 | #define PIN_AN0 PTB8 |
Rhyme | 0:1a2637f8e2dd | 128 | #define PIN_AN1 PTB9 |
Rhyme | 0:1a2637f8e2dd | 129 | #define PIN_AN2 PTA8 |
Rhyme | 0:1a2637f8e2dd | 130 | #define PIN_AN3 PTA0 |
Rhyme | 0:1a2637f8e2dd | 131 | #define PIN_AN4 PTA9 |
Rhyme | 0:1a2637f8e2dd | 132 | #define PIN_AN5 PTB13 |
Rhyme | 0:1a2637f8e2dd | 133 | #define BOARD_NAME "FRDM-KL05Z" |
Rhyme | 0:1a2637f8e2dd | 134 | |
Rhyme | 0:1a2637f8e2dd | 135 | #elif define (TARGET_F411RE) |
Rhyme | 0:1a2637f8e2dd | 136 | /* I2C */ |
Rhyme | 0:1a2637f8e2dd | 137 | #define PIN_SCL PB_8 |
Rhyme | 0:1a2637f8e2dd | 138 | #define PIN_SDA PB_9 |
Rhyme | 0:1a2637f8e2dd | 139 | /* SPI */ |
Rhyme | 0:1a2637f8e2dd | 140 | #define PIN_SCK PA_5 |
Rhyme | 0:1a2637f8e2dd | 141 | #define PIN_MISO PA_6 |
Rhyme | 0:1a2637f8e2dd | 142 | #define PIN_MOSI PA_7 |
Rhyme | 0:1a2637f8e2dd | 143 | #define PIN_CS0 PB_6 |
Rhyme | 0:1a2637f8e2dd | 144 | /* Interrupt */ |
Rhyme | 0:1a2637f8e2dd | 145 | #define PIN_INT0 PC_7 |
Rhyme | 0:1a2637f8e2dd | 146 | #define PIN_INT1 PA_9 |
Rhyme | 0:1a2637f8e2dd | 147 | #define PIN_INT2 PA_8 |
Rhyme | 0:1a2637f8e2dd | 148 | #define PIN_INT3 PB_10 |
Rhyme | 0:1a2637f8e2dd | 149 | #define PIN_INT4 PB_4 |
Rhyme | 0:1a2637f8e2dd | 150 | #define PIN_INT5 PB_5 |
Rhyme | 0:1a2637f8e2dd | 151 | /* Analog In */ |
Rhyme | 0:1a2637f8e2dd | 152 | #define PIN_AN0 PA_0 |
Rhyme | 0:1a2637f8e2dd | 153 | #define PIN_AN1 PA_1 |
Rhyme | 0:1a2637f8e2dd | 154 | #define PIN_AN2 PA_4 |
Rhyme | 0:1a2637f8e2dd | 155 | #define PIN_AN3 PB_0 |
Rhyme | 0:1a2637f8e2dd | 156 | #define PIN_AN4 PC_1 |
Rhyme | 0:1a2637f8e2dd | 157 | #define PIN_AN5 PC_0 |
Rhyme | 0:1a2637f8e2dd | 158 | #define BOARD_NAME "NUCLEO-F411RE" |
Rhyme | 0:1a2637f8e2dd | 159 | |
Rhyme | 0:1a2637f8e2dd | 160 | #else |
Rhyme | 0:1a2637f8e2dd | 161 | #error TARGET NOT DEFINED |
Rhyme | 0:1a2637f8e2dd | 162 | /* I2C */ |
Rhyme | 0:1a2637f8e2dd | 163 | #define PIN_SCL D15 |
Rhyme | 0:1a2637f8e2dd | 164 | #define PIN_SDA D14 |
Rhyme | 0:1a2637f8e2dd | 165 | /* SPI */ |
Rhyme | 0:1a2637f8e2dd | 166 | #define PIN_SCK D13 |
Rhyme | 0:1a2637f8e2dd | 167 | #define PIN_MISO D12 |
Rhyme | 0:1a2637f8e2dd | 168 | #define PIN_MOSI D11 |
Rhyme | 0:1a2637f8e2dd | 169 | #define PIN_CS0 D10 |
Rhyme | 0:1a2637f8e2dd | 170 | /* Interrupt */ |
Rhyme | 0:1a2637f8e2dd | 171 | #define PIN_INT0 D9 |
Rhyme | 0:1a2637f8e2dd | 172 | #define PIN_INT1 D8 |
Rhyme | 0:1a2637f8e2dd | 173 | #define PIN_INT2 D7 |
Rhyme | 0:1a2637f8e2dd | 174 | #define PIN_INT3 D6 |
Rhyme | 0:1a2637f8e2dd | 175 | #define PIN_INT4 D5 |
Rhyme | 0:1a2637f8e2dd | 176 | #define PIN_INT5 D4 |
Rhyme | 0:1a2637f8e2dd | 177 | /* Analog In */ |
Rhyme | 0:1a2637f8e2dd | 178 | #define PIN_AN0 A0 |
Rhyme | 0:1a2637f8e2dd | 179 | #define PIN_AN1 A1 |
Rhyme | 0:1a2637f8e2dd | 180 | #define PIN_AN2 A2 |
Rhyme | 0:1a2637f8e2dd | 181 | #define PIN_AN3 A3 |
Rhyme | 0:1a2637f8e2dd | 182 | #define PIN_AN4 A4 |
Rhyme | 0:1a2637f8e2dd | 183 | #define PIN_AN5 A5 |
Rhyme | 0:1a2637f8e2dd | 184 | /* MSS on board LEDs */ |
Rhyme | 0:1a2637f8e2dd | 185 | #define LED_D1 D13 |
Rhyme | 0:1a2637f8e2dd | 186 | #define LED_D2 D12 |
Rhyme | 0:1a2637f8e2dd | 187 | #define LED_D3 D11 |
Rhyme | 0:1a2637f8e2dd | 188 | #define LED_D4 D10 |
Rhyme | 0:1a2637f8e2dd | 189 | #define LED_D5 D3 |
Rhyme | 0:1a2637f8e2dd | 190 | #define LED_D6 D2 |
Rhyme | 0:1a2637f8e2dd | 191 | #define LED_D7 D1 |
Rhyme | 0:1a2637f8e2dd | 192 | #define LED_D8 D0 |
Rhyme | 0:1a2637f8e2dd | 193 | |
Rhyme | 0:1a2637f8e2dd | 194 | #endif |
Rhyme | 0:1a2637f8e2dd | 195 | |
Rhyme | 0:1a2637f8e2dd | 196 | #endif /* _MSS_H_ */ |