📄 atjplatformcmds.c
字号:
* * RETURNS: Button state * ****************************************************************************/PRIVATE uint8 u8ButtonReadRfd_Wrapper(void){ uint8 u8ButtonState; #ifdef JENNIC_PCB_NTS u8ButtonState = u8ButtonReadNts(); #else u8ButtonState = u8ButtonReadRfd(); #endif return u8ButtonState;}/**************************************************************************** * * NAME: u8ButtonReadFfd_Wrapper * * DESCRIPTION: * Calls the appropriate button read function depending on platform * * PARAMETERS: Name RW Usage * * RETURNS: Button state * ****************************************************************************/PRIVATE uint8 u8ButtonReadFfd_Wrapper(void){ uint8 u8ButtonState; #ifdef JENNIC_PCB_NTS u8ButtonState = u8ButtonReadNts(); #else u8ButtonState = u8ButtonReadFfd(); #endif return u8ButtonState;}/**************************************************************************** * * NAME: u16ALSreadChannelResult_Wrapper * * DESCRIPTION: * Returns the light level from the TSL2550 Light level sensor * * PARAMETERS: Name RW Usage * * RETURNS: Light Level * ****************************************************************************/PRIVATE uint16 u16ALSreadChannelResult_Wrapper(void){ return u16ALSreadChannelResult();}/**************************************************************************** * * NAME: vLEDOn_Wrapper * * DESCRIPTION: * Calls the LED control function to turn on the LED * * PARAMETERS: Name RW Usage * u32LED R LED bit in bitmap * * RETURNS: None * ****************************************************************************/PRIVATE void vLEDOn_Wrapper(uint32 u32LED){ vLedControl(u32LED, 1);}/**************************************************************************** * * NAME: vLEDOn_Wrapper * * DESCRIPTION: * Calls the LED control function to turn off the LED * * PARAMETERS: Name RW Usage * u32LED R LED bit in bitmap * * RETURNS: None * ****************************************************************************/PRIVATE void vLEDOff_Wrapper(uint32 u32LED){ vLedControl(u32LED, 0);}/**************************************************************************** * * NAME: vLCDWriteText_Wrapper * * DESCRIPTION: * Write text to the LCD * * PARAMETERS: Name RW Usage * *TextStr R Text to write * u32Row R Row * u32Col R Column * * RETURNS: None * ****************************************************************************/#ifndef JENNIC_PCB_NTSPRIVATE void vLCDWriteText_Wrapper(char *TextStr, uint32 u32Row, uint32 u32Col){ vLcdWriteText(TextStr, u32Row, u32Col); vLcdRefreshAll();}#endif/**************************************************************************** * * NAME: i32GetBoardVoltage * * DESCRIPTION: * Returns the board (battery) voltage by reading the dedicated ADC channel * and scales it in mV (e.g 3V = 3000). * If the ADC times out a non-valid negative value is returned * * PARAMETERS: Name RW Usage * * RETURNS: Scaled voltage. Returns -1 if ADC timed out. * ****************************************************************************/PRIVATE int32 i32GetBoardVoltage(void){ uint16 u16AdcReading; int32 i32VoltsReading = 0; volatile uint32 u32Timeout = 0; vAHI_AdcStartSample(); /* start sample */ while (bAHI_AdcPoll()) { if (ADC_TIMEOUT == u32Timeout++) { i32VoltsReading = -1; break; } } if (-1 != i32VoltsReading) { u16AdcReading = u16AHI_AdcRead(); i32VoltsReading = ((uint32)((uint32)(u16AdcReading * 586) + ((uint32)(u16AdcReading * 586) >> 1))) / 1000; } return i32VoltsReading;}/**************************************************************************** * * NAME: i32GetTemperature * * DESCRIPTION: * Returns the temperature by reading the appropriate temp sensor IC * i.e MCP9803 for NTS board or SHT1X (combined temp/humidity sensor) for other platforms * If the sensor reading times out a non-valid negative value is returned * * PARAMETERS: Name RW Usage * * RETURNS: Temperature in degrees C * ****************************************************************************/PRIVATE int32 i32GetTemperature(void){ int32 i32TempReading = 0; volatile uint32 u32Timeout = 0; #ifdef JENNIC_PCB_NTS tsMCP9803_Result sMCP9803; while (!bMCP9803_Read(&sMCP9803)) { if (TEMP_HUMID_TIMEOUT == u32Timeout++) { i32TempReading = -1; break; } } if (-1 != i32TempReading) { i32TempReading = (int32) sMCP9803.i8Temperature; } #else vHTSstartReadTemp(); while ((u32AHI_DioReadInput() & HTS_DATA_DIO_BIT_MASK) != 0) { if (TEMP_HUMID_TIMEOUT == u32Timeout++) { i32TempReading = -1; break; } } if (-1 != i32TempReading) { i32TempReading = (int32) u16HTSreadTempResult(); } #endif return i32TempReading;}/**************************************************************************** * * NAME: i32GetHumidity * * DESCRIPTION: * Returns the humidity by reading the SHT1X (combined temp/humidity sensor). * If the sensor reading times out a non-valid negative value is returned * Note the NTS board does not populate this chip and therefore returns zero. * * PARAMETERS: Name RW Usage * * RETURNS: Humidity in percentage * ****************************************************************************/PRIVATE int32 i32GetHumidity(void){ int32 i32HumidReading = 0; #ifndef JENNIC_PCB_NTS /* note NTS board not supported */ volatile uint32 u32Timeout = 0; vHTSstartReadHumidity(); while ((u32AHI_DioReadInput() & HTS_DATA_DIO_BIT_MASK) != 0) { if (TEMP_HUMID_TIMEOUT == u32Timeout++) { i32HumidReading = -1; break; } } if (-1 != i32HumidReading) { i32HumidReading = (int32) u16HTSreadHumidityResult(); } #endif return i32HumidReading;}/****************************************************************************//*** END OF FILE ***//****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -