Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: arduino/ArduinoCore-arc32
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.2
Choose a base ref
...
head repository: arduino/ArduinoCore-arc32
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Apr 4, 2017

  1. Change SRAM mapping and increase SRAM allocated to ARC core

    -increase SRAM to 40K
    -change SRAM start address
    -increase heap size to 16K
    -this change is needed for BLE scan for SensorTag
    yashaswini.hanji@intel.com authored and yashaswini-hanji committed Apr 4, 2017
    Copy the full SHA
    562cd84 View commit details
  2. Fix Jira 864 After BLE.end() a peripheral is still showing up in scans

    1. Stop scan, advertising and disconnect the connected devices when call end
    
    Changed files
    BLEDeviceManager.cpp - do the real action
    BLEDevice.cpp - only local BLE device call the real end
    sgbihu authored and yashaswini-hanji committed Apr 4, 2017
    Copy the full SHA
    1785ffc View commit details

Commits on Apr 12, 2017

  1. Copy the full SHA
    6d37b45 View commit details

Commits on Apr 21, 2017

  1. Copy the full SHA
    0ebbf9e View commit details
  2. udpate rtos to 1.6.0

    facchinm authored and yashaswini-hanji committed Apr 21, 2017
    Copy the full SHA
    faac761 View commit details
  3. update core to 2.1.0

    facchinm authored and yashaswini-hanji committed Apr 21, 2017
    Copy the full SHA
    8aabac9 View commit details

Commits on May 9, 2017

  1. stdlib_noniso.cpp: fix another rounding error in dtostrf

    Rounding up the passed float/double to the specified presicion must be the
    *very first* thing we do, before doing anything else with that value
    (In this case, the issue was cause by digitsBe4Decimal() returning an
    incorrect value, because it was being called before passed value was
    rounded up)
    eriknyquist committed May 9, 2017
    Copy the full SHA
    3f61b65 View commit details

Commits on May 12, 2017

  1. stdlib_noniso.cpp: dtostrf(), subtract rounding if number is negative

    If we are working with a negative number, then *adding* the rounding
    onto the number has the opposite to the intended effect. Need to check
    if the number is negative, and if so, subtract the rounding instead of
    adding.
    
    It may appear that a cleaner solution to this is to simply move the
    "handle negative numbers" block (starting on what is now line 222)
    before the "round up to the precision" block (starting on what is now
    line 202). However, I don't think this will work without a substantial
    re-design of this function, for the following reasons;
    
    Any leading padding must be added before handling a negative number
    (adding the '-' char. to output, and then flipping the number's sign for
    calculations). And in order to add the right amount of padding, we must run
    digitsBe4Decimal first, and in order to guarantee an accurate result
    from *that*, the rounding-up must have been done. So there's a fairly
    rigid order here.
    
    Oh, and I also removed the 'goto end', and the label, since an if()
    work just as well. Can't remember why I even added that in the first
    place.
    eriknyquist committed May 12, 2017
    Copy the full SHA
    50f30b3 View commit details

Commits on May 18, 2017

  1. Add IPM (Inter-Processor-Mailbox) driver to cores/arduino

    This allows the mailbox to be used for Serial (instead of polling shared
    memory). The CurieMailbox library, in the codk-m-corelibs branch, will
    not require any API changes, but will now just be a thin wrapper around
    the methods in mailbox.cpp
    eriknyquist authored and bigdinotech committed May 18, 2017
    Copy the full SHA
    936a638 View commit details

Commits on Aug 3, 2017

  1. Fix typo in CurieIMU

    bigdinotech committed Aug 3, 2017
    Copy the full SHA
    6d3c39d View commit details
  2. SoftwareSerial regression fix

    -set pinMode for RX and TX pins inside of begin instead of the
    constructor
    bigdinotech committed Aug 3, 2017
    Copy the full SHA
    c794c47 View commit details

Commits on Aug 8, 2017

  1. Copy the full SHA
    be920e7 View commit details

Commits on Aug 16, 2017

  1. Use IPM for cdc-acm

    -use the IPM instead of shared memory for passing data between ARC
    and x86 cores for cdc-acm.
    bigdinotech committed Aug 16, 2017
    Copy the full SHA
    7bc16b6 View commit details

Commits on Aug 17, 2017

  1. update rtos to 1.8.0

    bigdinotech committed Aug 17, 2017
    Copy the full SHA
    28876f0 View commit details

Commits on Aug 18, 2017

  1. update core to 2.2.0

    bigdinotech committed Aug 18, 2017
    Copy the full SHA
    c76b2ac View commit details

