![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Empty
main.cpp
- Committer:
- vermaelen
- Date:
- 2022-05-23
- Revision:
- 2:2616b6004345
- Parent:
- 1:61f61158c345
- Child:
- 3:6d221b7c12f2
File content as of revision 2:2616b6004345:
#include "mbed.h" void SPI_Ecrire2Octets(unsigned char MSB, unsigned char LSB); void Init_MAX7219(void); SPI spi(D11,D12,D13); // Arduino compatible MOSI, MISO, SCLK DigitalOut cs(D14); // Chip select // Programme principal int main() { cs.write(1); // CS initially High spi.format(8,0); // 8-bit format, mode 0,0 spi.frequency(1000000); // SCLK = 1 MHz Init_MAX7219(); // Initialize the LED controller while (1) { } } // Pour envoyer 2 octets sur le bus SPI void SPI_Ecrire2Octets(unsigned char MSB, unsigned char LSB) { // Ecrire ici le code de votre fonction } // initialisation du MAX7219 void Init_MAX7219(void) { for(int i=0; i<4; i++) { SPI_Ecrire2Octets(0x09, 0x00); // Decoding off SPI_Ecrire2Octets(0x0A, 0x08); // Brightness to intermediate SPI_Ecrire2Octets(0x0B, 0x07); // Scan limit = 7 SPI_Ecrire2Octets(0x0C, 0x01); // Normal operation mode SPI_Ecrire2Octets(0x0F, 0x0F); // Enable display test wait_ms(500); // 500 ms delay SPI_Ecrire2Octets(0x01, 0x00); // Clear row 0. SPI_Ecrire2Octets(0x02, 0x00); // Clear row 1. SPI_Ecrire2Octets(0x03, 0x00); // Clear row 2. SPI_Ecrire2Octets(0x04, 0x00); // Clear row 3. SPI_Ecrire2Octets(0x05, 0x00); // Clear row 4. SPI_Ecrire2Octets(0x06, 0x00); // Clear row 5. SPI_Ecrire2Octets(0x07, 0x00); // Clear row 6. SPI_Ecrire2Octets(0x08, 0x00); // Clear row 7. SPI_Ecrire2Octets(0x0F, 0x00); // Disable display test wait_ms(500); // 500 ms delay } }