void main (void) { signed char resultx, resulty, resultz; printf("Kinetis I2C Demo\n"); //Initialize I2C init_I2C(); //Configure MMA7660 sensor MMA7660WriteRegister(0x09,0xE0); //Disable tap detection MMA7660WriteRegister(0x07,0x19); //Enable auto-sleep, auto-wake, and put in active mode printf(" X Y Z\n"); while(1) { //Read x-axis register resultx = u8MMA7660ReadRegister(0x00); printf("%3d", convert(resultx)); //Read y-axis register resulty = u8MMA7660ReadRegister(0x01); printf(" %3d", convert(resulty)); //Read z-axis register resultz = u8MMA7660ReadRegister(0x02); printf(" %3d\n", convert(resultz)); //Delay for 250ms time_delay_ms(250); } }
void initSensors(void){ // TODO: init the GPS here fd = init_I2C(); init_compass(fd); gpioInit(); gpsRet = init_GPS(); }
void main (void) { Display_Intro(); init_I2C(); port_config(); DISABLE_USB_5V; // Disable USB 5v (for Host support) MAX3353_ISR(); if(MAX3353_Init()) printf("\nMAX3353 not Present\n"); else printf("\nMAX3353 Present\n"); while(1) { /*** Check for changes ****/ if(FLAG_CHK(_MAX3353,gu8ISR_Flags)) { FLAG_CLR(_MAX3353,gu8ISR_Flags); if(gu8MAX3353StatusRegister & ID_GND_EVENT) { printf("\nID-GND --> Changing to HOST mode (Enabling 5V)"); gu8USB_Mode=USB_HOST_MODE_INIT; } if(gu8MAX3353StatusRegister & ID_FLOAT_EVENT) { printf("\nID-FLOAT --> Changing to DEVICE mode (Disabling 5V)"); gu8USB_Mode=USB_DEVICE_MODE_INIT; } if(gu8MAX3353StatusRegister & VBUS_HIGH_EVENT) { printf("\nVBUS is Up"); } if(gu8MAX3353StatusRegister & VBUS_LOW_EVENT) { printf("\nVBUS is Down"); if(gu8USB_Mode==USB_DEVICE_MODE) gu8USB_Mode=USB_DEVICE_MODE_INIT; //enter_vlps(); // Enter VLPS //mcg_pbe_2_pee(); // Exit VLPS // Low power } } /* USB Switch stacks */ USB_State_Machine(); } }
void main() { TRISC = 0b00000000; // portC : output LATC = 0b00000000; // portC = 0 init_UART(); init_I2C(); //init_GYRO(); init_ACC(); LED_RED_On(); LED_GREEN_On(); while (1) { }; }
int main(void) { unsigned cmd; char c; int i = 0,j; timer_init(); #ifdef POWER_OFF_VDDIO f_serial_puts("sleep ... off\n"); #else f_serial_puts("sleep .......\n"); #endif while(1){ cmd = readl(P_AO_RTI_STATUS_REG0); if(cmd == 0) { delay_ms(10); continue; } c = (char)cmd; if(c == 't') { #if (defined(POWER_OFF_VDDIO) || defined(POWER_OFF_HDMI_VCC) || defined(POWER_OFF_AVDD33) || defined(POWER_OFF_AVDD25)) init_I2C(); #endif copy_reboot_code(); enter_power_down(); break; } else if(c == 'q') { serial_puts(" - quit command loop\n"); writel(0,P_AO_RTI_STATUS_REG0); break; } else { serial_puts(" - cmd no support (ARC)\n"); } //command executed writel(0,P_AO_RTI_STATUS_REG0); } while(1){ asm(".long 0x003f236f"); //add sync instruction. asm("SLEEP"); } return 0; }
void main(int * argv){ signal(SIGINT, signal_handler); fd = init_I2C(); init_compass(fd); gpioInit(); // testTurn(); /**turn(45.0); sleep(1); turn(280.0); sleep(1); turn(310.0); turn(180.0); **/ waypointManager(); //testTurn(); }
void main (void) { Display_Intro(); init_I2C(); port_config(); DISABLE_USB_5V; // Disable USB 5v (for Host support) if(MAX3353_Init()) printf("\nMAX3353 not Present\n"); else printf("\nMAX3353 Present\n"); MAX3353_ISR(); while(1) { in_char(); #if 0 //CW enter_vlps(); #endif //kevin //enter_stop(); mcg_pbe_2_pee(); if(FLAG_CHK(_MAX3353,gu8ISR_Flags)) { if(gu8MAX3353StatusRegister & ID_GND_EVENT) { ENABLE_USB_5V; printf("\nID-GND --> Changing to HOST mode (Enabling 5V)"); } if(gu8MAX3353StatusRegister & ID_FLOAT_EVENT) { DISABLE_USB_5V; printf("\nID-FLOAT --> Changing to DEVICE mode (Disabling 5V)"); } if(gu8MAX3353StatusRegister & VBUS_HIGH_EVENT) printf("\nVBUS is Up"); if(gu8MAX3353StatusRegister & VBUS_LOW_EVENT) printf("\nVBUS is Down"); FLAG_CLR(_MAX3353,gu8ISR_Flags); } } }
int main(void) { unsigned cmd; char c; p_arc_pwr_op = &arc_pwr_op; timer_init(); arc_pwr_register((struct arc_pwr_op *)p_arc_pwr_op);//init arc_pwr_op arc_param->serial_disable=0; serial_put_hex(readl(P_AO_RTI_STATUS_REG1),32); writel(0,P_AO_RTI_STATUS_REG1); f_serial_puts("sleep .......\n"); arc_param->serial_disable=0; while(1){ cmd = readl(P_AO_RTI_STATUS_REG0); if(cmd == 0) { delay_ms(10); continue; } c = (char)cmd; if(c == 't') { init_I2C(); // copy_reboot_code(); #ifdef CONFIG_MESON_TRUSTZONE copy_reboot_code_temp(temp_arm_base, sizeof(temp_arm_base)); #endif enter_power_down(); //test_arc_core(); break; } else if(c == 'q') { f_serial_puts(" - quit command loop\n"); writel(0,P_AO_RTI_STATUS_REG0); break; } else { f_serial_puts(" - cmd no support (ARC)\n"); } //command executed writel(0,P_AO_RTI_STATUS_REG0); } // asm("SLEEP"); while(1){ // udelay__(600); cmd = readl(P_AO_RTI_STATUS_REG1); c = (char)cmd; // f_serial_puts("REG2="); // serial_put_hex(readl(P_AO_RTI_STATUS_REG2),32); if(c == 0) { udelay__(6000); cmd = readl(P_AO_RTI_STATUS_REG1); c = (char)cmd; if((c == 0)||(c!='r')) { #ifdef _UART_DEBUG_COMMUNICATION_ serial_put_hex(cmd,32); f_serial_puts(" arm boot fail\n\n"); wait_uart_empty(); #endif #if 0 //power down cmd = readl(P_AO_GPIO_O_EN_N); cmd &= ~(1<<6); cmd &= ~(1<<22); writel(cmd,P_AO_GPIO_O_EN_N); #endif } } else if ( cmd == 1 ) { serial_put_hex(cmd,32); f_serial_puts(" ARM has started running\n"); wait_uart_empty(); } else if ( cmd == 2 ) { serial_put_hex(cmd,32); f_serial_puts(" Reenable SEC\n"); wait_uart_empty(); } else if(c=='r') { f_serial_puts("arm boot succ\n"); wait_uart_empty(); asm(".long 0x003f236f"); //add sync instruction. asm("flag 1"); asm("nop"); asm("nop"); asm("nop"); } else { #ifdef _UART_DEBUG_COMMUNICATION_ serial_put_hex(cmd,32); f_serial_puts(" arm unkonw state\n"); wait_uart_empty(); #endif } //cmd='f'; //writel(cmd,P_AO_RTI_STATUS_REG1); } return 0; }
int main(void) { unsigned cmd; char c; int i = 0,j; timer_init(); #ifdef POWER_OFF_VDDIO f_serial_puts("sleep ... off\n"); #else f_serial_puts("sleep7 .......\n"); #endif while(1){ cmd = readl(P_AO_RTI_STATUS_REG0); if(cmd == 0) { delay_ms(10); continue; } c = (char)cmd; if(c == 't') { #if (defined(POWER_OFF_VDDIO) || defined(POWER_OFF_HDMI_VCC) || defined(POWER_OFF_AVDD33) || defined(POWER_OFF_AVDD25)) init_I2C(); #endif copy_reboot_code(); enter_power_down(); //test_arc_core(); break; } else if(c == 'q') { serial_puts(" - quit command loop\n"); writel(0,P_AO_RTI_STATUS_REG0); break; } else { serial_puts(" - cmd no support (ARC)\n"); } //command executed writel(0,P_AO_RTI_STATUS_REG0); } while(1){ udelay(6000); cmd = readl(P_AO_RTI_STATUS_REG1); c = (char)cmd; if(c == 0) { udelay(6000); cmd = readl(P_AO_RTI_STATUS_REG1); c = (char)cmd; if((c == 0)||(c!='r')) { #ifdef _UART_DEBUG_COMMUNICATION_ serial_put_hex(cmd,32); f_serial_puts(" arm boot fail\n\n"); wait_uart_empty(); #endif #if 0 //power down cmd = readl(P_AO_GPIO_O_EN_N); cmd &= ~(1<<6); cmd &= ~(1<<22); writel(cmd,P_AO_GPIO_O_EN_N); #endif } } else if(c=='r') { writel(0,0xc8100030); #ifdef _UART_DEBUG_COMMUNICATION_ //f_serial_puts("arm boot succ\n"); //wait_uart_empty(); #endif } else { #ifdef _UART_DEBUG_COMMUNICATION_ serial_put_hex(cmd,32); f_serial_puts(" arm unkonw state\n"); wait_uart_empty(); #endif } //cmd='f'; //writel(cmd,P_AO_RTI_STATUS_REG1); asm(".long 0x003f236f"); //add sync instruction. //asm("SLEEP"); asm("FLAG 1");//halt mode } return 0; }
int main(void) { /* Initialize Interfaces */ if(PINB & (1<<SEL2)){ //SEL2 not installed, modeA init_StepDir(); //init_pwm(); } else { //SEL2 installed, modeB init_SPI(); init_UART(12,1); //For 1MHz testing, change to 14.7456Mhz init_I2C(); } //init_I2C(); //init_SPI(); //init_UART(95,0); /* Run UART at 9600 baud */ //init_StepDir(); init_stepper(); init_chopper(); sei(); int8_t motor_state = 0; motor_enable = WAVE; while(1) { if(motor_enable == FULL){ if(desired_step_cnt < 0){ //backwards if(motor_state == 0) normstep4(); if(motor_state == 2) normstep1(); if(motor_state == 4) normstep2(); if(motor_state == 6) normstep3(); motor_state -= 2; if(motor_state < 0) motor_state = 6; desired_step_cnt++; } else if(desired_step_cnt > 0){ if(motor_state == 0) normstep2(); if(motor_state == 2) normstep3(); if(motor_state == 4) normstep4(); if(motor_state == 6) normstep1(); motor_state += 2; if(motor_state > 6) motor_state = 0; desired_step_cnt--; } } else if(motor_enable == HALF){ if(desired_step_cnt < 0){ if(motor_state == 0) halfstep8(); if(motor_state == 1) halfstep1(); if(motor_state == 2) halfstep2(); if(motor_state == 3) halfstep3(); if(motor_state == 4) halfstep4(); if(motor_state == 5) halfstep5(); if(motor_state == 6) halfstep6(); if(motor_state == 7) halfstep7(); motor_state--; if(motor_state < 0) motor_state = 7; desired_step_cnt++; } else if(desired_step_cnt > 0){ if(motor_state == 0) halfstep2(); if(motor_state == 1) halfstep3(); if(motor_state == 2) halfstep4(); if(motor_state == 3) halfstep5(); if(motor_state == 4) halfstep6(); if(motor_state == 5) halfstep7(); if(motor_state == 6) halfstep8(); if(motor_state == 7) halfstep1(); motor_state++; if(motor_state > 7) motor_state = 0; desired_step_cnt--; } } else if(motor_enable == WAVE){ if(desired_step_cnt < 0){ if(motor_state == 1) wavestep4(); if(motor_state == 3) wavestep1(); if(motor_state == 5) wavestep2(); if(motor_state == 7) wavestep3(); motor_state -= 2; if(motor_state < 1) motor_state = 7; desired_step_cnt++; } else if(desired_step_cnt > 0){ if(motor_state == 1) wavestep2(); if(motor_state == 3) wavestep3(); if(motor_state == 5) wavestep4(); if(motor_state == 7) wavestep1(); motor_state += 2; if(motor_state > 7) motor_state = 1; desired_step_cnt--; } } _delay_ms(100);//Change according to speed input // normstep1(); // _delay_ms(100); // normstep2(); // _delay_ms(100); // normstep3(); // _delay_ms(100); // normstep4(); // _delay_ms(100); // halfstep1(); // _delay_ms(100); // halfstep2(); // _delay_ms(100); // halfstep3(); // _delay_ms(100); // halfstep4(); // _delay_ms(100); // halfstep5(); // _delay_ms(100); // halfstep6(); // _delay_ms(100); // halfstep7(); // _delay_ms(100); // halfstep8(); // _delay_ms(100); // wavestep1(); // _delay_ms(100); // wavestep2(); // _delay_ms(100); // wavestep3(); // _delay_ms(100); // wavestep4(); // _delay_ms(100); } return 0; }