凌云物联网实验室ISKBoard(IoT Starter Kits Board)开发板项目源码
guowenxue
2023-04-07 6ddecc5e53def103eec427a61f2de308552735f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    can.h
  * @brief   This file contains all the function prototypes for
  *          the can.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CAN_H__
#define __CAN_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Includes ------------------------------------------------------------------*/
#include "main.h"
 
/* USER CODE BEGIN Includes */
#include "usart.h"
#include "ringbuf.h"
/* USER CODE END Includes */
 
extern CAN_HandleTypeDef hcan1;
 
/* USER CODE BEGIN Private defines */
typedef struct can_s
{
    int                            fd;/* compatible with Linux API, not used */
    ring_buffer_t               xRxBuffer; /* receive data ring buffer */
} can_t;
 
extern can_t can;
/* USER CODE END Private defines */
 
void MX_CAN1_Init(void);
 
/* USER CODE BEGIN Prototypes */
extern can_t *can_init(CAN_HandleTypeDef *hcan);
extern int can_send(can_t *pcan, char *data, int bytes);
extern int can_recv(can_t *pcan, char *buf, int size, uint32_t timeout);
extern void can_term(can_t *pcan);
/* USER CODE END Prototypes */
 
#ifdef __cplusplus
}
#endif
 
#endif /* __CAN_H__ */