mirror of
https://github.com/candle-usb/candleLight_fw.git
synced 2025-01-28 06:02:52 +08:00
Add new boardtype : cannette
F042-based, galvanically isolated.
This commit is contained in:
parent
2416f260bb
commit
9cf7eccf3d
@ -96,7 +96,7 @@ endfunction()
|
||||
|
||||
########## generate list of targets.
|
||||
# the "_fw" part is appended automatically
|
||||
set(TGT042_LIST "cantact" "canalyze" "canable" "usb2can")
|
||||
set(TGT042_LIST "cantact" "canalyze" "canable" "usb2can" "cannette")
|
||||
set(TGT072_LIST "candleLight")
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ THE SOFTWARE.
|
||||
#define BOARD_canable 3
|
||||
#define BOARD_usb2can 4
|
||||
#define BOARD_canalyze 5
|
||||
#define BOARD_cannette 6
|
||||
|
||||
#if BOARD == BOARD_candleLight
|
||||
#define USBD_PRODUCT_STRING_FS (uint8_t*) "candleLight USB to CAN adapter"
|
||||
@ -133,6 +134,32 @@ THE SOFTWARE.
|
||||
#define LED2_Pin GPIO_PIN_1 /* red */
|
||||
#define LED2_Mode GPIO_MODE_OUTPUT_PP
|
||||
#define LED2_Active_High 1
|
||||
|
||||
#elif BOARD == BOARD_cannette
|
||||
#define USBD_PRODUCT_STRING_FS (uint8_t*) "cannette gs_usb"
|
||||
#define USBD_MANUFACTURER_STRING (uint8_t*) "chacaltech"
|
||||
#define DFU_INTERFACE_STRING_FS (uint8_t*) "cannette firmware upgrade interface"
|
||||
|
||||
// SILENT pin not connected
|
||||
|
||||
#define LED1_GPIO_Port GPIOA
|
||||
#define LED1_Pin GPIO_PIN_9 /* RX: green */
|
||||
#define LED1_Mode GPIO_MODE_OUTPUT_OD
|
||||
#define LED1_Active_High 0
|
||||
|
||||
#define LED2_GPIO_Port GPIOA
|
||||
#define LED2_Pin GPIO_PIN_8 /* TX: red */
|
||||
#define LED2_Mode GPIO_MODE_OUTPUT_OD
|
||||
#define LED2_Active_High 0
|
||||
|
||||
#define nCANSTBY_Port GPIOC
|
||||
#define nCANSTBY_Pin GPIO_PIN_14 /* control xceiver standby, active low */
|
||||
|
||||
#define nSI86EN_Port GPIOC
|
||||
#define nSI86EN_Pin GPIO_PIN_13 /* enable power to Si86xx isolater, active low */
|
||||
|
||||
#define DCDCEN_Port GPIOC
|
||||
#define DCDCEN_Pin GPIO_PIN_15 /* activate DCDC converter, active high */
|
||||
#else
|
||||
#error please define BOARD
|
||||
#endif
|
||||
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "can.h"
|
||||
#include "config.h"
|
||||
|
||||
void can_init(can_data_t *hcan, CAN_TypeDef *instance)
|
||||
{
|
||||
@ -104,11 +105,18 @@ void can_enable(can_data_t *hcan, bool loop_back, bool listen_only, bool one_sho
|
||||
can->FFA1R &= ~filter_bit; // assign filter 0 to FIFO 0
|
||||
can->FA1R |= filter_bit; // enable filter
|
||||
can->FMR &= ~CAN_FMR_FINIT;
|
||||
|
||||
#ifdef nCANSTBY_Pin
|
||||
HAL_GPIO_WritePin(nCANSTBY_Port, nCANSTBY_Pin, GPIO_PIN_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
void can_disable(can_data_t *hcan)
|
||||
{
|
||||
CAN_TypeDef *can = hcan->instance;
|
||||
#ifdef nCANSTBY_Pin
|
||||
HAL_GPIO_WritePin(nCANSTBY_Port, nCANSTBY_Pin, GPIO_PIN_RESET);
|
||||
#endif
|
||||
can->MCR |= CAN_MCR_INRQ ; // send can controller into initialization mode
|
||||
}
|
||||
|
||||
|
25
src/gpio.c
25
src/gpio.c
@ -27,6 +27,7 @@ THE SOFTWARE.
|
||||
#include "config.h"
|
||||
#include "stm32f0xx_hal.h"
|
||||
|
||||
//must run before can_init
|
||||
void gpio_init()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
@ -65,4 +66,28 @@ void gpio_init()
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(LED2_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
#if BOARD == BOARD_cannette
|
||||
HAL_GPIO_WritePin(nCANSTBY_Port, nCANSTBY_Pin, GPIO_PIN_RESET);
|
||||
GPIO_InitStruct.Pin = nCANSTBY_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(nCANSTBY_Port, &GPIO_InitStruct); //xceiver standby.
|
||||
|
||||
HAL_GPIO_WritePin(DCDCEN_Port, DCDCEN_Pin, GPIO_PIN_SET);
|
||||
GPIO_InitStruct.Pin = DCDCEN_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(DCDCEN_Port, &GPIO_InitStruct); //start DCDC (TODO : wait until enumerated)
|
||||
|
||||
HAL_GPIO_WritePin(nSI86EN_Port, nSI86EN_Pin, GPIO_PIN_RESET);
|
||||
GPIO_InitStruct.Pin = nSI86EN_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(nSI86EN_Port, &GPIO_InitStruct); //enable si86
|
||||
|
||||
#endif // BOARD_cannette
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user