add Chapter07
This commit is contained in:
28
Chapter07/error_handling/hal/inc/hal.hpp
Normal file
28
Chapter07/error_handling/hal/inc/hal.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <stm32f0xx_hal.h>
|
||||
|
||||
namespace hal
|
||||
{
|
||||
inline void init()
|
||||
{
|
||||
HAL_Init();
|
||||
}
|
||||
|
||||
inline std::uint32_t get_pc()
|
||||
{
|
||||
std::uint32_t pc;
|
||||
__asm volatile ("mov %0, pc" : "=r" (pc) );
|
||||
return pc;
|
||||
}
|
||||
|
||||
struct time
|
||||
{
|
||||
static std::uint32_t get_ms()
|
||||
{
|
||||
return HAL_GetTick();
|
||||
}
|
||||
};
|
||||
}; // namespace hal
|
||||
Reference in New Issue
Block a user