Implement millis() function
This commit is contained in:
parent
00810009ec
commit
1c695fbaa8
@ -49,7 +49,7 @@ add_executable(skl_tunnel
|
|||||||
radio/src/radio_gpio.c
|
radio/src/radio_gpio.c
|
||||||
radio/src/radio_hw_instance.cpp
|
radio/src/radio_hw_instance.cpp
|
||||||
|
|
||||||
app/src/app_logging.cpp
|
app/src/app_board.cpp
|
||||||
app/src/app_transparent_client.cpp
|
app/src/app_transparent_client.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
syscalls.c
|
syscalls.c
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by erki on 28.06.22.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef SKL_TUNNEL_APP_LOGGING_HPP
|
|
||||||
#define SKL_TUNNEL_APP_LOGGING_HPP
|
|
||||||
|
|
||||||
namespace App::Logging
|
|
||||||
{
|
|
||||||
|
|
||||||
void setup();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //SKL_TUNNEL_APP_LOGGING_HPP
|
|
||||||
@ -5,10 +5,6 @@
|
|||||||
#ifndef SKL_TUNNEL_SKULLC_SAMD21_HAL_HPP
|
#ifndef SKL_TUNNEL_SKULLC_SAMD21_HAL_HPP
|
||||||
#define SKL_TUNNEL_SKULLC_SAMD21_HAL_HPP
|
#define SKL_TUNNEL_SKULLC_SAMD21_HAL_HPP
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#include <hal_delay.h>
|
#include <hal_delay.h>
|
||||||
#include <hal_io.h>
|
#include <hal_io.h>
|
||||||
#include <hal_usart_async.h>
|
#include <hal_usart_async.h>
|
||||||
@ -16,6 +12,12 @@
|
|||||||
#include <utility_function.hpp>
|
#include <utility_function.hpp>
|
||||||
#include <utility_tag.hpp>
|
#include <utility_tag.hpp>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "app_board.hpp"
|
||||||
|
|
||||||
namespace Peripherals
|
namespace Peripherals
|
||||||
{
|
{
|
||||||
namespace Hal
|
namespace Hal
|
||||||
@ -26,7 +28,14 @@ namespace Samd
|
|||||||
struct StaticHal
|
struct StaticHal
|
||||||
{
|
{
|
||||||
static void initialize()
|
static void initialize()
|
||||||
{ }
|
{
|
||||||
|
App::Board::setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::uint32_t getMillis()
|
||||||
|
{
|
||||||
|
return App::Board::systickGet();
|
||||||
|
}
|
||||||
|
|
||||||
static void delay(const std::uint32_t milliseconds)
|
static void delay(const std::uint32_t milliseconds)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,15 +2,16 @@
|
|||||||
// Created by erki on 15.07.22.
|
// Created by erki on 15.07.22.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "driver_init.h"
|
||||||
|
|
||||||
#include "app_board.hpp"
|
#include "app_board.hpp"
|
||||||
|
|
||||||
#include "driver_init.h"
|
#include "skullc_samd21_hal.hpp"
|
||||||
|
|
||||||
#include <utility_logging.hpp>
|
#include <utility_logging.hpp>
|
||||||
#include <utility_asynclogger.hpp>
|
#include <utility_asynclogger.hpp>
|
||||||
#include <utility_staticpointer.hpp>
|
#include <utility_staticpointer.hpp>
|
||||||
|
|
||||||
#include "skullc_samd21_hal.hpp"
|
|
||||||
|
|
||||||
namespace Hal = Peripherals::Hal::Samd;
|
namespace Hal = Peripherals::Hal::Samd;
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ void setup()
|
|||||||
m_logger.setup(usart0);
|
m_logger.setup(usart0);
|
||||||
Utility::setLogger(*m_logger);
|
Utility::setLogger(*m_logger);
|
||||||
|
|
||||||
SysTick_Config(1000);
|
SysTick_Config(F_CPU / 1000u);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t systickGet()
|
std::uint32_t systickGet()
|
||||||
|
|||||||
@ -1,43 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by erki on 28.06.22.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "app_logging.hpp"
|
|
||||||
|
|
||||||
#include "driver_init.h"
|
|
||||||
|
|
||||||
#include <utility_logging.hpp>
|
|
||||||
#include <utility_asynclogger.hpp>
|
|
||||||
#include <utility_staticpointer.hpp>
|
|
||||||
|
|
||||||
#include "skullc_samd21_hal.hpp"
|
|
||||||
|
|
||||||
namespace Hal = Peripherals::Hal::Samd;
|
|
||||||
|
|
||||||
using Logger = Utility::AsyncLogger<Hal::SerialInterfaceAsync<usart_async_descriptor>, Hal::StaticHal, 5, 255>;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
Utility::StaticPointer<Logger> m_logger;
|
|
||||||
|
|
||||||
void m_txCompleteCb(const usart_async_descriptor* const)
|
|
||||||
{
|
|
||||||
m_logger->txCompleteCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace App::Logging
|
|
||||||
{
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
Hal::SerialInterfaceAsync<usart_async_descriptor> usart0{&USART_0};
|
|
||||||
usart0.registerTxCallback(m_txCompleteCb);
|
|
||||||
|
|
||||||
m_logger.setup(usart0);
|
|
||||||
Utility::setLogger(*m_logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
5
main.cpp
5
main.cpp
@ -6,7 +6,6 @@
|
|||||||
#include <utility_function.hpp>
|
#include <utility_function.hpp>
|
||||||
|
|
||||||
#include "radio_hw_instance.hpp"
|
#include "radio_hw_instance.hpp"
|
||||||
#include "app_logging.hpp"
|
|
||||||
#include "skullc_samd21_hal.hpp"
|
#include "skullc_samd21_hal.hpp"
|
||||||
#include "app_transparent_client.hpp"
|
#include "app_transparent_client.hpp"
|
||||||
|
|
||||||
@ -34,11 +33,10 @@ int main()
|
|||||||
atmel_start_init();
|
atmel_start_init();
|
||||||
|
|
||||||
Utility::Assert::setHandler(m_faultHandler);
|
Utility::Assert::setHandler(m_faultHandler);
|
||||||
|
Hal::StaticHal::initialize();
|
||||||
|
|
||||||
gpio_set_pin_level(OUT_LED_TX, false);
|
gpio_set_pin_level(OUT_LED_TX, false);
|
||||||
|
|
||||||
App::Logging::setup();
|
|
||||||
|
|
||||||
SKULLC_LOG_DEBUG("Begin.");
|
SKULLC_LOG_DEBUG("Begin.");
|
||||||
|
|
||||||
const App::RadioSettings settings;
|
const App::RadioSettings settings;
|
||||||
@ -57,6 +55,7 @@ int main()
|
|||||||
radio_status &= 0x1F;
|
radio_status &= 0x1F;
|
||||||
|
|
||||||
SKULLC_LOG_INFO("Status: %d", radio_status);
|
SKULLC_LOG_INFO("Status: %d", radio_status);
|
||||||
|
SKULLC_LOG_INFO("Millis: %u", Hal::StaticHal::getMillis());
|
||||||
|
|
||||||
delay_ms(1000);
|
delay_ms(1000);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user