добавлен led при отправке по can
This commit is contained in:
@@ -59,6 +59,9 @@ void wait_exact_ticks(uint16_t target_ticks) {
|
||||
|
||||
void CANEmu_SendFrame(CANEmu_HandleTypeDef *canemu) {
|
||||
if (canemu->bitrate_bps == 0) return;
|
||||
#ifdef LED_WORKING
|
||||
LED_WORKING(1);
|
||||
#endif
|
||||
|
||||
form_CAN_bitstream_full(&canemu->header, canemu->data, canemu->errors);
|
||||
|
||||
@@ -80,6 +83,9 @@ void CANEmu_SendFrame(CANEmu_HandleTypeDef *canemu) {
|
||||
|
||||
can_tx_set_1(); // Завершаем линию
|
||||
__enable_irq();
|
||||
#ifdef LED_WORKING
|
||||
LED_WORKING(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
#define CANEMU_TIM_US_TICKS 72 // Для 1 мкс при 72 МГц
|
||||
#define CANEMU_TIM_CLOCK_HZ 72000000UL // частота таймера
|
||||
#define CAN_MIN_PERIOD 20
|
||||
#define LED_WORKING(on_off) \
|
||||
do { \
|
||||
if (!on_off) GPIOC->ODR |= (1U << 13); \
|
||||
else GPIOC->ODR &= ~(1U << 13); \
|
||||
} while (0)
|
||||
// === Макросы управления GPIO ===
|
||||
|
||||
#define can_tx_set_1() (CANEMU_TX_GPIO_PORT->BSRR = (1U << CANEMU_TX_GPIO_PIN))
|
||||
|
||||
@@ -50,9 +50,19 @@ void MX_GPIO_Init(void)
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : PC13 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PB0 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
|
||||
Reference in New Issue
Block a user