Explains how to communicate over the CAN bus.
#include <stm32f4xx.h>
#include <stdio.h>
#include <lcd.h>
#define LCD_STRING_LENGTH (LCD_HOR_RESOLUTION / FONT_MIN_WIDTH)
static __IO uint32_t TimingDelay;
void Delay(__IO uint32_t nTime) {
TimingDelay = nTime;
while (TimingDelay != 0);
}
void SysTick_Handler(void) {
if (TimingDelay) {
TimingDelay--;
}
}
int main(void) {
uint16_t counter = 0;
char LCDmsg[LCD_STRING_LENGTH];
uint8_t i;
if (SysTick_Config(SystemCoreClock / 1000)) {
while (1);
}
LCD_Init();
LCD_SetFont(&font_6x12);
while (1) {
counter++;
CANmsg.
data[1] = counter >> 8;
CANmsg.
data[0] = counter;
snprintf(LCDmsg, sizeof(LCDmsg),
"CAN Tx: ID=0x%04lX DLC=%d D0=0x%02X D1=0x%02X", CANmsg.
id,
LCD_Log_AddMsg(LCDmsg);
snprintf(LCDmsg, sizeof(LCDmsg), "CAN Rx: ID=0x%04lX DLC=%d",
for (i = 0; i < CANmsg.
dlc; i++) {
snprintf(LCDmsg, sizeof(LCDmsg), "%s D%1u=0x%02X", LCDmsg, i,
}
LCD_Log_AddMsg(LCDmsg);
}
Delay(2000);
}
return 0;
}