From 25d0693eda8955442358581277a7cf35b3d5baa8 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 19 May 2020 17:58:58 -0500 Subject: [PATCH] minor hook cleanups - Rename asdf_hook_do() to asdf_hook_execute() - asdf.c: Call asdf_hook_execute() for ASDF_HOOK_EACH_SCAN hook call in the scan routine, instead of getting then calling the function via hook_get() - asdf.c: move the fetch of scan function hook outside the scan loop. --- firmware/asdf/src/asdf.c | 6 ++++-- firmware/asdf/src/asdf_hook.c | 4 ++-- firmware/asdf/src/asdf_hook.h | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/asdf/src/asdf.c b/firmware/asdf/src/asdf.c index c1b1ef5..f7c2747 100644 --- a/firmware/asdf/src/asdf.c +++ b/firmware/asdf/src/asdf.c @@ -512,9 +512,11 @@ static void asdf_handle_key_held_pressed(uint8_t row, uint8_t col) // void asdf_keyscan(void) { - asdf_hook_get(ASDF_HOOK_EACH_SCAN)(); + asdf_cols_t (*row_reader)(uint8_t) = (asdf_cols_t(*)(uint8_t)) asdf_hook_get(ASDF_HOOK_SCANNER); + + asdf_hook_execute(ASDF_HOOK_EACH_SCAN); + for (uint8_t row = 0; row < ASDF_NUM_ROWS; row++) { - asdf_cols_t (*row_reader)(uint8_t) = (asdf_cols_t(*)(uint8_t)) asdf_hook_get(ASDF_HOOK_SCANNER); asdf_cols_t row_key_state = (*row_reader)(row); asdf_cols_t changed = row_key_state ^ last_stable_key_state[row]; diff --git a/firmware/asdf/src/asdf_hook.c b/firmware/asdf/src/asdf_hook.c index 4677633..f0fa071 100644 --- a/firmware/asdf/src/asdf_hook.c +++ b/firmware/asdf/src/asdf_hook.c @@ -77,7 +77,7 @@ static uint8_t asdf_hook_valid_id(asdf_hook_id_t id) return (id > ASDF_HOOK_NULL && id < ASDF_NUM_HOOKS); } -// PROCEDURE: asdf_hook_do +// PROCEDURE: asdf_hook_execute // INPUTS: (asdf_hook_id_t) hook_id: The hook for which to execute the attached // function. // @@ -93,7 +93,7 @@ static uint8_t asdf_hook_valid_id(asdf_hook_id_t id) // // COMPLEXITY: 2 // -void asdf_hook_do(asdf_hook_id_t hook_id) +void asdf_hook_execute(asdf_hook_id_t hook_id) { if (asdf_hook_valid_id(hook_id)) { hook_map[hook_id](); diff --git a/firmware/asdf/src/asdf_hook.h b/firmware/asdf/src/asdf_hook.h index 52ba38a..d9f1d7c 100644 --- a/firmware/asdf/src/asdf_hook.h +++ b/firmware/asdf/src/asdf_hook.h @@ -48,12 +48,12 @@ typedef struct { } asdf_hook_initializer_t; -// PROCEDURE: asdf_hook_do +// PROCEDURE: asdf_hook_execute // INPUTS: (asdf_hook_id_t) hook_id: The hook for which to execute attache functions. // OUTPUTS: none // DESCRIPTION: if the hook ID is valid, then execute the function attached to the hook. // SIDE EFFECTS: variable depending on the hooks. -void asdf_hook_do(asdf_hook_id_t hook_id); +void asdf_hook_execute(asdf_hook_id_t hook_id); // PROCEDURE: asdf_hook_get // INPUTS: (asdf_hook_id_t) hook_id: The hook for which to retrieve the attached