Skip to content
This repository was archived by the owner on Jul 9, 2020. It is now read-only.

Commit a2dc985

Browse files
committed
Minor updates
1 parent 157a303 commit a2dc985

File tree

4 files changed

+59
-63
lines changed

4 files changed

+59
-63
lines changed

src/LPC/BoardConfig.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ static const boardConfigEntry_t boardConfigs[]=
7979
};
8080

8181

82-
static inline bool isSpaceOrTab(char c)
82+
static inline bool isSpaceOrTab(char c) noexcept
8383
{
8484
return (c == ' ' || c == '\t');
8585
}
8686

87-
BoardConfig::BoardConfig()
87+
BoardConfig::BoardConfig() noexcept
8888
{
8989

9090
}
@@ -201,7 +201,7 @@ void BoardConfig::Init()
201201

202202

203203
//Convert a pin string into a RRF Pin
204-
Pin BoardConfig::StringToPin(const char *strvalue)
204+
Pin BoardConfig::StringToPin(const char *strvalue) noexcept
205205
{
206206
//check size.. should be 3chars or 4 chars i.e. 0.1, 2.25, 2nd char should always be .
207207
uint8_t len = strlen(strvalue);
@@ -229,7 +229,7 @@ Pin BoardConfig::StringToPin(const char *strvalue)
229229

230230

231231

232-
void BoardConfig::PrintValue(MessageType mtype, configValueType configType, void *variable)
232+
void BoardConfig::PrintValue(MessageType mtype, configValueType configType, void *variable) noexcept
233233
{
234234
switch(configType)
235235
{
@@ -272,7 +272,7 @@ void BoardConfig::PrintValue(MessageType mtype, configValueType configType, void
272272

273273

274274
//Information printed by M122 P200
275-
void BoardConfig::Diagnostics(MessageType mtype)
275+
void BoardConfig::Diagnostics(MessageType mtype) noexcept
276276
{
277277
reprap.GetPlatform().MessageF(mtype, "== Configurable Board.txt Settings ==\n");
278278

@@ -325,7 +325,7 @@ void BoardConfig::Diagnostics(MessageType mtype)
325325

326326
}
327327

328-
void BoardConfig::PrintPinArray(MessageType mtype, Pin arr[], uint16_t numEntries)
328+
void BoardConfig::PrintPinArray(MessageType mtype, Pin arr[], uint16_t numEntries) noexcept
329329
{
330330
reprap.GetPlatform().MessageF(mtype, "[ ");
331331
for(uint8_t i=0; i<numEntries; i++)
@@ -345,7 +345,7 @@ void BoardConfig::PrintPinArray(MessageType mtype, Pin arr[], uint16_t numEntrie
345345

346346

347347
//Set a variable from a string using the specified data type
348-
void BoardConfig::SetValueFromString(configValueType type, void *variable, const char *valuePtr)
348+
void BoardConfig::SetValueFromString(configValueType type, void *variable, const char *valuePtr) noexcept
349349
{
350350
switch(type)
351351
{
@@ -422,7 +422,7 @@ void BoardConfig::SetValueFromString(configValueType type, void *variable, const
422422

423423

424424

425-
bool BoardConfig::GetConfigKeys(FileStore *configFile)
425+
bool BoardConfig::GetConfigKeys(FileStore *configFile) noexcept
426426
{
427427

428428
size_t maxLineLength = 120;

src/LPC/BoardConfig.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ class BoardConfig {
3333
public:
3434
static void Init();
3535

36-
static void Diagnostics(MessageType mtype);
37-
static Pin StringToPin(const char *strvalue);
36+
static void Diagnostics(MessageType mtype) noexcept;
37+
static Pin StringToPin(const char *strvalue) noexcept;
3838

3939
private:
40-
BoardConfig();
41-
static bool GetConfigKeys(FileStore *configFile );
42-
static void SetValueFromString(configValueType type, void *variable, const char *valuePtr);
43-
static void PrintValue(MessageType mtype, configValueType configType, void *variable);
44-
static void PrintPinArray(MessageType mtype, Pin arr[], uint16_t numEntries);
40+
BoardConfig() noexcept;
41+
static bool GetConfigKeys(FileStore *configFile ) noexcept;
42+
static void SetValueFromString(configValueType type, void *variable, const char *valuePtr) noexcept;
43+
static void PrintValue(MessageType mtype, configValueType configType, void *variable) noexcept;
44+
static void PrintPinArray(MessageType mtype, Pin arr[], uint16_t numEntries) noexcept;
4545

4646
};
4747

src/LPC/Pins_LPC.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,59 @@
99
//All I/Os default to input with pullup after reset (9.2.1 from manual)
1010
//The Smoothie Bootloader turns off Pins 2.4, 2.5, 2.6 and 2.7 which are used as Heater pins
1111

12-
Pin TEMP_SENSE_PINS[NumThermistorInputs] = {NoPin, NoPin, NoPin, NoPin};
12+
Pin TEMP_SENSE_PINS[NumThermistorInputs] = {NoPin, NoPin, NoPin, NoPin};
1313
Pin SpiTempSensorCsPins[MaxSpiTempSensors] = { NoPin, NoPin };
1414

1515
Pin ATX_POWER_PIN = NoPin;
1616
bool ATX_POWER_INVERTED = false;
1717

18-
19-
Pin SdCardDetectPins[NumSdCards] = { NoPin, NoPin };
20-
Pin SdSpiCSPins[NumSdCards] = { P0_6, NoPin }; // Internal, external. Note:: ("slot" 0 in CORE is configured to be LCP SSP1 to match default RRF behaviour)
21-
uint32_t ExternalSDCardFrequency = 4000000; //default to 4MHz
18+
//SDCard pins and settings
19+
Pin SdCardDetectPins[NumSdCards] = { NoPin, NoPin };
20+
Pin SdSpiCSPins[NumSdCards] = { P0_6, NoPin }; // Internal, external. Note:: ("slot" 0 in CORE is configured to be LCP SSP1 to match default RRF behaviour)
21+
uint32_t ExternalSDCardFrequency = 4000000; //default to 4MHz
2222
SSPChannel ExternalSDCardSSPChannel = SSP0; //default to SSP0
23-
uint32_t InternalSDCardFrequency = 25000000; //default to 25MHz
23+
uint32_t InternalSDCardFrequency = 25000000; //default to 25MHz
2424

2525

26-
Pin LcdCSPin = NoPin; //LCD Chip Select
27-
Pin LcdDCPin = NoPin; //DataControl Pin (A0) if none used set to NoPin
28-
Pin LcdBeepPin = NoPin;
29-
Pin EncoderPinA = NoPin;
30-
Pin EncoderPinB = NoPin;
31-
Pin EncoderPinSw = NoPin; //click
32-
Pin PanelButtonPin = NoPin; //Extra button on Viki and RRD Panels (reset/back etc)
26+
Pin LcdCSPin = NoPin; //LCD Chip Select
27+
Pin LcdDCPin = NoPin; //DataControl Pin (A0) if none used set to NoPin
28+
Pin LcdBeepPin = NoPin;
29+
Pin EncoderPinA = NoPin;
30+
Pin EncoderPinB = NoPin;
31+
Pin EncoderPinSw = NoPin; //click
32+
Pin PanelButtonPin = NoPin; //Extra button on Viki and RRD Panels (reset/back etc)
3333
SSPChannel LcdSpiChannel = SSP0;
3434

3535
Pin DiagPin = NoPin;
3636

37+
//Stepper settings
3738
Pin ENABLE_PINS[NumDirectDrivers] = {NoPin, NoPin, NoPin, NoPin, NoPin};
3839
Pin STEP_PINS[NumDirectDrivers] = {NoPin, NoPin, NoPin, NoPin, NoPin};
3940
Pin DIRECTION_PINS[NumDirectDrivers] = {NoPin, NoPin, NoPin, NoPin, NoPin};
40-
uint32_t STEP_DRIVER_MASK = 0; //SD: mask of the step pins on Port 2 used for writing to step pins in parallel
41+
uint32_t STEP_DRIVER_MASK = 0; //SD: mask of the step pins on Port 2 used for writing to step pins in parallel
42+
bool hasStepPinsOnDifferentPorts = false; //for boards that don't have all step pins on port2
43+
bool hasDriverCurrentControl = false; //Supports digipots to set stepper current
44+
float digipotFactor = 113.33; //defualt factor for converting current to digipot value
4145

42-
bool hasStepPinsOnDifferentPorts = false; //for boards that don't have all step pins on port2
43-
bool hasDriverCurrentControl = false;
44-
float digipotFactor = 113.33; //defualt factor for converting current to digipot value
45-
bool UARTPanelDueMode = false; //disable PanelDue support by default
4646

47-
Pin SoftwareSPIPins[3] = {NoPin, NoPin, NoPin}; //GPIO pins for softwareSPI (used with SharedSPI)
47+
Pin SoftwareSPIPins[3] = {NoPin, NoPin, NoPin}; //GPIO pins for softwareSPI (used with SharedSPI)
4848

4949
#if defined(HAS_LINUX_INTERFACE)
50-
Pin LinuxTfrReadyPin = NoPin;
50+
Pin LinuxTfrReadyPin = NoPin;
5151
#endif
5252

5353
#if defined(ESP8266WIFI)
5454
Pin EspDataReadyPin = NoPin;
55-
Pin SamTfrReadyPin = NoPin;
56-
Pin EspResetPin = NoPin;
57-
//Pin SamCsPin = NoPin;
55+
Pin SamTfrReadyPin = NoPin;
56+
Pin EspResetPin = NoPin;
5857
#endif
5958

6059
//Default to the Generic PinTable
6160
PinEntry *PinTable = (PinEntry *) PinTable_Generic;
6261
size_t NumNamedLPCPins = ARRAY_SIZE(PinTable_Generic);
6362
char lpcBoardName[MaxBoardNameLength] = "generic";
6463

65-
bool IsEmptyPinArray(Pin *arr, size_t len)
64+
bool IsEmptyPinArray(Pin *arr, size_t len) noexcept
6665
{
6766
for(size_t i=0; i<len; i++)
6867
{
@@ -72,7 +71,8 @@ bool IsEmptyPinArray(Pin *arr, size_t len)
7271
return true;
7372
}
7473

75-
void SetDefaultPinArray(const Pin *src, Pin *dst, size_t len)
74+
//If the dst array is empty, then copy the src array to dst array
75+
void SetDefaultPinArray(const Pin *src, Pin *dst, size_t len) noexcept
7676
{
7777
if(IsEmptyPinArray(dst, len))
7878
{
@@ -86,7 +86,7 @@ void SetDefaultPinArray(const Pin *src, Pin *dst, size_t len)
8686

8787

8888
//Find Board settings from string
89-
bool SetBoard(const char* bn)
89+
bool SetBoard(const char* bn) noexcept
9090
{
9191
const size_t numBoards = ARRAY_SIZE(LPC_Boards);
9292

@@ -97,7 +97,7 @@ bool SetBoard(const char* bn)
9797
PinTable = (PinEntry *)LPC_Boards[i].boardPinTable;
9898
NumNamedLPCPins = LPC_Boards[i].numNamedEntries;
9999

100-
//copy defaults (if needed)
100+
//copy default settings (if not set in board.txt)
101101
SetDefaultPinArray(LPC_Boards[i].defaults.enablePins, ENABLE_PINS, MaxTotalDrivers);
102102
SetDefaultPinArray(LPC_Boards[i].defaults.stepPins, STEP_PINS, MaxTotalDrivers);
103103
SetDefaultPinArray(LPC_Boards[i].defaults.dirPins, DIRECTION_PINS, MaxTotalDrivers);
@@ -115,7 +115,7 @@ bool SetBoard(const char* bn)
115115

116116
// Function to look up a pin name pass back the corresponding index into the pin table
117117
// On this platform, the mapping from pin names to pins is fixed, so this is a simple lookup
118-
bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted)
118+
bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted) noexcept
119119
{
120120
if (StringEqualsIgnoreCase(pn, NoPinName))
121121
{
@@ -162,8 +162,8 @@ bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted)
162162
}
163163

164164
//pn did not match a label in the lookup table, so now
165-
//look up by classic port.pin
166-
//Note: only allocated pins already in the lookup table are suported.
165+
//look up by classic port.pin format
166+
//Note: only pins in the selected board lookup table are suported.
167167
const Pin lpcPin = BoardConfig::StringToPin(pn);
168168
if(lpcPin != NoPin){
169169
//find pin in lookup table

src/LPC/Pins_LPC.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,11 @@
6666
#endif
6767

6868

69-
#define NO_EXTRUDER_ENDSTOPS 1 // Temporary!!!
70-
71-
72-
7369
// The physical capabilities of the machine
7470
constexpr size_t NumDirectDrivers = 5; // The maximum number of drives supported by the electronics
7571
constexpr size_t MaxSmartDrivers = 0; // The maximum number of smart drivers
7672

77-
constexpr size_t MaxSensorsInSystem = 32;
78-
typedef uint32_t SensorsBitmap;
73+
constexpr size_t MaxSensors = 32;
7974

8075
constexpr size_t MaxHeaters = 3; // The maximum number of heaters in the machine
8176
constexpr size_t MaxExtraHeaterProtections = 3; // The number of extra heater protection instances
@@ -133,8 +128,8 @@ constexpr float EXT_SHC = 0.0;
133128
constexpr float DefaultThermistorSeriesR = 4700.0;
134129

135130
constexpr size_t MaxSpiTempSensors = 2;
136-
extern Pin SpiTempSensorCsPins[MaxSpiTempSensors]; // Digital pins the 31855s have their select lines tied to
137-
constexpr SSPChannel TempSensorSSPChannel = SSP0; //Conect SPI Temp sensor to SSP0
131+
extern Pin SpiTempSensorCsPins[MaxSpiTempSensors]; // Digital pins the 31855s have their select lines tied to
132+
constexpr SSPChannel TempSensorSSPChannel = SSP0; //Connect SPI Temp sensor to SSP0
138133

139134
#if HAS_LINUX_INTERFACE
140135
extern Pin LinuxTfrReadyPin;
@@ -257,10 +252,10 @@ constexpr inline PinCapability operator|(PinCapability a, PinCapability b)
257252

258253
struct PinEntry
259254
{
260-
bool CanDo(PinAccess access) const;
261-
Pin GetPin() const { return pin; }
262-
PinCapability GetCapability() const { return cap; }
263-
const char* GetNames() const { return names; }
255+
bool CanDo(PinAccess access) const noexcept;
256+
Pin GetPin() const noexcept{ return pin; }
257+
PinCapability GetCapability() const noexcept{ return cap; }
258+
const char* GetNames() const noexcept{ return names; }
264259

265260
Pin pin;
266261
PinCapability cap;
@@ -271,7 +266,7 @@ extern PinEntry *PinTable;
271266

272267

273268

274-
bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted);
269+
bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted) noexcept;
275270

276271
constexpr const char *DefaultEndstopPinNames[] = { "nil", "nil", "nil" };
277272
constexpr const char *DefaultZProbePinNames = "nil";
@@ -282,7 +277,7 @@ constexpr PwmFrequency DefaultFanPwmFrequencies[] = { DefaultFanPwmFreq };
282277

283278
//Boards
284279

285-
bool SetBoard(const char* bn);
280+
bool SetBoard(const char* bn) noexcept;
286281

287282
constexpr size_t MaxBoardNameLength = 20;
288283
extern char lpcBoardName[MaxBoardNameLength];
@@ -316,6 +311,7 @@ struct BoardEntry
316311

317312

318313

314+
//Known boards with built in stepper configurations and pin table
319315
constexpr BoardEntry LPC_Boards[] =
320316
{
321317
{"mbed", PinTable_Mbed, ARRAY_SIZE(PinTable_Mbed), mbedDefaults}, //for debugging
@@ -346,7 +342,7 @@ namespace StepPins
346342
// All our step pins are on port D, so the bitmap is just the map of step bits in port D.
347343

348344
// Calculate the step bit for a driver. This doesn't need to be fast. It must return 0 if the driver is remote.
349-
static inline uint32_t CalcDriverBitmap(size_t driver)
345+
static inline uint32_t CalcDriverBitmap(size_t driver) noexcept
350346
{
351347
if (driver >= NumDirectDrivers)
352348
{
@@ -365,8 +361,7 @@ namespace StepPins
365361

366362
// Set the specified step pins high
367363
// This needs to be as fast as possible, so we do a parallel write to the port(s).
368-
// We rely on only those port bits that are step pins being set in the PIO_OWSR register of each port
369-
static inline void StepDriversHigh(uint32_t driverMap)
364+
static inline void StepDriversHigh(uint32_t driverMap) noexcept
370365
{
371366
if(hasStepPinsOnDifferentPorts == true )
372367
{
@@ -392,7 +387,7 @@ namespace StepPins
392387
// Set all step pins low
393388
// This needs to be as fast as possible, so we do a parallel write to the port(s).
394389
// We rely on only those port bits that are step pins being set in the STEP_DRIVER_MASK variable
395-
static inline void StepDriversLow()
390+
static inline void StepDriversLow() noexcept
396391
{
397392
if(hasStepPinsOnDifferentPorts == true )
398393
{
@@ -403,6 +398,7 @@ namespace StepPins
403398
}
404399
else
405400
{
401+
//pins all on port 2, parallel write
406402
LPC_GPIO2->CLR = STEP_DRIVER_MASK; //clear only pins that are 1 in the mask
407403
}
408404
}

0 commit comments

Comments
 (0)