fix button int mux error
This commit is contained in:
parent
9f50648334
commit
034f12a602
1 changed files with 7 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
// TODO fix line 27
|
// Note: unlike ch582, ch592 has no RB_PIN_INTX mux, so cannot use PB22,23 as INT pins!
|
||||||
// LED: PA8 (active low)
|
// LED: PA8 (active low)
|
||||||
// BUT: PB22 (active low, no pullup)
|
// BUT: PB4 (active low, no pullup)
|
||||||
|
|
||||||
#include "CH59x_common.h"
|
#include "CH59x_common.h"
|
||||||
|
|
||||||
|
|
@ -8,9 +8,9 @@ __INTERRUPT
|
||||||
__HIGH_CODE
|
__HIGH_CODE
|
||||||
void GPIOB_IRQHandler()
|
void GPIOB_IRQHandler()
|
||||||
{
|
{
|
||||||
if (GPIOB_ReadITFlagBit(GPIO_Pin_8)) {
|
if (GPIOB_ReadITFlagBit(GPIO_Pin_4)) {
|
||||||
GPIOA_InverseBits(GPIO_Pin_8);
|
GPIOA_InverseBits(GPIO_Pin_8);
|
||||||
GPIOB_ClearITFlagBit(GPIO_Pin_8);
|
GPIOB_ClearITFlagBit(GPIO_Pin_4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,10 +21,9 @@ int main()
|
||||||
GPIOA_SetBits(GPIO_Pin_8); // LED
|
GPIOA_SetBits(GPIO_Pin_8); // LED
|
||||||
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_ModeOut_PP_5mA);
|
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_ModeOut_PP_5mA);
|
||||||
|
|
||||||
GPIOB_ModeCfg(GPIO_Pin_22, GPIO_ModeIN_PU); // button
|
GPIOB_ModeCfg(GPIO_Pin_4, GPIO_ModeIN_PU); // button
|
||||||
GPIOB_ITModeCfg(GPIO_Pin_8, GPIO_ITMode_FallEdge); // PB8 mux'd as PB22 see below
|
GPIOB_ITModeCfg(GPIO_Pin_4, GPIO_ITMode_FallEdge);
|
||||||
GPIOB_ClearITFlagBit(GPIO_Pin_8);
|
GPIOB_ClearITFlagBit(GPIO_Pin_4);
|
||||||
GPIOPinRemap(ENABLE, RB_PIN_INTX); // <================== workaround, as R16_PB_INT reg is 16b wide
|
|
||||||
PFIC_EnableIRQ(GPIO_B_IRQn);
|
PFIC_EnableIRQ(GPIO_B_IRQn);
|
||||||
|
|
||||||
while (1);
|
while (1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue