/******************************************************************************* * Function Name: main ******************************************************************************** * * Summary: * Main function performs following functions: * 1. Initialises the DMA to move data from ADC_SAR_1 work registers to the * PrISM pulse density registers. * 2. Initialises the ISR connected to the DMA nrq terminal(DMA done). * 3. Initialises the LCD. * 4. Initialises the PrISM with 1Mhz clock. * 5. Initialises the two SAR ADCs. * 6. Displays the results of ADC_SAR_1 when DmaDone ISR rises. * The results are read from PrISM pulse density register. * 7. Displays the results of ADC_SAR_2 when internal EOC ISR rises. * * Parameters: * None. * * Return: * None. * *******************************************************************************/ int main() { char8 resultStr[16u]; float res; /* Initializes the LCD. */ LCD_Start(); LCD_Position(1u,0u); LCD_PrintString("ADC2= V"); ADC_SAR_2_Start(); ADC_SAR_2_IRQ_StartEx(ADC_SAR_2_ISR_LOC); ADC_SAR_2_StartConvert(); CyGlobalIntEnable; for(;;) { /* Show ADC2 result on LCD*/ if(dataReady != 0u) { res = ADC_SAR_2_CountsTo_Volts(result); sprintf((char *)resultStr,"%+1.2f",res); LCD_Position(1u,5u); LCD_PrintString(resultStr); dataReady = 0u; } } }
signed char DisplayChoices(const char *Menu[], char ItemCount, const char *Prompt, char Initial) { char SelectedItem = 0; signed char ret = 0; SelectedItem = Initial; while (1) { LCD_ClearDisplay(); LCD_PrintString(Prompt); LCD_SetPosition(1, 0); LCD_PrintChar('*'); LCD_PrintString(Menu[SelectedItem]); ret = GetInput(); if (ret < 0) return ret; switch (ret) { case USER_INPUT_CLICK: return (SelectedItem); case USER_INPUT_BACK: return (-1); case USER_INPUT_CANCEL: return (-2); case USER_INPUT_INC: if (SelectedItem == ItemCount) SelectedItem = ItemCount; else SelectedItem++; break; case USER_INPUT_DEC: if (SelectedItem == 0) SelectedItem = 0; else SelectedItem--; break; } } return (0); }
int main(void) { /* USER CODE BEGIN 1 */ uint8_t damogranlabs_logo[]={ 0x0F, 0x13, 0x11, 0x11, 0x0e, 0x00, 0x00 }; /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ LCD_Init(2, 20); LCD_CreateChar(0, damogranlabs_logo); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ LCD_PrintString(2, 1, "n: "); LCD_PrintNumber(2, 4, -10); LCD_PrintString(2, 10, "f: "); LCD_PrintFloat(2, 13, -326.5635, 5); while (1) { LCD_PrintStringWindow(1, 3, 14, 350, "Find us on github and www.damogranlabs.com"); LCD_Clear(); LCD_PrintString(1, 1, "www.damogranlabs.com"); LCD_PutCustom(2, 10, 0); LCD_ClearArea(1, 5, 12); HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin); HAL_Delay(2000); /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
signed char GetYesNo(const char *prompt, signed char Initial) { signed char answer; signed char inp; LCD_ClearDisplay(); LCD_PrintString(prompt); answer = Initial; while (1) { LCD_SetPosition(1, 0); if (answer) LCD_PrintString("<YES>\0"); else LCD_PrintString("<NO> \0"); inp = GetInput(); if (inp < 0) return inp; switch (inp) { case USER_INPUT_CLICK: //The User Pressed the button to select something... return (answer); case USER_INPUT_CANCEL: return -2; case USER_INPUT_BACK: return -1; case USER_INPUT_INC: //Rot + case USER_INPUT_DEC: //Rot - answer = !answer; break; default: break; } } return (0); }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ LCD_Init(2, 20); LCD_PrintString(0, 0, "Damogran Labs"); Encoder_Init(&encoder1, ENC1_A_GPIO_Port, ENC1_A_Pin, ENC1_B_GPIO_Port, ENC1_B_Pin); Encoder_Init(&encoder2, ENC2_A_GPIO_Port, ENC2_A_Pin, ENC2_B_GPIO_Port, ENC2_B_Pin); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ LCD_PrintNumber(1, 0, encoder1.abs_rot); LCD_PrintNumber(1, 6, encoder2.abs_rot); while (1) { if(Encoder_GetState(&encoder1)){ LCD_PrintString(1, 0, " "); LCD_PrintNumber(1, 0, encoder1.abs_rot); } if(Encoder_GetState(&encoder2)){ LCD_PrintString(1, 6, " "); LCD_PrintNumber(1, 6, encoder2.abs_rot); } if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) == GPIO_PIN_SET){ Encoder_SetAbsToZero(&encoder1); Encoder_SetAbsToZero(&encoder2); } HAL_Delay(100); /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
//main routine for ADC (linear) calibration testing void TestADCCalibration(void) { unsigned int * ADCBuffer; double * ADCRealValues; double P, Q; unsigned int i; unsigned int NumOfData; volatile double diffOrig; volatile double diffCalib; unsigned char DEBUG_STRING[30]; //set external clock (16MHz XTALL required) SetCPUClock(0); //allocate buffer space if ((ADCBuffer = malloc(ADC_BUFFER_SIZE * sizeof(ADCBuffer[0]))) == NULL) _asm("trap\n"); if ((ADCRealValues = malloc(ADC_BUFFER_SIZE * sizeof(ADCRealValues[0]))) == NULL) _asm("trap\n"); //main test { //collect data NumOfData = ADCCollectDataCalib(ADCBuffer, ADCRealValues); P= GetMultiplierCalib(ADCBuffer, ADCRealValues, NumOfData); diffOrig = GetErrorCalib(ADCBuffer, ADCRealValues, NumOfData, P, 0); //calib data ADCCalibratePQ(ADCBuffer, ADCRealValues, NumOfData, &P, &Q); diffCalib = GetErrorCalib(ADCBuffer, ADCRealValues, NumOfData, P, Q); //print errors sprintf(DEBUG_STRING, "Orig = %f", diffOrig); LCD_PrintString(LCD_LINE1, ENABLE, DISABLE, DEBUG_STRING); sprintf(DEBUG_STRING, "Calib= %f", diffCalib); LCD_PrintString(LCD_LINE2, ENABLE, DISABLE, DEBUG_STRING); delay(500000l);//to show results } //see real values after ADC calibration - for checking calibration LCD_Clear(); LCD_PrintString(LCD_LINE1, DISABLE, ENABLE, "Real calibrated U"); while(!JOY_SEL) { //start single conversion ADC2_StartConversion(); while (!ADC2_GetFlagStatus()); //clear end of conversion bit ADC2_ClearFlag(); //collect ADC value and display LCD_SetCursorPos(LCD_LINE2, 4);//set cursor position LCD_PrintDec4((P*ADC2_GetConversionValue() + Q)*1000); } //unallocate buffer free(ADCBuffer); }//TestADCCalibration
void printDebug(STATE state){ LCD_MoveCursor(1,1); char stringToPrint[16]; sprintf(stringToPrint,"%4d%4d%4d%4d",IRSensor_GetLeftFront(), IRSensor_GetCenterLeft(), IRSensor_GetCenterRight(), IRSensor_GetRightFront()); LCD_PrintString(stringToPrint); LCD_MoveCursor(1,2); sprintf(stringToPrint,"OC:%5d:%5d %1d",OC2RS,OC4RS,state); LCD_PrintString(stringToPrint); };
signed char GetFloat(const char *prompt, const char *unit, double* Value, double Min, double Max, double Precision) { double Output; char WholePlaces; char FractionalPlaces; signed char ret = 0; if ((Max >= 10000) || (Min <= -10000)) WholePlaces = 5; else if (Max >= 1000 | Min <= -1000) WholePlaces = 4; else if (Max >= 100 | Min <= -100) WholePlaces = 3; else if (Max >= 10 | Min <= -10) WholePlaces = 2; else WholePlaces = 2; if (Precision >= 1.0) FractionalPlaces = 0; else if (Precision >= 0.1) FractionalPlaces = 1; else if (Precision >= 0.01) FractionalPlaces = 2; else if (Precision >= 0.001) FractionalPlaces = 3; else if (Precision >= 0.0001) FractionalPlaces = 4; Output = *Value; LCD_ClearDisplay(); LCD_PrintString(prompt); LCD_SetPosition(1, 0); LCD_PrintFloat(Output, WholePlaces, FractionalPlaces, 1); LCD_PrintString(unit); while (1) { LCD_SetPosition(1, 0); LCD_PrintFloat(Output, WholePlaces, FractionalPlaces, 1); ret = GetInput(); if (ret < 0) return ret; switch (ret) { case USER_INPUT_CLICK: //user has pressed the switch to accept. *Value = Output; return (0); case USER_INPUT_CANCEL: return -2; case USER_INPUT_BACK: return -1; case USER_INPUT_INC: //Rot+ Output += GetRotaryMultiplier() * Precision; if (Output > Max) Output = Max; break; case USER_INPUT_DEC: Output -= GetRotaryMultiplier() * Precision; if (Output < Min) Output = Min; break; } } return (0); }
/************************************************ * Method to calculate the heartrate based on * the start and end values of a counter that * is driven by interrupts which are driven by * the heartbeat. * @return heartrate The last recorded heartrate ************************************************/ float Detect_heartrate(void) { LCD_Position(0,0); LCD_PrintString("Heartrate: "); LCD_PrintString(" "); LCD_Position(1,0); /* 600000 because the clock speed of the heartrate is set to kHz */ heartrate = (600000/(endCounts-startCounts)); LCD_PrintU32Number(heartrate); LCD_PrintString(" "); return heartrate; }
/** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { LCD_PrintString(LCD_LINE1, DISABLE, DISABLE, " ERR "); LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, " ASSERT "); } }
signed char ShowVoltage() { double Batt; LCD_ClearDisplay(); bLock_BatteryVoltage = 1; Batt = BatteryVoltage; bLock_BatteryVoltage = 0; Batt *= Config.Volts_per_Count; LCD_PrintString("BATTERY VOLTAGE:\0"); LCD_SetPosition(1, 0); LCD_PrintFloat(Batt, 2, 2, 0); LCD_PrintString(" VOLTS\0"); return GetClick(); }
signed char GetPresetNumber() { signed char inp; char pnum; signed char ptype; LCD_ClearDisplay(); LCD_PrintString("PRESET SLOT:\0"); LCD_SetPosition(1, 0); LCD_PrintString("PRESET 01\0"); pnum = 1; while (1) { LCD_SetPosition(1, 7); LCD_PrintLong((int) pnum, 2, 0); ptype = GetPresetType(pnum); switch (ptype) { case 0: LCD_PrintString("-EMPTY \0"); break; case 1: LCD_PrintString("-WAYPOINT \0"); break; case 2: LCD_PrintString("-ORBIT \0"); break; } inp = GetInput(); if (inp<0) return inp; switch (inp) { case USER_INPUT_DEC: if (pnum > 1) pnum--; break; case USER_INPUT_INC: if (pnum < 5) pnum++; break; case USER_INPUT_CLICK: return (pnum); case USER_INPUT_BACK: return (-1); case USER_INPUT_CANCEL: return (-2); } } return (-2); }
/******************************************************************************* * Function Name: main ******************************************************************************** * * Summary: * main() performs following functions: * 1: Initializes the LCD * 2: Starts ADC * 3: Starts ADC converstion. * 4: Gets the converted result and displays it in LCD. * * Parameters: * None. * * Return: * None. * *******************************************************************************/ int main() { int16 output; /* Start the components */ LCD_Start(); ADC_DelSig_1_Start(); /* Start the ADC conversion */ ADC_DelSig_1_StartConvert(); /* Display the value of ADC output on LCD */ LCD_Position(0u, 0u); LCD_PrintString("ADC_Output"); for(;;) { if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS)) { output = ADC_DelSig_1_GetResult16(); /* Saturate ADC result to positive numbers. */ if(output < 0) { output = 0; } LCD_Position(1u, 0u); LCD_PrintInt16(output); } } }
////////////////////////////////////////////////////// // This function display current input from user ////////////////////////////////////////////////////// void UserInput(void) { //Write_Lcd(0x0D, 0); char_menu_pw[current_pw_digit] = digit; char_menu_pw[current_pw_digit+1] = 0; LCD_PrintString(char_menu_pw, LCD_ROW1, 1); }
/******************************************************************************* * Function name: DisplayPrintLastTimeSkier ******************************************************************************** * * Summary: * print time last skier from position row = 1, column = 0 * *******************************************************************************/ void DisplayLastSkierTime(uint32_t sec, uint16_t milisec) { /*printf time in format mm:ss:msmsms*/ sprintf(buff, "Result %02u:%02u:%03u",sec/60,sec%60, milisec); LCD_Position(0,0); LCD_PrintString(buff); }
static void kb_draw_key(struct guiBox *box, char c, u8 pressed) { u16 w, h; u16 bg_color; u16 fg_color; char ch[2]; const char *str = ""; if ( c == '\x06') { //DONE str = "DONE"; if (pressed) { bg_color = Display.keyboard.fg_key3; fg_color = Display.keyboard.bg_key3; } else { bg_color = Display.keyboard.bg_key3; fg_color = Display.keyboard.fg_key3; } } else if (c < ' ') { //CAPS, DEL, NUMPAD if (c == '\x09') str = caps_str; else if (c == '\x08') str = del_str; else if (c == '\x01') str = mix_str; else if (c == '\x02') str = char_str; if (pressed) { bg_color = Display.keyboard.fg_key2; fg_color = Display.keyboard.bg_key2; } else { bg_color = Display.keyboard.bg_key2; fg_color = Display.keyboard.fg_key2; } } else { if (c == ' ') { str = space_str; } else { ch[0] = c; ch[1] = 0; str = ch; } if (pressed) { bg_color = Display.keyboard.fg_key1; fg_color = Display.keyboard.bg_key1; } else { bg_color = Display.keyboard.bg_key1; fg_color = Display.keyboard.fg_key1; } } /* printf("(%dx%dx%dx%d)", box->x, box->y, box->width, box->height); if(coords1) printf(" coords1: %dx%d", coords1->x, coords1->y); if(coords2) printf(" coords2: %dx%d", coords2->x, coords2->y); printf(" Draw: %d\n", draw); */ LCD_SetFont(Display.keyboard.font); _draw_key_bg(box, pressed, bg_color); LCD_GetStringDimensions((const u8 *)str, &w, &h); LCD_SetXY(box->x + (box->width - w) / 2, box->y + (box->height - h) / 2); LCD_SetFontColor(fg_color); LCD_PrintString((const char *)str); }
int main(void) { CyGlobalIntEnable; /* Enable global interrupts. */ DisplayStart(); Display("System init..."); RTC_WDT_Init(); InitNetwork(); Display("Sync time..."); uint8_t number = 0; while((result = NTPsync()) != TIME_SYNC_OK) { char buf[10]; sprintf(buf, "Sync time -%d", number++); LCD_Position(0,0); LCD_PrintString(buf); CyDelay(500); } Display("Sync ok "); CyDelay(4*TIMEOUT_USER_READ_INFO); for(;;) { DisplayRealTime(); CyDelay(500); } }
void main_play_ttc(){ LCD_Start(); // initialize lcd LCD_ClearDisplay(); UART_Start(); // initialize UART UART_PutChar(0x81); // init connection; set to 16x12 image struct disp_grid_81 disp; disp_grid_init(&disp,0x3F); // init our display grid matrix to white disp_grid_transmit(&disp); struct tic_tac_toe lolz; ttc_init(&lolz,4,3); disp_grid_init_ttc(&disp,lolz.grid); // init the board disp_grid_draw_xia(&disp,26,16,0x30); // draw xia disp_grid_transmit(&disp); int x,y,z; int Values; while (lolz.game_not_won == 0){ //Values = read_from_8255(Values); Values = Pin3_Read(); if (Values >= 0 && Values <= 63){ //integer value z = Values / 16; x = Values % 4; //get row value y = Values / 4 - z*4; // LCD_ClearDisplay(); LCD_PrintNumber(Values); LCD_PrintString(" x"); LCD_PrintNumber(x); LCD_PrintString(" y"); LCD_PrintNumber(y); LCD_PrintString(" z"); LCD_PrintNumber(z); } if (ttc_get_grid(&lolz,x,y,z) == 0){ // has not been accessed ttc_step(&disp,&lolz,x,y,z); // step & print disp_grid_transmit(&disp); } } LCD_ClearDisplay(); LCD_Position(0,0); //move to bot row LCD_PrintString("GAME OVER!"); }
/******************************************************************************* * Function name: DisplayPrintfRealTime ******************************************************************************** * * Summary: * print real time from position row = 1, column = 0 * *******************************************************************************/ void DisplayRealTime(void) { uint32_t time; time = RTC_GetTime(); sprintf(buff, "%02lu:%02lu:%02lu ", RTC_GetHours(time),RTC_GetMinutes(time), RTC_GetSecond(time)); LCD_Position(1,0); LCD_PrintString(buff); }
void gotoMenuResetState(void) { static unsigned int boardrequest = 12000; int i; char s[17] = ""; // Sends a request to bottom board to get readings. // Any readings received will be processed in mcu.c. if( TickGet()-Timer > (5*TICK_SECOND) ) { //s[0] = ph_4total; // 2014-07-01 Liz removed s[0] = 0; // 2014-07-01 Liz added s[1] = 10; s[2] = 'N'; //2012-09-24: Liz added to distinguish from EEPROM request. // Show on the LCD the reading that is in the local variable // while at the same time request for a new reading from the // bottom board. // 2012-05-10(Eric) - No need to retry here since it is not critical. // More impt to release control back to main loop. MCURequestToBOTTOMBoard(MMT_READING_REQUEST, s, 3, FALSE, FALSE); //MCURequestToBOTTOMBoard(MMT_READING_REQUEST, s, 2, FALSE, TRUE); // 2014-07-01 Liz removed // ph_4total++; // if( ph_4total >= 4) // { // ph_4total = 1; // //Convert3RealEnergyToCharArray(s); // Convert3RealEnergyToCharArray(s, 1, 1); // // LCD_PrintString(s, LCD_ROW1, 0); // } // 20114-07-01 Liz added Convert3RealEnergyToCharArray(s, 1, 1); LCD_PrintString(s, LCD_ROW1, 0); /////////////////////// Timer = TickGet(); } switch (menu_control(reset_table, reset_table_max)) { case -2: break; case 0: setMenuCurrentState(MENU_IDLE_STATE); set_current_menu(0); gotoMenuIdleState(); LCD_PrintStringPGM("",LCD_ROW1); break; default: break; } }
// Show shift register contents and flags void show(void) { uint8 i; LCD_Position(0, 0); for (i = 0; i < 8; i++) { LCD_PrintInt8(v[i]); } LCD_Position(1, 0); if (SR1_Read() & 1) { LCD_PrintString("FULL "); } else { LCD_PrintString(" "); } if (SR1_Read() & 2) { LCD_PrintString("EMPTY "); } else { LCD_PrintString(" "); } }
////////////////////////////////////////////////////// // This function initialize states of 4 buttons ////////////////////////////////////////////////////// void set_button_state(void) { button_down_old_state = 0; button_up_old_state = 0; button_escape_old_state = 0; button_enter_old_state = 0; is_button_pressed = 0; Timer = TickGet() + 5*TICK_SECOND; // 2014-07-02 Liz. Top board will immediately send request after initialisation. LCD_PrintString((char *)reset_table[0], LCD_ROW0, 0); // 2012-05-04 Liz: add in cursor display mode for LCD_PrintString() }
/** * @brief Example main entry point. * @par Parameters: * None * @retval * None */ void main(void) { /* Initialize SPI for LCD */ SPI_DeInit(); SPI_Init(SPI_FIRSTBIT_MSB, SPI_BAUDRATEPRESCALER_128, SPI_MODE_MASTER, SPI_CLOCKPOLARITY_HIGH, SPI_CLOCKPHASE_2EDGE, SPI_DATADIRECTION_1LINE_TX, SPI_NSS_SOFT, 0x07); SPI_Cmd(ENABLE); /* Configure GPIO used to drive the joystick JOYSTICK_UP --> PB6 JOYSTICK_DOWN --> PB7 JOYSTICK_LEFT --> PB4 */ GPIO_Init(GPIOB, GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_MODE_IN_FL_IT); EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOB, EXTI_SENSITIVITY_FALL_LOW); enableInterrupts(); /* Initialize LCD */ LCD_Init(); /* Clear LCD lines */ LCD_Clear(); LCD_Backlight(ENABLE); LCD_PrintString(LCD_LINE1, ENABLE, DISABLE, "Clock Selection"); LCD_PrintString(LCD_LINE2, ENABLE, DISABLE, " Use joystick"); CLK_DeInit(); CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); /* Output Fcpu on CLK_CCO pin */ CLK_CCOConfig(CLK_OUTPUT_MASTER); while (1) { } }
//when a user dies, we are going to print "USER DEATH" and pause EVERYthing for a second// void DEATH(void){ LCD_SetCursor(140,80); LCD_SetTextColor(255,0,0); LCD_PrintString("USER DEATH"); for(deathPause = 0; deathPause < 30; deathPause++){ while(Semaphore == 0){}; //do nothing until SysTick interrupt Semaphore = 0; //"acknowledge" SysTick if(newMissile >3){newMissile = 0;} //missile count probably very high from all the SysTick calls } }
void main_test_disp(){ LCD_Start(); // initialize lcd uint8 current; for (;;){ LCD_ClearDisplay(); LCD_Position(0,0); //move back to top row current = Pin0_Read(); //next, read a new value LCD_PrintString("P0: "); LCD_PrintNumber(current); //print value I am getting LCD_Position(1,0); //move to bot row current = Pin3_Read(); //next, read a new value LCD_PrintString("P3: "); LCD_PutChar(current); //print ascii value LCD_PrintString(" HEX: "); LCD_PrintNumber(current); //print value I am getting waiter(4); } }
void main(){ CYGlobalIntDisable;//Disable interrupts to avoid triggering during setup. LCD_Start();// Start LCD. UART_Start();// Start UART. Rx_Int_Start();//Start the Interrupt. Rx_Int_SetVector(Rx_ISR);//Set the Vector to the ISR. LCD_PrintString("UART:RX ISR Demo");//Print to the LCD. UART_PutString("UART:RX ISR Demo");//Print to Serial Terminal. CyDelay(1000); LCD_ClearDisplay();//Clear the screen for RX Data. CYGlobalIntEnable;//Enable Interrupts,and let the Games begin! for(;;); }
/******************************************************************************* * Function name: DisplayPrintfLoading ******************************************************************************** * * print loading from position row = 1, column = 0 * *******************************************************************************/ void DisplayLoading(uint32_t numLoad) { if(numLoad == 0) { /*clear row 1*/ LCD_Position(1,0); LCD_PrintString(" "); } if((numLoad > 0) && numLoad < 16) { LCD_Position(1,numLoad-1); LCD_PutChar(LCD_CUSTOM_4); } }
int main( void ) { char cIPAddress[ 16 ]; /* Enough space for "xxx.xxx.xxx.xxx\0". */ /* Configure the hardware for use by this demo. */ prvSetupHardware(); /* Start the standard demo tasks. These are just here to exercise the kernel port and provide examples of how the FreeRTOS API can be used. */ vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); vCreateBlockTimeTasks(); vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); vStartQueuePeekTasks(); vStartRecursiveMutexTasks(); vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY ); /* Create the USB task. */ xTaskCreate( vUSBTask, ( signed char * ) "USB", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL ); /* Display the IP address, then create the uIP task. The WEB server runs in this task. */ LCDdriver_initialisation(); LCD_PrintString( 5, 10, "FreeRTOS.org", 14, COLOR_GREEN); sprintf( cIPAddress, "%d.%d.%d.%d", configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 ); LCD_PrintString( 5, 30, cIPAddress, 14, COLOR_RED); xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was insufficient memory to create the idle task. The idle task is created within vTaskStartScheduler(). */ for( ;; ); }
/******************************************************************************* * Function Name: main ******************************************************************************** * Summary: * Main function performs following functions: * 1. Starts Character LCD and print project info * 2. Starts SPI Master component * 3. Configures the DMA transfer for RX and TX directions * 4. Displays the results on Character LCD * * Parameters: * None. * * Return: * None. * *******************************************************************************/ int main() { uint8 i; LCD_Start(); LCD_Position(0u,0u); LCD_PrintString("SPI Master"); LCD_Position(1u,0u); LCD_PrintString("example"); CyDelay(2000u); DmaTxConfiguration(); DmaRxConfiguration(); SPIM_Start(); CyDmaChEnable(rxChannel, STORE_TD_CFG_ONCMPLT); CyDmaChEnable(txChannel, STORE_TD_CFG_ONCMPLT); while (0u == (SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE)) { } LCD_ClearDisplay(); LCD_PrintString("Master Rx data:"); LCD_Position(1u,0u); for(i=0u; i<BUFFER_SIZE; i++) { LCD_PrintHexUint8(rxBuffer[i]); } for(;;) { } }
signed char DisplayMenu(const char *Menu[], char ItemCount, char Initial) { char SecondLine = 0; signed char SelectedItem = 0; signed char ret = 0; SelectedItem = Initial; while (1) { LCD_ClearDisplay(); if (SecondLine) { LCD_SetPosition(0, 1); if (SelectedItem == 0) LCD_PrintString(Menu[ItemCount]); else LCD_PrintString(Menu[SelectedItem - 1]); LCD_SetPosition(1, 0); LCD_PrintChar('*'); LCD_PrintString(Menu[SelectedItem]); LCD_SetPosition(1, 0); } else { LCD_PrintChar('*'); LCD_PrintString(Menu[SelectedItem]); LCD_SetPosition(1, 1); if (SelectedItem == ItemCount) LCD_PrintString(Menu[0]); else LCD_PrintString(Menu[SelectedItem + 1]); LCD_SetPosition(0, 0); } ret = GetInput(); if (ret < 0) { SelectedItem = ret; goto exit; } switch (ret) { case USER_INPUT_CLICK: goto exit; case USER_INPUT_BACK: SelectedItem = -1; goto exit; case USER_INPUT_CANCEL: SelectedItem = -2; goto exit; case USER_INPUT_INC: SecondLine = 1; if (SelectedItem == ItemCount) SelectedItem = ItemCount; else SelectedItem++; break; case USER_INPUT_DEC: SecondLine = 0; if (SelectedItem == 0) SelectedItem = 0; else SelectedItem--; break; } } exit: return (SelectedItem); }