Hey Alice,
Thanks alot for sharing those projects :smileyhappy: . But still if possible can you just fix or guide me a possible replacement for this code snippet.
#include "BL_SW.h"
#include "PORT_PDD.h"
static bool BL_CheckBootloaderMode(void) {
/* let's check if the user presses the BTLD switch. Need to configure the pin first */
/* PTB1 as input */
/* clock all port pins */
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK |
SIM_SCGC5_PORTB_MASK |
SIM_SCGC5_PORTC_MASK |
SIM_SCGC5_PORTD_MASK |
SIM_SCGC5_PORTE_MASK;
/* Configure pin as input */
#if 0
/* GPIOB_PDDR: PDD&=~0x0100 */
GPIOB_PDDR = (uint32_t)((GPIOB_PDDR & (uint32_t)~0x0100UL) | (uint32_t)0x00UL);
/* Initialization of Port Control register */
/* PORTB_PCR1: ISF=0,MUX=1 */
PORTB_PCR1 = (uint32_t)((PORTB_PCR1 & (uint32_t)~0x01000600UL) | (uint32_t)0x0100UL);
#else
(void)BitIoLdd1_Init(NULL); /* initialize the port pin PTB8 */
/* enable internal pull-up on PTB1 */
PORT_PDD_SetPinPullSelect(PORTB_BASE_PTR, 1, PORT_PDD_PULL_UP);
PORT_PDD_SetPinPullEnable(PORTB_BASE_PTR, 1, PORT_PDD_PULL_ENABLE);
WAIT1_Waitms(5); /* wait get pull-up a chance to pull-up */
#endif
if (!BL_SW_GetVal()) { /* button pressed (has pull-up!) */
WAIT1_Waitms(50); /* wait to debounce */
if (!BL_SW_GetVal()) { /* still pressed */
return TRUE; /* go into boot loader mode */
}
}
/* BTLD switch not pressed, and we have a valid user application vector */
return FALSE; /* do not enter boot loader mode */
}
What the above code has to do is to Clock all the port pins, Configure Port B pin 1 (PTB1) as input, initialize the port pin PTB1, enable internal pull-up on PTB1, rest are common Wait statements.
You said, In KE-02 controllers, clocking is done by default after reset. But am clueless as to how to write the code for other operations mentioned above. Can you provide me a code snippet which replaces the above but supports KE-02Z controllers.
I owe a deep gratitude to you Alice :smileyhappy: . Thanks alot.