From 451f4493b79ae57bedb72d2d2b7ccd284dcca30f Mon Sep 17 00:00:00 2001 From: serisman Date: Mon, 6 Jul 2020 11:50:08 -0500 Subject: [PATCH] Use function pointer instead of inline assembly for factory calibration macros --- factory_calibration.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/factory_calibration.h b/factory_calibration.h index 3da645a..45661c1 100644 --- a/factory_calibration.h +++ b/factory_calibration.h @@ -5,21 +5,19 @@ #error "You must #include "pdk/device.h" instead of "pdk/factory_calibration.h" by itself." #endif +typedef unsigned char (*getfactorycalibration_funcptr)(void); + // Factory Calibration macros #if defined(FACTORY_IHRCR_ADDR) + #define GET_FACTORY_IHRCR ((getfactorycalibration_funcptr)FACTORY_IHRCR_ADDR) #define PDK_USE_FACTORY_IHRCR_16MHZ() \ - __asm__( \ - "call #("_STR(FACTORY_IHRCR_ADDR)") \n" \ - "mov "_STR_VAR(IHRCR)",a \n" \ - ) + IHRCR = GET_FACTORY_IHRCR() #endif #if defined(FACTORY_BGTR_ADDR) + #define GET_FACTORY_BGTR ((getfactorycalibration_funcptr)FACTORY_BGTR_ADDR) #define PDK_USE_FACTORY_BGTR() \ - __asm__( \ - "call #("_STR(FACTORY_BGTR_ADDR)") \n" \ - "mov "_STR_VAR(BGTR)",a \n" \ - ) + BGTR = GET_FACTORY_BGTR() #endif #endif //__PDK_FACTORY_CALIBRATION_H__