Technical information
CSI to SPI Peripheral Communication in V850ES Microcontrollers
**
**---------------------------------------------------------------------------
*/
void main( void )
{
MD_STATUS status;
unsigned char sw_val;
short temp; /* 16-bit signed temperature value */
sw_init(); /* initialize switch variables */
led_init(); /* initialize LED */
status = Temp_Init(); /* set up temperature sensors */
CheckStatusError(status); /* report error if problem with
initialization */
led_out_left(LED_PAT_DASH); /* show dashes before first temperature
read */
led_out_right(LED_PAT_DASH);
TM00_Start(); /* start timer for switch debouncing and millisecond
counting */
while (1) {
/* check switches for actions to take */
sw_val = sw_get(); /* get debounced switch state */
switch (sw_val) {
case SW_LD_RU: /* SW2 down, select temp sensor 1 */
temp = Temp_Read_1(); /* read temperature sensor 1 */
Temp_Display(temp); /* and display it */
while (SW_LD_RU == sw_get())
; /* wait for switches different */
break;
case SW_LU_RD: /* SW3 down, select temp sensor 2 */
temp = Temp_Read_2(); /* read temperature sensor 2 */
Temp_Display(temp); /* and display it */
while (SW_LU_RD == sw_get())
; /* wait for switches different */
break;
case SW_LD_RD: /* Both SW2 and SW3 down */
case SW_LU_RU: /* Both SW2 and SW3 are up */
default:
break; /* do nothing if both up or both down */
}
} /* end of while (1) loop */
} /* end of main() */
4.1.2 Temper.h
/*
*****************************************************************************
**
**
** This file was created for the NEC V850ES SPI/IIC Application Note
44