Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

Commit 35037cb

Browse files
ridhaosWi6labsVVESTM
authored andcommitted
Update SPI library for STM8 architecture
1 parent 4b422c6 commit 35037cb

File tree

5 files changed

+339
-252
lines changed

5 files changed

+339
-252
lines changed

libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@
2929
const int PRESSURE = 0x1F; //3 most significant bits of pressure
3030
const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure
3131
const int TEMPERATURE = 0x21; //16 bit temperature reading
32-
const byte READ = 0b11111100; // SCP1000's read command
33-
const byte WRITE = 0b00000010; // SCP1000's write command
32+
const byte READ = B11111100; // SCP1000's read command
33+
const byte WRITE = B00000010; // SCP1000's write command
3434

3535
// pins used for the connection with the sensor
3636
// the other you need are controlled by the SPI library):
3737
const int dataReadyPin = 6;
3838
const int chipSelectPin = 7;
3939

40+
unsigned int readRegister(byte thisRegister, int bytesToRead);
41+
void writeRegister(byte thisRegister, byte thisValue);
42+
4043
void setup() {
4144
Serial.begin(9600);
4245

@@ -72,7 +75,7 @@ void loop() {
7275

7376
//Read the pressure data highest 3 bits:
7477
byte pressure_data_high = readRegister(0x1F, 1);
75-
pressure_data_high &= 0b00000111; //you only needs bits 2 to 0
78+
pressure_data_high &= B00000111; //you only needs bits 2 to 0
7679

7780
//Read the pressure data lower 16 bits:
7881
unsigned int pressure_data_low = readRegister(0x20, 2);
@@ -140,4 +143,3 @@ void writeRegister(byte thisRegister, byte thisValue) {
140143
// take the chip select high to de-select:
141144
digitalWrite(chipSelectPin, HIGH);
142145
}
143-

libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
// set pin 10 as the slave select for the digital pot:
3535
const int slaveSelectPin = 10;
3636

37+
void digitalPotWrite(int address, int value);
38+
3739
void setup() {
3840
// set the slaveSelectPin as an output:
3941
pinMode(slaveSelectPin, OUTPUT);

libraries/SPI/library.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version=1.0
33
author=Arduino, Wi6Labs
44
maintainer=stm32duino
55
sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus.
6-
paragraph=This library is based on the official Arduino SPI library and adapted to STM32 boards.
6+
paragraph=This library is based on the official Arduino SPI library and adapted to STM8 boards.
77
category=Communication
88
url=http://www.arduino.cc/en/Reference/SPI
9-
architectures=stm32
9+
architectures=stm8

0 commit comments

Comments
 (0)