Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 4:d3c9c6df14a8, committed 2019-01-22
- Comitter:
- mcm
- Date:
- Tue Jan 22 11:40:31 2019 +0000
- Parent:
- 3:cae1eaf473be
- Commit message:
- The driver was completed and tested ( NUCLEO-L152RE ), it works as expected
Changed in this revision
AMG8833.cpp | Show annotated file Show diff for this revision Revisions of this file |
AMG8833.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r cae1eaf473be -r d3c9c6df14a8 AMG8833.cpp --- a/AMG8833.cpp Fri Jan 11 14:15:01 2019 +0000 +++ b/AMG8833.cpp Tue Jan 22 11:40:31 2019 +0000 @@ -595,7 +595,7 @@ AMG8833::AMG8833_status_t aux; /* Get thermistor raw temperature data */ - aux = AMG8833_GetThermistorRawData ( myThermistorValue ); + aux = AMG8833::AMG8833_GetThermistorRawData ( myThermistorValue ); /* Check if the temperature is negative */ if ( ( myThermistorValue->termistorOutputRawValue & 0x800 ) == 0x800 ) @@ -746,12 +746,12 @@ */ AMG8833::AMG8833_status_t AMG8833::AMG8833_GetPixelTemperatures ( AMG8833_data_t* myPixelTemperatureData ) { - char i = 0U; + uint8_t i = 0U; float mySign = 0.0; AMG8833::AMG8833_status_t aux; /* Get pixel raw temperature data */ - aux = AMG8833_GetPixelRawTemperatures ( myPixelTemperatureData ); + aux = AMG8833::AMG8833_GetPixelRawTemperatures ( myPixelTemperatureData ); /* Parse the data */
diff -r cae1eaf473be -r d3c9c6df14a8 AMG8833.h --- a/AMG8833.h Fri Jan 11 14:15:01 2019 +0000 +++ b/AMG8833.h Tue Jan 22 11:40:31 2019 +0000 @@ -22,7 +22,152 @@ /** Example: @code +#include "mbed.h" +#include "AMG8833.h" +AMG8833 myAMG8833 ( I2C_SDA, I2C_SCL, AMG8833::AMG8833_ADDRESS_AD_SELECT_VDD, 400000 ); +Serial pc ( USBTX, USBRX ); // tx, rx + +DigitalOut myled ( LED1 ); +Ticker newAction; + + + +//@brief Constants. + // + + +//@brief Variables. + // +volatile uint32_t myState; // State that indicates when to perform an ADC sample + + + +// + // @brief FUNCTION PROTOTYPES + // +void changeDATA ( void ); + + + + +//@brief FUNCTION FOR APPLICATION MAIN ENTRY. + // +int main() +{ + AMG8833::AMG8833_status_t aux; + AMG8833::AMG8833_data_t myAMG8833_Data; + + pc.baud ( 115200 ); + + + myled = 1; + wait(3); + myled = 0; + + // Put the device in Normal mode + myAMG8833_Data.operationMode = AMG8833::PCTL_NORMAL_MODE; + aux = myAMG8833.AMG8833_SetOperationMode ( myAMG8833_Data ); + + // Reset the device by software + aux = myAMG8833.AMG8833_SoftwareReset ( AMG8833::RST_INITIAL_RESET ); + wait_ms ( 500 ); + + // Set frame rate: 10 FPSC + aux = myAMG8833.AMG8833_SetFrameMode ( AMG8833::FPSC_10FPS ); + + // Set moving average Output Mode: OFF + aux = myAMG8833.AMG8833_SetAverageOutputMode ( AMG8833::MAMOD_WICE_MOVING_AVERAGE_OUTPUT_MODE_OFF ); + + // Clear all flags + aux = myAMG8833.AMG8833_ClearFlags ( ( AMG8833::OVT_CLR_THERMISTOR_TEMPERATURE_OVERFLOW_CLEAR_FLAG | AMG8833::OVS_CLR_TEMPERATURE_OVERFLOW_CLEAR_FLAG | AMG8833::INTCLR_INTERRUPT_OUTBREAK_CLEAR_FLAG ) ); + + // Resume from reset state + aux = myAMG8833.AMG8833_SoftwareReset ( AMG8833::RST_RESUME_FROM_RESET ); + wait_ms ( 500 ); + + // Put the device in Normal mode + myAMG8833_Data.operationMode = AMG8833::PCTL_NORMAL_MODE; + aux = myAMG8833.AMG8833_SetOperationMode ( myAMG8833_Data ); + + + myState = 0UL; // Reset the variable + newAction.attach( &changeDATA, 1U ); // the address of the function to be attached ( changeDATA ) and the interval ( 1s ) + + + // Let the callbacks take care of everything + while(1) { + sleep(); + + if ( myState == 1UL ) { + myled = 1U; + + // Get thermistor temperature value + aux = myAMG8833.AMG8833_GetThermistorValue ( &myAMG8833_Data ); + + // Get pixel temperature values + aux = myAMG8833.AMG8833_GetPixelTemperatures ( &myAMG8833_Data ); + + + // Transmit result through the UART + // Raw data + //uint8_t myAuxVar = 0U; + //myAuxVar = ( myAMG8833_Data.termistorOutputRawValue >> 8U ) ; + //pc.putc( myAuxVar ); + //myAuxVar = ( myAMG8833_Data.termistorOutputRawValue & 0xFF ) ; + //pc.putc( myAuxVar ); + + //for ( uint32_t i = 0U; i < 64U; i++ ) + //{ + // myAuxVar = ( myAMG8833_Data.pixelOutputRawValues[i] >> 8U ) ; + // pc.putc( myAuxVar ); + // myAuxVar = ( myAMG8833_Data.pixelOutputRawValues[i] & 0xFF ) ; + // pc.putc( myAuxVar ); + //} + + + // Final data + pc.printf ( "\r\n%0.4fC\r\n[ %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f\r\n %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f\r\n %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f\r\n %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f\r\n %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f\r\n %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f\r\n %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f\r\n %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f ]\r\n", + myAMG8833_Data.termistorOutputValue, myAMG8833_Data.pixelOutputValues[0], myAMG8833_Data.pixelOutputValues[1], myAMG8833_Data.pixelOutputValues[2], myAMG8833_Data.pixelOutputValues[3], myAMG8833_Data.pixelOutputValues[4], myAMG8833_Data.pixelOutputValues[5], myAMG8833_Data.pixelOutputValues[6], myAMG8833_Data.pixelOutputValues[7], myAMG8833_Data.pixelOutputValues[8], myAMG8833_Data.pixelOutputValues[9], myAMG8833_Data.pixelOutputValues[10], + myAMG8833_Data.pixelOutputValues[11], myAMG8833_Data.pixelOutputValues[12], myAMG8833_Data.pixelOutputValues[13], myAMG8833_Data.pixelOutputValues[14], myAMG8833_Data.pixelOutputValues[15], myAMG8833_Data.pixelOutputValues[16], myAMG8833_Data.pixelOutputValues[17], myAMG8833_Data.pixelOutputValues[18], myAMG8833_Data.pixelOutputValues[19], myAMG8833_Data.pixelOutputValues[20], myAMG8833_Data.pixelOutputValues[21], myAMG8833_Data.pixelOutputValues[22], + myAMG8833_Data.pixelOutputValues[23], myAMG8833_Data.pixelOutputValues[24], myAMG8833_Data.pixelOutputValues[25], myAMG8833_Data.pixelOutputValues[26], myAMG8833_Data.pixelOutputValues[27], myAMG8833_Data.pixelOutputValues[28], myAMG8833_Data.pixelOutputValues[29], myAMG8833_Data.pixelOutputValues[30], myAMG8833_Data.pixelOutputValues[31], myAMG8833_Data.pixelOutputValues[32], myAMG8833_Data.pixelOutputValues[33], myAMG8833_Data.pixelOutputValues[34], + myAMG8833_Data.pixelOutputValues[35], myAMG8833_Data.pixelOutputValues[36], myAMG8833_Data.pixelOutputValues[37], myAMG8833_Data.pixelOutputValues[38], myAMG8833_Data.pixelOutputValues[39], myAMG8833_Data.pixelOutputValues[40], myAMG8833_Data.pixelOutputValues[41], myAMG8833_Data.pixelOutputValues[42], myAMG8833_Data.pixelOutputValues[43], myAMG8833_Data.pixelOutputValues[44], myAMG8833_Data.pixelOutputValues[45], myAMG8833_Data.pixelOutputValues[46], + myAMG8833_Data.pixelOutputValues[47], myAMG8833_Data.pixelOutputValues[48], myAMG8833_Data.pixelOutputValues[49], myAMG8833_Data.pixelOutputValues[50], myAMG8833_Data.pixelOutputValues[51], myAMG8833_Data.pixelOutputValues[52], myAMG8833_Data.pixelOutputValues[53], myAMG8833_Data.pixelOutputValues[54], myAMG8833_Data.pixelOutputValues[55], myAMG8833_Data.pixelOutputValues[56], myAMG8833_Data.pixelOutputValues[57], myAMG8833_Data.pixelOutputValues[58], + myAMG8833_Data.pixelOutputValues[59], myAMG8833_Data.pixelOutputValues[60], myAMG8833_Data.pixelOutputValues[61], myAMG8833_Data.pixelOutputValues[62], myAMG8833_Data.pixelOutputValues[63] ); + + + // Reset the variables + myState = 0UL; + myled = 0U; + } + } +} + + + +/// + / @brief changeDATA ( void ) + / + / @details It changes myState variable + / + / @param[in] N/A + / + / @param[out] N/A. + / + / + / @return N/A. + / + / + / @author Manuel Caballero + / @date 10/December/2018 + / @version 10/December/2018 The ORIGIN + / @pre N/A + / @warning N/A. + // +void changeDATA ( void ) +{ + myState = 1UL; +} @endcode */