Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification of ArduinoCore-avr to use API #329

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

giulcioffi
Copy link

@giulcioffi giulcioffi commented Apr 10, 2020

The following proposed modifications are intended to port the API to the AVR boards:

  1. rename the "HardwareSerial" classes (from the API) with "UART" (from ArduinoCore-avr);
  2. remove functions/definitions from several files in ArduinoCore-avr, since they are already implemented/defined by the API.
    Files modified:
    • "Arduino.h" : it now includes "api/ArduinoAPI.h" and "api/Common.h"
    • "WMath.cpp": few functionalities are already implemented by "api/Common*"
      Files deleted, because included in the API:
    • "Client.h"
    • "IPAddress*"
    • "Print"
    • "Server.h"
    • "Stream*"
    • "Udp.h"
    • "WCharacter.h"
    • "WString*"
    • "binary.h"
  3. port USB, SPI and Wire into API: for all of them types u8/u32 have been replaced with standard types;
  4. the digital* APIs have been adapted;
  5. modification of compile recipes (in "platform.txt") to add the API folder.

Copy link
Contributor

@bxparks bxparks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some drive-by comments, because I was curious to see what this was about...

@@ -114,7 +115,7 @@ void HardwareSerial::_tx_udr_empty_irq(void)

// Public Methods //////////////////////////////////////////////////////////////

void HardwareSerial::begin(unsigned long baud, byte config)
void UartClass::begin(unsigned long baud, uint16_t config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config is later assigned to a *_ucsrc which is declared as a uint8_t in UART.h. Was this change intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to https://github.com/arduino/ArduinoCore-API/blob/master/api/HardwareSerial.h#L91 , so the signature must be uint16_t .
Said that, I'll push a commit to fix this by casting the assignment
*_ucsrc = (uint8_t)config; (since we are assured that config fits an uint8_t)


#include "Stream.h"
#if ARDUINO_API_VERSION > 10000
using namespace arduino;
Copy link
Contributor

@bxparks bxparks Apr 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment to explain why this using namespace statement is needed. It us contrary to the usual recommendation of avoiding using namespace in a C++ header file: https://stackoverflow.com/questions/5849457/using-namespace-in-c-headers

volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr);
void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
void begin(unsigned long, uint8_t);
void begin(unsigned long, uint16_t);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, it's not clear why this was changed to a uint16_t, when the config is later assigned only to a uint8_t.

@Tnthr
Copy link

Tnthr commented Sep 12, 2023

Has there been any further discussion on this? Or generally bringing the AVR core into the API? forum or mailing list perhaps?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants