![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Empty
main.cpp@5:f619f1f71966, 2022-05-24 (annotated)
- Committer:
- vermaelen
- Date:
- Tue May 24 12:02:49 2022 +0000
- Revision:
- 5:f619f1f71966
- Parent:
- 4:9e6950da125f
V4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vermaelen | 2:2616b6004345 | 1 | #include "mbed.h" |
icserny | 0:bd34a367f642 | 2 | |
vermaelen | 2:2616b6004345 | 3 | void SPI_Ecrire2Octets(unsigned char MSB, unsigned char LSB); |
vermaelen | 2:2616b6004345 | 4 | void Init_MAX7219(void); |
icserny | 0:bd34a367f642 | 5 | |
vermaelen | 4:9e6950da125f | 6 | // Déclarer ici le composant |
vermaelen | 4:9e6950da125f | 7 | |
vermaelen | 4:9e6950da125f | 8 | // Déclarer ici le CS |
vermaelen | 4:9e6950da125f | 9 | |
vermaelen | 4:9e6950da125f | 10 | // Programme principal |
vermaelen | 1:61f61158c345 | 11 | int main() |
vermaelen | 1:61f61158c345 | 12 | { |
vermaelen | 5:f619f1f71966 | 13 | // Initialiser le CS à 1 |
vermaelen | 5:f619f1f71966 | 14 | // préciser le format 8-bit , mode 0,0 |
vermaelen | 5:f619f1f71966 | 15 | // Fixer l'horloge à 1MHz |
vermaelen | 5:f619f1f71966 | 16 | // Initialiser le composant MAX7219 |
vermaelen | 4:9e6950da125f | 17 | |
vermaelen | 1:61f61158c345 | 18 | while (1) { |
vermaelen | 4:9e6950da125f | 19 | |
vermaelen | 1:61f61158c345 | 20 | |
vermaelen | 1:61f61158c345 | 21 | } |
vermaelen | 1:61f61158c345 | 22 | } |
vermaelen | 4:9e6950da125f | 23 | // Pour envoyer 2 octets sur le bus SPI |
vermaelen | 2:2616b6004345 | 24 | void SPI_Ecrire2Octets(unsigned char MSB, unsigned char LSB) |
vermaelen | 2:2616b6004345 | 25 | { |
vermaelen | 2:2616b6004345 | 26 | // Ecrire ici le code de votre fonction |
vermaelen | 2:2616b6004345 | 27 | } |
icserny | 0:bd34a367f642 | 28 | |
vermaelen | 4:9e6950da125f | 29 | // initialisation du MAX7219 |
vermaelen | 2:2616b6004345 | 30 | void Init_MAX7219(void) |
vermaelen | 1:61f61158c345 | 31 | { |
vermaelen | 4:9e6950da125f | 32 | |
vermaelen | 4:9e6950da125f | 33 | SPI_Ecrire2Octets(0x09, 0x00); // Decoding off |
vermaelen | 4:9e6950da125f | 34 | SPI_Ecrire2Octets(0x0A, 0x08); // Brightness to intermediate |
vermaelen | 4:9e6950da125f | 35 | SPI_Ecrire2Octets(0x0B, 0x07); // Scan limit = 7 |
vermaelen | 4:9e6950da125f | 36 | SPI_Ecrire2Octets(0x0C, 0x01); // Normal operation mode |
vermaelen | 4:9e6950da125f | 37 | SPI_Ecrire2Octets(0x0F, 0x0F); // Enable display test |
vermaelen | 4:9e6950da125f | 38 | wait_ms(500); // 500 ms delay |
vermaelen | 2:2616b6004345 | 39 | |
vermaelen | 4:9e6950da125f | 40 | SPI_Ecrire2Octets(0x01, 0x00); // Clear row 0. |
vermaelen | 4:9e6950da125f | 41 | SPI_Ecrire2Octets(0x02, 0x00); // Clear row 1. |
vermaelen | 4:9e6950da125f | 42 | SPI_Ecrire2Octets(0x03, 0x00); // Clear row 2. |
vermaelen | 4:9e6950da125f | 43 | SPI_Ecrire2Octets(0x04, 0x00); // Clear row 3. |
vermaelen | 4:9e6950da125f | 44 | SPI_Ecrire2Octets(0x05, 0x00); // Clear row 4. |
vermaelen | 4:9e6950da125f | 45 | SPI_Ecrire2Octets(0x06, 0x00); // Clear row 5. |
vermaelen | 4:9e6950da125f | 46 | SPI_Ecrire2Octets(0x07, 0x00); // Clear row 6. |
vermaelen | 4:9e6950da125f | 47 | SPI_Ecrire2Octets(0x08, 0x00); // Clear row 7. |
vermaelen | 4:9e6950da125f | 48 | SPI_Ecrire2Octets(0x0F, 0x00); // Disable display test |
vermaelen | 4:9e6950da125f | 49 | wait_ms(500); // 500 ms delay |
vermaelen | 4:9e6950da125f | 50 | } |
vermaelen | 3:6d221b7c12f2 | 51 |