STM32F769 CAN bus reciever
Dependencies: BSP_DISCO_F769NI
Revision 0:9ba764db8c0f, committed 2020-02-27
- Comitter:
- ruigao
- Date:
- Thu Feb 27 15:18:58 2020 +0000
- Commit message:
- 15KV_F769_CAN_rcv
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Feb 27 15:18:58 2020 +0000 @@ -0,0 +1,2 @@ +BUILD +mbed-os/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F769NI.lib Thu Feb 27 15:18:58 2020 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/teams/ST/code/BSP_DISCO_F769NI/#d13d7c447539
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 27 15:18:58 2020 +0000 @@ -0,0 +1,89 @@ +#include "mbed.h" +#include "stm32f769i_discovery.h" +#include "stm32f769i_discovery_ts.h" +#include "stm32f769i_discovery_lcd.h" + +TS_StateTypeDef TS_State = {0}; + +CAN can1(PB_8, PA_12); +int ct = 0; + + +int main() +{ + uint16_t x1, y1; + CANMessage msgRev; + can1.frequency(500000); + + char LCDbuf[3]; + + // printf("\n\n CAN BUS Reciver:\n"); + + BSP_LCD_Init(); + BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); + BSP_LCD_SelectLayer(0); + + /* Touchscreen initialization */ + if (BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()) == TS_ERROR) { + printf("BSP_TS_Init error\n"); + } + + /* Clear the LCD */ + BSP_LCD_Clear(LCD_COLOR_WHITE); + + /* Set Touchscreen Demo1 description */ + BSP_LCD_SetTextColor(LCD_COLOR_BLUE); + BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 200); + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); + BSP_LCD_SetFont(&Font24); + BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"CAN BUS READ", CENTER_MODE); + + printf("Start CAN BUS \r\n"); + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + BSP_LCD_SetBackColor(LCD_COLOR_WHITE); + // BSP_LCD_DisplayStringAt(0, 300, (uint8_t *)"CAN data", CENTER_MODE); + + while (1) { + + + if(can1.read(msgRev)) { + //printf("Message received: %d\r\n", msgRev.data[0]); + BSP_LCD_DisplayStringAt(100, 250, (uint8_t *)"Can Msg", CENTER_MODE); + + if (msgRev.id == 1330){ + //printf ("CAN %d, %d \r\n", msgRev.id, msgRev.data[0]); + sprintf(LCDbuf, "%d", msgRev.data[0]); + BSP_LCD_DisplayStringAt(100, 350, (uint8_t *)LCDbuf, LEFT_MODE); + + } + + if (msgRev.id == 1331){ + sprintf(LCDbuf, "%d", msgRev.data[0]); + BSP_LCD_DisplayStringAt(700, 350, (uint8_t *)LCDbuf, LEFT_MODE); + //printf ("CAN %d, %d \r\n", msgRev.id, msgRev.data[0]); + } + + + } + // BSP_LCD_DisplayStringAt(0, 350, (uint8_t *)ct, CENTER_MODE); + + +// BSP_TS_GetState(&TS_State); +// if (TS_State.touchDetected) { + /* One or dual touch have been detected */ + + /* Get X and Y position of the first touch post calibrated */ +// x1 = TS_State.touchX[0]; +// y1 = TS_State.touchY[0]; + //printf("Touch Detected x=%d y=%d\n", x1, y1); + + // BSP_LCD_SetTextColor(LCD_COLOR_BLUE); + // BSP_LCD_FillCircle(x1, y1, 20); + + // HAL_Delay(100); +// ct++; + wait_us(200); + // } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Feb 27 15:18:58 2020 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#699372421a3b388fe568e9be85b1a985749a438f