aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-06-12 11:55:46 -0400
committerKevin O'Connor <kevin@koconnor.net>2022-06-16 11:03:48 -0400
commitfc7838855f886383917076cee87b13938d8bbe40 (patch)
tree4266addc37bb5ebc80dd0da654fa8a79c371e34b /src/stm32
parent3f7d05dd18469927dff1cf5a7d35d67ec9fd7cdc (diff)
downloadkutter-fc7838855f886383917076cee87b13938d8bbe40.tar.gz
kutter-fc7838855f886383917076cee87b13938d8bbe40.tar.xz
kutter-fc7838855f886383917076cee87b13938d8bbe40.zip
canbus: Move canbus uuid calculation to canbus.c
Move the uuid hash calculation to canbus.c and call canbus_set_uuid() from src/stm32/chipid.c . This simplifies the low-level canbus hardware code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32')
-rw-r--r--src/stm32/Makefile2
-rw-r--r--src/stm32/can.c5
-rw-r--r--src/stm32/chipid.c10
-rwxr-xr-xsrc/stm32/fdcan.c5
4 files changed, 7 insertions, 15 deletions
diff --git a/src/stm32/Makefile b/src/stm32/Makefile
index 2f096369..fa662f91 100644
--- a/src/stm32/Makefile
+++ b/src/stm32/Makefile
@@ -62,7 +62,7 @@ src-$(CONFIG_SERIAL) += $(serial-src-y) generic/serial_irq.c
canbus-src-y := generic/canbus.c ../lib/fast-hash/fasthash.c
canbus-src-$(CONFIG_HAVE_STM32_CANBUS) += stm32/can.c
canbus-src-$(CONFIG_HAVE_STM32_FDCANBUS) += stm32/fdcan.c
-src-$(CONFIG_CANSERIAL) += $(canbus-src-y)
+src-$(CONFIG_CANSERIAL) += $(canbus-src-y) stm32/chipid.c
src-$(CONFIG_HAVE_GPIO_HARD_PWM) += stm32/hard_pwm.c
# Binary output file rules
diff --git a/src/stm32/can.c b/src/stm32/can.c
index 16623f4b..9cd72209 100644
--- a/src/stm32/can.c
+++ b/src/stm32/can.c
@@ -10,7 +10,6 @@
#include "autoconf.h" // CONFIG_MACH_STM32F1
#include "board/irq.h" // irq_disable
#include "command.h" // DECL_CONSTANT_STR
-#include "fasthash.h" // fasthash64
#include "generic/armcm_boot.h" // armcm_enable_irq
#include "generic/canbus.h" // canbus_notify_tx
#include "internal.h" // enable_pclock
@@ -272,9 +271,5 @@ can_init(void)
if (CAN_RX0_IRQn != CAN_TX_IRQn)
armcm_enable_irq(CAN_IRQHandler, CAN_TX_IRQn, 0);
SOC_CAN->IER = CAN_IER_FMPIE0;
-
- // Convert unique 96-bit chip id into 48 bit representation
- uint64_t hash = fasthash64((uint8_t*)UID_BASE, 12, 0xA16231A7);
- canbus_set_uuid(&hash);
}
DECL_INIT(can_init);
diff --git a/src/stm32/chipid.c b/src/stm32/chipid.c
index 73e27503..03517739 100644
--- a/src/stm32/chipid.c
+++ b/src/stm32/chipid.c
@@ -4,6 +4,7 @@
//
// This file may be distributed under the terms of the GNU GPLv3 license.
+#include "generic/canbus.h" // canbus_set_uuid
#include "generic/usb_cdc.h" // usb_fill_serial
#include "generic/usbstd.h" // usb_string_descriptor
#include "internal.h" // UID_BASE
@@ -25,9 +26,10 @@ usbserial_get_serialid(void)
void
chipid_init(void)
{
- if (!CONFIG_USB_SERIAL_NUMBER_CHIPID)
- return;
- usb_fill_serial(&cdc_chipid.desc, ARRAY_SIZE(cdc_chipid.data)
- , (void*)UID_BASE);
+ if (CONFIG_USB_SERIAL_NUMBER_CHIPID)
+ usb_fill_serial(&cdc_chipid.desc, ARRAY_SIZE(cdc_chipid.data)
+ , (void*)UID_BASE);
+ if (CONFIG_CANSERIAL)
+ canbus_set_uuid((void*)UID_BASE, CHIP_UID_LEN);
}
DECL_INIT(chipid_init);
diff --git a/src/stm32/fdcan.c b/src/stm32/fdcan.c
index 8a462f76..cf2cc276 100755
--- a/src/stm32/fdcan.c
+++ b/src/stm32/fdcan.c
@@ -10,7 +10,6 @@
#include "autoconf.h" // CONFIG_MACH_STM32F1
#include "board/irq.h" // irq_disable
#include "command.h" // DECL_CONSTANT_STR
-#include "fasthash.h" // fasthash64
#include "generic/armcm_boot.h" // armcm_enable_irq
#include "generic/canbus.h" // canbus_notify_tx
#include "generic/serial_irq.h" // serial_rx_byte
@@ -260,9 +259,5 @@ can_init(void)
armcm_enable_irq(CAN_IRQHandler, CAN_IT0_IRQn, 0);
SOC_CAN->ILE = FDCAN_ILE_EINT0;
SOC_CAN->IE = FDCAN_IE_RF0NE | FDCAN_IE_TC;
-
- // Convert unique 96-bit chip id into 48 bit representation
- uint64_t hash = fasthash64((uint8_t*)UID_BASE, 12, 0xA16231A7);
- canbus_set_uuid(&hash);
}
DECL_INIT(can_init);