You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
245 lines
6.8 KiB
245 lines
6.8 KiB
#include "main.h"
|
|
#include "delay.h"
|
|
#include "deviceSetup.h"
|
|
#include "usart.h"
|
|
#include "ascii.h"
|
|
#include "timer.h"
|
|
#include "spi.h"
|
|
#include "max7219.h"
|
|
|
|
unsigned char A[] = {0b00000000,0b00111100,0b01100110,0b01100110,0b01111110,0b01100110,0b01100110,0b01100110};
|
|
unsigned char B[] = {0b01111000,0b01001000,0b01001000,0b01110000,0b01001000,0b01000100,0b01000100,0b01111100};
|
|
unsigned char C[] = {0b00000000,0b00011110,0b00100000,0b01000000,0b01000000,0b01000000,0b00100000,0b00011110};
|
|
unsigned char D[] = {0b00000000,0b00111000,0b00100100,0b00100010,0b00100010,0b00100100,0b00111000,0b00000000};
|
|
unsigned char E[] = {0b00000000,0b00111100,0b00100000,0b00111000,0b00100000,0b00100000,0b00111100,0b00000000};
|
|
unsigned char F[] = {0b00000000,0b00111100,0b00100000,0b00111000,0b00100000,0b00100000,0b00100000,0b00000000};
|
|
unsigned char G[] = {0b00000000,0b00111110,0b00100000,0b00100000,0b00101110,0b00100010,0b00111110,0b00000000};
|
|
unsigned char H[] = {0b00000000,0b00100100,0b00100100,0b00111100,0b00100100,0b00100100,0b00100100,0b00000000};
|
|
unsigned char I[] = {0b00000000,0b00111000,0b00010000,0b00010000,0b00010000,0b00010000,0b00111000,0b00000000};
|
|
unsigned char J[] = {0b00000000,0b00011100,0b00001000,0b00001000,0b00001000,0b00101000,0b00111000,0b00000000};
|
|
unsigned char K[] = {0b00000000,0b00100100,0b00101000,0b00110000,0b00101000,0b00100100,0b00100100,0b00000000};
|
|
unsigned char L[] = {0b00000000,0b00100000,0b00100000,0b00100000,0b00100000,0b00100000,0b00111100,0b00000000};
|
|
unsigned char M[] = {0b00000000,0b00000000,0b01000100,0b10101010,0b10010010,0b10000010,0b10000010,0b00000000};
|
|
unsigned char N[] = {0b00000000,0b00100010,0b00110010,0b00101010,0b00100110,0b00100010,0b00000000,0b00000000};
|
|
unsigned char O[] = {0b00000000,0b00111100,0b01000010,0b01000010,0b01000010,0b01000010,0b00111100,0b00000000};
|
|
unsigned char P[] = {0b00000000,0b00111000,0b00100100,0b00100100,0b00111000,0b00100000,0b00100000,0b00000000};
|
|
unsigned char Q[] = {0b00000000,0b00111100,0b01000010,0b01000010,0b01000010,0b01000110,0b00111110,0b00000001};
|
|
unsigned char R[] = {0b00000000,0b00111000,0b00100100,0b00100100,0b00111000,0b00100100,0b00100100,0b00000000};
|
|
unsigned char S[] = {0b00000000,0b00111100,0b00100000,0b00111100,0b00000100,0b00000100,0b00111100,0b00000000};
|
|
unsigned char T[] = {0b00000000,0b01111100,0b00010000,0b00010000,0b00010000,0b00010000,0b00010000,0b00000000};
|
|
unsigned char U[] = {0b00000000,0b01000010,0b01000010,0b01000010,0b01000010,0b00100100,0b00011000,0b00000000};
|
|
unsigned char V[] = {0b00000000,0b00100010,0b00100010,0b00100010,0b00010100,0b00010100,0b00001000,0b00000000};
|
|
unsigned char W[] = {0b00000000,0b10000010,0b10010010,0b01010100,0b01010100,0b00101000,0b00000000,0b00000000};
|
|
unsigned char X[] = {0b00000000,0b01000010,0b00100100,0b00011000,0b00011000,0b00100100,0b01000010,0b00000000};
|
|
unsigned char Y[] = {0b00000000,0b01000100,0b00101000,0b00010000,0b00010000,0b00010000,0b00010000,0b00000000};
|
|
unsigned char Z[] = {0b00000000,0b00111100,0b00000100,0b00001000,0b00010000,0b00100000,0b00111100,0b00000000};
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
uint8_t i = 0;
|
|
uint8_t j = 0;
|
|
|
|
uint8_t f[] = {
|
|
0x00,
|
|
0x7E,
|
|
0x40,
|
|
0x40,
|
|
0x3E,
|
|
0x40,
|
|
0x40,
|
|
0x40
|
|
};
|
|
|
|
uint8_t matrix[] = {
|
|
0xAA,
|
|
0xFF,
|
|
0xAA,
|
|
0xFF,
|
|
0xAA,
|
|
0xFF,
|
|
0xAA,
|
|
0xFF};
|
|
|
|
uint8_t matrix_1[] = {
|
|
0x11,
|
|
0x11,
|
|
0x11,
|
|
0x11,
|
|
0x11,
|
|
0x11,
|
|
0x11,
|
|
0x11};
|
|
spi_ch_t spi_test_channel;
|
|
max7219_t ledMatrix;
|
|
|
|
// making array with all available timers
|
|
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
|
|
|
|
pinConfig(pinB3, output, pushPull, output, def_speed);
|
|
pinConfig(pinA0, input, def_stage, pullDown, def_speed);
|
|
|
|
setupInit(); // This is the sescond call of System init the assebly start code is calling it before the main.
|
|
|
|
|
|
usartInit( usart2,
|
|
pinA2,
|
|
pinA15,
|
|
115200,
|
|
eight,
|
|
NO_PARITY_CTRL,
|
|
noFlowControl);
|
|
|
|
//clears screen and send the wellcome messgae
|
|
print_Usart(usart2, ASCII_clear);
|
|
print_Usart(usart2, "HEllooo to our KED project\n\r");
|
|
|
|
|
|
for(i = 0 ; i < 5 ; i++) {
|
|
delayMs(100);
|
|
pinToggle(pinB3);
|
|
delayMs(100);
|
|
}
|
|
|
|
pinWrite(pinB3,0);
|
|
|
|
pinInit(pinA3);
|
|
|
|
//pinConfig(pinA6, alternate, floating, pullDown, veryFast);
|
|
pinConfig(pinA3, output, pushPull, output, veryFast);
|
|
|
|
// spi hardware channel setup
|
|
spiInitMaster(SPI_CH_1,
|
|
SPI_NONINVERTED,
|
|
SPI_CAPTURE_ON_FIRST_CLK_TRANSITION,
|
|
SPI_MSB_FIRST,
|
|
SPI_DOUPLEX,
|
|
7,
|
|
pinA5,
|
|
0,
|
|
pinA7,
|
|
0,
|
|
pinA6,
|
|
0);
|
|
|
|
spiSetupCH(&spi_test_channel, SPI_CH_1, pinA3);
|
|
|
|
// LED Matrix object setup
|
|
//ledMatrix.spiCH = &spi_test_channel;
|
|
max7219_init(&ledMatrix, &spi_test_channel);
|
|
|
|
spiEnable(SPI_CH_1);
|
|
/*
|
|
* MAX7219 hoockup for this example
|
|
*
|
|
* Signal pin nucleo
|
|
* --------------------------
|
|
* MOSI pinA7 A6
|
|
* MISO pinA6 A5
|
|
* CLK pinA5 A4
|
|
* CS pinA4 A3
|
|
*/
|
|
|
|
|
|
for(i = 0 ; i < 10 ; i++) {
|
|
delayMs(50);
|
|
pinToggle(pinB3);
|
|
delayMs(50);
|
|
}
|
|
|
|
max7219_testDisplay(&ledMatrix,1);
|
|
delayMs(500);
|
|
max7219_testDisplay(&ledMatrix,0);
|
|
max7219_shutdownDiaply(&ledMatrix,0);
|
|
max7219_setDecodeMode(&ledMatrix, NO_DECODE_DIGIT_7_TO_0);
|
|
max7219_setScanLimit(&ledMatrix, DSIPLAX_DIGIT_7_TO_0);
|
|
max7219_setIntensity(&ledMatrix,0x01);
|
|
|
|
max7219_ledMatrixSetLED(&ledMatrix,0,0);
|
|
delayMs(1000);
|
|
max7219_setAllLEDsOff(&ledMatrix);
|
|
/*
|
|
for(i=0; i < 8; i++) {
|
|
max7219_ledMatrixSetLED(&ledMatrix,i,i);
|
|
delayMs(100);
|
|
}
|
|
*/
|
|
|
|
while(1) {
|
|
max7219_printLedMatrix(&ledMatrix, F);
|
|
//max7219_ledMatrixSetLED(&ledMatrix, 0, 0);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, A);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, T);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, I);
|
|
delayMs(300);
|
|
max7219_setAllLEDsOff(&ledMatrix);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, G);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, E);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, N);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, T);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, I);
|
|
delayMs(300);
|
|
max7219_setAllLEDsOff(&ledMatrix);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, E);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, D);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, W);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, I);
|
|
delayMs(300);
|
|
max7219_printLedMatrix(&ledMatrix, N);
|
|
delayMs(300);
|
|
max7219_setAllLEDsOff(&ledMatrix);
|
|
delayMs(300);
|
|
}
|
|
|
|
while(1) {
|
|
for(i=0; i < 0x8; i++) {
|
|
max7219_ledMatrixSetLED(&ledMatrix,i,i+j);
|
|
delayMs(100);
|
|
}
|
|
//delayMs(10);
|
|
j++;
|
|
if(j > 7) j =0;
|
|
}
|
|
|
|
/*
|
|
while(1){
|
|
pinToggle(pinB3);
|
|
dispTest(&ledMatrix);
|
|
//max7219_test_display(&spi_test_channel);
|
|
}
|
|
*/
|
|
for(i = 0 ; i < 100 ; i++) {
|
|
pinWrite(pinB3, 1);
|
|
//pinWrite(pinA4,1);
|
|
delayMs(100);
|
|
pinWrite(pinB3, 0);
|
|
//pinWrite(pinA4,0);
|
|
delayMs(900);
|
|
}
|
|
|
|
|
|
//timer_capture_compare_test(timer_2);
|
|
//print_Usart(usart2, "All is working fine \r\n");
|
|
|
|
while(1)
|
|
{
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
|