Обновление
This commit is contained in:
parent
6101d47316
commit
a5219d9971
339
Lins.c
339
Lins.c
|
|
@ -8,6 +8,12 @@
|
||||||
|
|
||||||
tLinPorts LIN_PORTS;
|
tLinPorts LIN_PORTS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//начало--------------------------LIN 1-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 1-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 1-------------------------------------------------
|
||||||
|
|
||||||
#define numOfClassicPID 20
|
#define numOfClassicPID 20
|
||||||
|
|
||||||
const uint8_t classicPID[numOfClassicPID] = {
|
const uint8_t classicPID[numOfClassicPID] = {
|
||||||
|
|
@ -33,16 +39,15 @@ const uint8_t classicPID[numOfClassicPID] = {
|
||||||
RFR_IDE
|
RFR_IDE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void Lin1CallbackHandler(uint8_t u8LinIndex, void *state) {
|
||||||
static void Lin0CallbackHandler(uint8_t u8LinIndex, void *state) {
|
LIN_PORTS.lin1.LinExtCallbackHandler(LIN_PORTS.lin1.envCallExtBack, u8LinIndex, state);
|
||||||
LIN_PORTS.lin0.LinExtCallbackHandler(LIN_PORTS.lin0.envCallExtBack, u8LinIndex, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FCUART4_RxTx_IRQHandler(void) {
|
void FCUART4_RxTx_IRQHandler(void) {
|
||||||
LIN_DrvIRQHandler(LIN_PORTS.lin0.UART_INDEX);
|
LIN_DrvIRQHandler(LIN_PORTS.lin1.UART_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
tLinData *Lin0_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
tLinData *Lin1_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
||||||
|
|
||||||
tLinPorts *env = &LIN_PORTS;
|
tLinPorts *env = &LIN_PORTS;
|
||||||
|
|
||||||
|
|
@ -81,7 +86,7 @@ tLinData *Lin0_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
||||||
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
LIN_Initial(
|
LIN_Initial(
|
||||||
&env->lin0,
|
&env->lin1,
|
||||||
FCUART4,
|
FCUART4,
|
||||||
9600,
|
9600,
|
||||||
|
|
||||||
|
|
@ -90,16 +95,330 @@ tLinData *Lin0_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
||||||
0xFF,
|
0xFF,
|
||||||
|
|
||||||
NULL,
|
NULL,
|
||||||
Lin0CallbackHandler,
|
Lin1CallbackHandler,
|
||||||
Lin_ExtCallbackHandler,
|
Lin_ExtCallbackHandler,
|
||||||
&env->lin0.linData,
|
&env->lin1.linData,
|
||||||
|
|
||||||
classicPID,
|
classicPID,
|
||||||
numOfClassicPID
|
numOfClassicPID
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
env->lin0_Io = vLinGetIo(&env->lin0);
|
env->lin1_Io = vLinGetIo(&env->lin1);
|
||||||
|
|
||||||
return &env->lin0.linData;
|
return &env->lin1.linData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//конец--------------------------LIN 1-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 1-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 1-------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//начало--------------------------LIN 2-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 2-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 2-------------------------------------------------
|
||||||
|
static void Lin2CallbackHandler(uint8_t u8LinIndex, void *state) {
|
||||||
|
LIN_PORTS.lin2.LinExtCallbackHandler(LIN_PORTS.lin2.envCallExtBack, u8LinIndex, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCUART5_RxTx_IRQHandler(void) {
|
||||||
|
LIN_DrvIRQHandler(LIN_PORTS.lin2.UART_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
tLinData *Lin2_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
||||||
|
|
||||||
|
tLinPorts *env = &LIN_PORTS;
|
||||||
|
|
||||||
|
PORT_InitType tInitStruct = {0};
|
||||||
|
GPIO_InitType tGpioInitStruct = {0};
|
||||||
|
|
||||||
|
// Port C16: MUX = ALT7, UART5_RX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_16;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTC_16_FCUART5_RX;
|
||||||
|
tInitStruct.bPullEn = true;
|
||||||
|
tInitStruct.ePullSel = PORT_PULL_UP;
|
||||||
|
PORT_InitPins(PORT_C, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_16;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_IN;
|
||||||
|
GPIO_InitPins(GPIO_C, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port C15: MUX = ALT7, UART5_TX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_15;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTC_15_FCUART5_TX;
|
||||||
|
PORT_InitPins(PORT_C, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_15;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_C, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port D19: MUX = GPIO output ENABLE
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_19;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_GPIO_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_19;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
|
LIN_Initial(
|
||||||
|
&env->lin2,
|
||||||
|
FCUART5,
|
||||||
|
9600,
|
||||||
|
|
||||||
|
5, // UART0 = 0 ... UART7 = 7
|
||||||
|
FCUART5_IRQn, // FCUART0_IRQn ... FCUART7_IRQn
|
||||||
|
0xFF,
|
||||||
|
|
||||||
|
NULL,
|
||||||
|
Lin2CallbackHandler,
|
||||||
|
Lin_ExtCallbackHandler,
|
||||||
|
&env->lin2.linData,
|
||||||
|
|
||||||
|
classicPID,
|
||||||
|
numOfClassicPID
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
env->lin2_Io = vLinGetIo(&env->lin2);
|
||||||
|
|
||||||
|
return &env->lin2.linData;
|
||||||
|
}
|
||||||
|
|
||||||
|
//конец--------------------------LIN 2-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 2-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 2-------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//начало--------------------------LIN 3-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 3-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 3-------------------------------------------------
|
||||||
|
static void Lin3CallbackHandler(uint8_t u8LinIndex, void *state) {
|
||||||
|
LIN_PORTS.lin3.LinExtCallbackHandler(LIN_PORTS.lin3.envCallExtBack, u8LinIndex, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCUART3_RxTx_IRQHandler(void) {
|
||||||
|
LIN_DrvIRQHandler(LIN_PORTS.lin3.UART_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
tLinData *Lin3_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
||||||
|
|
||||||
|
tLinPorts *env = &LIN_PORTS;
|
||||||
|
|
||||||
|
PORT_InitType tInitStruct = {0};
|
||||||
|
GPIO_InitType tGpioInitStruct = {0};
|
||||||
|
|
||||||
|
// Port D9: MUX = ALT7, UART3_RX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_9;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTD_9_FCUART3_RX;
|
||||||
|
tInitStruct.bPullEn = true;
|
||||||
|
tInitStruct.ePullSel = PORT_PULL_UP;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_9;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_IN;
|
||||||
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port C1: MUX = ALT7, UART3_TX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_1;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTC_1_FCUART3_TX;
|
||||||
|
PORT_InitPins(PORT_C, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_1;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_C, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port D20: MUX = GPIO output ENABLE
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_20;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_GPIO_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_20;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
|
LIN_Initial(
|
||||||
|
&env->lin3,
|
||||||
|
FCUART3,
|
||||||
|
9600,
|
||||||
|
|
||||||
|
3, // UART0 = 0 ... UART7 = 7
|
||||||
|
FCUART3_IRQn, // FCUART0_IRQn ... FCUART7_IRQn
|
||||||
|
0xFF,
|
||||||
|
|
||||||
|
NULL,
|
||||||
|
Lin3CallbackHandler,
|
||||||
|
Lin_ExtCallbackHandler,
|
||||||
|
&env->lin3.linData,
|
||||||
|
|
||||||
|
classicPID,
|
||||||
|
numOfClassicPID
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
env->lin3_Io = vLinGetIo(&env->lin3);
|
||||||
|
|
||||||
|
return &env->lin3.linData;
|
||||||
|
}
|
||||||
|
|
||||||
|
//конец--------------------------LIN 3-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 3-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 3-------------------------------------------------
|
||||||
|
|
||||||
|
//начало--------------------------LIN 4-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 4-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 4-------------------------------------------------
|
||||||
|
static void Lin4CallbackHandler(uint8_t u8LinIndex, void *state) {
|
||||||
|
LIN_PORTS.lin4.LinExtCallbackHandler(LIN_PORTS.lin4.envCallExtBack, u8LinIndex, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCUART2_RxTx_IRQHandler(void) {
|
||||||
|
LIN_DrvIRQHandler(LIN_PORTS.lin4.UART_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
tLinData *Lin4_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
||||||
|
|
||||||
|
tLinPorts *env = &LIN_PORTS;
|
||||||
|
|
||||||
|
PORT_InitType tInitStruct = {0};
|
||||||
|
GPIO_InitType tGpioInitStruct = {0};
|
||||||
|
|
||||||
|
// Port D6: MUX = ALT2, UART2_RX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_6;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTD_6_FCUART2_RX;
|
||||||
|
tInitStruct.bPullEn = true;
|
||||||
|
tInitStruct.ePullSel = PORT_PULL_UP;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_6;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_IN;
|
||||||
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port D7: MUX = ALT2, UART2_TX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_7;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTD_7_FCUART2_TX;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_7;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port D8: MUX = GPIO output ENABLE
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_8;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_GPIO_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_8;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
|
LIN_Initial(
|
||||||
|
&env->lin4,
|
||||||
|
FCUART2,
|
||||||
|
9600,
|
||||||
|
|
||||||
|
2, // UART0 = 0 ... UART7 = 7
|
||||||
|
FCUART2_IRQn, // FCUART0_IRQn ... FCUART7_IRQn
|
||||||
|
0xFF,
|
||||||
|
|
||||||
|
NULL,
|
||||||
|
Lin4CallbackHandler,
|
||||||
|
Lin_ExtCallbackHandler,
|
||||||
|
&env->lin4.linData,
|
||||||
|
|
||||||
|
classicPID,
|
||||||
|
numOfClassicPID
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
env->lin4_Io = vLinGetIo(&env->lin4);
|
||||||
|
|
||||||
|
return &env->lin4.linData;
|
||||||
|
}
|
||||||
|
|
||||||
|
//конец--------------------------LIN 4-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 4-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 4-------------------------------------------------
|
||||||
|
|
||||||
|
//начало--------------------------LIN 5-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 5-------------------------------------------------
|
||||||
|
//начало--------------------------LIN 5-------------------------------------------------
|
||||||
|
static void Lin5CallbackHandler(uint8_t u8LinIndex, void *state) {
|
||||||
|
LIN_PORTS.lin5.LinExtCallbackHandler(LIN_PORTS.lin5.envCallExtBack, u8LinIndex, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCUART0_RxTx_IRQHandler(void) {
|
||||||
|
LIN_DrvIRQHandler(LIN_PORTS.lin5.UART_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
tLinData *Lin5_Init(lin_callback_ext_t Lin_ExtCallbackHandler) {
|
||||||
|
|
||||||
|
tLinPorts *env = &LIN_PORTS;
|
||||||
|
|
||||||
|
PORT_InitType tInitStruct = {0};
|
||||||
|
GPIO_InitType tGpioInitStruct = {0};
|
||||||
|
|
||||||
|
// Port A2: MUX = ALT6, UART0_RX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_2;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTA_2_FCUART0_RX;
|
||||||
|
tInitStruct.bPullEn = true;
|
||||||
|
tInitStruct.ePullSel = PORT_PULL_UP;
|
||||||
|
PORT_InitPins(PORT_A, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_2;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_IN;
|
||||||
|
GPIO_InitPins(GPIO_A, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port A3: MUX = ALT6, UART0_TX
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_3;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTA_3_FCUART0_TX;
|
||||||
|
PORT_InitPins(PORT_A, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_3;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_A, &tGpioInitStruct);
|
||||||
|
|
||||||
|
// Port D8: MUX = GPIO output ENABLE
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_8;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_GPIO_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
tGpioInitStruct.u32GpioPins = GPIO_PIN_8;
|
||||||
|
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||||
|
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||||
|
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||||
|
|
||||||
|
LIN_Initial(
|
||||||
|
&env->lin5,
|
||||||
|
FCUART0,
|
||||||
|
9600,
|
||||||
|
|
||||||
|
0, // UART0 = 0 ... UART7 = 7
|
||||||
|
FCUART0_IRQn, // FCUART0_IRQn ... FCUART7_IRQn
|
||||||
|
0xFF,
|
||||||
|
|
||||||
|
NULL,
|
||||||
|
Lin5CallbackHandler,
|
||||||
|
Lin_ExtCallbackHandler,
|
||||||
|
&env->lin5.linData,
|
||||||
|
|
||||||
|
classicPID,
|
||||||
|
numOfClassicPID
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
env->lin5_Io = vLinGetIo(&env->lin5);
|
||||||
|
|
||||||
|
return &env->lin5.linData;
|
||||||
|
}
|
||||||
|
|
||||||
|
//конец--------------------------LIN 5-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 5-------------------------------------------------
|
||||||
|
//конец--------------------------LIN 5-------------------------------------------------
|
||||||
23
Lins.h
23
Lins.h
|
|
@ -36,12 +36,29 @@
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
tLinFlagchip lin0;
|
tLinFlagchip lin1;
|
||||||
tLinIO lin0_Io;
|
tLinIO lin1_Io;
|
||||||
|
|
||||||
|
tLinFlagchip lin2;
|
||||||
|
tLinIO lin2_Io;
|
||||||
|
|
||||||
|
tLinFlagchip lin3;
|
||||||
|
tLinIO lin3_Io;
|
||||||
|
|
||||||
|
tLinFlagchip lin4;
|
||||||
|
tLinIO lin4_Io;
|
||||||
|
|
||||||
|
tLinFlagchip lin5;
|
||||||
|
tLinIO lin5_Io;
|
||||||
|
|
||||||
} tLinPorts;
|
} tLinPorts;
|
||||||
|
|
||||||
extern tLinPorts LIN_PORTS;
|
extern tLinPorts LIN_PORTS;
|
||||||
|
|
||||||
tLinData* Lin0_Init(lin_callback_ext_t Lin_ExtCallbackHandler);
|
tLinData *Lin1_Init(lin_callback_ext_t Lin_ExtCallbackHandler);
|
||||||
|
tLinData *Lin2_Init(lin_callback_ext_t Lin_ExtCallbackHandler);
|
||||||
|
tLinData *Lin3_Init(lin_callback_ext_t Lin_ExtCallbackHandler);
|
||||||
|
tLinData *Lin4_Init(lin_callback_ext_t Lin_ExtCallbackHandler);
|
||||||
|
tLinData *Lin5_Init(lin_callback_ext_t Lin_ExtCallbackHandler);
|
||||||
|
|
||||||
#endif //FLAG_LINS_H
|
#endif //FLAG_LINS_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue