PX4 Firmware
PX4 Autopilot Software http://px4.io
internal.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014, 2018 Pavel Kirienko <pavel.kirienko@gmail.com>
3  * Kinetis Port Author David Sidrane <david_s5@nscdg.com>
4  */
5 
6 #pragma once
7 
9 
10 #if UAVCAN_KINETIS_NUTTX
11 # include <nuttx/arch.h>
12 # include "up_arch.h"
13 # include <arch/board/board.h>
14 # include <hardware/kinetis_pit.h>
15 # include <hardware/kinetis_sim.h>
16 # include <syslog.h>
17 #else
18 # error "Unknown OS"
19 #endif
20 
21 /**
22  * Debug output
23  */
24 #ifndef UAVCAN_KINETIS_LOG
25 # if 1
26 # define UAVCAN_KINETIS_LOG(fmt, ...) syslog(LOG_INFO, "uavcan_kinetis: " fmt "\n", ## __VA_ARGS__)
27 # else
28 # define UAVCAN_KINETIS_LOG(...) ((void)0)
29 # endif
30 #endif
31 
32 /**
33  * IRQ handler macros
34  */
35 #define UAVCAN_KINETIS_IRQ_HANDLER(id) int id(int irq, FAR void* context, FAR void *arg)
36 
37 
38 /**
39  * Glue macros
40  */
41 #define UAVCAN_KINETIS_GLUE2_(A, B) A ## B
42 #define UAVCAN_KINETIS_GLUE2(A, B) UAVCAN_KINETIS_GLUE2_(A, B)
43 
44 #define UAVCAN_KINETIS_GLUE3_(A, B, C) A ## B ## C
45 #define UAVCAN_KINETIS_GLUE3(A, B, C) UAVCAN_KINETIS_GLUE3_(A, B, C)
46 
47 namespace uavcan_kinetis
48 {
49 #if UAVCAN_KINETIS_NUTTX
50 
51 struct CriticalSectionLocker {
52  const irqstate_t flags_;
53 
54  CriticalSectionLocker()
55  : flags_(enter_critical_section())
56  {
57  }
58 
59  ~CriticalSectionLocker()
60  {
61  leave_critical_section(flags_);
62  }
63 };
64 
65 #endif
66 
67 namespace clock
68 {
69 uavcan::uint64_t getUtcUSecFromCanInterrupt();
70 }
71 }
uavcan::uint64_t getUtcUSecFromCanInterrupt()