XCP_SIM
hw.cpp
1 /*
2  * pySART - Simplified AUTOSAR-Toolkit for Python.
3  *
4  * (C) 2007-2018 by Christoph Schueler <github.com/Christoph2,
5  * cpu12.gems@googlemail.com>
6  *
7  * All Rights Reserved
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  *
23  * s. FLOSS-EXCEPTION.txt
24  */
25 
26 #include <Arduino.h>
27 #include <stdint.h>
28 
30 #include "xcp.h"
31 
34 typedef struct tagHwStateType {
35  uint32_t StartingTime;
36 } HwStateType;
37 
38 static HwStateType HwState = {0};
39 
40 void XcpHw_Init(void) {
41  HwState.StartingTime = millis();
42  pinMode(LED_BUILTIN, OUTPUT);
43 }
44 
45 void XcpHw_Deinit(void) {}
46 
47 uint32_t XcpHw_GetTimerCounter(void) {
48 #if XCP_DAQ_TIMESTAMP_UNIT == XCP_DAQ_TIMESTAMP_UNIT_1US
49  return micros();
50 #elif XCP_DAQ_TIMESTAMP_UNIT == XCP_DAQ_TIMESTAMP_UNIT_1MS
51  return millis();
52 #else
53 #error Timestamp-unit not supported.
54 #endif // XCP_DAQ_TIMESTAMP_UNIT
55 }
56 
57 uint32_t XcpHw_GetTimerCounterMS(void) { return millis(); }
58 
59 bool XcpHw_SxIAvailable(void) { return Serial.available(); }
60 
61 uint8_t XcpHw_SxIRead(void) { return (uint8_t)Serial.read(); }
62 
63 void XcpHw_AcquireLock(uint8_t lockIdx) {
64  if (lockIdx >= XCP_HW_LOCK_COUNT) {
65  return;
66  }
67 }
68 
69 void XcpHw_ReleaseLock(uint8_t lockIdx) {
70  if (lockIdx >= XCP_HW_LOCK_COUNT) {
71  return;
72  }
73 }
74 
75 #include <vector>
76 
77 class Timer {
78 public:
79  Timer();
80 
81 private:
82  std::vector<int> m_timers;
83 };
Definition: hw.cpp:77