ccNOos  v0.0.0
Build Portable Microcontroller Applications!
Platform_PSoC4.h
Go to the documentation of this file.
1 /** \file Platform_PSoC4.h
2 * \brief <a href="https://www.inmechasol.org/" target="_blank">IMS</a>:
3  <a href="https://github.com/InMechaSol/ccNOos" target="_blank">ccNOos</a>,
4  Platform Specification, PSoC4
5 
6  Copyright 2021 <a href="https://www.inmechasol.org/" target="_blank">InMechaSol, Inc</a>
7 
8  Licensed under the Apache License, Version 2.0(the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 
20 Notes:
21  (.c includes .h) - for straight C or
22  (.cpp includes .c which includes .h) - for C++ wrapped straight C
23  *Always compiled to a single compilation unit, either C or CPP, not both
24 
25 */
26 
27 #if PLATFORM_NAME!=PSoC4
28  error PLATFORM_NAME must be PSoC4
29 #endif
30 
31 
32 #ifdef REDEFINE_NULLPTR
33  #error Must not compile with -DREDEFINE_NULLPTR on PSoC4
34 #endif // !REDEFINE_NULLPTR
35 #ifdef __NOEXCEPTIONS
36  #error Must not compile with -D__NOEXCEPTIONS on PSoC4
37 #endif // !__NOEXCEPTIONS
38 
39 
40 #include <project.h> // for PSoC
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <time.h>
44 #include <unistd.h>
45 #include <stdarg.h>
46 
47 #include "../../executionSystem/execution_system.h"
48 #include "../../consoleMenu/console_menu.h"
49 
51 #define LIGHT_OFF (1u) // 1-PSoC4, 0-most others
52 #define uSEC_PER_CLOCK (1000u)
53 #define MAXLINELENGTH (80)
54 
55 
56 // 0) (Optional) Platform Config and Log Files/Devices
57 // 1) Platform Setup Function
59 {
60  //<platformSetup>
61 #ifdef __USINGCONSOLEMENU
62 #ifdef __USINGFLOATPRINTF
63  asm(".global _printf_float");
64 #endif
65 #endif
66  /* Enable global interrupts. */
67  CyGlobalIntEnable;
68  //</platformSetup>
69 }
70 // 2) Platform Start Function
72 {
73  //<platformStart>
74  /* Configure the SysTick timer to generate interrupt every 1 ms
75  * and start its operation. Call the function before assigning the
76  * callbacks as it calls CySysTickInit() during first run that
77  * re-initializes the callback addresses to the NULL pointers.
78  */
79  CySysTickStart();
80 
81  /* Find unused callback slot and assign the callback. */
82  for (int i = 0u; i < (int)CY_SYS_SYST_NUM_OF_CALLBACKS; ++i)
83  {
84  if (CySysTickGetCallback(i) == NULL)
85  {
86  /* Set callback */
87  CySysTickSetCallback(i, SysTickISRCallback);
88  break;
89  }
90  }
91  UART_Start();
92  //</platformStart>
93 }
94 // 3) Platform Loop Delay Function
96 {
97  //<platformLoopDelay>
98  //CyDelay(1); // on PSoc, only if desired
99  ; // let it run full throttle, its a machine after all...
100  //</platformLoopDelay>
101 }
102 
103 #ifdef __USINGCONSOLEMENU
104 // 4) Basic ability for user console input
105 void GetMenuChars(char* inStringPtr)
106 {
107  static UI_32 tTHEN = 0u;
108 
109  if(tTHEN == 0)
110  tTHEN = getuSecTicks();
111 
112  if((getuSecTicks()-tTHEN)>1000000)
113  {
114  inStringPtr[0] = ';';
115  tTHEN = getuSecTicks();
116  inStringPtr[1] = 0x00;
117  }
118  else
119  inStringPtr[0] = 0x00;
120 }
121 // 5) Basic ability for user console output
122 void WriteMenuLine(char* outStringPtr)
123 {
124  UART_PutString(outStringPtr);
125 }
126 // 6) (Optional) Logging Output
127 void WriteLogLine(char* outStringPtr)
128 {
129 
130 }
131 // 7) (Optional) Config Input
132 void ReadConfigLine(char* inStringPtr)
133 {
134 
135 
136 }
137 // 8) Platform API Functions (From Template?)
138 PlatformAPIFuncsTemplate(size + 1);
139 #endif
140 // 9) Global Execution System Instance
141 //PLATFORM_EXESYS_DECLARE(PLATFORM_NAME);
142 // 10) ExeSys API Functions (From Template?)
GetMenuChars
void GetMenuChars(struct uiStruct *uiStructPtrin)
Definition: Application_Platform_Main.c:111
SysTickISRCallback
void SysTickISRCallback()
WriteLogLine
void WriteLogLine(struct logStruct *logStructPtrin)
Definition: Application_Platform_Main.c:167
ExeSysAPIFuncsTemplate
#define ExeSysAPIFuncsTemplate
Definition: execution_system.h:97
getuSecTicks
UI_32 getuSecTicks()
ReadConfigLine
void ReadConfigLine(struct configStruct *configStructPtrin)
Definition: Application_Platform_Main.c:172
platformLoopDelay
void platformLoopDelay()
Definition: Platform_PSoC4.h:95
WriteMenuLine
void WriteMenuLine(struct uiStruct *uiStructPtrin)
Definition: Application_Platform_Main.c:144
platformStart
void platformStart()
Definition: Platform_PSoC4.h:71
platformSetup
void platformSetup()
Definition: Platform_PSoC4.h:58