Technical information
SCI to SPI Peripheral Communication in V850ES Microcontrollers
extern void sw_set_debounce(unsigned char count); /* set deboune cound */
extern void sw_isr(void); /* debounce routine, called by
timer ISR */
#endif /* _SW_VKJ1_H */
4.1.14 Sw_vkj1.c
/* sw_vkj1.c - routines for switch input */
/* for M-V850ES-KJ1 CPU board on M-Station base board */
/* Version: 1.1 05-08-2006 */
/* P94 = input for left switch (SW2) */
/* P95 = input for right switch (SW3) */
/* To connect ports to switches on M-Station 1.1, make the
following jumper connections between ROW1 and ROW2.
To connect ports to swtiches on M-Station 2, make sure
the default SBxx connections are inserted.
Port Switch M-Station 1.1 M-Station 2.2
---- --- ------------- -------------
P94 SW2 R1.5 - R2.5 SB7
P95 SW3 R1.6 - R2.6 SB8
*/
/* need pragma declaration to access SFR's in C */
#pragma ioreg
#include "sw_vkj1.h"
/* local variables for switch handling */
static unsigned char sw_last; /* last debounced switch value */
static unsigned char sw_new; /* new value being debounced */
static unsigned char sw_deb_value; /* value of debounce counter */
static unsigned char sw_deb_count; /* debounce counter */
/* void sw_init(void) */
/* set up ports for switch input */
void sw_init(void)
{
#if 0 /* initialization done in Port_Init() by Applilet */
/* set P94 and P95 to port mode */
PMC9L &= 0xCF;
/* set P94 and P95 to inputs */
PM9L |= 0x30;
/* set pullups on P94 and P95 */
PU9L |= 0x30;
#endif
/* set static variables */
sw_last = SW_LU_RU; /* default is right up, left up (no switch
pressed) */
sw_deb_value = SW_DEF_DEB_COUNT; /* set default debounce counter
value */
sw_deb_count = SW_DEF_DEB_COUNT; /* set counter to max */
71