void LED_IOinit(void) { EALLOW; GpioCtrlRegs.GPBMUX1.bit.Blue_IO=0; GpioCtrlRegs.GPBDIR.bit.Blue_IO=1; GpioCtrlRegs.GPBMUX1.bit.Red_IO=0; GpioCtrlRegs.GPBDIR.bit.Red_IO=1; GpioCtrlRegs.GPAMUX1.bit.Core_LED=0; GpioCtrlRegs.GPADIR.bit.Core_LED=1; GpioCtrlRegs.GPAMUX1.bit.Fan_IO=0; GpioCtrlRegs.GPADIR.bit.Fan_IO=1; GpioCtrlRegs.GPAMUX1.bit.Bell_IO=0; GpioCtrlRegs.GPADIR.bit.Bell_IO=1; GpioCtrlRegs.GPAMUX2.bit.SIN_IO=0; GpioCtrlRegs.GPADIR.bit.SIN_IO=1; EDIS; LED_Red_Off(); LED_Blue_Off(); LED_Core_Off(); FAN_Stop(); BELL_Stop(); SIN_Off(); }
void LED_Error_Flash(void) { if(light_state3 == 0) { LED_Red_Off(); LED_Blue_On(); i3++; if(i3>=10) { light_state3 = 1; i3 = 0; } } else { LED_Blue_Off(); LED_Red_On(); i3++; if(i3>=10) { light_state3 = 0; i3 = 0; } } }
void RTC_Start(){ if(RTC_SR == RTC_SR_TCE_MASK){ // If RTC clock is already running RTC = RTC_Init(NULL, true); // Initialise the RTC softly }else{ RTC = RTC_Init(NULL, false); // Initialise the RTC hard (reset time/date etc.) for(uint8 i = 0; i < 4; i++){ LED_Red_On(); DelayMs(500); LED_Red_Off(); DelayMs(500); } } }
void LED_Red_Flash_Slow(void) { if(red_light_state2 == 0) { LED_Red_Off(); i2++; if(i2>=1) { red_light_state2 = 1; i2 = 0; } } else { LED_Red_On(); i2++; if(i2>=1) { red_light_state2 = 0; i2 = 0; } } }
void LED_Red_Flash(void) { if(red_light_state1 == 0) { LED_Red_Off(); i1++; if(i1>=2) { red_light_state1 = 1; i1 = 0; } } else { LED_Red_On(); i1++; if(i1>=2) { red_light_state1 = 0; i1 = 0; } } }
void MPU9250_Init() { uint32_t Device_ID; SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_7); GPIOPinConfigure(GPIO_PA2_SSI0CLK); GPIOPinConfigure(GPIO_PA3_SSI0FSS); GPIOPinConfigure(GPIO_PA4_SSI0RX); GPIOPinConfigure(GPIO_PA5_SSI0TX); GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 1000000, 8); SSIEnable(SSI0_BASE); // // Display the example setup on the console. // UARTprintf("\nPower up.\n"); // MPU-6500 Device ID check and initial Device_ID = 0x0; Device_ID = MPU9250_ReadReg(MPU6500_WHO_AM_I); if(Device_ID == MPU6500_Device_ID) { UARTprintf("MPU6500 Device ID: 0x%X\n--- MPU6500 Initialization done.\n", Device_ID); } else { OLED_Print(0,0,"MPU6500 ERR"); UARTprintf("MPU6500 Device ID: 0x%X\n--- MPU6500 Initialization error.\n", Device_ID); while (1); } MPU9250_SetParameter(); #ifdef USE_MAG // AK9875 Device ID check // if AK9875 ID check check failed with no reason, re-power-up the system. MPU9250_WriteAuxReg(AK8963_CNTL2, 0x01); //soft reset MPU9250_Delay_nop(100000); Device_ID = 0x00; Device_ID = MPU9250_ReadAuxReg(AK8963_WIA); if(Device_ID == AK8963_Device_ID) { UARTprintf("AK8963 Device ID: 0x%X\n--- AK8963 Initialization done.\n", Device_ID); LED_Blue_Off(); } else { UARTprintf("AK8963 Device ID: 0x%X\n--- AK8963 Initialization error.\n", Device_ID); OLED_Print(0,0,"AK8963 Init ERR"); LED_Red_Off(); LED_Green_Off(); } MPU9250_GetMagAdjValue(); MPU9250_WriteAuxReg(AK8963_CNTL1, 0x16); // 16-bits, Rate 100Hz //MPU9250_WriteAuxReg(AK8963_CNTL1, 0x2); // 14-bits, Rate 8Hz Device_ID = MPU9250_ReadAuxReg(AK8963_CNTL1); #else UARTprintf("AK8963 is disabled.\n"); #endif }