APPLICATION NOTE IOT ENABLER User Application Creation Guideline R01AN2773EA0100 Rev.1.00 APR22, 2015 Introduction R01ANxxxxEJ0932 Rev.1.00 This application note describes how to create an application and integrate it into the IoT Enabler workspace. Feb 22, 2015 Target Device RDKRL78/G14 R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 1 of 4 APPLICATION NOTE Contents 1. Overview ......................................................................................................................... 3 2. Introduction to factory demonstration workspace....................................................... 4 2.1 Workspace Structure .................................................................................................................. 4 2.1.1 YRDKRL78G14 Folder ........................................................................................................... 4 2.1.2 Lib Folder ................................................................................................................................ 4 2.1.3 Apps Folder ............................................................................................................................. 5 3. Basic Input / Output ....................................................................................................... 5 3.1 Switches and LEDs ..................................................................................................................... 5 3.1.1 Switches .................................................................................................................................. 5 3.1.2 LEDs ....................................................................................................................................... 6 3.2 EInk Segment Display ..................................................................... Error! Bookmark not defined. 3.3 LCD ............................................................................................................................................... 7 3.4 Serial Port .................................................................................................................................... 8 3.5 EEPROM ..................................................................................................................................... 10 4. On-board Sensors ........................................................................................................ 11 4.1 Initialization................................................................................................................................ 11 4.2 Sensors' data acquisition ......................................................................................................... 11 4.2.1 3-Axis accelerometer ............................................................................................................ 11 4.2.2 Ambient light sensor ............................................................................................................. 12 4.2.3 Temperature sensor .............................................................................................................. 12 4.2.4 Potentiometer ........................................................................................................................ 12 4.2.5 MEMS Microphone ............................................................................................................... 13 5. Application Creation Sample ....................................................................................... 14 5.1 Target application ..................................................................................................................... 14 5.2 Create a skeleton for application ............................................................................................ 14 5.2.1 Create application source ..................................................................................................... 15 5.2.2 Create a menu entry for the application ................................................................................ 16 5.3 Using the on-board devices in the application ...................................................................... 18 R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 2 of 4 RDKRL78/G14 1. User Application Creation Guideline Overview The IoT Enabler workspace includes three main parts: The MCU's peripheral driver The external device drivers and libraries The applications Applications Buglabs Cloud Connectivity Provisioning Demo Applications Diagnostic Programs External Device Drivers & Libraries EEPROM LED LCD Console Switch ATCmdLib GSHAL jsmn Sensors GPS MCU's Peripheral Drivers GPIO ADC Timer I2C SPI UART RL78/G14 MCU Figure 1. Firmware Overview User Application Creation Guidelines Rev.1.00 Feb 22, 2015 Page 3 of 4 APPLICATION NOTE 2. Introduction to factory demonstration workspace 2.1 Workspace Structure IoT Enabler_Vxx YRDKRL78G14 Lib Apps Figure 2. RDKRL78/G14 Workspace file structure 2.1.1 YRDKRL78G14 Folder This is the main project folder. This folder contains: 2.1.2 Project's files and project's setting Main function Hardware setup function MCU's peripheral drivers System device: Millisecond timer, Console System definition: YRDKRL78G14.h Lib Folder This folder contains all libraries used to manipulate external devices and libraries used in application. External devices which supported in current factory demonstration include: Switches LEDs LCD EEPROM Gainspan Wifi module Sensors: Accelerometer, Ambient light sensor, Temperature sensor, Potentiometer, MEMS Microphone Other libraries include: AT command library JSON parser library GPS NMEA parser Skywire Cellular Drivers R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 4 of 4 APPLICATION NOTE 2.1.3 Apps Folder This folder contains the factory demonstration source code. It includes: 3. Buglabs cloud connectivity demo with Dweet client Provisioning Various Demo Apps Basic Input / Output 3.1 Switches and LEDs 3.1.1 Switches The IoT Enabler provides three switches SW1, SW2 and SW3 for user input. To manipulate switches operation, the workspace provide switches library under Lib folder. The switches library APIs are described as below: APIs header: Switch.h APIs description: No. 1 Prototype bool Switch1IsPressed(void) Description Check if SW1 is pressed. Input: None. Output: True - If SW1 is pressed. False - If SW1 is not pressed. 2 bool Switch2IsPressed(void) Check if SW2 is pressed. Input: None. Output: True - If SW2 is pressed. False - If SW2 is not pressed. 3 bool Switch3IsPressed(void) Check if SW3 is pressed. Input: None. Output: True - If SW3 is pressed. False - If SW3 is not pressed. 4 bool checkSwitches( Check if any switch status changed since last check using this function. char * switches Input: switches - Pointer to location used to store switches status. ) Output: True - If switches status changed False - If switches status not changed R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 5 of 4 APPLICATION NOTE 3.1.2 LEDs The IoT Enabler provides twelve LEDs from LED3 to LED15 to indicate status. The LEDs is controlled by LEDs library under Lib folder. The LED library APIs are described as below: APIs header: led.h APIs description: No. 1 Prototype void led_init(void) Description Initialize LED driver. Input: None. Output: None 2 void led_all_off(void) Light off all LEDs from LED3 to LED15 Input: None. Output: None 3 void led_all_on(void) Light on all LEDs from LED3 to LED15 Input: None. Output: None 4 void led_on(int n) Light on specified LED. Input: n - Index number of specified LED n=0 <=> LED3 ... n=12 <=> LED15 Output: None 5 void led_off(int n) Light off specified LED. Input: n - Index number of specified LED n=0 <=> LED3 ... n=12 <=> LED15 Output: None 6 uint8_t led_get(int n) Get status of specified LED. Input: n - Index number of specified LED. n=0 <=> LED3 ... n=12 <=> LED15 Output: 0 - If LED is lighted off. 1 - If LED is lighted on. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 6 of 4 APPLICATION NOTE 3.2 LCD The LCD library under Lib folder provides APIs to manipulate the build in Okaya graphic LCD. This application note only describes LCD usage in text mode to display text on the LCD. Supported APIs are described as below: APIs header: lcd.h APIs description: No. 1 Prototype void InitialiseLCD(void) Description Initialize LCD driver. Input: None. Output: None. 2 void LCDSelectFont ( LCDFONT font Select font size for LCD. Input: font - Font set. FONT_SMALL - 5x7 font. ) FONT_LARGE - 8x8 font. FONT_LOGOS - Graphics to display Renesas Logo Output: None 3 void ClearLCD(void) Clear LCD. Input: None. Output: None. 4 void DisplayLCD( uint8_t position, Display pre-defined state on the display. Input: position - Line number of display. const uint8_t * string The display supports 8 lines with up to 12 characters per line. ) Use the defines LCD_LINE1 to LCD_LINE8 to specify starting position. String - Pointer to null terminated string. Output: None. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 7 of 4 APPLICATION NOTE 3.3 Serial Port The IoT Enabler supports two channels of UART for serial communication. The UART driver under YRDKRL78G14\drv provides APIs to manipulate UART operation. In addition, the console driver under YRDKRL78G14\system provides console-like APIs using UART1 to manipulate built-in serial port of the RDK. The dr ivers' details are described below: APIs header: drv\UART.h APIs description: No. 1 Prototype void RL78G14RDK_UART_Start( Initialize UARTs driver with specified baud-rates. uint32_t UART0_baud, Input: UART0_baud - Baud-rate of UART0 to be used. uint32_t UART1_baud UART1_baud - Baud-rate of UART1 to be used. Output: None. ) 2 Description bool UART0_SendByte( uint8_t aByte Put a byte in the UART0 output buffer if there is room in the transmit FIFO. Input: aByte - Byte to be sent. ) Output: True - If byte is placed in transmit output buffer. False - If byte is not placed in transmit output buffer. 3 bool UART1_SendByte( uint8_t aByte Put a byte in the UART1 output buffer if there is room in the transmit FIFO. Input: aByte - Byte to be sent. ) Output: True - If byte is placed in transmit output buffer. False - If byte is not placed in transmit output buffer. 4 bool UART0_ReceiveByte( uint8_t *aByte Attempt to retrieve a waiting byte in the UART0 receive FIFO. Input: aByte - Pointer to received data buffer. Output: True - If there is a byte read. ) False - If there is no byte read. 5 bool UART1_ReceiveByte( uint8_t *aByte Attempt to retrieve a waiting byte in the UART1 receive FIFO. Input: aByte - Pointer to received data buffer. Output: True - If there is a byte read. ) False - If there is no byte read. 6 uint32_t UART0_SendData( const uint8_t *aData, uint32_t aLen uint32_t UART1_SendData( const uint8_t *aData, uint32_t aLen aLen - Number of bytes to send. Attempts to send a group of data to the UART1 transmit buffer. Input: aData - Pointer to bytes to send out aLen - Number of bytes to send. Output: Number of bytes actually sent ); 8 Input: aData - Pointer to bytes to send out Output: Number of bytes actually sent ); 7 Attempts to send a group of data to the UART0 transmit buffer. void UART0_SendDataBlock( const uint8_t *aData, uint32_t aLen ); Attempts to send a group of data to the UART0 transmit buffer. Block until all data is sent. Input: aData - Pointer to bytes to send out aLen - Number of bytes to send. Output: None. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 8 of 4 RDKRL78/G14 9 User Application Creation Guideline void UART1_SendDataBlock( const uint8_t *aData, uint32_t aLen Attempts to send a group of data to the UART1 transmit buffer. Block until all data is sent. Input: aData - Pointer to bytes to send out aLen - Number of bytes to send. ); Output: None. 10 bool UART0_IsTransmitEmpty(void) Determine if all bytes in the transmit FIFO buffer of UART0 have all been sent. Input: None. Output: True - If all bytes are transmitted. False - If not all bytes are transmitted. 11 bool UART1_IsTransmitEmpty(void) Determine if all bytes in the transmit FIFO buffer of UART1 have all been sent. Input: None. Output: True - If all bytes are transmitted. False - If not all bytes are transmitted. APIs header: system\console.h APIs description: No. 1 Prototype void ConsolePrintf( const char * format, Description Output a formatted string of text to the console. Input: format - Format of string to output. ... - List of parameters. ... Output: None. ); 2 void ConsoleSendString( const char *string void ConsoleReadLine( char *string ); Input: string - String of characters to output on console. Output: None ); 3 Send a string to the console. Read a string from console until CR or LF character. Input: string - Pointer to received string buffer. Output: None. User Application Creation Guidelines Rev.1.00 Feb 22, 2015 Page 9 of 4 APPLICATION NOTE 3.4 EEPROM The IoT Enabler has a built-in EEPROM to store non-volatile data. The EEPROM library under Lib\EEPROM folder provide the APIs to read, write, erase data in the built-in EEPROM. The library details are described as below: APIs header: EPPROM\EEPROM.h APIs description: No. 1 Prototype uint8_t EEPROM_Erase( uint16_t offset, uint16_t aSize ) Description This function enters a for loop, and erases blocks of data EEPROM memory that cover the given address range. This routine will not keep the existing data in a block that is erased. Input: offset - Offset byte from start of EEPROM. aSize - number of bytes to erase of EEPROM. Output: None. 2 uint8_t EEPROM_Write( uint16_t offset, Writes the given contents to the EEPROM, at the given location. Input: offset - Offset byte from start of EEPROM. uint8_t *aData, aData - Pointer to bytes to write to EEPROM. uint16_t aSize aSize - number of bytes to write to EEPROM. Output: 0 - If success ) Not 0 - If failure 3 uint8_t EEPROM_Read( uint16_t offset, Read the contents from the EEPROM at the given location. Input: offset - Offset byte from start of EEPROM. uint8_t *aData, aData - Pointer to bytes to read from EEPROM. uint16_t aSize aSize - number of bytes to read from EEPROM. Output: 0 - If success ) Not 0 - If failure 4 void EEPROM_WriteStr( uint16_t addr, char *pdata Input: addr - Address of location to be written. pdata - Pointer to string location. Output: None. ) 5 Write a null terminated string to EEPROM at specified address. int16_t EEPROM_Seq_Read( uint16_t addr, Read the contents from the EEPROM at the given location. Input: offset - Offset byte from start of EEPROM. uint8_t *pdata, aData - Pointer to bytes to read from EEPROM. uint16_t r_lenth aSize - number of bytes to read from EEPROM. ) Output: 0 - If success Not 0 - If failure R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 10 of 4 APPLICATION NOTE 4. On-board Sensors The IoT Enabler provides a number of on-board sensors including: 3-Axis accelerometer Ambient light sensor Temperature sensor Potentiometer MEMS Microphone The factory demo workspace has integrated libraries under Lib\sensors folder to manipulate those sensors. Each sensor has two main operations: initialization and sensor's data acquisition. 4.1 Initialization The sensor driver initialization needs to be done before acquiring data from the sensors. Each sensor initialization function is described as below: No. Sensor Header API 1 3-Axis accelerometer Sensors\Accelerometer.h void Accelerometer_Init(void) 2 Ambient light sensor Sensors\LightSensor.h void LightSensor_Init(void) 3 Temperature sensor Sensors\Temperature.h void Temperature_Init(void) 4 Potentiometer 5 MEMS microphone Sensors\Potentiometer.h void Potentiometer_Init(void) Sensors' data acquisition 4.2 After initialization, the sensors' data can be acquired. 4.2.1 3-Axis accelerometer Accelerometer_Get() Synopsis Read acceleration values of 3 axis x, y and z measured by accelerator sensor. Prototype uint16_t * Accelerometer_Get( void ); Description Return Value Read acceleration value of 3 axis x, y and z then return the pointer to result location. uint16_t pointer to result location. Result data is stored in global array gAccData where gAccData[0] - Acceleration value for x axis. gAccData[1] - Acceleration value for y axis. gAccData[2] - Acceleration value for z axis. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 11 of 4 APPLICATION NOTE 4.2.2 Ambient light sensor LightSensor_Get() Synopsis Read light sensor value. Prototype uint16_t LightSensor_Get( void ); Description Return Value 4.2.3 Read and return illuminances value in Lux. Illuminances value. Temperature sensor Temperature_Get() Synopsis Read temperature value. Prototype uint16_t Temperature_Get( void ); Description Return Value 4.2.4 Read and return temperature value in Celcius. Temperature value. Potentiometer Potentiometer_Get() Synopsis Read relative position of potentiometer. Prototype uint32_t Potentiormeter_Get( void ); Description Return Value Read and return relative position of potentiometer. Relative position of potentiometer. Value in range 0 to 1000 for 0% to 100%. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 12 of 4 APPLICATION NOTE 4.2.5 MEMS Microphone Microphone_Get() Synopsis Read relative value of sound level. Prototype uint32_t Microphone_Get( void ); Description Return Value Read and return relative value of sound level captured by microphone. Relative value of sound level. Value in range 0 to 1000 for 0% to 100%. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 13 of 4 APPLICATION NOTE 5. Application Creation Sample This section is a tutorial that provides information to create a simple application and integrate it into the IoT Enabler workspace. 5.1 Target application The application will read the sensors data when SW2 is pressed and display the result to the board's LCD. The application will be called by selecting the option in the demo menu on the RDK's LCD. UP Tutorial Tutorial SEL DWN Application Application =================== -------------- x:00 Read on-board Temp : 027 *C sensors value Light: 450 lux and display to Pot : 1000 LCD Mic : 60 y:00 a) z:00 b) Figure 3. LCD display for tutorial application a) Menu entry content. b) Application LCD display. 5.2 Create a skeleton for application A blank application can be created in two steps: Step 1: Create application source Step 2: Create a menu entry for the application R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 14 of 4 APPLICATION NOTE 5.2.1 Create application source If not already present in the Apps folder, create a new C source file and save it as Apps\ApplicationTutorial.c. Include ApplicationTutorial.c to Apps group inside e2studio. Open ApplicationTutorial.c and add following contents: /*-------------------------------------------------------------------------* * File: AppplicationTutorial.c *-------------------------------------------------------------------------* * Description: * Application creation tutorial. *-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------* * Includes: *-------------------------------------------------------------------------*/ #include "Apps.h" /*-------------------------------------------------------------------------* * Routine: ApplicationTutorial *-------------------------------------------------------------------------* * Description: * Entry point for application. * In this tutorial, sensors' values are read when SW2 is pressed. * The sensing values are displayed on LCD. * Inputs: * void * Outputs: * void *-------------------------------------------------------------------------*/ void ApplicationTutorial(void) { while (1) { ; } } Declare the application prototype in Apps.h: /*-------------------------------------------------------------------------* * Prototypes: *-------------------------------------------------------------------------*/ void ApplicationTutorial(void); Now the tutorial application can be invoked by calling ApplicationTutorial() from the main() function. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 15 of 4 APPLICATION NOTE 5.2.2 Create a menu entry for the application YRDKRL78G14\main.c will be modified to add a menu entry for the tutorial application. At first, add an application mode enumeration value to AppMode_T: /*-------------------------------------------------------------------------* * Types: *-------------------------------------------------------------------------*/ /* Application Modes */ typedef enum { RUN_PROVISIONING, // Demo 2: Provisioning GAINSPAN_CLIENT, // Demo 3: Webserver demo with client mode DWEET_CONN_MODE, // Demo 4: Buglabs cloud connectivity demo RUN_EXOSITE, // Demo 5: Exosite cloud connectivity demo RUN_PROBE, // Demo 6: Micrium uC/Probe running wireless SPI_PT_MODE, // Gainspan SPI pass-through PROGRAM_MODE, // Gainspan Wifi in program mode APP_TUTORIAL, // Tutorial application APPMODE_INVALID // Invalid }AppMode_T; In this tutorial APP_TUTORIAL enumeration value is added. It must be placed before the APPMODE_INVALID. This enumeration value will be used to identify the content of menu entry and also to invoke the correct tutorial application. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 16 of 4 APPLICATION NOTE The menu entry content can be now created by modifying "Application Menu" part inside the main() function. The source code below indicates APP_TUTORIAL is added into the menu. /* Application menu display content */ switch (AppCurrent) { case GAINSPAN_DEMO: // DisplayLCD max characters per line is 19 // |<--------------->| DisplayLCD(LCD_LINE1, "UP DEMO 1 "); DisplayLCD(LCD_LINE2, " "); DisplayLCD(LCD_LINE3, " GainSpan DEMO "); DisplayLCD(LCD_LINE4, " "); DisplayLCD(LCD_LINE5, "SEL Monitor the "); DisplayLCD(LCD_LINE6, " board via "); DisplayLCD(LCD_LINE7, " direct AP "); DisplayLCD(LCD_LINE8, "DWN "); break; ... case APP_TUTORIAL: // DisplayLCD max characters per line is 19 // |<--------------->| DisplayLCD(LCD_LINE1, "UP "); DisplayLCD(LCD_LINE2, " Tutorial "); DisplayLCD(LCD_LINE3, " Application "); DisplayLCD(LCD_LINE4, " --------------"); DisplayLCD(LCD_LINE5, "SEL Read on-board "); DisplayLCD(LCD_LINE6, " sensors value "); DisplayLCD(LCD_LINE7, " and display to"); DisplayLCD(LCD_LINE8, "DWN LCD "); break; default: break; } Finally, modify "Application Process" part of main() function by adding APP_TUTORIAL case to invoke the application. /* Invoke selected application */ switch (AppMode) { case RUN_PROVISIONING: App_WebProvisioning_OverAirPush(); break; ... case APP_TUTORIAL: ApplicationTutorial(); break; default: /* Start default the webserver demo */ break; } R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 17 of 4 APPLICATION NOTE 5.3 Using the on-board devices in the application After create a skeleton for the tutorial application in the section 5.2, the application now can be run when selected from the demo selection menu. However the application only has an infinite loop without any process. It is time to add processing code to achieve the target which is defined in section 5.1. The application will use following libraries: Switch Sensors: Accelerometer, Temperature sensor, Light sensor, Potentiometer, MEMS microphone LCD Appropriate header files need to be included in the application: /*-------------------------------------------------------------------------* * Includes: *-------------------------------------------------------------------------*/ #include "Apps.h" #include "Switch\Switch.h" #include "Sensors\Accelerometer.h" #include "Sensors\Temperature.h" #include "Sensors\LightSensor.h" #include "Sensors\Potentiometer.h" #include "lcd\lcd.h" The sensors and LCD require initialization prior usage. A new function can be created to handle the application initialization. R01AN2773EA0100 Rev.1.00 Feb 22, 2015 Page 18 of 4 RDKRL78/G14 User Application Creation Guideline /*-------------------------------------------------------------------------* * Routine: ApplicationTutorial_Init *-------------------------------------------------------------------------* * Description: * Initialize devices and libaries. * Inputs: * void * Outputs: * void *-------------------------------------------------------------------------*/ void ApplicationTutorial_Init(void) { /* Initialize accelerometer sensors */ Accelerometer_Init(); /* Initialize accelerometer sensors */ Temperature_Init(); /* Initialize accelerometer sensors */ LightSensor_Init(); /* Initialize accelerometer sensors */ Potentiometer_Init(); /* Initialize LCD module */ InitialiseLCD(); /* Select small font for LCD display */ LCDSelectFont(FONT_SMALL); } After application initialization complete, the application can used the APIs to manipulate each driver operation. The activity diagram for tutorial application: Application Initialization False SW2 is pressed? True Read Sensors value Display value to LCD Figure 4. Tutorial application activity User Application Creation Guidelines Rev.1.00 Feb 22, 2015 Page 19 of 4 RDKRL78/G14 User Application Creation Guideline /*-------------------------------------------------------------------------* * File: AppplicationTutorial.c *-------------------------------------------------------------------------* * Description: * Application creation tutorial. *-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------* * Includes: *-------------------------------------------------------------------------*/ /* Support sprintf function */ #include /* Support application interface */ #include "Apps.h" /* Libraries used in application */ #include "Switch\Switch.h" #include "Sensors\Accelerometer.h" #include "Sensors\Temperature.h" #include "Sensors\LightSensor.h" #include "Sensors\Potentiometer.h" #include "lcd\lcd.h" /*-------------------------------------------------------------------------* * Prototypes: *-------------------------------------------------------------------------*/ void ApplicationTutorial_Init(void); /*-------------------------------------------------------------------------* * Routine: ApplicationTutorial *-------------------------------------------------------------------------* * Description: * Entry point for application. * In this tutorial, sensors' values are read when SW2 is pressed. * The sensing values are displayed on LCD. * Inputs: * void * Outputs: * void *-------------------------------------------------------------------------*/ void ApplicationTutorial(void) { /* Accelerometer read data place holder */ uint16_t *ppAccRead; /* Temperature read data place holder */ uint16_t pTempRead; char paTempVal[2]; float pTempResult; /* Light level read data place holder */ uint16_t pLightLevel; /* Potentiometer level data place holder */ uint32_t pPotLevel; /* Microphone read data place holder */ uint32_t pMicLevel; /* LCD line buffer */ uint8_t paLcdBuff[20]; User Application Creation Guidelines Rev.1.00 Feb 22, 2015 Page 20 of 4 RDKRL78/G14 User Application Creation Guideline /* Application initialization */ ApplicationTutorial_Init(); /* Display application name */ DisplayLCD(LCD_LINE1, " Tutorial "); DisplayLCD(LCD_LINE2, " Application "); DisplayLCD(LCD_LINE3, "==================="); /* Main loop */ while (1) { /* Check if SW2 is pressed */ if (Switch2IsPressed()) { /* Acquire acceleration data */ gpAccRead = Accelerometer_Get(); /* Acquire temperature data */ pTempRead = Temperature_Get(); /* Acquire light sensor data */ pLightLevel = LightSensor_Get(); /* Acquire potentiometer data */ pPotLevel = Potentiometer_Get(); /* Acquire microphone data */ pMicLevel = Microphone_Get(); /* Compute and display data to LCD */ sprintf( paLcdBuff, "x:%2d y:%2d z:%2d\0", (gpAccRead[0] * 90) / 32, (gpAccRead[1] * 90) / 32, (gpAccRead[2] * 90) / 32 ); DisplayLCD(LCD_LINE4, paLcdBuff); /* Convert read value into float */ paTempVal[1] = (pTempRead & 0xFF00) >> 8; paTempVal[0] = (pTempRead & 0x00FF); pTempResult = *(uint16_t *)paTempVal; sprintf( paLcdBuff, "Temp: %0.2f\0", pTempResult ); DisplayLCD(LCD_LINE5, paLcdBuff); sprintf( paLcdBuff, "Light: %d\0", pLightLevel ); DisplayLCD(LCD_LINE6, paLcdBuff); sprintf( paLcdBuff, User Application Creation Guidelines Rev.1.00 Feb 22, 2015 Page 21 of 4 RDKRL78/G14 User Application Creation Guideline "Pot: %d\0", pPotLevel ); DisplayLCD(LCD_LINE7, paLcdBuff); sprintf( paLcdBuff, "Mic: %d\0", pMicLevel ); DisplayLCD(LCD_LINE8, paLcdBuff); } } } /*-------------------------------------------------------------------------* * Routine: ApplicationTutorial_Init *-------------------------------------------------------------------------* * Description: * Initialize devices and libraries. * Inputs: * void * Outputs: * void *-------------------------------------------------------------------------*/ void ApplicationTutorial_Init(void) { /* Initialize accelerometer sensors */ Accelerometer_Init(); /* Initialize accelerometer sensors */ Temperature_Init(); /* Initialize accelerometer sensors */ LightSensor_Init(); /* Initialize accelerometer sensors */ Potentiometer_Init(); /* Initialize LCD module */ InitialiseLCD(); /* Select small font for LCD display */ LCDSelectFont(FONT_SMALL); } User Application Creation Guidelines Rev.1.00 Feb 22, 2015 Page 22 of 4 RDKRL78/G14 User Application Creation Guideline Website and Support Renesas Electronics Website http://www.renesas.com/ Inquiries http://www.renesas.com/contact/ All trademarks and registered trademarks are the property of their respective owners. User Application Creation Guidelines Rev.1.00 Feb 22, 2015 Page 23 of 4 Revision History Rev. 1.00 Date Feb. 22, 2015 Description Page Summary First release. A-1 General Precautions in the Handling of MPU/MCU Products The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the products covered by this document, refer to the relevant sections of the document as well as any technical updates that have been issued for the products. 1. Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pins in the manual. The input pins of CMOS products are generally in the high-impedance state. In operation with an unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of LSI, an associated shoot-through current flows internally, and malfunctions occur due to the false recognition of the pin state as an input signal become possible. Unused pins should be handled as described under Handling of Unused Pins in the manual. 2. Processing at Power-on The state of the product is undefined at the moment when power is supplied. The states of internal circuits in the LSI are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied. In a finished product where the reset signal is applied to the external reset pin, the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed. In a similar way, the states of pins in a product that is reset by an on-chip power-on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified. 3. Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited. The reserved addresses are provided for the possible future expansion of functions. Do not access these addresses; the correct operation of LSI is not guaranteed if they are accessed. 4. Clock Signals After applying a reset, only release the reset line after the operating clock signal has become stable. When switching the clock signal during program execution, wait until the target clock signal has stabilized. When the clock signal is generated with an external resonator (or from an external oscillator) during a reset, ensure that the reset line is only released after full stabilization of the clock signal. Moreover, when switching to a clock signal produced with an external resonator (or by an external oscillator) while program execution is in progress, wait until the target clock signal is stable. 5. Differences between Products Before changing from one product to another, i.e. to a product with a different part number, confirm that the change will not lead to problems. The characteristics of an MPU or MCU in the same group but having a different part number may differ in terms of the internal memory capacity, layout pattern, and other factors, which can affect the ranges of electrical characteristics, such as characteristic values, operating margins, immunity to noise, and amount of radiated noise. When changing to a product with a different part number, implement a system-evaluation test for the given product. Notice 1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for the incorporation of these circuits, software, and information in the design of your equipment. Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits, software, or information. 2. Renesas Electronics has used reasonable care in preparing the information included in this document, but Renesas Electronics does not warrant that such information is error free. Renesas Electronics 3. Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein. technical information described in this document. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or others. 4. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. Renesas Electronics assumes no responsibility for any losses incurred by you or 5. Renesas Electronics products are classified according to the following two quality grades: "Standard" and "High Quality". The recommended applications for each Renesas Electronics product depends on third parties arising from such alteration, modification, copy or otherwise misappropriation of Renesas Electronics product. the product's quality grade, as indicated below. "Standard": Computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic equipment; and industrial robots etc. "High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control systems; anti-disaster systems; anti-crime systems; and safety equipment etc. Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury (artificial life support devices or systems, surgical implantations etc.), or may cause serious property damages (nuclear reactor control systems, military equipment etc.). You must check the quality grade of each Renesas Electronics product before using it in a particular application. You may not use any Renesas Electronics product for any application for which it is not intended. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics. 6. You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics, especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges. 7. Although Renesas Electronics endeavors to improve the quality and reliability of its products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please be sure to implement safety measures to guard them against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a Renesas Electronics product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or systems manufactured by you. 8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive. Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations. 9. Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. You should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or use by the military, including but not limited to the development of weapons of mass destruction. When exporting the Renesas Electronics products or technology described in this document, you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations. 10. It is the responsibility of the buyer or distributor of Renesas Electronics products, who distributes, disposes of, or otherwise places the product with a third party, to notify such third party in advance of the contents and conditions set forth in this document, Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products. 11. This document may not be reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics. 12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products, or if you have any other inquiries. (Note 1) "Renesas Electronics" as used in this document means Renesas Electronics Corporation and also includes its majority-owned subsidiaries. (Note 2) "Renesas Electronics product(s)" means any product developed or manufactured by or for Renesas Electronics. http://www.renesas.com SALES OFFICES Refer to "http://www.renesas.com/" for the latest and detailed information. Renesas Electronics America Inc. 2801 Scott Boulevard Santa Clara, CA 95050-2549, U.S.A. Tel: +1-408-588-6000, Fax: +1-408-588-6130 Renesas Electronics Canada Limited 9251 Yonge Street, Suite 8309 Richmond Hill, Ontario Canada L4C 9T3 Tel: +1-905-237-2004 Renesas Electronics Europe Limited Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.K Tel: +44-1628-585-100, Fax: +44-1628-585-900 Renesas Electronics Europe GmbH Arcadiastrasse 10, 40472 Dusseldorf, Germany Tel: +49-211-6503-0, Fax: +49-211-6503-1327 Renesas Electronics (China) Co., Ltd. Room 1709, Quantum Plaza, No.27 ZhiChunLu Haidian District, Beijing 100191, P.R.China Tel: +86-10-8235-1155, Fax: +86-10-8235-7679 Renesas Electronics (Shanghai) Co., Ltd. Unit 301, Tower A, Central Towers, 555 Langao Road, Putuo District, Shanghai, P. R. China 200333 Tel: +86-21-2226-0888, Fax: +86-21-2226-0999 Renesas Electronics Hong Kong Limited Unit 1601-1611, 16/F., Tower 2, Grand Century Place, 193 Prince Edward Road West, Mongkok, Kowloon, Hong Kong Tel: +852-2265-6688, Fax: +852 2886-9022 Renesas Electronics Taiwan Co., Ltd. 13F, No. 363, Fu Shing North Road, Taipei 10543, Taiwan Tel: +886-2-8175-9600, Fax: +886 2-8175-9670 Renesas Electronics Singapore Pte. Ltd. 80 Bendemeer Road, Unit #06-02 Hyflux Innovation Centre, Singapore 339949 Tel: +65-6213-0200, Fax: +65-6213-0300 Renesas Electronics Malaysia Sdn.Bhd. Unit 1207, Block B, Menara Amcorp, Amcorp Trade Centre, No. 18, Jln Persiaran Barat, 46050 Petaling Jaya, Selangor Darul Ehsan, Malaysia Tel: +60-3-7955-9390, Fax: +60-3-7955-9510 Renesas Electronics India Pvt. Ltd. No.777C, 100 Feet Road, HALII Stage, Indiranagar, Bangalore, India Tel: +91-80-67208700, Fax: +91-80-67208777 Renesas Electronics Korea Co., Ltd. 12F., 234 Teheran-ro, Gangnam-Gu, Seoul, 135-080, Korea Tel: +82-2-558-3737, Fax: +82-2-558-5141 (c) 2015 Renesas Electronics Corporation. All rights reserved. Colophon 5.0