Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdbool.h>
- #include <inc/hw_memmap.h>
- #include <time.h>
- #include <stdlib.h>
- #include <xdc/std.h>
- #include <xdc/runtime/System.h>
- #include <xdc/runtime/Error.h>
- #include <ti/sysbios/BIOS.h>
- #include <ti/sysbios/knl/Clock.h>
- #include <ti/sysbios/knl/Task.h>
- #include <ti/sysbios/knl/Event.h>
- #include <ti/sysbios/knl/Semaphore.h>
- #include <ti/sysbios/knl/Queue.h>
- #include <driverlib/gpio.h>
- #include <driverlib/pin_map.h>/*supplies GPIO_PIN_x*/
- #include <driverlib/sysctl.h>
- #include <EK_TM4C1294XL.h>
- #include <ti/drivers/SPI.h>
- #include <driverlib/ssi.h>
- #include <inc/hw_ssi.h>
- #include <inc/hw_memmap.h>
- #include "8X8 FONT.h"
- #include "EK_TM4C1294XL.h"
- #include "Board.h"
- #define DELAY 50
- #define IMG_SIZE 20
- void click_init(char mikrobus);
- void display_image_const(char *image);
- void display_image(char *image);
- void slide_text_double(char *slide);
- extern void EK_TM4C1294XL_initSPI(void);
- void blinkled();
- char transImage1[8], transImage2[8], transImage3[8], transImage4[8];
- uint16_t lineAdresses[] = { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700, 0x800 };
- uint8_t dataMemory[] = { 255, 255, 255, 255, 255, 255, 255, 255 };
- extern char font[];
- // Serial 7-seg Display connections
- char i;
- char intro[] = " FUCK JAVA "; // Text to display
- uint32_t ui32SysClkFreq;
- void initGPIO();
- void SSI_write(uint16_t address, uint16_t data);
- void SSI_write_data(uint8_t data[8]);
- /*
- * ======== main ========
- */
- Int main()
- {
- Task_Params tskParams;
- ui32SysClkFreq=Board_initGeneral(120000000);
- initGPIO();
- /* create a ledblink task */
- Task_Params_init(&tskParams);
- tskParams.priority = 15;
- tskParams.arg0 = NULL;
- Task_create(&blinkled, &tskParams, NULL);
- BIOS_start(); /* does not return */
- return(0);
- }
- void initGPIO()
- {
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); /* ist das obere booster board GPIOQ ist das untere */
- SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
- SPI_init();
- GPIOPinConfigure(GPIO_PD3_SSI2CLK);/*hier nur Clock, RX und TX. Slave Select wird manuell gemacht */
- GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
- GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
- GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3); /*SPI aktivieren wichtig PIN 2 für SS auslassen */
- SysCtlPeripheralEnable(GPIO_PORTH_BASE); /*H2 ist der Pin für Slave select beim unteren platz waere es P5 */
- GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, GPIO_PIN_2);
- SSIClockSourceSet(SSI2_BASE,SSI_CLOCK_SYSTEM); /*Clock festlegen für SPI */
- SSIConfigSetExpClk(SSI2_BASE, 120000000, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000000, 16); /*CPU ist auf 120 Mhz, Click board/ SPI läuft auf 10 Mhz */
- SSIEnable(SSI2_BASE);
- //--init CLICK 8x8--------------------------
- SSI_write(0x900, 0x00); //no decode
- SSI_write(0xA00, 0x0F); //luminosity
- SSI_write(0xB00, 0x07); //activate all leds
- SSI_write(0xC00, 0x01); //Turn on the display
- SSI_write(0xF00, 0x00); //Set test off
- //----------------------------------------
- return;
- }
- void SSI_write(uint16_t address, uint16_t data)
- {
- GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, 0); //set cs low
- SSIDataPut(SSI2_BASE, address | data); //send address
- while (SSIBusy(SSI2_BASE)); //finish operation
- GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, GPIO_PIN_2); //send cs high
- }
- void SSI_write_data(uint8_t data[8])
- {
- uint8_t line;
- for(line = 0; line < 8; line++)
- {
- if(dataMemory[line] != data[line])
- {
- SSI_write(lineAdresses[line], data[line]);
- dataMemory[line] = data[line];
- }
- }
- }
- void blinkled()
- {
- slide_text_double(intro); // Text slide animation
- while(1){
- for(i = 0 ; i < IMG_SIZE ; i++){ // Play graphical sequence forward
- display_image_const(img1[i]);
- display_image_const(img2[i]);
- Task_sleep(120);
- }
- Task_sleep(200);
- slide_text_double(intro);
- Task_sleep(600);
- for(i = IMG_SIZE-1 ; i > 0 ; i--){ // Play graphical sequence backward
- display_image_const(img1[IMG_SIZE-1-i]); // Reverse and play forward 8x8 R click in first mikroBUS socket
- display_image_const(img2[i]);
- Task_sleep(120);
- }
- }
- }
- void display_image_const(char *image) {
- SSI_write_data((int)image);
- }
- void display_image(char *image) {
- SSI_write_data((int)image);
- }
- void slide_text_double(char *slide) {
- int i, j;
- int cntr;
- int tmp;
- char image1, image2, image3;
- display_image_const(font+(*slide << 3));
- display_image_const(font+(*(slide+1) << 3));
- Task_sleep(DELAY);
- cntr = 0;
- while (slide[cntr+1]) {
- image1 = *(slide+cntr);
- image2 = *(slide+cntr+1);
- image3 = *(slide+cntr+2);
- for (i=0; i<8; i++) {
- tmp = (image1 << 3) + i;
- transImage1[i] = *(font+tmp);
- tmp = (image2 << 3) + i;
- transImage2[i] = *(font+tmp);
- transImage4[i] = *(font+tmp);
- tmp = (image3 << 3) + i;
- transImage3[i] = *(font+tmp);
- }
- for (j=7; j>=0; j--){
- for (i=7; i>=1; i--){
- transImage1[i] = transImage1[i-1];
- transImage2[i] = transImage2[i-1];
- }
- transImage1[0] = transImage4[j];
- transImage2[0] = transImage3[j];
- display_image(transImage1);
- display_image(transImage2);
- Task_sleep(DELAY);
- }
- cntr++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement