Skip to content

Commit

Permalink
cm: Add optional processing callback
Browse files Browse the repository at this point in the history
Board code can optionally implement this callback. It's called whenever
we're waiting for the next command.
  • Loading branch information
Jonas Blixt committed Jun 5, 2024
1 parent 72e673d commit 3fa9624
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/pb/cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct cm_config {
int (*status)(uint8_t *buf, size_t *length);
int (*password_auth)(const char *password, size_t length);
int (*command)(uint32_t cmd, uint8_t *bfr, size_t bfr_length, uint8_t *rsp, size_t *rsp_size);
int (*process)(void);
const struct cm_transport_ops tops;
};

Expand Down
10 changes: 10 additions & 0 deletions src/cm/cm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,16 @@ int cm_run(void)

while (true) {
plat_wdog_kick();

if (cfg->process) {
rc = cfg->process();

if (rc != PB_OK) {
LOG_ERR("process (%i)", rc);
goto err_out;
}
}

rc = cfg->tops.complete();

if (rc == PB_OK) {
Expand Down

0 comments on commit 3fa9624

Please sign in to comment.