int main(void){ // Initialize the UART,Timers, and I2C1 int count = 0; Board_init(); Timer_init(); Serial_init(); Thermal_init(); while(1){ if(count == 0){ readChipTemp(); calculateChipTemp(); } count++; if(count >= 16){ count = 0; } readPixelValue(); readCPixelValue(); calculateIRTemp(); int i; for(i = 0; i <= 63; ++i){ while(!Serial_isTransmitEmpty()); printf("V_ir[%d]: %.2f\n",i,finalPixelTempF[i]); } } }
void readEeprom(void){ BOOL success = FALSE; int index; do { if(!I2C_startTransfer(THERMAL_I2C_ID, FALSE)){ #ifdef DEBUG printf("FAILED initial transfer!\n"); #endif break; } // Transmit the slave's address to notify it if (!I2C_sendData(THERMAL_I2C_ID,EEPROM_WRITE_ADDRESS)) break; // Tranmit the read address module if(!I2C_sendData(THERMAL_I2C_ID,EEPROM_READ_COMMAND)){ #ifdef DEBUG printf("Error: Sent byte was not acknowledged\n"); #endif break; } // Send a Repeated Started condition if(!I2C_startTransfer(THERMAL_I2C_ID,TRUE)){ #ifdef DEBUG printf("FAILED Repeated start!\n"); #endif break; } // Transmit the address with the READ bit set if (!I2C_sendData(THERMAL_I2C_ID,EEPROM_READ_ADDRESS)) break; // Read the I2C bus most significant byte and send an acknowledge bit for(index = 0; index <=0xFF; index++){ eepromData[index] = I2C_getData(THERMAL_I2C_ID); if(index < 0xFF) I2CAcknowledgeByte(I2C1, TRUE); else I2CAcknowledgeByte(I2C1, FALSE); while(!I2CAcknowledgeHasCompleted(I2C1)); } success = TRUE; } while(0); // Send the stop bit to finish the transfer I2C_stopTransfer(THERMAL_I2C_ID); if(!success){ printf("Data transfer unsuccessful.\n"); return; } // Stop transfer twice? I2C_stopTransfer(THERMAL_I2C_ID); int Index; for(Index = 0; Index <=255; Index++){ while(!Serial_isTransmitEmpty()); //printf("EEPROM %x / %d: %x\n", Index, Index, eepromData[Index]); } }
int main(void) { // Initialize the UART,Timers, and I2C1v Board_init(); Serial_init(); I2C_init(MAGNETOMETER_I2C_ID, I2C_CLOCK_FREQ); Magnetometer_init(); while(1){ Magnetometer_runSM(); while(!Serial_isTransmitEmpty()); printf("Angle: %.1f\n", Magnetometer_getDegree()); } return (SUCCESS); }
int main(void) { Board_init(); Serial_init(); printf("\r\nUno Serial Test Harness\r\nAfter this Message the terminal should mirror anything you type.\r\n"); unsigned char ch = 0; while (1) { if (Serial_isTransmitEmpty() == TRUE) if (Serial_isReceiveEmpty() == FALSE) Serial_putChar(Serial_getChar()); } return 0; }
/**************************************************************************** Function Serial_runSM Parameters None. Returns None. Description Sends one character from buffer if there are any characters and the trasmit * buffer is empty. Author Max Dunne, 2011.11.10 ****************************************************************************/ void Serial_runSM() { if (Serial_isTransmitEmpty() && bufferIndex < sizeof(buffer)) Serial_putChar(buffer[bufferIndex++]); }