Commits on Sep 5, 2017

  1. Use correct separator in keywords.txt

    The Arduino IDE requires the use of a tab separator between the name and identifier. Without this tab the keyword is not highlighted.
    
    Reference: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywords
    per1234 authored and bigdinotech committed Sep 5, 2017
    Copy the full SHA
    2227ce1 View commit details

Commits on Oct 26, 2017

  1. Set a baud rate limit for cdc-acm internally

    -set a baud rate limit for cdc-acm due to the limitation of Inter Processor Mailbox
    bigdinotech committed Oct 26, 2017
    Copy the full SHA
    00f50b3 View commit details

Commits on May 30, 2018

  1. Replace boolean type with bool in examples

    This is part of a move to encourage use of the standard bool type over Arduino's non-standard boolean type alias.
    per1234 committed May 30, 2018
    Copy the full SHA
    0482f6b View commit details

Commits on Mar 26, 2019

  1. Add necessary delays to SPI DigitalPotControl example

    According to arduino/Arduino#6395, these delays are required for the SPI communication with the digital potentiometer to work.
    SimonePDA authored and per1234 committed Mar 26, 2019
    Copy the full SHA
    2729d38 View commit details

Commits on May 7, 2019

  1. Merge pull request #585 from per1234/boolean-bool

    Replace boolean type with bool in examples
    pnndra authored May 7, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    09026ef View commit details
  2. Merge pull request #595 from per1234/digitalpotcontrol-delays

    Add necessary delays to SPI DigitalPotControl example
    pnndra authored May 7, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9f2e5e1 View commit details
Showing with 5,411 additions and 94 deletions.
  1. +87 −26 cores/arduino/CDCSerialClass.cpp
  2. +8 −5 cores/arduino/CDCSerialClass.h
  3. +1 −1 cores/arduino/Print.h
  4. +163 −0 cores/arduino/mailbox.cpp
  5. +22 −0 cores/arduino/mailbox.h
  6. +19 −15 cores/arduino/stdlib_noniso.cpp
  7. +1 −1 libraries/CurieBLE/examples/Peripheral/ButtonLED/ButtonLED.ino
  8. +1 −1 libraries/CurieBLE/keywords.txt
  9. +6 −1 libraries/CurieBLE/src/BLEDevice.cpp
  10. +4 −0 libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
  11. +1 −1 libraries/CurieI2S/examples/I2SDMA_TXCallBack/I2SDMA_TXCallBack.ino
  12. +1 −1 libraries/CurieIMU/examples/FreeFallDetect/FreeFallDetect.ino
  13. +1 −1 libraries/CurieIMU/examples/MotionDetect/MotionDetect.ino
  14. +1 −1 libraries/CurieIMU/examples/RawImuDataSerial/RawImuDataSerial.ino
  15. +1 −1 libraries/CurieIMU/examples/ShockDetect/ShockDetect.ino
  16. +2 −2 libraries/CurieIMU/examples/StepCount/StepCount.ino
  17. +1 −1 libraries/CurieIMU/examples/ZeroMotionDetect/ZeroMotionDetect.ino
  18. +4 −4 libraries/CurieIMU/keywords.txt
  19. +1 −1 libraries/CurieIMU/src/CurieIMU.cpp
  20. +296 −0 libraries/CuriePowerManagement/README.md
  21. +16 −0 libraries/CuriePowerManagement/examples/TimedWakeup/TimedWakeup.ino
  22. +28 −0 libraries/CuriePowerManagement/examples/WakeFromIMU/WakeFromIMU.ino
  23. +24 −0 libraries/CuriePowerManagement/keywords.txt
  24. +9 −0 libraries/CuriePowerManagement/library.properties
  25. +478 −0 libraries/CuriePowerManagement/src/Power.cpp
  26. +133 −0 libraries/CuriePowerManagement/src/Power.h
  27. +89 −0 libraries/CuriePowerManagement/src/qmsi/power_states.h
  28. +207 −0 libraries/CuriePowerManagement/src/qmsi/qm_interrupt_router_regs.h
  29. +673 −0 libraries/CuriePowerManagement/src/qmsi/qm_sensor_regs.h
  30. +410 −0 libraries/CuriePowerManagement/src/qmsi/qm_soc_interrupts.h
  31. +2,105 −0 libraries/CuriePowerManagement/src/qmsi/qm_soc_regs.h
  32. +295 −0 libraries/CuriePowerManagement/src/qmsi/ss_power_states.h
  33. +172 −0 libraries/CuriePowerManagement/src/wsrc.c
  34. +113 −0 libraries/CuriePowerManagement/src/wsrc.h
  35. +3 −2 libraries/CurieSoftwareSerial/src/SoftwareSerial.cpp
  36. +19 −19 libraries/CurieTimerOne/keywords.txt
  37. +2 −2 libraries/EEPROM/src/EEPROM.cpp
  38. +2 −0 libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino
  39. +1 −1 libraries/SPI/keywords.txt
  40. +1 −1 libraries/Wire/examples/bus_scan/bus_scan.ino
  41. +4 −4 platform.txt
  42. +2 −2 variants/arduino_101/linker_scripts/flash.ld
  43. +4 −0 variants/arduino_101/variant.cpp
113 changes: 87 additions & 26 deletions cores/arduino/CDCSerialClass.cpp
Original file line number Diff line number Diff line change
@@ -30,12 +30,35 @@
#include "wiring_digital.h"
#include "variant.h"

#define CDCACM_FIXED_DELAY 64
#define CDC_MAILBOX_TX_CHANNEL 7
#define CDC_MAILBOX_RX_CHANNEL 6

extern void CDCSerial_Handler(void);
extern void serialEventRun1(void) __attribute__((weak));
extern void serialEvent1(void) __attribute__((weak));

static void cdc_mbox_isr(CurieMailboxMsg msg)
{
char *rxbuffptr = (char*)msg.data;
int new_head;
for(int i = 0; i < MBOX_BYTES; i++)
{
if((uint8_t)(*(rxbuffptr+i)) != '\0')
{
new_head = (Serial._rx_buffer->head +1) % CDCACM_BUFFER_SIZE;
if(new_head != Serial._rx_buffer->tail)
{
Serial._rx_buffer->data[Serial._rx_buffer->head] = *(rxbuffptr+i);
Serial._rx_buffer->head = new_head;
}
}
else
{
break;
}
}
}

// Constructors ////////////////////////////////////////////////////////////////

CDCSerialClass::CDCSerialClass(uart_init_info *info)
@@ -47,9 +70,9 @@ CDCSerialClass::CDCSerialClass(uart_init_info *info)

void CDCSerialClass::setSharedData(struct cdc_acm_shared_data *cdc_acm_shared_data)
{
this->_shared_data = cdc_acm_shared_data;
this->_rx_buffer = cdc_acm_shared_data->rx_buffer;
this->_tx_buffer = cdc_acm_shared_data->tx_buffer;
_shared_data = cdc_acm_shared_data;
_rx_buffer = cdc_acm_shared_data->rx_buffer;
_tx_buffer = cdc_acm_shared_data->tx_buffer;
}

void CDCSerialClass::begin(const uint32_t dwBaudRate)
@@ -63,8 +86,13 @@ void CDCSerialClass::begin(const uint32_t dwBaudRate, const uint8_t config)
}


void CDCSerialClass::init(const uint32_t dwBaudRate, const uint8_t modeReg)
void CDCSerialClass::init(uint32_t dwBaudRate, const uint8_t modeReg)
{
/* Set a max internal baud rate due to the limitation of the
* Inter Processor Mailbox */
if(dwBaudRate > 115200)
dwBaudRate = 115200;

/* Set a per-byte write delay approximately equal to the time it would
* take to clock out a byte on a standard UART at this baud rate */
_writeDelayUsec = 8000000 / dwBaudRate;
@@ -73,7 +101,9 @@ void CDCSerialClass::init(const uint32_t dwBaudRate, const uint8_t modeReg)
* Empty the Rx buffer but don't touch Tx buffer: it is drained by the
* LMT one way or another */
_rx_buffer->tail = _rx_buffer->head;


mailbox_register(CDC_MAILBOX_RX_CHANNEL, cdc_mbox_isr);
mailbox_enable_receive(CDC_MAILBOX_RX_CHANNEL);
_shared_data->device_open = true;
}

@@ -84,12 +114,10 @@ void CDCSerialClass::end( void )

int CDCSerialClass::available( void )
{
#define SBS CDCACM_BUFFER_SIZE

if (!_shared_data->device_open)
return (0);
else
return (int)(SBS + _rx_buffer->head - _rx_buffer->tail) % SBS;
return (int)(CDCACM_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % CDCACM_BUFFER_SIZE;
}

int CDCSerialClass::availableForWrite(void)
@@ -131,28 +159,61 @@ void CDCSerialClass::flush( void )
}
}

size_t CDCSerialClass::write( const uint8_t uc_data )
size_t CDCSerialClass::write(uint8_t uc_data )
{
uint32_t retries = 2;
CurieMailboxMsg cdcacm_msg;

if (!_shared_data->device_open || !_shared_data->host_open)
return(0);

do {
int i = (uint32_t)(_tx_buffer->head + 1) % CDCACM_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != _tx_buffer->tail) {
_tx_buffer->data[_tx_buffer->head] = uc_data;
_tx_buffer->head = i;

// Just use a fixed delay to make it compatible with the CODK-M based firmware
delayMicroseconds(CDCACM_FIXED_DELAY);
break;
cdcacm_msg.channel = CDC_MAILBOX_TX_CHANNEL;
cdcacm_msg.data[0] = uc_data;
mailbox_write(cdcacm_msg);
delayMicroseconds(_writeDelayUsec);
return 1;
}

size_t CDCSerialClass::write(const uint8_t *buffer, size_t size)
{
CurieMailboxMsg cdcacm_msg;
cdcacm_msg.channel = CDC_MAILBOX_TX_CHANNEL;
if (!_shared_data->device_open || !_shared_data->host_open)
return(0);

int msg_len = size;

for(int i = 0;msg_len > 0; msg_len -= MBOX_BYTES, i += MBOX_BYTES)
{
/* Copy data into mailbox message */
memset(cdcacm_msg.data, 0, MBOX_BYTES);
if(msg_len >= MBOX_BYTES)
{
memcpy(cdcacm_msg.data, buffer+i, MBOX_BYTES);
}
} while (retries--);
else
{
memcpy(cdcacm_msg.data, buffer+i, msg_len);
}
/* Write to mailbox*/
mailbox_write(cdcacm_msg);
}

return 1;
// Mimick the throughput of a typical UART by throttling the data
// flow according to the configured baud rate
delayMicroseconds(_writeDelayUsec * size);

return size;
}

size_t CDCSerialClass::write(const char *str)
{
if (str == NULL) return 0;
CurieMailboxMsg cdcacm_msg;
cdcacm_msg.channel = CDC_MAILBOX_TX_CHANNEL;
if (!_shared_data->device_open || !_shared_data->host_open)
return(0);

int msg_len = strlen(str);

return write((const uint8_t *)str, msg_len);
}
13 changes: 8 additions & 5 deletions cores/arduino/CDCSerialClass.h
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
#include "HardwareSerial.h"
#include "platform.h"
#include "wiring.h"
#include "mailbox.h"

#include <board.h>
#include <uart.h>
@@ -36,6 +37,10 @@ class CDCSerialClass : public HardwareSerial
CDCSerialClass(uart_init_info *info);

void setSharedData(struct cdc_acm_shared_data *cdc_acm_shared_data);

struct cdc_acm_shared_data *_shared_data;
struct cdc_ring_buffer *_rx_buffer;
struct cdc_ring_buffer *_tx_buffer;

void begin(const uint32_t dwBaudRate);
void begin(const uint32_t dwBaudRate, const uint8_t config);
@@ -46,6 +51,8 @@ class CDCSerialClass : public HardwareSerial
int read(void);
void flush(void);
size_t write(const uint8_t c);
size_t write(const char *str);
size_t write(const uint8_t *buffer, size_t size);
using Print::write; // pull in write(str) and write(buf, size) from Print

operator bool() {
@@ -56,11 +63,7 @@ class CDCSerialClass : public HardwareSerial
};

protected:
void init(const uint32_t dwBaudRate, const uint8_t config);

struct cdc_acm_shared_data *_shared_data;
struct cdc_ring_buffer *_rx_buffer;
struct cdc_ring_buffer *_tx_buffer;
void init(uint32_t dwBaudRate, const uint8_t config);

uart_init_info *info;
uint32_t _writeDelayUsec;
2 changes: 1 addition & 1 deletion cores/arduino/Print.h
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ class Print
void clearWriteError() { setWriteError(0); }

virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
virtual size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
163 changes: 163 additions & 0 deletions cores/arduino/mailbox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#include <string.h>
#include "interrupt.h"
#include "scss_registers.h"
#include "mailbox.h"

#define CHANNEL_STS_MASK 0x1
#define CHANNEL_INT_MASK 0x2
#define CTRL_WORD_MASK 0x7FFFFFFF
#define CHALL_STATUS_MASK 0xFFFF
#define CHANNEL_STS_BITS (CHANNEL_STS_MASK | CHANNEL_INT_MASK)

/* Mailbox channel status register */
#define IO_REG_MAILBOX_CHALL_STS (SCSS_REGISTER_BASE + 0xAC0)

