Commit 18f2fe6c authored by Jake Read's avatar Jake Read
Browse files

refactor stepper for osape-d51 submodule

parent 4e2fb2ea
......@@ -4,3 +4,6 @@
[submodule "firmware/cl-step-controller/src/osape"]
path = firmware/cl-step-controller/src/osape
url = ssh://git@gitlab.cba.mit.edu:846/jakeread/osape.git
[submodule "firmware/osape-smoothieroll-drop-stepper/src/osape-d51"]
path = firmware/osape-smoothieroll-drop-stepper/src/osape-d51
url = ssh://git@gitlab.cba.mit.edu:846/jakeread/osape-d51.git
......@@ -18,7 +18,7 @@ is; no warranty is provided, and users accept all liability.
#include <arduino.h>
#include "indicators.h"
#include "../osape/utils/syserror.h"
#include "../syserror.h"
// scrape https://github.com/adafruit/ArduinoCore-samd/blob/master/cores/arduino/wiring_analog.c
// scrape https://github.com/adafruit/ArduinoCore-samd/blob/master/cores/arduino/startup.c (clock)
......
......@@ -19,7 +19,7 @@ is; no warranty is provided, and users accept all liability.
#include "dacs.h"
#include "indicators.h"
#include "../osape/utils/syserror.h"
#include "../syserror.h"
// C_SCALE
// 1: DACs go 0->512 (of 4096, peak current is 1.6A at 4096): 0.2A
......
// for the new one! with the DIP switch!
#define CLKLIGHT_PIN 27
#define CLKLIGHT_PORT PORT->Group[0]
#define ERRLIGHT_PIN 8
#define ERRLIGHT_PORT PORT->Group[1]
#define DEBUG1PIN_PIN 13
#define DEBUG1PIN_PORT PORT->Group[1]
#define DEBUG2PIN_PIN 12
#define DEBUG2PIN_PORT PORT->Group[1]
#define DEBUG3PIN_PIN 13
#define DEBUG3PIN_PORT PORT->Group[1]
#define DEBUG4PIN_PIN 14
#define DEBUG4PIN_PORT PORT->Group[1]
// PA27
#define CLKLIGHT_BM (uint32_t)(1 << CLKLIGHT_PIN)
#define CLKLIGHT_ON CLKLIGHT_PORT.OUTCLR.reg = CLKLIGHT_BM
#define CLKLIGHT_OFF CLKLIGHT_PORT.OUTSET.reg = CLKLIGHT_BM
#define CLKLIGHT_TOGGLE CLKLIGHT_PORT.OUTTGL.reg = CLKLIGHT_BM
#define CLKLIGHT_SETUP CLKLIGHT_PORT.DIRSET.reg = CLKLIGHT_BM; CLKLIGHT_OFF
// PB08
#define ERRLIGHT_BM (uint32_t)(1 << ERRLIGHT_PIN)
#define ERRLIGHT_ON ERRLIGHT_PORT.OUTCLR.reg = ERRLIGHT_BM
#define ERRLIGHT_OFF ERRLIGHT_PORT.OUTSET.reg = ERRLIGHT_BM
#define ERRLIGHT_TOGGLE ERRLIGHT_PORT.OUTTGL.reg = ERRLIGHT_BM
#define ERRLIGHT_SETUP ERRLIGHT_PORT.DIRSET.reg = ERRLIGHT_BM; ERRLIGHT_OFF
#define DEBUG1PIN_BM (uint32_t)(1 << DEBUG1PIN_PIN)
#define DEBUG1PIN_ON DEBUG1PIN_PORT.OUTSET.reg = DEBUG1PIN_BM
#define DEBUG1PIN_OFF DEBUG1PIN_PORT.OUTCLR.reg = DEBUG1PIN_BM
#define DEBUG1PIN_TOGGLE DEBUG1PIN_PORT.OUTTGL.reg = DEBUG1PIN_BM
#define DEBUG1PIN_SETUP DEBUG1PIN_PORT.DIRSET.reg = DEBUG1PIN_BM; DEBUG1PIN_OFF
#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 DEBUG3PIN_BM (uint32_t)(1 << DEBUG3PIN_PIN)
#define DEBUG3PIN_ON DEBUG3PIN_PORT.OUTSET.reg = DEBUG3PIN_BM
#define DEBUG3PIN_OFF DEBUG3PIN_PORT.OUTCLR.reg = DEBUG3PIN_BM
#define DEBUG3PIN_TOGGLE DEBUG3PIN_PORT.OUTTGL.reg = DEBUG3PIN_BM
#define DEBUG3PIN_SETUP DEBUG3PIN_PORT.DIRSET.reg = DEBUG3PIN_BM; DEBUG3PIN_OFF
#define DEBUG4PIN_BM (uint32_t)(1 << DEBUG4PIN_PIN)
#define DEBUG4PIN_ON DEBUG4PIN_PORT.OUTSET.reg = DEBUG4PIN_BM
#define DEBUG4PIN_OFF DEBUG4PIN_PORT.OUTCLR.reg = DEBUG4PIN_BM
#define DEBUG4PIN_TOGGLE DEBUG4PIN_PORT.OUTTGL.reg = DEBUG4PIN_BM
#define DEBUG4PIN_SETUP DEBUG4PIN_PORT.DIRSET.reg = DEBUG4PIN_BM; DEBUG4PIN_OFF
\ No newline at end of file
......@@ -2,17 +2,17 @@
#include "drivers/indicators.h"
#include "drivers/step_a4950.h"
#include "osape/osap/osap.h"
#include "osape/osap/vt_usbSerial.h"
#include "osape/osap/vt_ucBusDrop.h"
#include "osape/ucbus/ucBusDrop.h"
#include "osape-d51/osape/osap/osap.h"
#include "osape-d51/vertices/vt_usbSerial.h"
#include "osape-d51/vertices/vt_ucBusDrop.h"
#include "osape-d51/vertices/ucBusDrop.h"
// bare defaults: use vm / bus id to set on startup
uint8_t axis_pick = 0;
float spu = 400.0F;
float old_spu = 400.0F;
volatile boolean spu_was_set = false;
float c_scale = 0.2F;
float c_scale = 0.05F;
#define TICKS_PER_PACKET 25.0F
#define TICKS_PER_SECOND 50000.0F
......
Subproject commit e0c99875e43b267a4565cb92ebc74907ee6e1b79
#include "syserror.h"
#include "osape-d51/osape/osap/ts.h"
#include "osape-d51/vertices/ucBusDrop.h"
#include "osape-d51/osape/utils/cobs.h"
#include "config.h"
uint8_t errBuf[1028];
uint8_t errEncoded[1028];
/*
boolean writeString(unsigned char* dest, uint16_t* dptr, String msg){
uint16_t len = msg.length();
dest[(*dptr) ++] = TS_STRING_KEY;
writeLenBytes(dest, dptr, len);
msg.getBytes(dest, len + 1);
return true;
}
boolean writeLenBytes(unsigned char* dest, uint16_t* dptr, uint16_t len){
dest[(*dptr) ++] = len;
dest[(*dptr) ++] = (len >> 8) & 255;
return true;
}
*/
#ifdef UCBUS_IS_DROP
//uint8_t escape[512];
//uint8_t escapeHeader[10] = { PK_BUSF_KEY, 0, 0, 0, 0, PK_PTR, PK_PORTF_KEY, 0, 0, PK_DEST };
// config-your-own-ll-escape-hatch
void sysError(String msg){
//ERRLIGHT_ON;
/*
uint32_t len = msg.length();
errBuf[0] = PK_LLERR; // the ll-errmsg-key
errBuf[1] = len & 255;
errBuf[2] = (len >> 8) & 255;
errBuf[3] = (len >> 16) & 255;
errBuf[4] = (len >> 24) & 255;
msg.getBytes(&(errBuf[5]), len + 1);
// write header,
memcpy(escape, escapeHeader, 10);
// write segsize, checksum
uint16_t wptr = 10;
ts_writeUint16(128, escape, &wptr);
ts_writeUint16(len + 5, escape, &wptr);
memcpy(&(escape[wptr]), errBuf, len + 5);
// transmit on ucbus
// potential here to hang-up and do while(!(ucBusDrop->cts())) ... I *think* that would clear on an interrupt
ucBusDrop->transmit(escape, len + wptr + 5);
*/
}
#else
// config-your-own-ll-escape-hatch
void sysError(String msg){
// whatever you want,
//ERRLIGHT_ON;
uint32_t len = msg.length();
errBuf[0] = 0; // serport looks for acks in each msg, this is not one
errBuf[1] = PK_PTR;
errBuf[2] = PK_LLESCAPE_KEY; // the ll-errmsg-key
errBuf[3] = len & 255;
errBuf[4] = (len >> 8) & 255;
errBuf[5] = (len >> 16) & 255;
errBuf[6] = (len >> 24) & 255;
msg.getBytes(&(errBuf[7]), len + 1);
size_t ecl = cobsEncode(errBuf, len + 7, errEncoded);
// direct escape
//if(Serial.availableForWrite() > (int64_t)ecl){
Serial.write(errEncoded, ecl);
Serial.flush();
//} else {
// ERRLIGHT_ON;
//}
}
#endif
void logPacket(uint8_t* pck, uint16_t len){
String errmsg;
errmsg.reserve(1024);
errmsg = "pck: "; // max 64
for(uint8_t i = 0; i < 64; i ++){
if(i >= len) break;
errmsg += String(pck[i]);
errmsg += ", ";
}
sysError(errmsg);
}
\ No newline at end of file
#ifndef SYSERROR_H_
#define SYSERROR_H_
#include <Arduino.h>
void sysError(String msg);
void logPacket(uint8_t* pck, uint16_t len);
//void sysError(uint8_t* bytes, uint16_t len);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment