From ec4b3e59cea9cabfb287ea82b952d0519f05e297 Mon Sep 17 00:00:00 2001 From: Jake Read <jake.read@cba.mit.edu> Date: Thu, 18 Nov 2021 16:29:00 -0500 Subject: [PATCH] d21 d51 bus align --- firmware/fab-step/src/config.h | 23 +++++++++++-- firmware/fab-step/src/indicators.h | 9 ++++++ firmware/fab-step/src/main.cpp | 52 ++++++++++++++++++++---------- firmware/fab-step/src/osape-d21 | 2 +- 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/firmware/fab-step/src/config.h b/firmware/fab-step/src/config.h index 53df0cd..160448f 100644 --- a/firmware/fab-step/src/config.h +++ b/firmware/fab-step/src/config.h @@ -1,3 +1,22 @@ -// head or drop on the bus +// compile-time configur8or +#ifndef CONFIG_H_ +#define CONFIG_H_ + +// for the bus: head, or drop? //#define UCBUS_IS_HEAD -#define UCBUS_IS_DROP \ No newline at end of file +// *genuine* max is 63 ! +#define UCBUS_MAX_DROPS 32 +#define UCBUS_IS_DROP +// and D21 or D51? +//#define UCBUS_IS_D51 +#define UCBUS_IS_D21 + +// 3, 2, or 1 MBaud: +#define UCBUS_BAUD 2 + +// if you're using the 'module board' https://gitlab.cba.mit.edu/jakeread/ucbus-module +// the first (og) revision has an SMT header, and some of the RS485 pins are varied, +// set this flag. otherwise, if you have thru-hole JTAG header, comment it out +//#define IS_OG_MODULE + +#endif \ No newline at end of file diff --git a/firmware/fab-step/src/indicators.h b/firmware/fab-step/src/indicators.h index 1668f6d..d26a874 100644 --- a/firmware/fab-step/src/indicators.h +++ b/firmware/fab-step/src/indicators.h @@ -28,5 +28,14 @@ #define DEBUG1PIN_TOGGLE DEBUG1PIN_PORT.OUTTGL.reg = DEBUG1PIN_BM #define DEBUG1PIN_SETUP DEBUG1PIN_PORT.DIRSET.reg = DEBUG1PIN_BM; DEBUG1PIN_OFF +// the "bus light" : led pts to gnd +#define DEBUG2PIN_PIN 22 +#define DEBUG2PIN_PORT PORT->Group[0] +#define DEBUG2PIN_BM (uint32_t)(1 << DEBUG2PIN_PIN) +#define DEBUG2PIN_ON DEBUG2PIN_PORT.OUTSET.reg = DEBUG2PIN_BM +#define DEBUG2PIN_OFF DEBUG2PIN_PORT.OUTCLR.reg = DEBUG2PIN_BM +#define DEBUG2PIN_TOGGLE DEBUG2PIN_PORT.OUTTGL.reg = DEBUG2PIN_BM +#define DEBUG2PIN_SETUP DEBUG2PIN_PORT.DIRSET.reg = DEBUG2PIN_BM; DEBUG2PIN_OFF + #define ERRLIGHT_ON #define ERRLIGHT_OFF diff --git a/firmware/fab-step/src/main.cpp b/firmware/fab-step/src/main.cpp index 06ba565..95b9e85 100644 --- a/firmware/fab-step/src/main.cpp +++ b/firmware/fab-step/src/main.cpp @@ -1,17 +1,24 @@ #include <Arduino.h> #include "indicators.h" #include "config.h" -//#include "drivers/ucBusHead.h" + //#include "drivers/step_a4950.h" -//#include "osape-d21/osape/osap/osap.h" -//#include "osape-d21/vertices/vt_usbSerial.h" -#include "osape-d21/vertices/ucBusDrop.h" +#include "osape-d21/osape/osap/osap.h" +#include "osape-d21/vertices/vt_usbSerial.h" +#include "osape-d21/vertices/ucbus/vt_ucBusDrop.h" +#include "osape-d21/vertices/ucbus/ucBusDrop.h" -/* -// -------------------------------------------------------- Dummy +// bus light on PA22, to flip: + +EP_ONDATA_RESPONSES onDemoData(uint8_t* data, uint16_t len){ + DEBUG2PIN_TOGGLE; + return EP_ONDATA_ACCEPT; +} + +vertex_t* demoEP = osapBuildEndpoint("demo", onDemoData, nullptr); -vertex_t* spiBusDummy = osapBuildEndpoint("spiDummy", nullptr, nullptr); +/* // -------------------------------------------------------- Axis Pick @@ -42,11 +49,18 @@ vertex_t* cScaleEp = osapBuildEndpoint("currentScale", nullptr, nullptr); void setup() { CLKLIGHT_SETUP; - BUSLIGHT_SETUP; + //BUSLIGHT_SETUP; DEBUG1PIN_SETUP; + // setup demo light + DEBUG2PIN_SETUP; // osap setup... - // osapSetup(); - ucBusDrop_setup(2); + osapSetup(); + vt_usbSerial_setup(); + osapAddVertex(vt_usbSerial); + vt_ucBusDrop_setup(false, 2); + osapAddVertex(vt_ucBusDrop); + // demo endpoint (?) + osapAddVertex(demoEP); // startup stepper HW // step_a4950_init(); // step_a4950_set_cscale(0.25F); @@ -56,8 +70,6 @@ void setup() { //osapAddVertex(spiBusDummy); // 1 //osapAddVertex(axisPickEp); // 2 //osapAddVertex(axisInvertEp); // 3 - // pinMode(); - PORT->Group[0].DIRSET.reg = (uint32_t)(1 << 14); } // -------------------------------------------------------- LOOP @@ -66,15 +78,21 @@ void setup() { unsigned long last_tick = 0; void loop() { - // digitalWrite(); - PORT->Group[0].OUTSET.reg = (uint32_t)(1 << 14); - PORT->Group[0].OUTCLR.reg = (uint32_t)(1 << 14); + // DEBUG2PIN_TOGGLE; // do osap things, - // osapLoop(); + osapLoop(); // blink if(millis() > last_tick + CLK_TICK){ //step_a4950_step(); - CLKLIGHT_TOGGLE; + //CLKLIGHT_TOGGLE; last_tick = millis(); } +} + +void ucBusDrop_onPacketARx(uint8_t* inBufferA, volatile uint16_t len){ + +} + +void ucBusDrop_onRxISR(void){ + } \ No newline at end of file diff --git a/firmware/fab-step/src/osape-d21 b/firmware/fab-step/src/osape-d21 index d7df297..b8595b1 160000 --- a/firmware/fab-step/src/osape-d21 +++ b/firmware/fab-step/src/osape-d21 @@ -1 +1 @@ -Subproject commit d7df297e7039d697def2a1252e34eebfa3981e1d +Subproject commit b8595b13aff606d9be49ccd251e73281d7111603 -- GitLab