/**************************************************************************** DESCRIPTION Called after the configuration has been read and will trigger buttons events if a pio has been pressed or held whilst the configuration was still being loaded , i.e. the power on button press */ void ButtonsCheckForChangeAfterInit(void) { uint32 pio_state; ButtonsTaskData * lButtonsTask = theHeadset.theButtonsTask ; lButtonsTask->gBTime = B_INVALID ; { /* get 32 bit pio state for BC5 onwards chips */ pio_state = (((PIOGET() & 0xffff) | CHARGER_VREG_VALUE | CHARGER_CONNECT_VALUE)) ; /* perform a level detect looking for transistion of recently added button definition, mask pio's against level configured pios to prevent false butotn press indications */ ButtonsLevelDetect ( (pio_state & lButtonsTask->gPerformLevelCheck) , lButtonsTask ) ; /* perform an edge detect looking for transistion of recently added button definition, mask pio's against edge configured pios to prevent false button press indications */ ButtonsEdgeDetect ( (pio_state & lButtonsTask->gPerformEdgeCheck) , lButtonsTask) ; } /* store current set pio state in order to be able to detect the transition of a PIO in the button handler */ lButtonsTask->gOldPioState = pio_state; /* Debounce required PIO lines */ pio_state = PioDebounce32((0xFFFF & lButtonsTask->gButtonLevelMask), /* mask off upper 16 bits */ lButtonsTask->button_config->debounce_number, lButtonsTask->button_config->debounce_period_ms ); /* check whether it has been possible to select the use of PIOs specified, if it was not possible to use all the PIOs specified due to a PIO being assigned a different function by PSKEY then none of the PIOs will now work so mask out the unavailable PIO and assign the PIOs that are available for receiving change notifications */ if(pio_state) { /* mask out the unavailable PIOs and register those PIOs that are available for receiving change events */ PioDebounce32((0xFFFF & lButtonsTask->gButtonLevelMask & ~pio_state), /* mask off upper 16 bits */ lButtonsTask->button_config->debounce_number, lButtonsTask->button_config->debounce_period_ms ); B_DEBUG(("B: **** ERROR **** PIO NOT AVAILABLE = 0x%lx\n",pio_state)) ; #ifdef DEBUG_BUTTONS Panic(); #endif } #ifdef BHC612_ ChargerDebounce( (CHARGER_VREG_EVENT|CHARGER_CONNECT_EVENT), 4, 250 ); #else ChargerDebounce( (CHARGER_VREG_EVENT|CHARGER_CONNECT_EVENT), lButtonsTask->button_config->debounce_number, lButtonsTask->button_config->debounce_period_ms ); #endif }
/**************************************************************************** DESCRIPTION Called after the configuration has been read and will trigger buttons events if a pio has been pressed or held whilst the configuration was still being loaded , i.e. the power on button press */ void ButtonsCheckForChangeAfterInit(void) { uint32 input_state; /* contains translated pio and capsense bits, format is inputs */ ButtonsTaskData * lButtonsTask = theSink.theButtonsTask ; lButtonsTask->gBTime = B_INVALID ; /* translate the pio and capsense bits into 'input' bits mask */ #ifdef ENABLE_CAPSENSE input_state = ButtonsTranslate(lButtonsTask->gOldCapState, (((PIOGET()^theSink.conf1->PIOIO.pio_invert) | CHARGER_VREG_VALUE | CHARGER_CONNECT_VALUE))); #else input_state = ButtonsTranslate(0, (((PIOGET()^theSink.conf1->PIOIO.pio_invert) | CHARGER_VREG_VALUE | CHARGER_CONNECT_VALUE))); #endif /* perform a level detect looking for transistion of recently added button definition, mask inputs against level configured inputs to prevent false button press indications */ ButtonsLevelDetect ( (input_state & lButtonsTask->gPerformInputLevelCheck) , lButtonsTask ) ; /* perform an edge detect looking for transistion of recently added button definition, mask inputs against edge configured inputs to prevent false button press indications */ ButtonsEdgeDetect ( (input_state & lButtonsTask->gPerformInputEdgeCheck) , lButtonsTask) ; /* store current input states in order to be able to detect the transition of an input (pio or capsense) in the button handler */ lButtonsTask->gBOldInputState = input_state; /* Debounce required PIO lines */ if(!PioCommonDebounce((lButtonsTask->gButtonPIOLevelMask & ~(VREG_PIN_MASK|CHG_PIN_MASK)), lButtonsTask->button_config->debounce_number, lButtonsTask->button_config->debounce_period_ms )) { B_DEBUG(("B: **** ERROR **** PIO NOT AVAILABLE = 0x%lx\n",input_state)) ; #ifdef DEBUG_BUTTONS Panic(); #endif } ChargerDebounce( (CHARGER_VREG_EVENT|CHARGER_CONNECT_EVENT), lButtonsTask->button_config->debounce_number, lButtonsTask->button_config->debounce_period_ms ); B_DEBUG(("B: initial buttoncheck\n")) ; }