SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
Pins.h
Go to the documentation of this file.
1
45#ifndef __ECU_PINS_H__
46#define __ECU_PINS_H__
47
48// IMPROVE: pin priority
49
50#include <stdint.h>
51#include <stdlib.h>
52
53#include "PPHelp.h"
54#include "PinConfig.def"
55
59#define PINS_ANALOG_RES CONF_PINS_ANALOG_WRITE_RESOLUTION
63#define PINS_ANALOG_MAX pwrtwo(PINS_ANALOG_RES)
67#define PINS_ANALOG_HIGH (PINS_ANALOG_MAX - 1)
71#define PINS_ANALOG_MIN 0
72
76#define PINS_VOLT_TO_ANALOG(x) (int)min(max((x / 5) * PINS_ANALOG_HIGH, PINS_ANALOG_MIN), PINS_ANALOG_HIGH)
77
85namespace Pins {
86
90typedef void (*PinHandler)(uint8_t CAN_GPIO_Pin, int &value);
91
100int getCanPinValue(uint8_t CAN_GPIO_Pin);
101
108int getPinValue(uint8_t GPIO_Pin);
109
116void setPinValue(uint8_t GPIO_Pin, int value);
117
125void setInternalValue(uint8_t Internal_Pin, int value);
126
133
138void update(void);
139
143void stopCanPins(void);
144
148void startCanPins(void);
149
153void initialize(void);
154
158void debugPrint(void);
159
160} // namespace Pins
161
162#endif // __ECU_PINS_H__
Compilation of various helpful preprocessor macros.
Pin Configuration.
Get and set values to predefined pins.
Definition Pins.h:85
void stopCanPins(void)
Stops background interrupts from sending canPins.
void setPinValue(uint8_t GPIO_Pin, int value)
Set the pin value of a predefined pin.
void(* PinHandler)(uint8_t CAN_GPIO_Pin, int &value)
A typedef for pin handler functions.
Definition Pins.h:90
int getCanPinValue(uint8_t CAN_GPIO_Pin)
Get the pin value of a predefined canbus pin.
void initialize(void)
Initialize all predefined pins.
int getPinValue(uint8_t GPIO_Pin)
Get the pin value of a predefined pin.
void update(void)
Poll analog pin values.
void startCanPins(void)
Starts background interrupts to send canPins, if any are to be sent.
void setInternalValue(uint8_t Internal_Pin, int value)
Set the value of an internal pin.
void debugPrint(void)
Used for debugging.
void resetPhysicalPins()
Resets physical pins to their inital state.