Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
87fba8d6
Commit
87fba8d6
authored
Jul 05, 2019
by
schneider
Browse files
fix(pmic): Check pmic interrupt state from application context
Closes #13
parent
d19fa787
Changes
6
Hide whitespace changes
Inline
Side-by-side
bootloader/bootloader-usb.c
View file @
87fba8d6
...
...
@@ -51,7 +51,7 @@
#include
"msc.h"
#include
"descriptors.h"
#include
"mscmem.h"
#include
"card10.h"
/***** Definitions *****/
#define EVENT_ENUM_COMP MAXUSB_NUM_EVENTS
...
...
@@ -212,6 +212,8 @@ void run_usbmsc(void)
printf
(
"Remote Wakeup
\n
"
);
}
}
card10_poll
();
}
}
...
...
epicardium/support.c
View file @
87fba8d6
...
...
@@ -7,6 +7,8 @@
#include
"api/dispatcher.h"
#include
"card10.h"
extern
TaskHandle_t
dispatcher_task_id
;
/*
...
...
@@ -39,6 +41,10 @@ void post_idle_sleep(TickType_t xExpectedIdleTime)
if
(
api_dispatcher_poll_once
())
{
xTaskNotifyGive
(
dispatcher_task_id
);
}
// Do card10 house keeping. E.g. polling the i2c devices if they triggered an interrupt
// TODO: Do this in a more task fokused way (high/low ISR)
card10_poll
();
}
void
vApplicationGetIdleTaskMemory
(
...
...
lib/card10/card10.c
View file @
87fba8d6
...
...
@@ -185,3 +185,7 @@ void core1_stop(void) {
MXC_GCR
->
perckcn1
|=
MXC_F_GCR_PERCKCN1_CPU1
;
}
void
card10_poll
(
void
)
{
pmic_poll
();
}
lib/card10/card10.h
View file @
87fba8d6
...
...
@@ -12,4 +12,5 @@ void card10_diag(void);
void
core1_start
(
void
);
void
core1_stop
(
void
);
void
card10_poll
(
void
);
#endif
lib/card10/pmic.c
View file @
87fba8d6
...
...
@@ -9,11 +9,14 @@ static const gpio_cfg_t pmic_interrupt_pin = {
PORT_0
,
PIN_12
,
GPIO_FUNC_IN
,
GPIO_PAD_PULL_UP
};
static
pmic_button_callback_fn
pmic_button_callback
=
NULL
;
static
volatile
bool
interrupt_pending
;
void
pmic_init
(
void
)
{
uint8_t
didm
=
MAX77650_getDIDM
();
uint8_t
cid
=
MAX77650_getChipID
();
interrupt_pending
=
false
;
printf
(
"MAX7765x DIDM: 0x%02x CID: 0x%02x
\n
"
,
didm
,
cid
);
MAX77650_setIP_SBB0
(
0
b11
);
//Limit switch current of SBB0 to 500mA for noise reduction
...
...
@@ -99,14 +102,23 @@ void pmic_init(void)
static
void
pmic_interrupt_callback
(
void
*
_
)
{
uint8_t
int_flag
=
MAX77650_getINT_GLBL
();
interrupt_pending
=
true
;
}
if
(
int_flag
&
(
MAX77650_INT_nEN_R
|
MAX77650_INT_nEN_F
))
{
if
(
pmic_button_callback
!=
NULL
)
{
(
*
pmic_button_callback
)(
int_flag
&
MAX77650_INT_nEN_F
);
void
pmic_poll
(
void
)
{
if
(
interrupt_pending
)
{
/* There might be a race condition here. Don't care ATM. */
interrupt_pending
=
false
;
uint8_t
int_flag
=
MAX77650_getINT_GLBL
();
if
(
int_flag
&
(
MAX77650_INT_nEN_R
|
MAX77650_INT_nEN_F
))
{
if
(
pmic_button_callback
!=
NULL
)
{
(
*
pmic_button_callback
)(
int_flag
&
MAX77650_INT_nEN_F
);
}
}
/* TODO: Other pmic interrupts */
}
/* TODO: Other pmic interrupts */
}
void
pmic_set_button_callback
(
pmic_button_callback_fn
cb
)
...
...
lib/card10/pmic.h
View file @
87fba8d6
...
...
@@ -6,6 +6,7 @@
void
pmic_init
(
void
);
void
pmic_set_led
(
uint8_t
led
,
uint8_t
val
);
void
pmic_poll
(
void
);
typedef
void
(
*
pmic_button_callback_fn
)(
bool
falling
);
void
pmic_set_button_callback
(
pmic_button_callback_fn
cb
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment