Lite SBC Library  v1.0.0
TLE94x1.h
Go to the documentation of this file.
1 /*********************************************************************************************************************
2  * Copyright (c) 2019, Infineon Technologies AG
3  *
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  *
7  *
8  * Boost Software License - Version 1.0 - August 17th, 2003
9  *
10  * Permission is hereby granted, free of charge, to any person or organization
11  * obtaining a copy of the software and accompanying documentation covered by
12  * this license (the "Software") to use, reproduce, display, distribute,
13  * execute, and transmit the Software, and to prepare derivative works of the
14  * Software, and to permit third-parties to whom the Software is furnished to
15  * do so, all subject to the following:
16  *
17  * The copyright notices in the Software and this entire statement, including
18  * the above license grant, this restriction and the following disclaimer,
19  * must be included in all copies of the Software, in whole or in part, and
20  * all derivative works of the Software, unless such copies or derivative
21  * works are solely in the form of machine-executable object code generated by
22  * a source language processor.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
27  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
28  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
29  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  *
32  *********************************************************************************************************************/
33 
34 
35 /****************************************************************************************************/
49 #ifndef TLE94x1_H
50 #define TLE94x1_H
51 
52 
53 
54 
55 
56 
57 /* ================================================================================ */
58 /* ============================ HEADER FILES ================================ */
59 /* ================================================================================ */
60 
61 
62 
63 #include "TLE94x1_DEFINES.h"
64 #include "TLE94x1_ISR.h"
65 #include "TLE94x1_SPI.h"
66 #include <stdint.h>
67 
68 
69 
70 
71 /* ================================================================================ */
72 /* ================================ MACROS ================================== */
73 /* ================================================================================ */
74 
75 
81 #define SBC_Write_Bit (0x80U)
82 
88 #define SBC_Read_Mask (0x7FU)
89 
90 
91 
92 
93 /* ================================================================================ */
94 /* =========================== Library Functions ============================ */
95 /* ================================================================================ */
96 
97 struct __SBC_ErrorCode;
98 
104 typedef struct __SBC_ErrorCode {
105  uint8_t SBC_Register;
106  uint8_t flippedBitsMask;
107  uint8_t expectedValue;
108 } SBC_ErrorCode;
109 
113 typedef void (*SBC_Func_Callback)(uint8_t callbackHandler);
114 
115 
116 
117 
118 
119 
120 /* -------------------------------- Main Functions ------------------------------- */
121 
122 
129 
130 
139 uint16_t SBC_Read_Command(uint8_t SBC_Reg);
140 
141 
152 uint8_t SBC_Read_RegField(uint8_t SBC_Reg, uint8_t SBC_FieldMsk, uint8_t SBC_FieldPos);
153 
154 
155 
167 SBC_ErrorCode SBC_Write_Reg(uint8_t SBC_Reg, uint8_t SBC_Val, uint16_t * returnval);
168 
169 
189 SBC_ErrorCode SBC_Write_RegField(uint8_t SBC_Reg, uint8_t SBC_FieldMsk, uint8_t SBC_FieldPos, uint8_t SBC_FieldVal, uint16_t * returnval);
190 
191 
200 SBC_ErrorCode SBC_Init(void);
201 
202 /* -------------------------------- ISR Functions -------------------------------- */
203 
204 
218 void SBC_Register_Callback(uint32_t ISR_Vector, void (*Callback_Handler)(uint8_t callbackHandler));
219 
220 
232 SBC_ErrorCode SBC_ISR(void);
233 
234 
235 
236 /* -------------------------------- API Calls ----------------------------------- */
237 
244 
245 
252 
253 
262 
263 
270 SBC_ErrorCode SBC_Set_DutyCycle_PWM(uint8_t PWM_DC);
271 
272 
279 SBC_ErrorCode SBC_Set_Timer_On(uint8_t OnTime);
280 
287 SBC_ErrorCode SBC_Set_Timer_Period(uint8_t Period);
288 
289 
296 
297 
304 
305 
312 
313 
320 
321 
328 
329 
336 
337 
344 
345 
352 
353 
359 uint16_t SBC_SYS_STAT_Read(void);
360 
361 
367 SBC_ErrorCode SBC_SYS_STAT_Write(uint16_t SystemStatus);
368 
369 
376 
377 
384 
385 
392 
393 #endif /*TLE94x1_H*/
struct __SBC_ErrorCode SBC_ErrorCode
A structure for simple error readout.
SBC_ErrorCode SBC_Clear_Wake_Status(void)
Clears both Wake Status registers.
Definition: TLE94x1.c:578
SBC_ErrorCode SBC_Mode_Sleep(void)
Clears all wake status registers and enter SBC sleep mode. Depending on configuration also the select...
Definition: TLE94x1.c:365
SBC_ErrorCode SBC_Set_Timer_Period(uint8_t Period)
Sets the Period time of the internal timer.
Definition: TLE94x1.c:467
SBC_ErrorCode SBC_WK_MEAS_Off(void)
Disable Voltage Sensing and enable wake-up functionality. See chapter 9.2.4 in datasheet.
Definition: TLE94x1.c:497
uint16_t SBC_SYS_STAT_Read(void)
Reads System Status Control, both lower and higher bits. See page 138 in datasheet.
Definition: TLE94x1.c:512
SBC_ErrorCode SBC_TIMER_WK_EN_Off(void)
WK wake-up disabled. See chapter 5.2.
Definition: TLE94x1.c:507
SBC_ErrorCode SBC_Mode_Stop(void)
Enters SBC stop mode.
Definition: TLE94x1.c:360
SBC_ErrorCode SBC_SYS_STAT_Write(uint16_t SystemStatus)
Writes System Status Control, both lower and higher bits. See page 138 in datasheet.
Definition: TLE94x1.c:521
A structure for simple error readout.
Definition: TLE94x1.h:104
uint8_t expectedValue
Expected readout of the register.
Definition: TLE94x1.h:107
uint8_t SBC_Read_RegField(uint8_t SBC_Reg, uint8_t SBC_FieldMsk, uint8_t SBC_FieldPos)
This method will proceed a readout of a dedicated bitfield within a register.
Definition: TLE94x1.c:94
SBC_ErrorCode SBC_Init(void)
This method must be called one time at startup of the microcontroller.
Definition: TLE94x1.c:140
SBC_ErrorCode SBC_WD_Trigger(void)
This method will trigger the watchdog.
Definition: TLE94x1.c:81
SBC_ErrorCode SBC_Set_Timer_On(uint8_t OnTime)
Sets the OnTime of the internal timer.
Definition: TLE94x1.c:462
void SBC_Register_Callback(uint32_t ISR_Vector, void(*Callback_Handler)(uint8_t callbackHandler))
This function can register a self-defined function to a specific interrupt-event of the SBC.
Definition: TLE94x1.c:281
SBC_ErrorCode SBC_Set_DutyCycle_PWM(uint8_t PWM_DC)
Sets the duty-cycle of the internal PWM generator.
Definition: TLE94x1.c:457
Declaration file for TLE94x1 SBC family device SPI functions.
Main header declaration file for TLE94x1 SBC family device.
uint16_t SBC_Read_Command(uint8_t SBC_Reg)
This method will proceed a readout of a register.
Definition: TLE94x1.c:88
SBC_ErrorCode SBC_Lock_Configuration(void)
Locks CP_EN, GPIO configuration and 'rwl'-bits.
Definition: TLE94x1.c:535
uint8_t flippedBitsMask
Masks the bits that differ from the expected value. Is 0 if readout is as expected.
Definition: TLE94x1.h:106
SBC_ErrorCode SBC_Write_RegField(uint8_t SBC_Reg, uint8_t SBC_FieldMsk, uint8_t SBC_FieldPos, uint8_t SBC_FieldVal, uint16_t *returnval)
This method can be used for manipulating a single bit-field in a control-register.
Definition: TLE94x1.c:114
SBC_ErrorCode SBC_Unlock_Configuration(void)
Unlocks CP_EN, GPIO configuration and 'rwl'-bits.
Definition: TLE94x1.c:557
SBC_ErrorCode SBC_WK_MEAS_On(void)
Enable Voltage Sensing. No wake-up events are generated. See chapter 9.2.4 in datasheet.
Definition: TLE94x1.c:492
SBC_ErrorCode SBC_FO_Test_Off(void)
FO output deactivated by software for testing. Only working if FO/GPIO is configured as FO.
Definition: TLE94x1.c:477
uint8_t SBC_Register
The register where an error occurred.
Definition: TLE94x1.h:105
void(* SBC_Func_Callback)(uint8_t callbackHandler)
Typedef for interrupt callbacks.
Definition: TLE94x1.h:113
SBC_ErrorCode SBC_CP_Off(void)
Charge-Pump (VCP-Pin) is disabled. See chapter 5.3 in datasheet.
Definition: TLE94x1.c:487
SBC_ErrorCode SBC_ISR(void)
Interrupt Service Routine for handling interrupts.
Definition: TLE94x1.c:306
SBC_ErrorCode SBC_Write_Reg(uint8_t SBC_Reg, uint8_t SBC_Val, uint16_t *returnval)
Writes a whole byte to a register and verifies it.
Definition: TLE94x1.c:100
SBC_ErrorCode SBC_FO_Test_On(void)
FO output activated by software for testing. Only working if FO/GPIO is configured as FO.
Definition: TLE94x1.c:472
SBC_ErrorCode SBC_Mode_Normal(void)
Enters SBC normal mode.
Definition: TLE94x1.c:355
Declaration file for ISR-Vectors and ISR related functions.
SBC_ErrorCode SBC_TIMER_WK_EN_On(void)
WK is enabled as wake source. See chapter 5.2.
Definition: TLE94x1.c:502
SBC_ErrorCode SBC_CP_On(void)
Charge-Pump (VCP-Pin) is enabled. See chapter 5.3 in datasheet.
Definition: TLE94x1.c:482