Skip to content

Commit

Permalink
correct LED initialization for canable interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nexulm authored and fenugrec committed Nov 5, 2019
1 parent 9003f5e commit 89c44fe
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
58 changes: 51 additions & 7 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ THE SOFTWARE.
#define USBD_VID 0x1d50
#define USBD_PID_FS 0x606f
#define USBD_LANGID_STRING 1033
#define USBD_MANUFACTURER_STRING (uint8_t*) "bytewerk"
#define USBD_CONFIGURATION_STRING_FS (uint8_t*) "gs_usb config"
#define USBD_INTERFACE_STRING_FS (uint8_t*) "gs_usb interface"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "candleLight firmware upgrade interface"

#define BOARD_candleLight 1
#define BOARD_cantact 2
#define BOARD_canable 3
#define BOARD_usb2can 4

#if BOARD == BOARD_candleLight
#define USBD_PRODUCT_STRING_FS (uint8_t*) "candleLight USB to CAN adapter"

#define USBD_PRODUCT_STRING_FS (uint8_t*) "candleLight USB to CAN adapter"
#define USBD_MANUFACTURER_STRING (uint8_t*) "bytewerk"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "candleLight firmware upgrade interface"
#define CAN_S_Pin GPIO_PIN_13
#define CAN_S_GPIO_Port GPIOC

Expand All @@ -56,18 +57,61 @@ THE SOFTWARE.
#define LED2_Active_Low

#elif BOARD == BOARD_cantact
#define USBD_PRODUCT_STRING_FS (uint8_t*) "cantact gs_usb"
#define USBD_PRODUCT_STRING_FS (uint8_t*) "cantact gs_usb"
#define USBD_MANUFACTURER_STRING (uint8_t*) "cantact.io"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "cantact firmware upgrade interface"

// SILENT pin not connected

#define LED1_GPIO_Port GPIOB
#define LED1_Pin GPIO_PIN_0
#define LED1_Pin GPIO_PIN_0 /* green */
#define LED1_Mode GPIO_MODE_OUTPUT_PP

#define LED2_GPIO_Port GPIOB
#define LED2_Pin GPIO_PIN_1
#define LED2_Pin GPIO_PIN_1 /* red */
#define LED2_Mode GPIO_MODE_OUTPUT_PP

#elif BOARD == BOARD_canable
#define USBD_PRODUCT_STRING_FS (uint8_t*) "canable gs_usb"
#define USBD_MANUFACTURER_STRING (uint8_t*) "canable.io"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "canble firmware upgrade interface"

// SILENT pin not connected

#define LED1_GPIO_Port GPIOB
#define LED1_Pin GPIO_PIN_0 /* green */
#define LED1_Mode GPIO_MODE_OUTPUT_PP

#define LED2_GPIO_Port GPIOB
#define LED2_Pin GPIO_PIN_1 /* blue */
#define LED2_Mode GPIO_MODE_OUTPUT_PP

#elif BOARD == BOARD_usb2can
#define USBD_PRODUCT_STRING_FS (uint8_t*) "USB2CAN RCA gs_usb"
#define USBD_MANUFACTURER_STRING (uint8_t*) "Roboter Club Aachen"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "usb2can firmware upgrade interface"

// SILENT pin not connected

#define LED4_GPIO_Port GPIOA
#define LED4_Pin GPIO_PIN_0 /* white */
#define LED4_Mode GPIO_MODE_OUTPUT_OD
#define LED4_Active_Low

#define LED2_GPIO_Port GPIOA
#define LED2_Pin GPIO_PIN_1 /* blue */
#define LED2_Mode GPIO_MODE_OUTPUT_OD
#define LED2_Active_Low

#define LED3_GPIO_Port GPIOA
#define LED3_Pin GPIO_PIN_2 /* red */
#define LED3_Mode GPIO_MODE_OUTPUT_OD
#define LED3_Active_Low

#define LED1_GPIO_Port GPIOB
#define LED1_Pin GPIO_PIN_3 /* green */
#define LED1_Mode GPIO_MODE_OUTPUT_OD
#define LED1_Active_Low
#else
#error please define BOARD
#endif
1 change: 1 addition & 0 deletions src/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static void led_set(led_state_t *led, bool state)
if (!led->is_active_high) {
state = !state;
}

HAL_GPIO_WritePin(led->port, led->pin, state ? GPIO_PIN_SET : GPIO_PIN_RESET);
}

Expand Down
5 changes: 4 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ int main(void)

gpio_init();

#if BOARD == BOARD_canable
led_init(&hLED, LED1_GPIO_Port, LED1_Pin, true, LED2_GPIO_Port, LED2_Pin, true);
#else
led_init(&hLED, LED1_GPIO_Port, LED1_Pin, false, LED2_GPIO_Port, LED2_Pin, false);
#endif
led_set_mode(&hLED, led_mode_off);

timer_init();

can_init(&hCAN, CAN);
Expand Down

0 comments on commit 89c44fe

Please sign in to comment.