mirror of
https://github.com/candle-usb/candleLight_fw.git
synced 2025-01-28 06:02:52 +08:00
bxcan: move CAN_btconst to CAN driver
This commit is contained in:
parent
206de0067a
commit
ad72111d65
@ -46,6 +46,8 @@ typedef struct {
|
|||||||
uint8_t nr;
|
uint8_t nr;
|
||||||
} can_data_t;
|
} can_data_t;
|
||||||
|
|
||||||
|
extern const struct gs_device_bt_const CAN_btconst;
|
||||||
|
|
||||||
void can_init(can_data_t *channel, CAN_TypeDef *instance);
|
void can_init(can_data_t *channel, CAN_TypeDef *instance);
|
||||||
bool can_set_bittiming(can_data_t *channel, uint16_t brp, uint8_t phase_seg1, uint8_t phase_seg2, uint8_t sjw);
|
bool can_set_bittiming(can_data_t *channel, uint16_t brp, uint8_t phase_seg1, uint8_t phase_seg2, uint8_t sjw);
|
||||||
void can_enable(can_data_t *channel, uint32_t mode);
|
void can_enable(can_data_t *channel, uint32_t mode);
|
||||||
|
@ -32,6 +32,28 @@
|
|||||||
#include "hal_include.h"
|
#include "hal_include.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
|
const struct gs_device_bt_const CAN_btconst = {
|
||||||
|
.feature =
|
||||||
|
GS_CAN_FEATURE_LISTEN_ONLY |
|
||||||
|
GS_CAN_FEATURE_LOOP_BACK |
|
||||||
|
GS_CAN_FEATURE_HW_TIMESTAMP |
|
||||||
|
GS_CAN_FEATURE_IDENTIFY |
|
||||||
|
GS_CAN_FEATURE_PAD_PKTS_TO_MAX_PKT_SIZE
|
||||||
|
#ifdef TERM_Pin
|
||||||
|
| GS_CAN_FEATURE_TERMINATION
|
||||||
|
#endif
|
||||||
|
,
|
||||||
|
.fclk_can = CAN_CLOCK_SPEED,
|
||||||
|
.tseg1_min = 1,
|
||||||
|
.tseg1_max = 16,
|
||||||
|
.tseg2_min = 1,
|
||||||
|
.tseg2_max = 8,
|
||||||
|
.sjw_max = 4,
|
||||||
|
.brp_min = 1,
|
||||||
|
.brp_max = 1024,
|
||||||
|
.brp_inc = 1,
|
||||||
|
};
|
||||||
|
|
||||||
// The STM32F0 only has one CAN interface, define it as CAN1 as
|
// The STM32F0 only has one CAN interface, define it as CAN1 as
|
||||||
// well, so it doesn't need to be handled separately.
|
// well, so it doesn't need to be handled separately.
|
||||||
#if !defined(CAN1) && defined(CAN)
|
#if !defined(CAN1) && defined(CAN)
|
||||||
|
@ -213,29 +213,6 @@ static const struct gs_device_config USBD_GS_CAN_dconf = {
|
|||||||
.hw_version = 1,
|
.hw_version = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// bit timing constraints
|
|
||||||
static const struct gs_device_bt_const USBD_GS_CAN_btconst = {
|
|
||||||
.feature =
|
|
||||||
GS_CAN_FEATURE_LISTEN_ONLY |
|
|
||||||
GS_CAN_FEATURE_LOOP_BACK |
|
|
||||||
GS_CAN_FEATURE_HW_TIMESTAMP |
|
|
||||||
GS_CAN_FEATURE_IDENTIFY |
|
|
||||||
GS_CAN_FEATURE_PAD_PKTS_TO_MAX_PKT_SIZE
|
|
||||||
#ifdef TERM_Pin
|
|
||||||
| GS_CAN_FEATURE_TERMINATION
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
.fclk_can = CAN_CLOCK_SPEED,
|
|
||||||
.tseg1_min = 1,
|
|
||||||
.tseg1_max = 16,
|
|
||||||
.tseg2_min = 1,
|
|
||||||
.tseg2_max = 8,
|
|
||||||
.sjw_max = 4,
|
|
||||||
.brp_min = 1,
|
|
||||||
.brp_max = 1024,
|
|
||||||
.brp_inc = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* It's unclear from the documentation, but it appears that the USB library is
|
/* It's unclear from the documentation, but it appears that the USB library is
|
||||||
* not safely reentrant. It attempts to signal errors via return values if it is
|
* not safely reentrant. It attempts to signal errors via return values if it is
|
||||||
* reentered, but that code is not interrupt-safe and the error values are
|
* reentered, but that code is not interrupt-safe and the error values are
|
||||||
@ -357,8 +334,8 @@ static uint8_t USBD_GS_CAN_Config_Request(USBD_HandleTypeDef *pdev, USBD_SetupRe
|
|||||||
len = sizeof(struct gs_device_mode);
|
len = sizeof(struct gs_device_mode);
|
||||||
break;
|
break;
|
||||||
case GS_USB_BREQ_BT_CONST:
|
case GS_USB_BREQ_BT_CONST:
|
||||||
src = &USBD_GS_CAN_btconst;
|
src = &CAN_btconst;
|
||||||
len = sizeof(USBD_GS_CAN_btconst);
|
len = sizeof(CAN_btconst);
|
||||||
break;
|
break;
|
||||||
case GS_USB_BREQ_DEVICE_CONFIG:
|
case GS_USB_BREQ_DEVICE_CONFIG:
|
||||||
src = &USBD_GS_CAN_dconf;
|
src = &USBD_GS_CAN_dconf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user