From ea8b335f8d7f8bc5b60013db418844e31ad37210 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 3 Jul 2021 21:36:46 +0200 Subject: [PATCH] progmem: fix for AVR - Fix header name - Rename pgm_read_word to read_word since pgm_read_word is a macro and cannot be scoped --- src/hal/progmem.h | 6 +++--- tests/unit/hal/progmem/test_progmem.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hal/progmem.h b/src/hal/progmem.h index c67106e..9f0bf8c 100644 --- a/src/hal/progmem.h +++ b/src/hal/progmem.h @@ -2,7 +2,7 @@ #include #ifdef __AVR__ -#include +#include #else #define PROGMEM // ignored #endif @@ -13,12 +13,12 @@ namespace hal { namespace progmem { /// read a 16bit word from PROGMEM -static inline uint16_t pgm_read_word(const uint16_t* addr) +static inline uint16_t read_word(const uint16_t* addr) { #ifndef __AVR__ return *addr; #else - return (uint16_t)::pgm_read_word(addr); + return (uint16_t)pgm_read_word(addr); #endif } diff --git a/tests/unit/hal/progmem/test_progmem.cpp b/tests/unit/hal/progmem/test_progmem.cpp index abd54f7..ab0da9a 100644 --- a/tests/unit/hal/progmem/test_progmem.cpp +++ b/tests/unit/hal/progmem/test_progmem.cpp @@ -2,14 +2,14 @@ #include "progmem.h" using Catch::Matchers::Equals; -using hal::progmem::pgm_read_word; +namespace pm = hal::progmem; -TEST_CASE("progmem::basic", "[progmem]") { +TEST_CASE("progmem::read_word", "[progmem]") { // create a PROGMEM array const uint16_t arr[2] PROGMEM = {0, 1}; // ensure it can be read correctly - REQUIRE(0 == pgm_read_word(&arr[0])); - REQUIRE(1 == pgm_read_word(&arr[1])); + REQUIRE(0 == pm::read_word(&arr[0])); + REQUIRE(1 == pm::read_word(&arr[1])); }