Renesas Solution Starter Kit for RX23W
R20UT4449EG0100 Rev. 1.00
Page 50 of 64
Aug.30.19
Next add the highlighted code below in the main function and the code inside the while loop, resulting in the
code shown below:
void
main(
void
)
{
/* Initialize the switch module */
R_SWITCH_Init();
/* Set the call back function when SW1 or SW2 is pressed */
R_SWITCH_SetPressCallback(cb_switch_press);
/* Initialize the debug LCD */
R_LCD_Init ();
/* Displays the application name on the debug LCD */
R_LCD_Display(0, (uint8_t
*
)
" RSSKRX23W "
);
R_LCD_Display(1, (uint8_t
*
)
" Tutorial "
);
R_LCD_Display(2, (uint8_t
*
)
" Press Any Switch "
);
/* Start the A/D converter */
R_Config_S12AD0_Start();
while
(1U)
{
uint16_t adc_result;
/* Wait for user requested A/D conversion flag to be set (SW1 or SW2) */
if
(TRUE
==
g_adc_trigger)
{
/* Call the function to perform an A/D conversion */
adc_result
=
get_adc();
/* Display the result on the LCD */
lcd_display_adc(adc_result);
/* Reset the flag */
g_adc_trigger
=
FALSE;
}
else
{
/* do nothing */
}
}
}
Then add the definition for the switch call-back, get_adc and lcd_display_adc functions below the main
function, as shown below:
/******************************************************************************
* Function Name : cb_switch_press
* Description : Switch press callback function. Sets g_adc_trigger flag.
* Argument : none
* Return value : none
******************************************************************************/
static
void
cb_switch_press (
void
)
{
/* Check if switch 1 or 2 was pressed */
if
(g_switch_flag
&
(SWITCHPRESS_1
|
SWITCHPRESS_2))
{
/* set the flag indicating a user requested A/D conversion is required */
g_adc_trigger
=
TRUE;
/* Clear flag */
g_switch_flag
=
0x0;
}
}
/******************************************************************************
* End of function cb_switch_press
******************************************************************************/
Содержание RSSK
Страница 64: ...R20UT4449EG0100 RX23W Group ...