Init
This commit is contained in:
commit
edc6ddb3c7
|
|
@ -0,0 +1,126 @@
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Created by ilya on 22.03.24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Gpios.h"
|
||||||
|
#include <SpiPorts.h>
|
||||||
|
#include "SystemDelayInterface.h"
|
||||||
|
#include "PwmSim7600e.h"
|
||||||
|
|
||||||
|
tGpios GPIOS;
|
||||||
|
|
||||||
|
void Gpios_InitMainPower(tMainPower *env){
|
||||||
|
env->ecallOut= InitGpioPin(GPIOB, GPIO_PINS_2, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->garage = InitGpioPin(GPIOE, GPIO_PINS_7, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->muteP = InitGpioPin(GPIOD, GPIO_PINS_11, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->muteN = InitGpioPin(GPIOE, GPIO_PINS_8, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->Power12V = InitGpioPinOpenDrain(GPIOE, GPIO_PINS_13, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->inAnt = InitGpioPin(GPIOC, GPIO_PINS_6, GPIO_MODE_OUTPUT, GPIO_PIN_REVERSE);
|
||||||
|
env->ignition = InitGpioPin(GPIOD, GPIO_PINS_10, GPIO_MODE_INPUT, GPIO_PIN_REVERSE);
|
||||||
|
env->standby = InitGpioPin(GPIOD, GPIO_PINS_14, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_CanStandby(tCanStandby *env) {
|
||||||
|
env->can1_standby = InitGpioPin(GPIOD, GPIO_PINS_3, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->can2_standby = InitGpioPin(GPIOB, GPIO_PINS_7, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Gpios_InitBattery(tBatteryPower *env) {
|
||||||
|
env->enable = InitGpioPin(GPIOD, GPIO_PINS_2, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->charge =InitGpioPin(GPIOC, GPIO_PINS_10, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Gpios_InitBIP(tBipPins *env) {
|
||||||
|
crm_periph_clock_enable(CRM_GPIOC_PERIPH_CLOCK, TRUE);
|
||||||
|
env->led.ledsBip = InitGpioPin(GPIOE, GPIO_PINS_14, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->led.red = InitGpioPin(GPIOA, GPIO_PINS_5, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->led.green = InitGpioPin(GPIOA, GPIO_PINS_6, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->Backlight = InitGpioPin(GPIOA, GPIO_PINS_4, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->Diagnost = InitGpioPin(GPIOC, GPIO_PINS_4, GPIO_MODE_INPUT, GPIO_PIN_REVERSE);
|
||||||
|
|
||||||
|
env->buttons.additional = InitGpioPin(GPIOE, GPIO_PINS_1, GPIO_MODE_INPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->buttons.emergency = InitGpioPin(GPIOE, GPIO_PINS_0, GPIO_MODE_INPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->lastTestTime = 0;
|
||||||
|
GpioPinSet(&env->led.green, false);
|
||||||
|
GpioPinSet(&env->led.red, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_DeviceLeds(tOnBoardLed *env){
|
||||||
|
env->red1 = InitGpioPin(GPIOE, GPIO_PINS_2, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->green1 = InitGpioPin(GPIOE, GPIO_PINS_3, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->red2 = InitGpioPin(GPIOE, GPIO_PINS_4, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->green2 = InitGpioPin(GPIOE, GPIO_PINS_5, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_InitSim7600(tSim7600ePower *env) {
|
||||||
|
env->gsm.powerKey = InitGpioPin(GPIOE, GPIO_PINS_11, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->gsm.PowerGsm = InitGpioPin(GPIOA, GPIO_PINS_8, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->gsm.PowerCheckGsm = InitGpioPin(GPIOA, GPIO_PINS_10, GPIO_MODE_INPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->powerStatus = InitGpioPin(GPIOA, GPIO_PINS_9, GPIO_MODE_INPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->reset = InitGpioPin(GPIOE, GPIO_PINS_10, GPIO_MODE_INPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->SimSelector = InitGpioPin(GPIOD, GPIO_PINS_15, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_AccelPins(tAccelPins *env){
|
||||||
|
env->spiChipSelect = InitGpioPin(GPIOB, GPIO_PINS_12, GPIO_MODE_OUTPUT, GPIO_PIN_REVERSE);
|
||||||
|
env->int1 = InitGpioPin(GPIOA, GPIO_PINS_11, GPIO_MODE_INPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->int2 = InitGpioPin(GPIOA, GPIO_PINS_12, GPIO_MODE_INPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_RS485DirectionPins(tRs485DirectionPins *env){
|
||||||
|
env->transmit = InitGpioPin(GPIOB, GPIO_PINS_8, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->receive = InitGpioPin(GPIOB, GPIO_PINS_9, GPIO_MODE_OUTPUT, GPIO_PIN_REVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_InitAudio(tAudioPower *env){
|
||||||
|
env->resetAmp = InitGpioPin(GPIOB, GPIO_PINS_0, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
// env->powerAmp = InitGpioPinOpenDrain(GPIOE, GPIO_PINS_12, GPIO_MODE_OUTPUT, GPIO_PIN_REVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_InitTestAudio(tSpekTestPower *env){
|
||||||
|
env->PowerCheckSpkOn = InitGpioPinOpenDrain(GPIOA, GPIO_PINS_7, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
env->PowerTestSpkIn = InitGpioPin(GPIOC, GPIO_PINS_5, GPIO_MODE_INPUT, GPIO_PIN_REVERSE);
|
||||||
|
env->speakTestAcsess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Gpios_InitPower(tPowerSusystem *env) {
|
||||||
|
env->PowerRS485 = InitGpioPin(GPIOC, GPIO_PINS_3, GPIO_MODE_OUTPUT, GPIO_PIN_NOREVERSE);
|
||||||
|
|
||||||
|
Gpios_InitTestAudio(&env->SpekTestPower);
|
||||||
|
Gpios_InitSim7600(&env->sim7600);
|
||||||
|
|
||||||
|
Gpios_InitAudio(&env->audio);
|
||||||
|
Gpios_InitMainPower(&env->main);
|
||||||
|
Gpios_InitBattery(&env->battery);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_ClcInit() {
|
||||||
|
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable(CRM_GPIOC_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable(CRM_GPIOD_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable(CRM_GPIOE_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable(CRM_GPIOF_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable(CRM_GPIOH_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable(CRM_GPIOG_PERIPH_CLOCK, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpios_Init() {
|
||||||
|
Gpios_ClcInit();
|
||||||
|
|
||||||
|
tGpios *env = &GPIOS;
|
||||||
|
|
||||||
|
Gpios_AccelPins(&env->accel);
|
||||||
|
Gpios_DeviceLeds(&env->onBoardLed);
|
||||||
|
Gpios_RS485DirectionPins(&env->comIntDir);
|
||||||
|
Gpios_InitBIP(&env->bip);
|
||||||
|
|
||||||
|
Gpios_InitPower(&env->powerSusystem);
|
||||||
|
Gpios_InitAudio(&env->powerSusystem.audio);
|
||||||
|
Gpios_InitSim7600(&env->powerSusystem.sim7600);
|
||||||
|
Gpios_CanStandby(&env->powerSusystem.canStandby);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// Created by ilya on 22.03.24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SMART_COMPONENTS_GPIOS_H
|
||||||
|
#define SMART_COMPONENTS_GPIOS_H
|
||||||
|
#include <SerialPorts.h>
|
||||||
|
//#include "PowerManagement.h"
|
||||||
|
#include "UserInput.h"
|
||||||
|
#include "UserIndication.h"
|
||||||
|
#include "SpiPorts.h"
|
||||||
|
#include "PowerManagment.h"
|
||||||
|
//#include "PowerManagment.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tBipLed led;
|
||||||
|
tUserInputPins buttons;
|
||||||
|
tGpioPin Backlight;
|
||||||
|
tGpioPin Power;
|
||||||
|
tGpioPin Diagnost;
|
||||||
|
uint16_t lastTestTime;
|
||||||
|
} tBipPins;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tAccelPins accel;
|
||||||
|
tFlashPins flash;
|
||||||
|
tOnBoardLed onBoardLed;
|
||||||
|
tBipPins bip;
|
||||||
|
tRs485DirectionPins comIntDir;
|
||||||
|
|
||||||
|
tPowerSusystem powerSusystem;
|
||||||
|
} tGpios;
|
||||||
|
|
||||||
|
extern tGpios GPIOS;
|
||||||
|
|
||||||
|
void Gpios_Init();
|
||||||
|
void Gpios_CanStandby(tCanStandby *env);
|
||||||
|
|
||||||
|
#endif //SMART_COMPONENTS_GPIOS_H
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"cmake": {
|
||||||
|
"inc_dirs": [
|
||||||
|
"./"
|
||||||
|
],
|
||||||
|
"srcs": [
|
||||||
|
"./**.c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue