From 546093f54d2eb5da97295fc6c5017023158d3892 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Mon, 5 Oct 2020 17:56:29 +0200 Subject: [PATCH] chore(bhi160): Move FIFO statics into function body These two static variables aren't (and shouldn't!) be used anywhere outside of bhi160_fetch_fifo() so let's move them into the function. Signed-off-by: Rahix <rahix@rahix.de> --- epicardium/modules/bhi.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/epicardium/modules/bhi.c b/epicardium/modules/bhi.c index 6c1d4e193..fb2182350 100644 --- a/epicardium/modules/bhi.c +++ b/epicardium/modules/bhi.c @@ -44,10 +44,6 @@ static float bhi160_sic_array[3 * 3] = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; /* clang-format on */ -/* BHI160 Fifo */ -static uint8_t bhi160_fifo[BHI160_FIFO_SIZE]; -static size_t start_index = 0; - /* BHI160 Task ID */ static TaskHandle_t bhi160_task_id = NULL; @@ -348,6 +344,13 @@ static void bhi160_fetch_fifo(void) * You'll probably be best of leaving it as it is ... */ + /* + * FIFO buffer. Access to this static variable is safe because this + * function is guarded by the bhi160_mutex. + */ + static uint8_t bhi160_fifo[BHI160_FIFO_SIZE]; + static size_t start_index = 0; + int result = 0; /* Number of bytes left in BHI160's FIFO buffer */ uint16_t bytes_left_in_fifo = 1; -- GitLab