Empty

Dependencies:   mbed

Committer:
vermaelen
Date:
Tue May 24 11:59:07 2022 +0000
Revision:
3:6d221b7c12f2
Parent:
2:2616b6004345
Child:
4:9e6950da125f
V2

Who changed what in which revision?

UserRevisionLine numberNew 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 3:6d221b7c12f2 6 // Déclarer ici le composant
vermaelen 3:6d221b7c12f2 7
vermaelen 3:6d221b7c12f2 8 // Déclarer ici le CS
vermaelen 3:6d221b7c12f2 9
vermaelen 2:2616b6004345 10 // Programme principal
vermaelen 1:61f61158c345 11 int main()
vermaelen 1:61f61158c345 12 {
vermaelen 2:2616b6004345 13 cs.write(1); // CS initially High
vermaelen 1:61f61158c345 14 spi.format(8,0); // 8-bit format, mode 0,0
vermaelen 1:61f61158c345 15 spi.frequency(1000000); // SCLK = 1 MHz
vermaelen 1:61f61158c345 16 Init_MAX7219(); // Initialize the LED controller
vermaelen 2:2616b6004345 17
vermaelen 1:61f61158c345 18 while (1) {
vermaelen 2:2616b6004345 19
vermaelen 1:61f61158c345 20
vermaelen 1:61f61158c345 21 }
vermaelen 1:61f61158c345 22 }
vermaelen 2:2616b6004345 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 2:2616b6004345 29 // initialisation du MAX7219
vermaelen 2:2616b6004345 30 void Init_MAX7219(void)
vermaelen 1:61f61158c345 31 {
vermaelen 3:6d221b7c12f2 32
vermaelen 2:2616b6004345 33 SPI_Ecrire2Octets(0x09, 0x00); // Decoding off
vermaelen 2:2616b6004345 34 SPI_Ecrire2Octets(0x0A, 0x08); // Brightness to intermediate
vermaelen 2:2616b6004345 35 SPI_Ecrire2Octets(0x0B, 0x07); // Scan limit = 7
vermaelen 2:2616b6004345 36 SPI_Ecrire2Octets(0x0C, 0x01); // Normal operation mode
vermaelen 2:2616b6004345 37 SPI_Ecrire2Octets(0x0F, 0x0F); // Enable display test
vermaelen 2:2616b6004345 38 wait_ms(500); // 500 ms delay
vermaelen 2:2616b6004345 39
vermaelen 2:2616b6004345 40 SPI_Ecrire2Octets(0x01, 0x00); // Clear row 0.
vermaelen 2:2616b6004345 41 SPI_Ecrire2Octets(0x02, 0x00); // Clear row 1.
vermaelen 2:2616b6004345 42 SPI_Ecrire2Octets(0x03, 0x00); // Clear row 2.
vermaelen 2:2616b6004345 43 SPI_Ecrire2Octets(0x04, 0x00); // Clear row 3.
vermaelen 2:2616b6004345 44 SPI_Ecrire2Octets(0x05, 0x00); // Clear row 4.
vermaelen 2:2616b6004345 45 SPI_Ecrire2Octets(0x06, 0x00); // Clear row 5.
vermaelen 2:2616b6004345 46 SPI_Ecrire2Octets(0x07, 0x00); // Clear row 6.
vermaelen 2:2616b6004345 47 SPI_Ecrire2Octets(0x08, 0x00); // Clear row 7.
vermaelen 2:2616b6004345 48 SPI_Ecrire2Octets(0x0F, 0x00); // Disable display test
vermaelen 2:2616b6004345 49 wait_ms(500); // 500 ms delay
vermaelen 1:61f61158c345 50 }
vermaelen 3:6d221b7c12f2 51