Particle Electron

Particle electron is a tiny development kit for creating 3G cellular connected products.

Particle electron uses its own SDK. theCore provides wrappers for I2C and Serial peripherals.

Particle electron platform can be configured via JSON. Configuration file must conform to a schema below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
  "$schema": "http://json-schema.org/schema#",

  "properties": {
    "name":       { "type": "string", "pattern": "^particle_electron$" },

    "systmr_cfg":
    {
      "type": "object",
      "properties": {
        "freq_hz":  { "type": "integer" },
        "owner":    { "enum": [ "thecore", "user" ] }
      }
    },

    "serial":
    {
      "type": "array",
      "items": { "type": "integer" }
    },

    "i2c":
    {
      "type": "object",
      "properties": {
        "speed":        { "type": "integer" },
        "stretch_clk":  { "type": "boolean" }
      }
    },

    "use_console": { "type": "boolean" }

  },

  "required": [ "name" ]
}

Following sections provide configuration reference for each periphery.

Serial

Serial is used for communication between the Electron and a computer or other devices. The Electron has four hardware (USART) serial channels and two USB serial channels.

theCore allows to enable particular Serial by its number on default baud rate. Desired serial number must put into array with serial name.

Example configuration

1
2
3
4
5
6
{
    "platform": {
        "name":   "particle_electron",
        "serial": [ 0, 2, 3 ]
    }
}

Example output

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
namespace ecl
{

// Serial devices definitions

using serial_device0 = uart_bus<uart_device::serial0>;
using serial_device2 = uart_bus<uart_device::serial2>;
using serial_device3 = uart_bus<uart_device::serial3>;

} // namespace ecl

Full Particle Electron Serial example header

Console

To enable console in theCore, set use_console flag and enable Serial0 via JSON:

1
2
3
4
5
6
7
{
    "platform": {
        "name":         "particle_electron",
        "serial":       [ 0 ],
        "console":      true,
    }
}

Check the Console streams section for more details about theCore console library.

Wire (I2C)

Note

theCore allows to configure only one Wire/I2C instance with a pinout:

  • SCL => D1
  • SDA => D0

Example configuration

1
2
3
4
5
6
7
8
9
{
    "platform": {
        "name":   "particle_electron",
        "i2c": {
            "speed": 20000,
            "stretch_clk": false
        }
    }
}

Example output

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
namespace ecl
{

// I2C device defintions


template<>
struct i2c_bus_cfg<i2c_device::wire0>
{
    static constexpr auto speed         = 20000;
    static constexpr auto stretch_clk   = false;
};

using i2c_dev = i2c_bus<i2c_device::wire0>;

} // namespace ecl

Full Particle Electron I2C/Wire example header

Properties

Timer allocation

To save power and improve performance, theCore uses one of Particle timers internally. Find more details of Timers in the Particle Electron documentation for software timers

Flashing firmware

To flash resulting binary to the board, follow next sequence:

  • Put device into the DFU mode
  • Launch scripts/electron_dfu.sh script with a path to a binary as an argument.