This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying my Blockstack ID is secured with the address 13pJM7w1H1E7zWp2caYhd3TedVicc8cEWo https://explorer.blockstack.org/address/13pJM7w1H1E7zWp2caYhd3TedVicc8cEWo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying my Blockstack ID is secured with the address 13pJM7w1H1E7zWp2caYhd3TedVicc8cEWo https://explorer.blockstack.org/address/13pJM7w1H1E7zWp2caYhd3TedVicc8cEWo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying my Blockstack ID is secured with the address 1PGgFRe5F8Q1YdepbaWU1b4hdMegLztnAf https://explorer.blockstack.org/address/1PGgFRe5F8Q1YdepbaWU1b4hdMegLztnAf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub extern fn main_entry() { | |
let mut s = Serial::new(); | |
s.tx_string("Hello from Rust!\n"); | |
loop { | |
let data = s.rx_i32(); | |
s.tx_string("Received: "); | |
s.tx_i32(data); | |
s.tx_string("\n"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Blink the LED connected to Pin PC13 on an STM32 Blue Pill | |
// From https://satoshinm.github.io/blog/171212_stm32_blue_pill_arm_development_board_first_look_bare_metal_programming.html | |
#define STACK_TOP 0x20002000 | |
#include "stm32f10x.h" | |
// from: stm32f103xb.h | |
#define RCC_APB2ENR_IOPAEN_Pos (2U) | |
#define RCC_APB2ENR_IOPAEN_Msk (0x1U << RCC_APB2ENR_IOPAEN_Pos) /*!< 0x00000004 */ | |
#define RCC_APB2ENR_IOPAEN RCC_APB2ENR_IOPAEN_Msk /*!< I/O port A clock enable */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() -> ! { | |
// Show "Hello, world!" on the debug console, which is shown in OpenOCD. "mut" means that this object is mutable, i.e. it can change. | |
let mut debug_out = hio::hstdout().unwrap(); | |
writeln!(debug_out, "Hello, world!").unwrap(); | |
// Get peripherals (clocks, flash memory, GPIO) for the STM32 Blue Pill microcontroller. | |
let bluepill = Peripherals::take().unwrap(); | |
// Get the clocks from the STM32 Reset and Clock Control (RCC) and freeze the Flash Access Control Register (ACR). | |
let mut rcc = bluepill.RCC.constrain(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get GPIO Port C, which also enables the Advanced Peripheral Bus 2 (APB2) clock for Port C. | |
let mut gpioc = bluepill.GPIOC.split(&mut rcc.apb2); | |
// Use Pin PC 13 of the Blue Pill for GPIO Port C. Select Output Push/Pull mode for the pin, which is connected to our LED. | |
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh); | |
... | |
// Loop forever. | |
loop { | |
// Output 3.3V on the LED Pin and show a message in OpenOCD console. | |
led.set_high(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() -> ! { | |
// Show "Hello, world!" on the debug console, which is shown in OpenOCD. "mut" means that this object is mutable, i.e. it can change. | |
let mut debug_out = hio::hstdout().unwrap(); | |
writeln!(debug_out, "Hello, world!").unwrap(); | |
// Get peripherals (clocks, flash memory, GPIO) for the STM32 Blue Pill microcontroller. | |
let bluepill = Peripherals::take().unwrap(); | |
// Get the clocks from the STM32 Reset and Clock Control (RCC) and freeze the Flash Access Control Register (ACR). | |
let mut rcc = bluepill.RCC.constrain(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void sensor_setup(uint8_t display_task_id) { | |
// Start the sensor tasks for each sensor to read and process sensor data. | |
// Edit this function to add your own sensors. | |
// Set up the sensors and get their sensor contexts. | |
const int pollInterval = 500; // Poll the sensor every 500 milliseconds. | |
SensorContext *tempContext = setup_temp_sensor(pollInterval, display_task_id); | |
SensorContext *humidContext = setup_humid_sensor(pollInterval, display_task_id); | |
// For each sensor, create sensor tasks using the same task function, but with unique sensor context. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void sensor_task(void) { | |
// Background task to receive and process sensor data. | |
// This task will be reused by all sensors: temperature, humidity, altitude. | |
SensorContext *context = NULL; // Declared outside the task to prevent cross-initialisation error in C++. | |
MsgQ_t queue; Evt_t event; // TODO: Workaround for msg_post() in C++. | |
task_open(); // Start of the task. Must be matched with task_close(). | |
for (;;) { // Run the sensor processing code forever. So the task never ends. | |
// This code is executed by multiple sensors. We use a global semaphore to prevent | |
// concurrent access to the single shared I2C Bus on Arduino Uno. | |
sem_wait(i2cSemaphore); // Wait until no other sensor is using the I2C Bus. Then lock the semaphore. |
OlderNewer