void start() { uint32_t temp; uint8_t getstr[20]; GPJ2CON = 0x1111; GPJ2DAT = 0x0a; uart0_init(115200); fimd_init(); xdev_out(uart0_putc); xdev_in(uart0_getc); xprintf("FA210 Tester v1\n"); while(1){ xputc('>'); xgets(getstr,15); } }
/** * * @brief Main Function * @param none * @retval none */ int main(void) { /* Set 1mSec Timer */ SysTickInit(INTERVAL); /* Initialize GPIO for the LED. */ FM3_GPIO->PDORF_f.P3 = 0; /* Set Clr(at first)*/ FM3_GPIO->PFRF_f.P3 = 0; /* Use PF3 as GPIO */ FM3_GPIO->DDRF_f.P3 = 1; /* Mode Output */ FM3_GPIO->PZRF_f.P3 = 1; /* Port Tristate */ /* Initialize UART */ UartInit(); /* To Use xprintf */ xdev_out(putch); xdev_in(getch); /* Test */ xprintf("Hello FM3 \r\n"); _delay_ms(1000); #if 0 while (1) /* loop forever */ { FM3_GPIO->PDORF_f.P3 = ~FM3_GPIO->PDORF_f.P3; /* Invert Pin */ _delay_ms(500); } #endif }
int main(void) { uint16_t i; FRESULT rc; map_io(); init_port(); InitRTCC(); uart2_init(); xdev_out(uart2_put); xdev_in(uart2_get); dbg_printf("$" PROJECT_NAME "\n"); dbg_printf("$" __DATE__ " " __TIME__ "\n"); rc = f_mount(&fatfs, "", 1); dbg_printf("$FF,f_mount,%s\n", get_rc(rc)); OpenTimer1(T1_PS_1_256 & T1_GATE_OFF & T1_SOURCE_INT & T1_IDLE_CON & T1_ON & T1_SYNC_EXT_OFF, 0xFFFF); ConfigIntTimer1(T1_INT_ON & T1_INT_PRIOR_1); OpenCapture1(IC_IDLE_STOP & IC_TIMER1_SRC & IC_INT_1CAPTURE & IC_EVERY_RISE_EDGE, IC_CASCADE_DISABLE & IC_TRIGGER_ENABLE & IC_UNTRIGGER_TIMER & IC_SYNC_TRIG_IN_DISABLE); ConfigIntCapture1(IC_INT_ON & IC_INT_PRIOR_5); _IC1IF = 0; while (1) { while (_RTCSYNC == 0); while (_RTCSYNC == 1); if (gps_pr > 0) { _T1IE = 0; float f = (float) TMR1 / gps_pr; _T1IE = 1; xprintf("%u\n", (uint16_t) (f * 1000)); } if (ngpslines > 0) { ngpslines--; if (xgets(gps_line, 128)) { xprintf("$GPS%s\n", gps_line); } } } while (0) { while (_RTCSYNC == 0); while (_RTCSYNC == 1); if (gps_pr > 0) { _T1IE = 0; float f = (float) TMR1 / gps_pr; _T1IE = 1; xprintf("%u\n", (uint16_t) (f * 1000)); } } return (EXIT_SUCCESS); }
void start() { uint8_t data_out[10]={0xff, 0xff, 0xff,0,0,0,0}; uint8_t data_in[10]={0xff, 0xff, 0xff,0,0,0,0}; uart_init(DEBUG_COM); xdev_in(get_char); xdev_out(put_char); xprintf("\nHello, 6410!\n"); // delay(DELAY_1S_VAL); // xprintf("init si470x..."); // if (si470x_init()){ // xprintf("ok\n"); // } // else { // xprintf("failed\n"); // } // delay(DELAY_1S_VAL); // xprintf("powerdown si470x..."); // if (si470x_powerdown()){ // xprintf("ok\n"); // } // else{ // xprintf("failed\n"); // } // delay(DELAY_1S_VAL); // xprintf("powerup si470x..."); // if (si470x_powerup()){ // xprintf("ok\n"); // } // else{ // xprintf("failed\n"); // } while(1){ } //test_FMRX(); // test_FMRXrds(); // Tunes to an RDS station and populates // variables with RDS information. }
/** xprintf need functions api setup */ void xprintf_setup(void) { if (xprintf_setup_flag) { return; } console_uart = uart_get_dev(CONSOLE_UART_ID); console_uart->uart_open(BOARD_CONSOLE_UART_BAUD); xdev_in(console_getchar); xdev_out(console_putchar); #if ENABLE_BANNER == 1 embarc_print_banner(); #endif xprintf("embARC Build Time: %s, %s\r\n", __DATE__, __TIME__); #if defined(__GNU__) xprintf("Compiler Version: ARC GNU, %s\r\n", __VERSION__); #else xprintf("Compiler Version: Metaware, %s\r\n", __VERSION__); #endif xprintf_setup_flag = 1; }
//////////////////// MAIN ///////////////////////////// int main (void) { int i; float temperature, pressure; float QNHPA; const int QNH_Calib=2; //AO: TODO Make this settable at startup and //write to nvRAM. float altitude_m,altitude_ft; struct ms5611_vars baro; //Coordinates for writing values on screen: uint8_t ALTFT_x=190, ALTFT_y=100; uint8_t QNH_x=90,QNH_y=120; //Location on screen to print QNH uint8_t ALTM_x=QNH_x, ALTM_y=140; uint8_t BARO_x=QNH_x,BARO_y=160; //Location on screen to print BARO uint8_t TEMP_x=QNH_x,TEMP_y=180; //Location on screen to print TEMP //TODO: Remove obsolete code. //TODO: Baro_Delay_Max becomes a #define. // int GPIO_Delay_Max =250; //Led's will stay on for this many ms. // int BARO_Delay_Max =200; //Baro refresh rate. //Display related: int a; // Both single speed and double speed access works. // Single speed is slower, needs less memory, vice versa for double speed. //u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_i2c, u8g_com_hw_i2c_fn); u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_2x_i2c, u8g_com_hw_i2c_fn); // Initialize hardware: disable_JTAG(); //So that some pins (notably LED) are freed up for use. init_BKP(); //Battery backup/RTC module init. init_ENC(); //Initialize ports connected to encoder. init_LED_GPIO(); //Initialize ports connected to LED. /* Init Chan's Embedded String Functions (xprintf etc) */ xdev_out(uart_putc); xdev_in(uart_getc); init_USART1(); // Initialize USART1: uart_open (USART1, 115200, 0); //USART2 is not supported. if (SysTick_Config(SystemCoreClock/1000)) while (1); // Every 1 msec, the timer will trigger a call to the SysTick_Handler. xprintf ("STM32F103 Naze32/Flip32.\n\r"); xprintf("System core clock rate is %d Hz\n\r",SystemCoreClock); xprintf("QNH calibration value set to: %d. \n\r",QNH_Calib); //Turn off LED LED_OFF(); QNH = BKP_ReadBackupRegister (BKP_DR1); QNH=1013; //TODO: Naze32 has no provision for backup battery connection. // The pin V_bat is connected to supply... // The function works correctly. Needs a board with V_bat wired correctly. if (QNH<950) //Quick sanity check. QNH=950; else if (QNH>1050) QNH=1050; ms5611_init(&baro); ms5611_measure(&baro); ms5611_calculate(&baro); QNHPA = (QNH+QNH_Calib)*100; //Convert to Pa. baro.pressure is also in pa. //Note: Uncomment following line for AGL measurement. //QNHPA= baro.pressure; BARO_Delay = BARO_Delay_Max; //Counts the number of timer ticks so far. //Display an introductory info message and wait 3s before starting: u8g_FirstPage(&u8g); do { draw_Intro(); } while ( u8g_NextPage(&u8g) ); i=0; while(i < INTRO_WAIT_MS){ //Keep info screen up for some time. if (TimerEventFlag==TRUE){ TimerEventFlag=FALSE; ++i; } } while (1) { if (TimerEventFlag==TRUE){ // QNH adjustment used to live here but because of the long delay // in calculating the altitude, it was moved into the ISR. TimerEventFlag=FALSE; } //Time to update barometer?: if (BARO_Delay >=BARO_Delay_Max){ BARO_Delay=0; //LED_ON(); //To check utilization. ms5611_measure(&baro); ms5611_calculate(&baro); //Note: Comment following line for AGL measurement. QNHPA = (QNH+QNH_Calib)*100;//Convert to Pa. baro.pressure is also in pa. altitude_m = 44330*(1- powf((baro.pressure/QNHPA),(0.19029495))); //m altitude_ft =altitude_m *3.28084; //ft. } //END: if (BARO_Delay >=BARO_Delay_Max) if (printQNH==TRUE){ //Time to print QNH: printQNH=FALSE; u8g_FirstPage(&u8g); do { draw_qnh((int)baro.pressure/100,(int)baro.temperature/100,(int)altitude_m,(int)altitude_ft,(int)QNH); } while ( u8g_NextPage(&u8g) ); BKP_WriteBackupRegister (BKP_DR1, QNH); } else if (printINFO==TRUE){ u8g_FirstPage(&u8g); do { draw_Intro(); } while ( u8g_NextPage(&u8g) ); }else{ u8g_FirstPage(&u8g); do { draw_alt((int)baro.pressure/100,(int)baro.temperature/100,(int)altitude_m,(int)altitude_ft,(int)QNH); } while ( u8g_NextPage(&u8g) ); } //LED_OFF(); //To check utilization. } //END: while(1) } //END: main
void initUART() { uart0_init(); xdev_out(uart0_putc); xdev_in(uart0_getc); }