Skip to content

Commit 8b2699b

Browse files
2 parents 54dd788 + 385dfbf commit 8b2699b

145 files changed

Lines changed: 4211 additions & 4366 deletions

File tree

Some content is hidden

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

STM32F1/cores/maple/stm32f1/wirish_digital_f1.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ void pinMode(uint8 pin, WiringPinMode mode) {
8080
gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, outputMode);
8181

8282
if (PIN_MAP[pin].timer_device != NULL) {
83-
/* Enable/disable timer channels if we're switching into or
84-
* out of PWM. */
83+
if ( pwm ) { // we're switching into PWM, enable timer channels
8584
timer_set_mode(PIN_MAP[pin].timer_device,
8685
PIN_MAP[pin].timer_channel,
87-
pwm ? TIMER_PWM : TIMER_DISABLED);
86+
TIMER_PWM );
87+
} else { // disable channel output in non pwm-Mode
88+
timer_cc_disable(PIN_MAP[pin].timer_device,
89+
PIN_MAP[pin].timer_channel);
90+
}
8891
}
8992
}

STM32F1/cores/maple/usb_serial.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ size_t n = 0;
119119
size_t USBSerial::write(const uint8 *buf, uint32 len)
120120
{
121121
size_t n = 0;
122-
if (!this->isConnected() || !buf) {
122+
if (!(bool) *this || !buf) {
123123
return 0;
124124
}
125125

@@ -190,10 +190,6 @@ uint8 USBSerial::pending(void) {
190190
return usb_cdcacm_get_pending();
191191
}
192192

193-
uint8 USBSerial::isConnected(void) {
194-
return usb_is_connected(USBLIB) && usb_is_configured(USBLIB) && usb_cdcacm_get_dtr();
195-
}
196-
197193
uint8 USBSerial::getDTR(void) {
198194
return usb_cdcacm_get_dtr();
199195
}
@@ -202,6 +198,10 @@ uint8 USBSerial::getRTS(void) {
202198
return usb_cdcacm_get_rts();
203199
}
204200

201+
USBSerial::operator bool() {
202+
return usb_is_connected(USBLIB) && usb_is_configured(USBLIB) && usb_cdcacm_get_dtr();
203+
}
204+
205205
#if BOARD_HAVE_SERIALUSB
206206
#ifdef SERIAL_USB
207207
USBSerial Serial;

STM32F1/cores/maple/usb_serial.h

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,41 +44,50 @@ class USBSerial : public Stream {
4444

4545
void begin(void);
4646

47-
// Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile.
48-
void begin(unsigned long);
49-
void begin(unsigned long, uint8_t);
47+
// Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile.
48+
void begin(unsigned long);
49+
void begin(unsigned long, uint8_t);
5050
void end(void);
5151

52-
operator bool() { return true; } // Roger Clark. This is needed because in cardinfo.ino it does if (!Serial) . It seems to be a work around for the Leonardo that we needed to implement just to be compliant with the API
53-
5452
virtual int available(void);// Changed to virtual
5553

5654
uint32 read(uint8 * buf, uint32 len);
57-
// uint8 read(void);
55+
// uint8 read(void);
5856

59-
// Roger Clark. added functions to support Arduino 1.0 API
57+
// Roger Clark. added functions to support Arduino 1.0 API
6058
virtual int peek(void);
6159
virtual int read(void);
6260
int availableForWrite(void);
6361
virtual void flush(void);
64-
65-
62+
63+
6664
size_t write(uint8);
6765
size_t write(const char *str);
6866
size_t write(const uint8*, uint32);
6967

7068
uint8 getRTS();
7169
uint8 getDTR();
72-
uint8 isConnected();
7370
uint8 pending();
7471

72+
/* SukkoPera: This is the Arduino way to check if an USB CDC serial
73+
* connection is open.
74+
75+
* Used for instance in cardinfo.ino.
76+
*/
77+
operator bool();
78+
79+
/* Old libmaple way to check for serial connection.
80+
*
81+
* Deprecated, use the above.
82+
*/
83+
uint8 isConnected() __attribute__((deprecated("Use !Serial instead"))) { return (bool) *this; }
84+
7585
protected:
7686
static bool _hasBegun;
7787
};
7888

79-
#ifdef SERIAL_USB
80-
extern USBSerial Serial;
89+
#ifdef SERIAL_USB
90+
extern USBSerial Serial;
8191
#endif
8292

8393
#endif
84-

STM32F1/libraries/A_STM32_Examples/examples/General/BlinkNcount/BlinkNcount.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void setup() {
1515
// Initialize virtual COM over USB on Maple Mini
1616
Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART
1717
// wait for serial monitor to be connected.
18-
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
18+
while (!Serial)
1919
{
2020
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
2121
delay(100); // fast blink

STM32F1/libraries/A_STM32_Examples/examples/General/IntegerInput/IntegerInput.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void setup()
1818
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
1919
Serial.setTimeout(timeoutPeriod); // default is 1 second
2020
// wait for serial monitor to be connected.
21-
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
21+
while (!Serial)
2222
{
2323
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
2424
delay(100); // fast blink

STM32F1/libraries/A_STM32_Examples/examples/General/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void setup()
1919
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
2020
Serial.setTimeout(timeoutPeriod); // default is 1 second
2121
// wait for serial monitor to be connected.
22-
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
22+
while (!Serial)
2323
{
2424
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
2525
delay(100); // fast blink

STM32F1/libraries/A_STM32_Examples/examples/General/InternalTempSensor/InternalTempSensor.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void setup(void)
3838
pinMode(A_RANDOM_ANALOG_PIN, INPUT_ANALOG);
3939

4040
// wait for serial monitor to be connected.
41-
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
41+
while (!Serial)
4242
{
4343
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
4444
delay(100); // fast blink
@@ -48,7 +48,7 @@ void setup(void)
4848
setup_temperature_sensor();
4949

5050
// announce start up
51-
if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))
51+
if(Serial)
5252
Serial.println("Temp mon startup");
5353
}
5454

@@ -69,7 +69,7 @@ void loop(void)
6969
t2 = micros();
7070
vsense = adc_read(ADC1, 16);
7171
t3 = micros();
72-
if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) {
72+
if(Serial) {
7373
sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1);
7474
Serial.println(buf);
7575
}

STM32F1/libraries/A_STM32_Examples/examples/General/PrimeNos/PrimeNos.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void setup()
2929
pinMode(33, OUTPUT);
3030
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
3131
// wait for serial monitor to be connected.
32-
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
32+
while (!Serial)
3333
{
3434
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
3535
delay(100); // fast blink

STM32F1/libraries/A_STM32_Examples/examples/General/PrimeNos2/PrimeNos2.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void setup() {
1818
pinMode(33, OUTPUT);
1919
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
2020
// wait for serial monitor to be connected.
21-
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
21+
while (!Serial)
2222
{
2323
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
2424
delay(100); // fast blink

STM32F1/libraries/A_STM32_Examples/examples/General/PrimeNos3/PrimeNos3.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void setup() {
1818
pinMode(33, OUTPUT);
1919
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
2020
// wait for serial monitor to be connected.
21-
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
21+
while (!Serial)
2222
{
2323
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
2424
delay(100); // fast blink

0 commit comments

Comments
 (0)