Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,8 @@ void delayMicroseconds(unsigned int us) {
}

unsigned long micros(void) {
return k_cyc_to_us_floor32(k_cycle_get_32());
return k_cyc_to_us_floor32(k_cycle_get_64());
}

unsigned long millis(void) {
return k_uptime_get_32();
}
Expand Down
26 changes: 21 additions & 5 deletions cores/arduino/zephyrSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ void arduino::ZephyrSerial::begin(unsigned long baud, uint16_t conf) {

uart_configure(uart, &config);
uart_irq_callback_user_data_set(uart, arduino::ZephyrSerial::IrqDispatch, this);
k_sem_take(&rx.sem, K_FOREVER);
ring_buf_reset(&rx.ringbuf);
k_sem_give(&rx.sem);

uart_irq_rx_enable(uart);
}

Expand Down Expand Up @@ -116,24 +120,36 @@ int arduino::ZephyrSerial::available() {
return ret;
}

int arduino::ZephyrSerial::peek() {
int arduino::ZephyrSerial::availableForWrite()
{
int ret;

k_sem_take(&tx.sem, K_FOREVER);
ret = ring_buf_space_get(&tx.ringbuf);
k_sem_give(&tx.sem);
Comment on lines +127 to +129
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This part is from
arduino@66f8f71d3.

Shouldn't the contribution of the author of this commit also be listed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure I understand , the author is indeed kept as is, it's just a cherrypick.

Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://github.com/arduino/ArduinoCore-zephyr/blame/main/cores/arduino/zephyrSerial.cpp#L126-L134

As you can clearly understand from blame list, this function
has three authorships.

arduino@66f8f71

This also only has matched three lines.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah okay, so I will try to pick all 3 then

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

One of them was just a formatting fix, which I'm leaving out for now


return ret;
}

int arduino::ZephyrSerial::peek()
{
uint8_t data;

k_sem_take(&rx.sem, K_FOREVER);
ring_buf_peek(&rx.ringbuf, &data, 1);
uint32_t cb_ret = ring_buf_peek(&rx.ringbuf, &data, 1);
k_sem_give(&rx.sem);

return data;
return cb_ret? data : -1;
}

int arduino::ZephyrSerial::read() {
uint8_t data;

k_sem_take(&rx.sem, K_FOREVER);
ring_buf_get(&rx.ringbuf, &data, 1);
uint32_t cb_ret = ring_buf_get(&rx.ringbuf, &data, 1);
k_sem_give(&rx.sem);

return data;
return cb_ret? data : -1;
}

size_t arduino::ZephyrSerial::write(const uint8_t *buffer, size_t size) {
Expand Down
1 change: 1 addition & 0 deletions cores/arduino/zephyrSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ZephyrSerial : public HardwareSerial {
}

int available();
int availableForWrite();
int peek();
int read();

Expand Down
Loading