From 86302c65cc0989b2a57701be4b7d24c11a4e96ab Mon Sep 17 00:00:00 2001 From: brentfpage Date: Thu, 29 Jan 2026 23:48:36 -0800 Subject: [PATCH 1/2] AVR_Code src edits that allow the firmware to be compiled using a Makefile --- .../USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c | 4 ++-- .../USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c | 2 +- AVR_Code/USB_BULK_TEST/src/tiny_calibration.c | 4 +++- AVR_Code/USB_BULK_TEST/src/tiny_calibration.h | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c b/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c index 123928a27..bdb4bfb32 100644 --- a/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c +++ b/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c @@ -1102,7 +1102,7 @@ static bool udc_reqvend(void){ uds.calValPos = cali_value_positive_gradient; uds.CALA = DFLLRC2M.CALA; uds.CALB = DFLLRC2M.CALB; - udd_set_setup_payload(&uds, udd_g_ctrlreq.req.wLength); + udd_set_setup_payload((uint8_t *) &uds, udd_g_ctrlreq.req.wLength); //asm("nop"); return 1; case 0xa1: //Receive waveform for signal gen @@ -1212,7 +1212,7 @@ static bool udc_reqvend(void){ : "memory"); __builtin_unreachable(); case 0xa8: //Firmware Version Request - udd_set_setup_payload(&firmver, udd_g_ctrlreq.req.wLength); + udd_set_setup_payload((uint8_t *) &firmver, udd_g_ctrlreq.req.wLength); return 1; case 0xa9: //Variant Version Request udd_set_setup_payload(&variant, udd_g_ctrlreq.req.wLength); diff --git a/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c b/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c index a0b77ded8..5d21fd567 100644 --- a/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c +++ b/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c @@ -249,7 +249,7 @@ static UDD_EP_t *udd_ep_get_ctrl(udd_ep_id_t ep); //@{ //! Global variable to give and record information about setup request management -udd_ctrl_request_t udd_g_ctrlreq; +extern udd_ctrl_request_t udd_g_ctrlreq; //! Bit definitions about endpoint control state machine for udd_ep_control_state typedef enum { diff --git a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c index a1ac1c4c9..64374af8a 100644 --- a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c +++ b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c @@ -10,6 +10,8 @@ #include "tiny_adc.h" volatile unsigned char median_TRFCNT_delay = 255; +volatile unsigned char cali_value_positive_gradient; +volatile unsigned char cali_value_negative_gradient; void tiny_calibration_init(){ //Set up 48MHz DFLL for USB. @@ -46,7 +48,7 @@ void tiny_calibration_init(){ return; } -tiny_calibration_first_sof(){ +void tiny_calibration_first_sof(){ PR.PRPE &= 0b11111110; TC_CALI.PER = 23999; TC_CALI.CNT = 12000; diff --git a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h index edd9e0f35..1e580a9ad 100644 --- a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h +++ b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h @@ -25,8 +25,8 @@ void tiny_calibration_synchronise_phase(unsigned int phase, unsigned int precisi extern volatile unsigned char calibration_values_found; extern volatile unsigned char median_TRFCNT_delay; -volatile unsigned char cali_value_negative_gradient; -volatile unsigned char cali_value_positive_gradient; +extern volatile unsigned char cali_value_negative_gradient; +extern volatile unsigned char cali_value_positive_gradient; -#endif /* TINY_CALIBRATION_H_ */ \ No newline at end of file +#endif /* TINY_CALIBRATION_H_ */ From a445ef60f9e2a4d5fa2c19a8967edba5ac3ff8ba Mon Sep 17 00:00:00 2001 From: brentfpage Date: Thu, 5 Feb 2026 19:12:03 -0800 Subject: [PATCH 2/2] udd_g_ctrlreq: removed from main.c; removed extern declaration in usb_device.c --- AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c | 2 +- AVR_Code/USB_BULK_TEST/src/main.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c b/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c index 5d21fd567..a0b77ded8 100644 --- a/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c +++ b/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c @@ -249,7 +249,7 @@ static UDD_EP_t *udd_ep_get_ctrl(udd_ep_id_t ep); //@{ //! Global variable to give and record information about setup request management -extern udd_ctrl_request_t udd_g_ctrlreq; +udd_ctrl_request_t udd_g_ctrlreq; //! Bit definitions about endpoint control state machine for udd_ep_control_state typedef enum { diff --git a/AVR_Code/USB_BULK_TEST/src/main.c b/AVR_Code/USB_BULK_TEST/src/main.c index 70b7fbdd9..18f5f02d4 100644 --- a/AVR_Code/USB_BULK_TEST/src/main.c +++ b/AVR_Code/USB_BULK_TEST/src/main.c @@ -164,9 +164,6 @@ int main(void){ } } -//! Global variable to give and record information about setup request management -udd_ctrl_request_t udd_g_ctrlreq; - //CALLBACKS: void main_suspend_action(void) {