Directed Electronics 3200HS Informations techniques Page 78

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 99
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 77
CSI to SPI Peripheral Communication in V850ES Microcontrollers
}
/* unsigned char sw_chk(void) */
/* return input from switches, undebounced */
unsigned char sw_chk(void)
{
return P9L & 0x30;
}
/* void sw_set_debounce(unsigned char count) */
/* set the debounce counter value */
void sw_set_debounce(unsigned char count)
{
sw_deb_value = count; /* set new debounce counter value */
sw_deb_count = count; /* set counter to max */
}
/* unsigned char sw_get(void) */
/* return debounced switch input */
unsigned char sw_get(void)
{
return sw_last;
}
/* void sw_isr( void ) */
/* this routine called by periodic timer interrupt to poll and debounce
switches */
/* after a new value has been seen steadily for sw_deb_value times, sw_last
is updated */
void sw_isr( void )
{
unsigned char val;
val = sw_chk(); /* get current value */
/* if value is the same as before, no change; reset debounce and return
*/
if (val == sw_last) {
sw_deb_count = sw_deb_value; /* reset debounce counter to max */
return;
}
/* val != sw_last, there is a new input */
/* if it's not the same as the previous new one, */
/* set the NEW new one, reset the debounce counter and return */
if (val != sw_new) {
sw_new = val;
sw_deb_count = sw_deb_value;
return;
}
/* val != sw_last, val == sw_new */
/* count down the debounce counter */
sw_deb_count--;
72
Vue de la page 77
1 2 ... 73 74 75 76 77 78 79 80 81 82 83 ... 98 99

Commentaires sur ces manuels

Pas de commentaire