//////////////////////////////////////////////////////////////////////////////// // The WaitForTinyBooterUpload method was designed to allow porting kit partners // to define how/when tinybooter mode is entered as well as configure default // timeout values. // // timeout_ms - this parameter determines the time in milliseconds TinyBooter is // supposed to wait for commands from the host. A -1 value will // indicate to wait forever. // return value - the boolean return value indicates whether TinyBooter should enter // upload mode. If false is returned the booter will attempt to // launch the first application in FLASH that it finds. If the return // value is true, TinyBooter will wait for the given timeout value // (parameter timeout_ms) for valid commands before launching the first // application //////////////////////////////////////////////////////////////////////////////// bool WaitForTinyBooterUpload( INT32 &timeout_ms ) { bool enterBooterMode = false; GPIO_BUTTON_CONFIG * ButtonConfig = &g_GPIO_BUTTON_Config; #if defined(TINYBOOTER_DEFAULT_TIMEOUT) timeout_ms = TINYBOOTER_DEFAULT_TIMEOUT; #endif #if defined(TINYBOOTER_ALWAYS_ENTER) enterBooterMode = true; #endif // wait forever when using RAM build #if defined(TARGETLOCATION_RAM) enterBooterMode = true; timeout_ms = -1; #endif // user override (UP+DOWN buttons held) if ((ButtonConfig->Mapping[BUTTON_DOWN_IDX].m_HW != GPIO_PIN_NONE) && (ButtonConfig->Mapping[BUTTON_UP_IDX].m_HW != GPIO_PIN_NONE)) { Events_WaitForEvents(0,100); // wait for buttons to init if(!CPU_GPIO_GetPinState( ButtonConfig->Mapping[BUTTON_DOWN_IDX].m_HW ) && !CPU_GPIO_GetPinState( ButtonConfig->Mapping[BUTTON_UP_IDX].m_HW )) { // user override, so lets stay forever timeout_ms = -1; enterBooterMode = true; } } return enterBooterMode; }
//////////////////////////////////////////////////////////////////////////////// // The WaitForTinyBooterUpload method was designed to allow porting kit partners // to define how/when tinybooter mode is entered as well as configure default // timeout values. // // timeout_ms - this parameter determines the time in milliseconds TinyBooter is // supposed to wait for commands from the host. A -1 value will // indicate to wait forever. // return value - the boolean return value indicates whether TinyBooter should enter // upload mode. If false is returned the booter will attempt to // launch the first application in FLASH that it finds. If the return // value is true, TinyBooter will wait for the given timeout value // (parameter timeout_ms) for valid commands before launching the first // application //////////////////////////////////////////////////////////////////////////////// bool WaitForTinyBooterUpload( INT32 &timeout_ms ) { bool enterBooterMode = false; GPIO_BUTTON_CONFIG * ButtonConfig = &g_GPIO_BUTTON_Config; // wait forever when using RAM build #if defined(TARGETLOCATION_RAM) enterBooterMode = true; timeout_ms = -1; #endif // user override (User button held) if (ButtonConfig->Mapping[BUTTON_USER_IDX].m_HW != GPIO_PIN_NONE) { Events_WaitForEvents(0,100); // wait for buttons to init if(!CPU_GPIO_GetPinState( ButtonConfig->Mapping[BUTTON_USER_IDX].m_HW )) { // user override, so lets stay forever timeout_ms = -1; enterBooterMode = true; } } return enterBooterMode; }
//////////////////////////////////////////////////////////////////////////////// // The WaitForTinyBooterUpload method was designed to allow porting kit partners // to define how/when tinybooter mode is entered as well as configure default // timeout values. // // timeout_ms - this parameter determines the time in milliseconds TinyBooter is // supposed to wait for commands from the host. A -1 value will // indicate to wait forever. // return value - the boolean return value indicates whether TinyBooter should enter // upload mode. If false is returned the booter will attempt to // launch the first application in FLASH that it finds. If the return // value is true, TinyBooter will wait for the given timeout value // (parameter timeout_ms) for valid commands before launching the first // application //////////////////////////////////////////////////////////////////////////////// bool WaitForTinyBooterUpload( INT32 &timeout_ms ) { bool enterBooterMode = false; GPIO_BUTTON_CONFIG * ButtonConfig = &g_GPIO_BUTTON_Config; // wait forever when using RAM build #if defined(TARGETLOCATION_RAM) enterBooterMode = true; timeout_ms = -1; #endif // user override (UP+DOWN buttons held) if ((ButtonConfig->Mapping[BUTTON_ENTR_IDX].m_HW != GPIO_PIN_NONE)) { Events_WaitForEvents(0,100); // wait for buttons to init if(!CPU_GPIO_GetPinState( ButtonConfig->Mapping[BUTTON_ENTR_IDX].m_HW)) { UINT32 down, up; // user override, so lets stay for 2sec timeout_ms = 2000; enterBooterMode = true; while(Buttons_GetNextStateChange(down, up) && (0 != (down & BUTTON_ENTR))); } } return enterBooterMode; }
BOOL GPIO_BUTTON_Driver::Initialize() { NATIVE_PROFILE_PAL_BUTTONS(); GPIO_BUTTON_CONFIG* Config = &g_GPIO_BUTTON_Config; HAL_CONFIG_BLOCK::ApplyConfig( Config->GetDriverName(), Config, sizeof(GPIO_BUTTON_CONFIG) ); // reset button fifo queue g_GPIO_BUTTON_Driver.m_ButtonFifo.Initialize(); // Buttons down, read as a 0 on the pins, and up buttons read as a 1, // for simplicity, we invert that notion when reading the pins // if we start up with keys pressed, store them as such // do all buttons GPIO_HW_TO_HAL_MAPPING* Mapping = &Config->Mapping[0 ]; GPIO_HW_TO_HAL_MAPPING* MappingEnd = &Config->Mapping[GPIO_BUTTON_CONFIG::c_COUNT]; for(; Mapping < MappingEnd; Mapping++) { GPIO_PIN hw = Mapping->m_HW; if(hw != GPIO_PIN_NONE) { CPU_GPIO_EnableInputPin( hw, TRUE, ISR, GPIO_INT_EDGE_BOTH, RESISTOR_PULLUP ); if(!CPU_GPIO_GetPinState( hw )) { Buttons_RegisterStateChange( Mapping->m_HAL, 0 ); } } } return TRUE; }
BOOL EnterMicroBooter(INT32& timeout) { CPU_GPIO_Initialize(); Events_WaitForEvents(0,100); // wait for buttons to init // check up/down button state if(!CPU_GPIO_GetPinState( MC9328MXL_GPIO::c_Port_B_10 ) && !CPU_GPIO_GetPinState( MC9328MXL_GPIO::c_Port_B_11 )) { // user override, so lets stay forever timeout = -1; return TRUE; } timeout = 0; return FALSE; }
BOOL EnterMicroBooter(INT32& timeout) { CPU_GPIO_Initialize(); Events_WaitForEvents(0,100); // wait for buttons to init // check up/down button state if(!CPU_GPIO_GetPinState( AT91_GPIO_Driver::PA25 ) && !CPU_GPIO_GetPinState( AT91_GPIO_Driver::PA27 )) { // user override, so lets stay forever timeout = -1; return TRUE; } timeout = 0; return FALSE; }
UINT32 GPIO_BUTTON_Driver::CurrentHWState() { NATIVE_PROFILE_PAL_BUTTONS(); GPIO_BUTTON_CONFIG* Config = &g_GPIO_BUTTON_Config; UINT32 HAL_Buttons = 0; // down = FALSE, up = TRUE, invert that notion here // do all buttons GPIO_HW_TO_HAL_MAPPING* Mapping = &Config->Mapping[0 ]; GPIO_HW_TO_HAL_MAPPING* MappingEnd = &Config->Mapping[GPIO_BUTTON_CONFIG::c_COUNT]; for(; Mapping < MappingEnd; Mapping++) { if(Mapping->m_HW != GPIO_PIN_NONE) { if(!CPU_GPIO_GetPinState( Mapping->m_HW )) { HAL_Buttons |= Mapping->m_HAL; } } } return HAL_Buttons; }
// --------------------------------------------------------------------------- void GPIO_IRQHandler(void* param) { GPIO_IRQ_T *obj = (GPIO_IRQ_T*)param; obj->isr(obj->pin, CPU_GPIO_GetPinState(obj->pin), obj->param); }