typedef struct mbox_channel mbox_channel_t;
typedef struct mbox_intmask mbox_intmask_t;

/* Represents the registers for a single mailbox channel */
struct mbox_channel {
uint32_t ctrl;
uint32_t data[CHANNEL_DATA_WORDS];
uint32_t sts;
};

/* Mailbox interrupt mask; right now we only care about the
* second byte, for SS mailbox interrupts (one bit per mailbox channel) */
struct mbox_intmask {
uint8_t lmt_intmask;
uint8_t ss_intmask;
uint8_t lmt_halt;
uint8_t ss_halt;
};

static volatile mbox_intmask_t *intmask;
static volatile mbox_channel_t *mbox;
static void (*callbacks[NUM_MAILBOX_CHANNELS])(CurieMailboxMsg);

void mailbox_register (int channel, void(*callback)(CurieMailboxMsg))
{
if (channel >= 0 && channel < NUM_MAILBOX_CHANNELS) {
callbacks[channel] = callback;
}
}

void mailbox_unregister (int channel)
{
if (channel >= 0 && channel < NUM_MAILBOX_CHANNELS) {
callbacks[channel] = 0;
}
}

void mailbox_disable_receive (int channel)
{
intmask->ss_intmask |= 1 << channel;
}

void mailbox_enable_receive (int channel)
{
intmask->ss_intmask &= ~(1 << channel);
}

static void do_callback (int channel, CurieMailboxMsg& msg)
{
void (*cb)(CurieMailboxMsg) = callbacks[channel];
if (cb) {
cb(msg);
}
}

static void mailbox_read (int channel, CurieMailboxMsg& msg)
{
unsigned int i;

/* Copy channel data into CurieMailboxMsg object */
msg.id = mbox[channel].ctrl & CTRL_WORD_MASK;
msg.channel = channel;

for (i = 0; i < CHANNEL_DATA_WORDS; ++i) {
msg.data[i] = mbox[channel].data[i];
}

/* Clear channel status & interrupt flags */
mbox[channel].sts |= CHANNEL_STS_BITS;
}

void mailbox_write (CurieMailboxMsg& msg)
{
int i;
uint32_t key;

/* Can't write if channel status flag is set */
while ((mbox[msg.channel].sts & CHANNEL_STS_MASK));
key = interrupt_lock();

/* Poplate channel payload */
mbox[msg.channel].ctrl |= (msg.id & CTRL_WORD_MASK);
for (i = 0; i < CHANNEL_DATA_WORDS; ++i) {
mbox[msg.channel].data[i] = msg.data[i];
}

/* Trigger interupt to host */
mbox[msg.channel].ctrl |= ~(CTRL_WORD_MASK);

/* Wait for HW to set the channel status bit */
while (!(mbox[msg.channel].sts & CHANNEL_STS_MASK));

/* Wait for destination processor to clear channel status bit */
while ((mbox[msg.channel].sts & CHANNEL_STS_MASK));
interrupt_unlock(key);
}

static uint16_t get_chall_sts (void)
{
return MMIO_REG_VAL(IO_REG_MAILBOX_CHALL_STS) & CHALL_STATUS_MASK;
}

static void mailbox_isr (void)
{
int i;
uint32_t sts;
CurieMailboxMsg msg;

sts = get_chall_sts();
/* Get channel number */
for (i = 0; i < NUM_MAILBOX_CHANNELS; ++i) {
if (sts & (1 << (i * 2 + 1))) {
break;
}
}

mailbox_read(i, msg);
do_callback(i, msg);
}

static void mailbox_hardware_init (void)
{
int i;

for (i = 0; i < NUM_MAILBOX_CHANNELS; ++i) {
mbox[i].sts &= ~(CHANNEL_STS_BITS);
}
}

static void mailbox_interrupts_init (bool master)
{
interrupt_disable(SOC_MBOX_INTERRUPT);

/* Mask SS mailbox interrupts for all channels;
* Unmasking is done by enableReceive */
intmask->ss_intmask = 0xFF;

if (master) mailbox_hardware_init();
interrupt_connect(SOC_MBOX_INTERRUPT, mailbox_isr);
interrupt_enable(SOC_MBOX_INTERRUPT);
}

void mailbox_init (bool master)
{
intmask = (mbox_intmask_t *)IO_REG_MAILBOX_INT_MASK;
mbox = (mbox_channel_t *)IO_REG_MAILBOX_BASE;
memset(callbacks, 0, sizeof(callbacks));
mailbox_interrupts_init(master);
}
Loading