v3.0.0-a15 : Fixed bug with changing FIFO depth during a motion command. Also added CU,255,1 for command debug printing (separated it out from CU,253,1)

feature/48bitSnap
EmbeddedMan 2023-09-21 11:47:17 -05:00
rodzic 3bc0ef7c46
commit 1891d486f2
7 zmienionych plików z 2968 dodań i 2911 usunięć

Wyświetl plik

@ -32,6 +32,7 @@
</formatting>
</data>
<spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
<word>Bitfield</word>
<word>breifly</word>
<word>comamnds</word>
<word>paramters</word>

Wyświetl plik

@ -110,6 +110,7 @@
#include "UBW.h"
#include "RCServo2.h"
#include "HardwareProfile.h"
#include "ebb.h"
#pragma udata RC2Servo_globals = 0x060

Wyświetl plik

@ -146,7 +146,7 @@ volatile unsigned int ChannelBit;
volatile UINT16 g_PowerMonitorThresholdADC; // 0-1023 ADC counts, below which
volatile BOOL g_PowerDropDetected; // True if power drops below PowerMonitorThreshold
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.0-a12"};
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.0-a15"};
#pragma udata ISR_buf = 0x100
volatile unsigned int ISR_A_FIFO[16]; // Stores the most recent analog conversions
@ -682,6 +682,26 @@ void UserInit(void)
// Initialize switch as an input
mInitSwitch();
//// JUST FOR TESTING! REMOVE!
TRISDbits.TRISD1 = 0; // D1 high when in ISR
TRISDbits.TRISD0 = 0; // D0 high when loading next command
TRISAbits.TRISA1 = 0; // A1 when FIFO empty
TRISCbits.TRISC0 = 0;
TRISAbits.TRISA5 = 0;
Open1USART(
USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH &
USART_ADDEN_OFF,
2 // At 48 MHz, this creates 1 Mbaud output
);
////
// Start off always using "OK" acknowledge.
g_ack_enable = TRUE;
@ -833,15 +853,6 @@ void UserInit(void)
g_PowerMonitorThresholdADC = 0;
g_PowerDropDetected = FALSE;
//// JUST FOR TESTING! REMOVE!
TRISDbits.TRISD1 = 0; // D1 high when in ISR
TRISDbits.TRISD0 = 0; // D0 high when loading next command
TRISAbits.TRISA1 = 0; // A1 when FIFO empty
TRISCbits.TRISC0 = 0;
TRISAbits.TRISA5 = 0;
////
}
/******************************************************************************
@ -1104,13 +1115,13 @@ void ProcessIO(void)
// Check to see if we need to print out a "Limit switch triggered" packet to the PC
if (gLimitSwitchReplies)
{
if (gLimitSwitchTriggered && !gLimitSwitchReplyPrinted)
if (bittstzero(gLimitSwitchTriggered) && !gLimitSwitchReplyPrinted)
{
printf((far rom char *)"Limit switch triggered. PortB=%02X", gLimitSwitchPortB);
print_line_ending(kLE_NORM);
gLimitSwitchReplyPrinted = TRUE;
}
else if (!gLimitSwitchTriggered && gLimitSwitchReplyPrinted)
else if (!bittstzero(gLimitSwitchTriggered) && gLimitSwitchReplyPrinted)
{
gLimitSwitchReplyPrinted = FALSE;
}
@ -1683,6 +1694,7 @@ void parse_R_packet(void)
// 252 {1|0} turns on or off the UART ISR DEBUG FULL (prints internal numbers at end of each ISR)
// 253 {1|0} turns on or off the UART COMMAND DEBUG (prints all received command bytes)
// 254 {1} turns on lock up mode. Tight loop of I/O toggles shows true ISR timing. Reset to exit.
// 255 {1|0} turns on or off command parsing debug printing on USB
void parse_CU_packet(void)
{
@ -1749,6 +1761,11 @@ void parse_CU_packet(void)
{
paramater_value = COMMAND_FIFO_MAX_LENGTH;
}
// Spin here until we're certain the FIFO is empty and there are no
// command executing. We want the ISR to be completely idle while we
// change this value.
while (process_QM())
;
gCurrentFIFOLength = paramater_value;
}
// CU,10,1 or CU,10,0 to turn on/off standardized line ending
@ -1785,7 +1802,7 @@ void parse_CU_packet(void)
gLimitSwitchMask = (paramater_value & 0xFF);
if (gLimitSwitchMask == 0u)
{
gLimitSwitchTriggered = FALSE;
bitclrzero(gLimitSwitchTriggered);
}
}
// CU,52,<limit_siwtch_target>
@ -1949,6 +1966,32 @@ void parse_CU_packet(void)
_endasm
}
}
// CU,255,1 or CU,255,0 to turn on/off command parsing debug printing on USB
else if (255u == parameter_number)
{
if (0 == paramater_value)
{
bitclr(TestMode, TEST_MODE_DEBUG_COMMAND_BIT_NUM);
}
else if (1 == paramater_value)
{
bitset(TestMode, TEST_MODE_DEBUG_COMMAND_BIT_NUM);
Open1USART(
USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH &
USART_ADDEN_OFF,
2 // At 48 MHz, this creates 1 Mbaud output
);
}
else
{
bitset(error_byte, kERROR_BYTE_PARAMETER_OUTSIDE_LIMIT);
}
}
else
{
// parameter_number is not understood

Wyświetl plik

@ -433,7 +433,6 @@ UINT8 gStandardizedCommandFormat;
// Local function definitions
UINT8 process_QM(void);
void clear_StepCounters(void);
static void process_low_level_move(
@ -1049,7 +1048,7 @@ NonStepperCommands:
acc_union[1].value = 0;
// All EM command clear the limit switch trigger
gLimitSwitchTriggered = FALSE;
bitclrzero(gLimitSwitchTriggered);
// This is probably unnecessary, but it's critical to be sure to indicate that the current command is finished
bitsetzero(AllDone);
@ -1545,7 +1544,7 @@ void EBB_Init(void)
PortBTemp = 0;
gLimitSwitchMask = 0;
gLimitSwitchTarget = 0;
gLimitSwitchTriggered = 0;
bitclrzero(gLimitSwitchTriggered);
// Clear out global stepper positions
clear_StepCounters();
@ -2331,7 +2330,7 @@ void process_low_level_move(
gFIFOLength++;
}
if(bittst(TestMode, TEST_MODE_USART_COMMAND_BIT_NUM))
if(bittst(TestMode, TEST_MODE_DEBUG_COMMAND_BIT_NUM))
{
// Print the final values used by the ISR for this move
printf((far rom char *)"R1=%ld S1=%lu A1=%ld J1=%ld R2=%ld S2=%lu A2=%ld J2=%ld",
@ -2667,7 +2666,7 @@ void parse_HM_packet(void)
Duration = 10;
}
if(bittst(TestMode, TEST_MODE_USART_COMMAND_BIT_NUM))
if(bittst(TestMode, TEST_MODE_DEBUG_COMMAND_BIT_NUM))
{
printf((far rom char *)"HM Duration=%lu SA1=%li SA2=%li",
Duration,
@ -2842,7 +2841,7 @@ static void process_simple_motor_move(
{
return;
}
if(bittst(TestMode, TEST_MODE_USART_COMMAND_BIT_NUM))
if(bittst(TestMode, TEST_MODE_DEBUG_COMMAND_BIT_NUM))
{
printf((far rom char *)"Duration=%lu SA1=%li SA2=%li",
Duration,
@ -2910,7 +2909,7 @@ static void process_simple_motor_move(
// If A1Stp is 1, then duration must be 763 or less.
// If A1Stp is 2, then duration must be 763 * 2 or less.
// If A1Stp is 0xFFFFFF, then duration must be at least 671088.
if(bittst(TestMode, TEST_MODE_USART_COMMAND_BIT_NUM))
if(bittst(TestMode, TEST_MODE_DEBUG_COMMAND_BIT_NUM))
{
// First check for duration to large.
if ((UINT32)A1Stp < (0xFFFFFFu/763u))
@ -3030,7 +3029,7 @@ static void process_simple_motor_move(
gMoveTemp.Accel[1] = 0;
gMoveTemp.Command = COMMAND_SM_XM_HM_MOVE_BIT;
if(bittst(TestMode, TEST_MODE_USART_COMMAND_BIT_NUM))
if(bittst(TestMode, TEST_MODE_DEBUG_COMMAND_BIT_NUM))
{
printf((far rom char *)"R1=%lu S1=%lu R2=%lu S2=%lu",
gMoveTemp.Rate[0],
@ -3667,7 +3666,7 @@ void parse_QG_packet(void)
result = result | (1 << 6);
g_PowerDropDetected = FALSE;
}
if (gLimitSwitchTriggered)
if (bittstzero(gLimitSwitchTriggered))
{
result = result | (1 << 7);
}

Wyświetl plik

@ -51,25 +51,27 @@
#ifndef EBB_H
#define EBB_H
#include <usart.h>
// Bitfield defines for the TestModes variable.
#define TEST_MODE_GPIO_BIT_NUM 1u
#define TEST_MODE_GPIO_BIT (1u << TEST_MODE_GPIO_BIT_NUM)
// Set for any ISR printing
// Set for printing ISR debug info to UART at end of every move
#define TEST_MODE_USART_ISR_BIT_NUM 2u
#define TEST_MODE_USART_ISR_BIT (1u << TEST_MODE_USART_ISR_BIT_NUM)
// Set this and TEST_MODE_USART_ISR_BIT_NUM for printing every ISR, not just end of move
#define TEST_MODE_USART_ISR_FULL_BIT_NUM 3u
#define TEST_MODE_USART_ISR_FULL_BIT (1u << TEST_MODE_USART_ISR_FULL_BIT_NUM)
// Prints every received byte out to debug UART
#define TEST_MODE_USART_COMMAND_BIT_NUM 4u
#define TEST_MODE_USART_COMMAND_BIT (1u << TEST_MODE_USART_COMMAND_BIT_NUM)
// Prints additional command debugging info to USB back to PC
#define TEST_MODE_DEBUG_COMMAND_BIT_NUM 5u
#define TEST_MODE_DEBUG_COMMAND_BIT (1u << TEST_MODE_DEBUG_COMMAND_BIT_NUM)
// This last bit is used during the ISR and is not available as a general test mode bit
#define TEST_MODE_PRINT_TRIGGER_BIT_NUM 7u
#define TEST_MODE_PRINT_TRIGGER_BIT (1u << TEST_MDOE_PRINT_TRIGGER_BIT_NUM)
// Enable this line to compile with a lot of debug prints for motion commands
//#define DEBUG_VALUE_PRINT
// These are used for Enable<X>IO to control the enable lines for the driver
#define ENABLE_MOTOR 0u
#define DISABLE_MOTOR 1u
@ -83,7 +85,7 @@
// element (command) that gives us a maximum of 43 for the FIFO depth.
// Because we want to leave some room for FIFO command expansion in the future,
// we artifically set this to 32 elements. That gives us room to grow the size
// of the command structure wihtout needing to decreasae the maximum size
// of the command structure without needing to decrease the maximum size
// of the FIFO in elements.
#define COMMAND_FIFO_MAX_LENGTH 32u
@ -330,4 +332,5 @@ void parse_T3_packet(void);
void parse_L3_packet(void);
void EBB_Init(void);
void process_SP(PenStateType NewState, UINT16 CommandDuration);
UINT8 process_QM(void);
#endif