Skip to content

Commit 238f2ea

Browse files
committed
update tools
1 parent 3ae21c3 commit 238f2ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2532
-614
lines changed

cores/nRF5/HardwarePWM.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ bool HardwarePWM::removePin(uint8_t pin)
205205
return true;
206206
}
207207

208+
bool HardwarePWM::removeAllPins(void)
209+
{
210+
for(int ch=0; ch<MAX_CHANNELS; ch++)
211+
{
212+
_set_psel(ch, 0xFFFFFFFFUL);
213+
}
214+
return true;
215+
}
216+
208217
bool HardwarePWM::writeChannel(uint8_t ch, uint16_t value, bool inverted)
209218
{
210219
VERIFY( ch < MAX_CHANNELS );

cores/nRF5/HardwarePWM.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
#include <atomic>
4242
#include <cstdint>
4343

44-
#ifdef NRF52840_XXAA
45-
#define HWPWM_MODULE_NUM 4
44+
#ifdef NRF_PWM3
45+
#define HWPWM_MODULE_NUM 4
4646
#else
47-
#define HWPWM_MODULE_NUM 3
47+
#define HWPWM_MODULE_NUM 3
4848
#endif
4949

5050
class HardwarePWM
@@ -88,6 +88,9 @@ class HardwarePWM
8888
// Remove a pin from PWM module
8989
bool removePin (uint8_t pin);
9090

91+
// Remove all pins from PWM module
92+
bool removeAllPins (void);
93+
9194
// Get the mapped channel of a pin
9295
int pin2channel(uint8_t pin) const
9396
{

cores/nRF5/HardwareSerial.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#ifdef NRF52832_XXAA
5050
#define SERIAL_8N1 (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos)
5151
#define SERIAL_8E1 (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos)
52-
#elif defined(NRF52840_XXAA)
52+
#elif defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
5353
#define SERIAL_8N1 ((UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos))
5454
#define SERIAL_8N2 ((UARTE_CONFIG_STOP_Two << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos))
5555
#define SERIAL_8E1 ((UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos) | (UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos))
@@ -70,6 +70,7 @@ class HardwareSerial : public Stream
7070
virtual void flush(void) = 0;
7171
virtual size_t write(uint8_t) = 0;
7272
virtual size_t write(const uint8_t *buffer, size_t size) = 0;
73+
virtual int availableForWrite(void);
7374
using Print::write; // pull in write(str) from Print
7475
virtual operator bool() = 0;
7576
};

cores/nRF5/Print.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class Print
9898
{
9999
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
100100
}
101+
102+
virtual void flush() { /* Empty implementation for backward compatibility */ }
101103
};
102104

103105
#endif

cores/nRF5/RingBuffer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ int RingBuffer::available()
6767
return delta;
6868
}
6969

70+
int RingBuffer::availableForStore() {
71+
if (_iHead >= _iTail) {
72+
return SERIAL_BUFFER_SIZE - 1 - _iHead + _iTail;
73+
} else {
74+
return _iTail - _iHead - 1;
75+
}
76+
}
77+
7078
int RingBuffer::peek()
7179
{
7280
if(_iTail == _iHead)

cores/nRF5/RingBuffer.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ class RingBuffer
3939
public:
4040
RingBuffer( void ) ;
4141
void store_char( uint8_t c ) ;
42-
void clear();
43-
int read_char();
44-
int available();
45-
int peek();
46-
bool isFull();
42+
void clear();
43+
int read_char();
44+
int available();
45+
int availableForStore();
46+
int peek();
47+
bool isFull();
4748

4849
private:
49-
int nextIndex(int index);
50+
int nextIndex(int index);
5051
} ;
5152

5253
#endif /* _RING_BUFFER_ */

cores/nRF5/Uart.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ size_t Uart::write(const uint8_t *buffer, size_t size)
253253
return sent;
254254
}
255255

256+
int Uart::availableForWrite(void) {
257+
// UART does not use ring buffer for TX, therefore it is either busy or not
258+
UBaseType_t available = uxSemaphoreGetCount(_end_tx_sem);
259+
return available ? SERIAL_BUFFER_SIZE : 0;
260+
}
261+
256262
//------------- Serial1 (or Serial in case of nRF52832) -------------//
257263
#ifdef NRF52832_XXAA
258264
Uart Serial( NRF_UARTE0, UARTE0_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX );

cores/nRF5/Uart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Uart : public HardwareSerial
3939
void begin(unsigned long baudrate, uint16_t config);
4040
void end();
4141
int available();
42+
int availableForWrite(void);
4243
int peek();
4344
int read();
4445
void flush();

cores/nRF5/common_func.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ const char* dbg_err_str(int32_t err_id); // TODO move to other place
179179
#define PRINT_LOCATION() PRINTF("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
180180
#define PRINT_MESS(x) PRINTF("%s: %d: %s \r\n" , __FUNCTION__, __LINE__, (char*)(x))
181181
#define PRINT_HEAP() if (CFG_DEBUG >= 3) PRINTF("\n%s: %d: Heap free: %d\r\n", __FUNCTION__, __LINE__, util_heap_get_free_size())
182-
#define PRINT_STR(x) PRINTF("%s: %d: " #x " = %s\r\n" , __FUNCTION__, __LINE__, (char*)(x) )
183-
#define PRINT_INT(x) PRINTF("%s: %d: " #x " = %ld\r\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
184-
#define PRINT_FLOAT(x) PRINTF("%s: %d: " #x " = %f\r\n" , __FUNCTION__, __LINE__, (float) (x) )
182+
#define PRINT_STR(x) PRINTF(#x " = %s\r\n" , (char*)(x) )
183+
#define PRINT_INT(x) PRINTF(#x " = %ld\r\n", (uint32_t) (x) )
184+
#define PRINT_FLOAT(x) PRINTF(#x " = %f\r\n" , (float) (x) )
185185

186186
#define PRINT_HEX(x) \
187187
do {\
188-
PRINTF("%s: %d: " #x " = 0x", __PRETTY_FUNCTION__, __LINE__);\
188+
PRINTF(#x " = 0x");\
189189
char fmt[] = "%00X\r\n";\
190190
fmt[2] += 2*sizeof(x); /* Hex with correct size */\
191191
PRINTF(fmt, (x) );\

cores/nRF5/freertos/Source/include/portable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEG
128128
*/
129129
void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
130130
void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
131+
void *pvPortRealloc( void *ptr, size_t xWantedSize ) PRIVILEGED_FUNCTION;
132+
void *pvPortCalloc( size_t nmemb, size_t xWantedSize ) PRIVILEGED_FUNCTION;
131133
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
132134
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
133135
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;

0 commit comments

Comments
 (0)