int main() { // initialize the board (void) Board_initGeneral(120 * 1000 * 1000); // initialize i2c initializeI2C(); // setup i2c task, who does the work (void) setup_I2C_Task(); // initialize uart initializeUART(); // setup uart task, printing the output (void) setup_UART_Task(); // setup the events which are used in combination with the queues (void) setup_Events(); // initialize interrupts initializeInterrupts(); // setup the interrupts - both for the ALTITUDE CLICK module and the USR_SW setup_Interrupts(); System_printf("Start BIOS\n"); System_flush(); /* Start BIOS */ BIOS_start(); }
int main(void) { initializeI2C(); affTexte("Test LCD\n"); initCoders(); setupInterrupt(); unsigned int count = 0; char s[20]; while (1) { count++; if ((count % 60000) == 0) { clrScreen(); int i; for (i=0; i<2; i++) { long coder = getCoderValue(i); sprintf(s, "%x_", (int)(coder >> 16)); affTexte(s); sprintf(s, "%x", (int)(coder & 0xFFFF)); affTexte(s); carRetCur(); } count = 0; } }
uint8_t readI2C(uint8_t base_address, uint8_t register_address) { initializeI2C(base_address, register_address); Wire.requestFrom(base_address, 1u); while (Wire.available() < 1u); return Wire.read(); }
CSL_Status setupAIC3204(void) { CSL_Status status; status = initializeI2C(); if (status != CSL_SOK) { printf("Could not initialize I2C!\n"); return status; } AIC_Write(0x00, 0x00); //Select page 0 AIC_Write(0x01, 0x01); //Software RESET AIC_Write(0x00, 0x01); //Select page 1 AIC_Write(0x01, 0x08); //Disable weak connection of AVDD with DVDD AIC_Write(0x02, 0x01); //AVDD=DVDD=1.72V, power up AVDD LDO, etc. AIC_Write(0x00, 0x00); //Select page 0 AIC_Write(0x1B, 0x0D); //I2S, 16bits // --------------- PLL & FS Setup --------------- // AIC_Write(0x04, 0x03); //Low PLL range, MCLK input to PLL, PLL CLK is CODEC_CLKIN AIC_Write(0x06, 0x08); //PLL J = 8 AIC_Write(0x07, 0x07); //PLL D (MSBs) AIC_Write(0x08, 0x80); //PLL D (LSBs) //PLL D = 1920 AIC_Write(0x1E, 0xA0); //BCLK N = 10 AIC_Write(0x05, 0x91); //PLL Power Up, P=1, R=1 AIC_Write(0x0D, 0x02); //DAC OSR (MSBs) AIC_Write(0x0E, 0x00); //DAC OSR (LSBs) //DOSR = 2 AIC_Write(0x14, 0x80); //AOSR = 128 AIC_Write(0x0B, 0x86); //NDAC = 6 AIC_Write(0x0C, 0x82); //MDAC = 2 AIC_Write(0x12, 0x88); //NADC = 8 AIC_Write(0x13, 0x86); //MADC = 6 // --------------- DAC & HPL Setup --------------- // AIC_Write(0x00, 0x01); //Select page 1 AIC_Write(0x0C, 0x08); //Left DAC positive terminal to HPL AIC_Write(0x0D, 0x08); //Right DAC positive terminal to HPR AIC_Write(0x00, 0x00); //Select page 0 AIC_Write(0x40, 0x02); //DAC unmute, right volume tracks left AIC_Write(0x41, 0x00); //DAC Left Volume = 0dB AIC_Write(0x3F, 0xD4); //DAC power up AIC_Write(0x10, 0x00); //HPL unmuted, gain = 0dB AIC_Write(0x11, 0x00); //HPR unmuted, gain = 0dB AIC_Write(0x09, 0x30); //HPL, HPR power up // ----------------- ADC Setup ----------------- // AIC_Write(0x00, 0x01); //Select page 1 AIC_Write(0x33, 0x00); //MICBIAS power down AIC_Write(0x34, 0x30); //IN2L routed to MICPGA (positive terminal) 40kOhm AIC_Write(0x37, 0x30); //IN2R routed to MICPGA (positive terminal) 40kOhm AIC_Write(0x36, 0x03); //CM2L routed to MICPGA (negative terminal) 40kOhm AIC_Write(0x39, 0x03); //CM2R routed to MICPGA (negative terminal) 40kOhm AIC_Write(0x3B, 0x00); //MICPGA (left) enabled, gain = 0dB AIC_Write(0x3C, 0x00); //MICPGA (right) enabled, gain = 0dB AIC_Write(0x00, 0x00); //Select page 0 AIC_Write(0x51, 0xC0); //Left/right ADC power up AIC_Write(0x52, 0x00); //Left/right ADC unmute, fine gain = 0dB return status; }
int main() { //char* buffers for printing stuff on the LCD char buffer[20]; char buffer2[20]; //create ESC object Esc escFL(FL), escBL(BL),escBR(BR), escFR(FR); //create objects for led strips WS2812 LEDFRT(1, FRT); // 100 LED cRGB valueFRT; //create IMU object IMU imu; //Initialize modules; comment out to deactivate feature initLCD(); //initRF(); //initializeESC(); //initWS2812(); initializeI2C(); imu.initialize(); initSerial(MYUBRR); //After everything is initialized, start interrupts startInterrupt(); while(1) { //LCD handler if(flagLCD){ flagLCD = 0; handleFSMLCD(); } // ////receive //sprintf(buffer, "%c", getSerialBuffer()); //sprintf(buffer2, ""); //changeLCDText(buffer,buffer2); //send //sprintf(buffer, "Simon Says Simon rules"); //serialTransmit(buffer); //_delay_ms(1000); //RF receiver handler if(flagRF) { flagRF = 0; handleFSMRF(); //sprintf(buffer, "1:%u 2:%u", ch_1_pw, ch_2_pw); //sprintf(buffer2, "3:%u 4:%u", ch_3_pw, ch_4_pw); //changeLCDText(buffer, buffer2); } //ESC handler if(flagESC) { flagESC = 0; escFL.set(ch_3_pw); escBL.set(ch_3_pw); escBR.set(ch_3_pw); escFR.set(ch_3_pw); } ////LED //if(flagWS2812) //{ //flagWS2812 = 0; // ////example of LED gradually //static int i = 0; //static bool directionUp = true; ////Led strips shit //for(int j = 0; j<1; j++) //{ //valueFRT.b = i; valueFRT.g = i; valueFRT.r = i; // RGB Value -> red //LEDFRT.set_crgb_at(j, valueFRT); // Set valueB at LED found at index j //valueFRT.b = 255; valueFRT.g = 255; valueFRT.r = 255; // RGB Value -> Blue //} //LEDFRT.sync(); // Sends the value to the LED //if(i>=255) directionUp = false; //if(i<=0) directionUp = true; //if (directionUp) i++; //else i--; //} if(flagIMU) { flagIMU = 0; imu.takeMeasures(); sprintf(buffer, "x:%i y:%i z:%i", imu.acc.X, imu.acc.Y, imu.acc.X); //serialTransmit(buffer); changeLCDText(buffer); } } return 0; }