Skip to content

Commit

Permalink
Use function pointer instead of inline assembly for factory calibrati…
Browse files Browse the repository at this point in the history
…on macros
  • Loading branch information
serisman committed Jul 6, 2020
1 parent 79d0ed8 commit 451f449
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions factory_calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__

0 comments on commit 451f449

Please sign in to comment.