├── .gitignore
├── 09_HelloRF_Receiver
├── nRF_SPI.h
├── nRF_RegText.h
├── nRF_Tx.h
├── 09_HelloRF_Receiver.dep
├── commonTypes.h
├── nRF_LowLevel.h
├── nRF_Tx.c
├── nRF_Modes.h
├── ClockUartLed.h
├── nRF_RegText.c
├── logs
│ └── 20151213-20h30.txt
├── 09_HelloRF_Receiver.ewt
├── nRF_LowLevel.c
└── main_RxreadOnce.c
├── 04_HelloRF_NordicAPI
├── nRF_SPI.h
├── ClockUartLed.h
├── Registers Dump output.txt
├── 04_HelloRF_NordicAPI.ewt
├── nRF_LowLevel.h
├── main.c
├── .Backups
│ └── main.c{Rev 2015;09;26 14;31;25 PM}.c
└── nRF_LowLevel.c
├── 08_HelloRF_Transmitter
├── nRF_SPI.h
├── nRF_RegText.h
├── nRF_Tx.h
├── logs
│ ├── 20151213-16h17 Transmitter.txt
│ ├── 20151213-12h32 Transmitter.txt
│ └── 20151213-20h37.txt
├── commonTypes.h
├── nRF_LowLevel.h
├── nRF_Tx.c
├── nRF_Modes.h
├── ClockUartLed.h
├── nRF_RegText.c
├── 08_HelloRF_Transmitter.ewt
├── nRF_LowLevel.c
└── main.c
├── 10_HelloRF_Receiver_IRQ
├── nRF_SPI.h
├── nRF_IRQ.h
├── nRF_RegText.h
├── nRF_Tx.h
├── commonTypes.h
├── nRF_LowLevel.h
├── nRF_Tx.c
├── nRF_Modes.h
├── ClockUartLed.h
├── nRF_RegText.c
├── main.c
├── 10_Hello_Receiver_IRQ.ewt
├── nRF_LowLevel.c
└── nRF_IRQ.c
├── 06_RGBLeds_24bitParam
├── Bits Timings.xlsx
├── HelloUart.ewt
├── 05_Hello_RGBLeds.ewt
├── .Backups
│ ├── HelloUart.ewt{Rev 2015;10;09 18;21;56 PM}.ewt
│ └── 02_HelloUart.dep{Rev 2015;10;09 18;21;56 PM}.dep
├── commonTypes.h
├── 06_Hello_RGBLeds_24BitsParam.ewt
├── ClockUartLed.h
├── WS2812B.h
├── 02_HelloUart.dep
├── 05_Hello_RGBLeds.dep
└── hello_leds_24bits.c
├── 17_STM8L_UART_HelloRF
├── pr00_LibraryCommon
│ ├── nRF_SPI.h
│ ├── nRF_IRQ.h
│ ├── nRF_RegText.h
│ ├── nRF_Tx.h
│ ├── commonTypes.h
│ ├── nRF_LowLevel.h
│ ├── temp_ds18b20.h
│ ├── nRF_Tx.c
│ ├── nRF_Modes.h
│ ├── nRF_RegText.c
│ ├── WS2812B.h
│ └── nRF_IRQ.c
├── ClockUartLed.h
├── 17_STM8L_UART_HelloRF.ewt
└── main.c
├── 19_STM8L_Hello_Battery
├── pr00_LibraryCommon
│ ├── nRF_SPI.h
│ ├── nRF_IRQ.h
│ ├── nRF_RegText.h
│ ├── nRF_Tx.h
│ ├── commonTypes.h
│ ├── nRF_LowLevel.h
│ ├── temp_ds18b20.h
│ ├── nRF_Tx.c
│ ├── nRF_Modes.h
│ ├── nRF_RegText.c
│ ├── WS2812B.h
│ └── nRF_IRQ.c
├── ClockUartLed.h
└── 19_STM8L_Hello_Battery.ewt
├── 21_STM8L_Hello_LowPower
├── pr00_LibraryCommon
│ ├── nRF_SPI.h
│ ├── nRF_IRQ.h
│ ├── nRF_RegText.h
│ ├── nRF_Tx.h
│ ├── commonTypes.h
│ ├── nRF_LowLevel.h
│ ├── temp_ds18b20.h
│ ├── nRF_Tx.c
│ ├── nRF_Modes.h
│ ├── nRF_RegText.c
│ ├── WS2812B.h
│ └── nRF_IRQ.c
├── ClockUartLed.h
└── 21_STM8L_Hello_LowPower.ewt
├── .gitattributes
├── 01_HelloLed
├── HelloLed.ewt
├── 01_HelloLed.dep
└── hello_led.c
├── 02_HelloUart
├── HelloUart.ewt
└── 02_HelloUart.dep
├── 05_Hello_RGBLeds
├── HelloUart.ewt
├── 05_Hello_RGBLeds.ewt
├── .Backups
│ ├── HelloUart.ewt{Rev 2015;10;09 18;21;56 PM}.ewt
│ └── 02_HelloUart.dep{Rev 2015;10;09 18;21;56 PM}.dep
├── 02_HelloUart.dep
└── 05_Hello_RGBLeds.dep
├── 15_Hello_STM8L_Signal
├── 15_Hello_STM8L_Signal.ewt
├── hello_led.c
└── 15_Hello_STM8L_Signal.dep
├── 11_HelloADC
├── commonTypes.h
├── main.c
├── 11_HelloADC.ewt
├── ClockUartLed.h
└── 11_HelloADC.dep
├── 14_Hello_I2C_Slave
├── commonTypes.h
├── 14_Hello_I2C_Slave.ewt
├── ClockUartLed.h
├── log.txt
├── main_i2c_Slave.c
└── i2c.h
├── 18_STM8L_HelloI2C
├── commonTypes.h
├── 18_STM8L_HelloI2C.ewt
├── ClockUartLed.h
└── i2c.h
├── 12_Hello_AutoWakeUp
├── commonTypes.h
├── 12_Hello_AutoWakeUp.ewt
├── ClockUartLed.h
└── 12_Hello_AutoWakeUp.dep
├── 13_Hello_I2C_Master
├── commonTypes.h
├── 13_Hello_I2C_Master.ewt
├── ClockUartLed.h
├── main_i2c_Master.c
├── log.txt
└── i2c.h
├── 22_Hello_AmbientLight_BH1750
├── commonTypes.h
├── 22_Hello_AmbientLight_BH1750.ewt
├── ClockUartLed.h
├── main_i2c_AmbientLight.c
└── i2c_m.h
├── 16_HelloTrainUart
├── 16_HelloTrainUart.ewt
└── ClockUartLed.h
├── 20_Hello_LightDimmer
├── 20_Hello_LightDimmer.ewt
├── ClockUartLed.h
├── main.c
└── 20_Hello_LightDimmer.dep
├── 07_Hello_Temperature
├── 07_Hello_Temperature.ewt
├── ClockUartLed.h
└── 07_Hello_Temperature.dep
├── STM8Incremental.eww
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | 01_HelloLed/Debug/
2 | 01_HelloLed/Release/
3 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_SPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/09_HelloRF_Receiver/nRF_SPI.h
--------------------------------------------------------------------------------
/04_HelloRF_NordicAPI/nRF_SPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/04_HelloRF_NordicAPI/nRF_SPI.h
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/nRF_SPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/08_HelloRF_Transmitter/nRF_SPI.h
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_SPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/10_HelloRF_Receiver_IRQ/nRF_SPI.h
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/Bits Timings.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/06_RGBLeds_24bitParam/Bits Timings.xlsx
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_SPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_SPI.h
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_SPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_SPI.h
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_SPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HomeSmartMesh/STM8_IoT_HelloWorld/HEAD/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_SPI.h
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_IRQ.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_IRQ.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 14.12.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | //nRF24L01P module IRQ on D2
14 |
15 | void nRF_IRQ_Config();
16 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_RegText.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "commonTypes.h"
13 |
14 | void nRF_PrintStatus(BYTE status);
15 | void nRF_PrintConfig();
16 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/nRF_RegText.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "commonTypes.h"
13 |
14 | void nRF_PrintStatus(BYTE status);
15 | void nRF_PrintConfig();
16 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_RegText.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "commonTypes.h"
13 |
14 | void nRF_PrintStatus(BYTE status);
15 | void nRF_PrintConfig();
16 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_IRQ.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_IRQ.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 14.12.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | //nRF24L01P module IRQ on D2
14 |
15 | void nRF_IRQ_Config();
16 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_IRQ.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_IRQ.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 14.12.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | //nRF24L01P module IRQ on D2
14 |
15 | void nRF_IRQ_Config();
16 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_IRQ.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_IRQ.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 14.12.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | //nRF24L01P module IRQ on D2
14 |
15 | void nRF_IRQ_Config();
16 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_RegText.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "commonTypes.h"
13 |
14 | void nRF_PrintStatus(BYTE status);
15 | void nRF_PrintConfig();
16 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_RegText.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "commonTypes.h"
13 |
14 | void nRF_PrintStatus(BYTE status);
15 | void nRF_PrintConfig();
16 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_RegText.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "commonTypes.h"
13 |
14 | void nRF_PrintStatus(BYTE status);
15 | void nRF_PrintConfig();
16 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_Tx.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | BYTE nRF_Transmit(BYTE* payload, BYTE size);
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/nRF_Tx.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | BYTE nRF_Transmit(BYTE* payload, BYTE size);
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_Tx.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | BYTE nRF_Transmit(BYTE* payload, BYTE size);
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_Tx.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | BYTE nRF_Transmit(BYTE* payload, BYTE size);
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_Tx.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | BYTE nRF_Transmit(BYTE* payload, BYTE size);
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_Tx.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | BYTE nRF_Transmit(BYTE* payload, BYTE size);
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/logs/20151213-16h17 Transmitter.txt:
--------------------------------------------------------------------------------
1 | _________________________
2 | STM8 Transmitter, Node 1
3 | Config updated: STATUS: Max Ret i; Rx Pipe Nb 0x06 ; TX Fifo Full;
4 | Clearing the status
5 | New STATUS: Rx Pipe not used ;
6 | SetMode_Tx: STATUS: Max Ret i; Rx Pipe Nb 0x06 ; TX Fifo Full;
7 | Tx: 0x01 ; STATUS: Rx Pipe not used ;
8 | CONFIG: 0x70
9 | Tx: 0x02 ; STATUS: Rx Pipe not used ;
10 | CONFIG: 0x70
11 | Tx: 0x03 ; STATUS: Rx Pipe not used ;
12 | CONFIG: 0x70
13 | Tx: 0x04 ; STATUS: Rx Pipe not used ;
14 | CONFIG: 0x70
15 |
--------------------------------------------------------------------------------
/01_HelloLed/HelloLed.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_led.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/02_HelloUart/HelloUart.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_uart.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/05_Hello_RGBLeds/HelloUart.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_uart.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/HelloUart.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_uart.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/05_Hello_RGBLeds/05_Hello_RGBLeds.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_leds.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/05_Hello_RGBLeds.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_leds.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/15_Hello_STM8L_Signal/15_Hello_STM8L_Signal.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_led.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/05_Hello_RGBLeds/.Backups/HelloUart.ewt{Rev 2015;10;09 18;21;56 PM}.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_uart.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/.Backups/HelloUart.ewt{Rev 2015;10;09 18;21;56 PM}.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\hello_uart.c
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/09_HelloRF_Receiver.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 2485860317
6 |
7 | Debug
8 |
9 |
10 | [MULTI_TOOL]
11 | ILINK
12 |
13 |
14 |
15 | Release
16 |
17 |
18 | [MULTI_TOOL]
19 | ILINK
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/11_HelloADC/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/14_Hello_I2C_Slave/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/18_STM8L_HelloI2C/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/12_Hello_AutoWakeUp/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/13_Hello_I2C_Master/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/22_Hello_AmbientLight_BH1750/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/commonTypes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 13.12.2015
10 | * $Revision:
11 | *
12 | */
13 |
14 | // UINT type definition
15 | #ifndef _UINT_DEF_
16 | #define _UINT_DEF_
17 | typedef unsigned int UINT;
18 | #endif
19 |
20 | // BYTE type definition
21 | #ifndef _BYTE_DEF_
22 | #define _BYTE_DEF_
23 | typedef unsigned char BYTE;
24 | #endif
25 |
26 |
27 | #ifndef E_OK
28 | #define E_OK 0x00
29 | #endif
30 |
31 | #ifndef E_Already_Initialised
32 | #define E_Already_Initialised 0x01
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/04_HelloRF_NordicAPI/ClockUartLed.h:
--------------------------------------------------------------------------------
1 | /** @file ClockUartLed.h
2 | *
3 | * @author Wassim FILALI taken over from http://blog.mark-stevens.co.uk/
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 20.09.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | void InitialiseUART();
14 |
15 | void UARTPrintf(char const *message);
16 |
17 | void UARTPrintfLn(char const *message);
18 |
19 | void UARTPrintfHex(unsigned char val);
20 |
21 | void UARTPrintfHexLn(unsigned char val);
22 |
23 |
24 | void InitialiseSystemClock();
25 |
26 | void delay(unsigned int n);
27 |
28 |
29 | // L E D
30 | void Initialise_TestLed_GPIO_B5();
31 | void Test_Led_On();
32 | void Test_Led_Off();
33 |
34 |
--------------------------------------------------------------------------------
/11_HelloADC/main.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 |
5 | #include "ClockUartLed.h"
6 | #include "commonTypes.h"
7 |
8 | int main( void )
9 | {
10 |
11 | BYTE counter = 0;
12 |
13 | InitialiseSystemClock();
14 |
15 | Initialise_TestLed_GPIO_B5();
16 |
17 | Test_Led_Off();
18 |
19 | InitialiseUART();
20 |
21 | UARTPrintf("\r\n_________________________\n\r");
22 | UARTPrintf("STM8 ADC...\n\r");
23 |
24 | while (1)
25 | {
26 |
27 | counter++;
28 | UARTPrintf("loop Rx counter: ");
29 | UARTPrintfHex(counter);
30 |
31 | Test_Led_Off();
32 | delay_1ms_Count(400);
33 |
34 | Test_Led_On();
35 | delay_1ms_Count(100);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/16_HelloTrainUart/16_HelloTrainUart.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\main.c
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/logs/20151213-12h32 Transmitter.txt:
--------------------------------------------------------------------------------
1 | _________________________
2 | STM8 Trandmitter, Node 1
3 | Stauts = 0x1D
4 | Tx: 0x01 ; STATUS: 0x0E
5 | Tx: 0x02 ; STATUS: 0x0E
6 | Tx: 0x03 ; STATUS: 0x0E
7 | Tx: 0x04 ; STATUS: 0x0F
8 | Tx: 0x05 ; STATUS: 0x0F
9 | Tx: 0x06 ; STATUS: 0x0F
10 |
11 | _________________________
12 | STM8 Trandmitter, Node 1
13 | Stauts = 0x1D 0001 1101 MAX_RT ; RX_P_NO(not used) ; TX_FULL
14 | Tx: 0x01 ; STATUS: 0x0E 0000 1110 RX_P_NO(RX fifo empty)
15 | Tx: 0x02 ; STATUS: 0x0E 0000 1110
16 | Tx: 0x03 ; STATUS: 0x0E 0000 1110
17 | Tx: 0x04 ; STATUS: 0x0F 0000 1111 RX_P_NO(RX fifo empty) ; TX_FULL
18 | Tx: 0x05 ; STATUS: 0x0F 0000 1111
19 | Tx: 0x06 ; STATUS: 0x0F 0000 1111
20 |
21 |
--------------------------------------------------------------------------------
/20_Hello_LightDimmer/20_Hello_LightDimmer.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\main.c
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/07_Hello_Temperature/07_Hello_Temperature.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\hello_Temperature.c
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/11_HelloADC/11_HelloADC.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\main.c
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/nRF_LowLevel.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * This low level is applied on the STM8103F3 so this should be the only file
8 | * to modify when porting this to another MCU
9 | *
10 | * $Date: 20.09.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | //------------------------Low Level API------------------------
19 |
20 | void SPI_Init_ChipEnable_Pin();
21 |
22 | void CE_Pin_LowDisable();
23 |
24 | void CE_Pin_HighEnable();
25 |
26 | void SPI_Init_ChipSelect_Pin();
27 |
28 | void CSN_Pin_LowSelect();
29 |
30 | void CSN_Pin_HighDisable();
31 |
32 | void SPI_Init_Peripheral();
33 |
34 | BYTE SPI_WriteRead(BYTE Data);
35 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_LowLevel.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * This low level is applied on the STM8103F3 so this should be the only file
8 | * to modify when porting this to another MCU
9 | *
10 | * $Date: 20.09.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | //------------------------Low Level API------------------------
19 |
20 | void SPI_Init_ChipEnable_Pin();
21 |
22 | void CE_Pin_LowDisable();
23 |
24 | void CE_Pin_HighEnable();
25 |
26 | void SPI_Init_ChipSelect_Pin();
27 |
28 | void CSN_Pin_LowSelect();
29 |
30 | void CSN_Pin_HighDisable();
31 |
32 | void SPI_Init_Peripheral();
33 |
34 | BYTE SPI_WriteRead(BYTE Data);
35 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_LowLevel.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * This low level is applied on the STM8103F3 so this should be the only file
8 | * to modify when porting this to another MCU
9 | *
10 | * $Date: 20.09.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | //------------------------Low Level API------------------------
19 |
20 | void SPI_Init_ChipEnable_Pin();
21 |
22 | void CE_Pin_LowDisable();
23 |
24 | void CE_Pin_HighEnable();
25 |
26 | void SPI_Init_ChipSelect_Pin();
27 |
28 | void CSN_Pin_LowSelect();
29 |
30 | void CSN_Pin_HighDisable();
31 |
32 | void SPI_Init_Peripheral();
33 |
34 | BYTE SPI_WriteRead(BYTE Data);
35 |
--------------------------------------------------------------------------------
/12_Hello_AutoWakeUp/12_Hello_AutoWakeUp.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\main.c
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_LowLevel.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * This low level is applied on the STM8103F3 so this should be the only file
8 | * to modify when porting this to another MCU
9 | *
10 | * $Date: 20.09.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | //------------------------Low Level API------------------------
19 |
20 | void SPI_Init_ChipEnable_Pin();
21 |
22 | void CE_Pin_LowDisable();
23 |
24 | void CE_Pin_HighEnable();
25 |
26 | void SPI_Init_ChipSelect_Pin();
27 |
28 | void CSN_Pin_LowSelect();
29 |
30 | void CSN_Pin_HighDisable();
31 |
32 | void SPI_Init_SCK_MOSI_MISO_Pins();
33 |
34 | void SPI_Init_Peripheral();
35 |
36 | BYTE SPI_WriteRead(BYTE Data);
37 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_LowLevel.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * This low level is applied on the STM8103F3 so this should be the only file
8 | * to modify when porting this to another MCU
9 | *
10 | * $Date: 20.09.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | //------------------------Low Level API------------------------
19 |
20 | void SPI_Init_ChipEnable_Pin();
21 |
22 | void CE_Pin_LowDisable();
23 |
24 | void CE_Pin_HighEnable();
25 |
26 | void SPI_Init_ChipSelect_Pin();
27 |
28 | void CSN_Pin_LowSelect();
29 |
30 | void CSN_Pin_HighDisable();
31 |
32 | void SPI_Init_SCK_MOSI_MISO_Pins();
33 |
34 | void SPI_Init_Peripheral();
35 |
36 | BYTE SPI_WriteRead(BYTE Data);
37 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_LowLevel.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * This low level is applied on the STM8103F3 so this should be the only file
8 | * to modify when porting this to another MCU
9 | *
10 | * $Date: 20.09.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | //------------------------Low Level API------------------------
19 |
20 | void SPI_Init_ChipEnable_Pin();
21 |
22 | void CE_Pin_LowDisable();
23 |
24 | void CE_Pin_HighEnable();
25 |
26 | void SPI_Init_ChipSelect_Pin();
27 |
28 | void CSN_Pin_LowSelect();
29 |
30 | void CSN_Pin_HighDisable();
31 |
32 | void SPI_Init_SCK_MOSI_MISO_Pins();
33 |
34 | void SPI_Init_Peripheral();
35 |
36 | BYTE SPI_WriteRead(BYTE Data);
37 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/nRF_Tx.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.c
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | #include "nRF_Tx.h"
16 | //for nRF_Mode
17 | #include "nRF_Modes.h"
18 | //for SPI_Write_Buf
19 | #include "nRF_SPI.h"
20 | #include "ClockUartLed.h"
21 | #include "nRF_LowLevel.h"
22 |
23 | //returns the status byte
24 | BYTE nRF_Transmit(BYTE* payload, BYTE size)
25 | {
26 | BYTE status;
27 | status = SPI_Command(FLUSH_TX,0x00);
28 | //unused result status
29 |
30 | if(nRF_Mode != nRF_Mode_Tx)
31 | {
32 | nRF_SetMode_TX();
33 | }
34 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size);
35 |
36 | CE_Pin_HighEnable();//pulse for more than 10 us
37 | delay_10us();
38 | delay_10us();
39 | CE_Pin_LowDisable();
40 |
41 | return status;
42 | }
43 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_Tx.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.c
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | #include "nRF_Tx.h"
16 | //for nRF_Mode
17 | #include "nRF_Modes.h"
18 | //for SPI_Write_Buf
19 | #include "nRF_SPI.h"
20 | #include "ClockUartLed.h"
21 | #include "nRF_LowLevel.h"
22 |
23 | //returns the status byte
24 | BYTE nRF_Transmit(BYTE* payload, BYTE size)
25 | {
26 | BYTE status;
27 | status = SPI_Command(FLUSH_TX,0x00);
28 | //unused result status
29 |
30 | if(nRF_Mode != nRF_Mode_Tx)
31 | {
32 | nRF_SetMode_TX();
33 | }
34 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size);
35 |
36 | CE_Pin_HighEnable();//pulse for more than 10 us
37 | delay_10us();
38 | delay_10us();
39 | CE_Pin_LowDisable();
40 |
41 | return status;
42 | }
43 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_Tx.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.c
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | #include "nRF_Tx.h"
16 | //for nRF_Mode
17 | #include "nRF_Modes.h"
18 | //for SPI_Write_Buf
19 | #include "nRF_SPI.h"
20 | #include "ClockUartLed.h"
21 | #include "nRF_LowLevel.h"
22 |
23 | //returns the status byte
24 | BYTE nRF_Transmit(BYTE* payload, BYTE size)
25 | {
26 | BYTE status;
27 | status = SPI_Command(FLUSH_TX,0x00);
28 | //unused result status
29 |
30 | if(nRF_Mode != nRF_Mode_Tx)
31 | {
32 | nRF_SetMode_TX();
33 | }
34 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size);
35 |
36 | CE_Pin_HighEnable();//pulse for more than 10 us
37 | delay_10us();
38 | delay_10us();
39 | CE_Pin_LowDisable();
40 |
41 | return status;
42 | }
43 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/temp_ds18b20.h:
--------------------------------------------------------------------------------
1 | /** @file temp_ds18b20.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 12.10.2015
11 | * this file was created for refactoring on 26.12.2015
12 | * $Date: 26.12.2015
13 | * $Revision:
14 | *
15 | */
16 |
17 | #include "commonTypes.h"
18 |
19 | void Initialise_OneWire_Pin_A2();
20 |
21 | void OneWire_Reset();
22 |
23 | BYTE OneWire_CheckPresence();
24 |
25 | BYTE OneWire_Init();
26 |
27 | BYTE OneWire_ReadBit();
28 |
29 | void OneWire_WriteByte(BYTE byte);
30 |
31 | BYTE OneWire_ReadByte();
32 |
33 | BYTE DS18B20_Single_ReadRom(BYTE * rom);
34 |
35 | BYTE DS18B20_Single_ReadScratchPad(BYTE * sp,BYTE length);
36 |
37 | BYTE DS18B20_Single_ReadTemperature(BYTE * data);
38 |
39 | void UARTPrint_DS18B20_Temperature(BYTE * data);
40 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/temp_ds18b20.h:
--------------------------------------------------------------------------------
1 | /** @file temp_ds18b20.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 12.10.2015
11 | * this file was created for refactoring on 26.12.2015
12 | * $Date: 26.12.2015
13 | * $Revision:
14 | *
15 | */
16 |
17 | #include "commonTypes.h"
18 |
19 | void Initialise_OneWire_Pin_A2();
20 |
21 | void OneWire_Reset();
22 |
23 | BYTE OneWire_CheckPresence();
24 |
25 | BYTE OneWire_Init();
26 |
27 | BYTE OneWire_ReadBit();
28 |
29 | void OneWire_WriteByte(BYTE byte);
30 |
31 | BYTE OneWire_ReadByte();
32 |
33 | BYTE DS18B20_Single_ReadRom(BYTE * rom);
34 |
35 | BYTE DS18B20_Single_ReadScratchPad(BYTE * sp,BYTE length);
36 |
37 | BYTE DS18B20_Single_ReadTemperature(BYTE * data);
38 |
39 | void UARTPrint_DS18B20_Temperature(BYTE * data);
40 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/temp_ds18b20.h:
--------------------------------------------------------------------------------
1 | /** @file temp_ds18b20.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 12.10.2015
11 | * this file was created for refactoring on 26.12.2015
12 | * $Date: 26.12.2015
13 | * $Revision:
14 | *
15 | */
16 |
17 | #include "commonTypes.h"
18 |
19 | void Initialise_OneWire_Pin_A2();
20 |
21 | void OneWire_Reset();
22 |
23 | BYTE OneWire_CheckPresence();
24 |
25 | BYTE OneWire_Init();
26 |
27 | BYTE OneWire_ReadBit();
28 |
29 | void OneWire_WriteByte(BYTE byte);
30 |
31 | BYTE OneWire_ReadByte();
32 |
33 | BYTE DS18B20_Single_ReadRom(BYTE * rom);
34 |
35 | BYTE DS18B20_Single_ReadScratchPad(BYTE * sp,BYTE length);
36 |
37 | BYTE DS18B20_Single_ReadTemperature(BYTE * data);
38 |
39 | void UARTPrint_DS18B20_Temperature(BYTE * data);
40 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_Tx.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.c
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | #include "nRF_Tx.h"
16 | //for nRF_Mode
17 | #include "nRF_Modes.h"
18 | //for SPI_Write_Buf
19 | #include "nRF_SPI.h"
20 | #include "ClockUartLed.h"
21 | #include "nRF_LowLevel.h"
22 |
23 | //returns the status byte
24 | BYTE nRF_Transmit(BYTE* payload, BYTE size)
25 | {
26 | BYTE status;
27 | status = SPI_Command(FLUSH_TX,0x00);
28 | //unused result status
29 |
30 | if(nRF_Mode != nRF_Mode_Tx)
31 | {
32 | nRF_SetMode_TX();
33 | }
34 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size);
35 |
36 | CE_Pin_HighEnable();//pulse for more than 10 us
37 | delay_10us();
38 | delay_10us();
39 | CE_Pin_LowDisable();
40 |
41 | return status;
42 | }
43 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_Tx.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.c
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | #include "nRF_Tx.h"
16 | //for nRF_Mode
17 | #include "nRF_Modes.h"
18 | //for SPI_Write_Buf
19 | #include "nRF_SPI.h"
20 | #include "ClockUartLed.h"
21 | #include "nRF_LowLevel.h"
22 |
23 | //returns the status byte
24 | BYTE nRF_Transmit(BYTE* payload, BYTE size)
25 | {
26 | BYTE status;
27 | status = SPI_Command(FLUSH_TX,0x00);
28 | //unused result status
29 |
30 | if(nRF_Mode != nRF_Mode_Tx)
31 | {
32 | nRF_SetMode_TX();
33 | }
34 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size);
35 |
36 | CE_Pin_HighEnable();//pulse for more than 10 us
37 | delay_10us();
38 | delay_10us();
39 | CE_Pin_LowDisable();
40 |
41 | return status;
42 | }
43 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_Tx.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_Tx.c
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | #include "nRF_Tx.h"
16 | //for nRF_Mode
17 | #include "nRF_Modes.h"
18 | //for SPI_Write_Buf
19 | #include "nRF_SPI.h"
20 | #include "ClockUartLed.h"
21 | #include "nRF_LowLevel.h"
22 |
23 | //returns the status byte
24 | BYTE nRF_Transmit(BYTE* payload, BYTE size)
25 | {
26 | BYTE status;
27 | status = SPI_Command(FLUSH_TX,0x00);
28 | //unused result status
29 |
30 | if(nRF_Mode != nRF_Mode_Tx)
31 | {
32 | nRF_SetMode_TX();
33 | }
34 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size);
35 |
36 | CE_Pin_HighEnable();//pulse for more than 10 us
37 | delay_10us();
38 | delay_10us();
39 | CE_Pin_LowDisable();
40 |
41 | return status;
42 | }
43 |
--------------------------------------------------------------------------------
/04_HelloRF_NordicAPI/Registers Dump output.txt:
--------------------------------------------------------------------------------
1 | _________________________
2 | Hello from nRF STM8....
3 | reg 0x00 CONFIG
4 | _________________________
5 | Hello from nRF STM8....
6 | reg 0x00 CONFIG : 0x08
7 | reg 0x01 EN_AA : 0x3F
8 | reg 0x02 EN_RXADDR : 0x03
9 | reg 0x03 SETUP_AW : 0x03
10 | reg 0x04 SETUP_RETR : 0x03
11 | reg 0x05 RF_CH : 0x02
12 | reg 0x06 RF_SETUP : 0x0F
13 | reg 0x07 STATUS : 0x0E
14 | reg 0x08 OBSERVE_TX : 0x00
15 | reg 0x09 CD : 0x00
16 | reg 0x0A RX_ADDR_P0 : 0xE7
17 | reg 0x0B RX_ADDR_P1 : 0xC2
18 | reg 0x0C RX_ADDR_P2 : 0xC3
19 | reg 0x0D RX_ADDR_P3 : 0xC4
20 | reg 0x0E RX_ADDR_P4 : 0xC5
21 | reg 0x0F RX_ADDR_P5 : 0xC6
22 | reg 0x10 TX_ADDR : 0xE7
23 | reg 0x11 RX_PW_P0 : 0x00
24 | reg 0x12 RX_PW_P1 : 0x00
25 | reg 0x13 RX_PW_P2 : 0x00
26 | reg 0x14 RX_PW_P3 : 0x00
27 | reg 0x15 RX_PW_P4 : 0x00
28 | reg 0x16 RX_PW_P5 : 0x00
29 | reg 0x17 FIFO_STATUS : 0x11
30 |
31 | ------------------------------
32 |
--------------------------------------------------------------------------------
/18_STM8L_HelloI2C/18_STM8L_HelloI2C.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\i2c.c
30 |
31 |
32 | $PROJ_DIR$\i2c.h
33 |
34 |
35 | $PROJ_DIR$\main.c
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/13_Hello_I2C_Master/13_Hello_I2C_Master.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\i2c.c
30 |
31 |
32 | $PROJ_DIR$\i2c.h
33 |
34 |
35 | $PROJ_DIR$\main_i2c_Master.c
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/14_Hello_I2C_Slave/14_Hello_I2C_Slave.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\i2c.c
30 |
31 |
32 | $PROJ_DIR$\i2c.h
33 |
34 |
35 | $PROJ_DIR$\main_i2c_Slave.c
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/06_Hello_RGBLeds_24BitsParam.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\hello_leds_24bits.c
30 |
31 |
32 | $PROJ_DIR$\WS2812B.c
33 |
34 |
35 | $PROJ_DIR$\WS2812B.h
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/22_Hello_AmbientLight_BH1750/22_Hello_AmbientLight_BH1750.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\i2c_m.c
30 |
31 |
32 | $PROJ_DIR$\i2c_m.h
33 |
34 |
35 | $PROJ_DIR$\main_i2c_AmbientLight.c
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/04_HelloRF_NordicAPI/04_HelloRF_NordicAPI.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\main.c
27 |
28 |
29 | $PROJ_DIR$\nRF_LowLevel.c
30 |
31 |
32 | $PROJ_DIR$\nRF_LowLevel.h
33 |
34 |
35 | $PROJ_DIR$\nRF_SPI.c
36 |
37 |
38 | $PROJ_DIR$\nRF_SPI.h
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/nRF_Modes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | * Directly inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | #define nRF_Mode_Uninitialised 0x00
19 | #define nRF_Mode_PowerDown 0x01
20 | #define nRF_Mode_Standby 0x02
21 | #define nRF_Mode_Tx 0x03
22 | #define nRF_Mode_Rx 0x04
23 |
24 | BYTE nRF_Config();
25 |
26 | BYTE nRF_Init();//Waiting power on reset and initialising SPI
27 |
28 | // The Radio control operational modes are following the description from
29 | // nRF24L01P Product Specification 1.0 page 21
30 |
31 | BYTE nRF_SetMode_PowerDown();
32 |
33 | BYTE nRF_SetMode_Standby_I();
34 |
35 | BYTE nRF_SetMode_RX();
36 |
37 | BYTE nRF_SetMode_TX();
38 |
39 | BYTE nRF_ClearStatus();
40 |
41 |
42 |
43 | //Global variable to manage the current mode
44 |
45 | extern BYTE nRF_Mode;
46 | extern BYTE ConfigVal;
47 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_Modes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | * Directly inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 | #define nRF_Mode_Uninitialised 0x00
19 | #define nRF_Mode_PowerDown 0x01
20 | #define nRF_Mode_Standby 0x02
21 | #define nRF_Mode_Tx 0x03
22 | #define nRF_Mode_Rx 0x04
23 |
24 | BYTE nRF_Config();
25 |
26 | BYTE nRF_Init();//Waiting power on reset and initialising SPI
27 |
28 | // The Radio control operational modes are following the description from
29 | // nRF24L01P Product Specification 1.0 page 21
30 |
31 | BYTE nRF_SetMode_PowerDown();
32 |
33 | BYTE nRF_SetMode_Standby_I();
34 |
35 | BYTE nRF_SetMode_RX();
36 |
37 | BYTE nRF_SetMode_TX();
38 |
39 | BYTE nRF_ClearStatus();
40 |
41 |
42 |
43 | //Global variable to manage the current mode
44 |
45 | extern BYTE nRF_Mode;
46 | extern BYTE ConfigVal;
47 |
--------------------------------------------------------------------------------
/04_HelloRF_NordicAPI/nRF_LowLevel.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * This low level is applied on the STM8103F3 so this should be the only file
8 | * to modify when porting this to another MCU
9 | *
10 | * $Date: 20.09.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | // UINT type definition
16 | #ifndef _UINT_DEF_
17 | #define _UINT_DEF_
18 | typedef unsigned int UINT;
19 | #endif /* _UINT_DEF_ */
20 |
21 | // BYTE type definition
22 | #ifndef _BYTE_DEF_
23 | #define _BYTE_DEF_
24 | typedef unsigned char BYTE;
25 | #endif /* _BYTE_DEF_ */
26 |
27 | //------------------------Low Level API------------------------
28 |
29 | void SPI_Init_ChipEnable_Pin();
30 |
31 | void CE_Pin_LowDisable();
32 |
33 | void CE_Pin_HighEnable();
34 |
35 | void SPI_Init_ChipSelect_Pin();
36 |
37 | void CSN_Pin_LowSelect();
38 |
39 | void CSN_Pin_HighDisable();
40 |
41 | void SPI_Init_Peripheral();
42 |
43 | BYTE SPI_WriteRead(BYTE Data);
44 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_Modes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | * Directly inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 |
19 | #define nRF_Mode_Uninitialised 0x00
20 | #define nRF_Mode_PowerDown 0x01
21 | #define nRF_Mode_Standby 0x02
22 | #define nRF_Mode_Tx 0x03
23 | #define nRF_Mode_Rx 0x04
24 |
25 | BYTE nRF_Config();
26 |
27 | BYTE nRF_Init();//Waiting power on reset and initialising SPI
28 |
29 | // The Radio control operational modes are following the description from
30 | // nRF24L01P Product Specification 1.0 page 21
31 |
32 | BYTE nRF_SetMode_PowerDown();
33 |
34 | BYTE nRF_SetMode_Standby_I();
35 |
36 | BYTE nRF_SetMode_RX();
37 |
38 | BYTE nRF_SetMode_TX();
39 |
40 | BYTE nRF_ClearStatus();
41 |
42 |
43 |
44 | //Global variable to manage the current mode
45 |
46 | extern BYTE nRF_Mode;
47 | extern BYTE ConfigVal;
48 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_Modes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | * Directly inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 |
19 | #define nRF_Mode_Uninitialised 0x00
20 | #define nRF_Mode_PowerDown 0x01
21 | #define nRF_Mode_Standby 0x02
22 | #define nRF_Mode_Tx 0x03
23 | #define nRF_Mode_Rx 0x04
24 |
25 | BYTE nRF_Config();
26 |
27 | BYTE nRF_Init();//Waiting power on reset and initialising SPI
28 |
29 | // The Radio control operational modes are following the description from
30 | // nRF24L01P Product Specification 1.0 page 21
31 |
32 | BYTE nRF_SetMode_PowerDown();
33 |
34 | BYTE nRF_SetMode_Standby_I();
35 |
36 | BYTE nRF_SetMode_RX();
37 |
38 | BYTE nRF_SetMode_TX();
39 |
40 | BYTE nRF_ClearStatus();
41 |
42 |
43 |
44 | //Global variable to manage the current mode
45 |
46 | extern BYTE nRF_Mode;
47 | extern BYTE ConfigVal;
48 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_Modes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | * Directly inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 |
19 | #define nRF_Mode_Uninitialised 0x00
20 | #define nRF_Mode_PowerDown 0x01
21 | #define nRF_Mode_Standby 0x02
22 | #define nRF_Mode_Tx 0x03
23 | #define nRF_Mode_Rx 0x04
24 |
25 | BYTE nRF_Config();
26 |
27 | BYTE nRF_Init();//Waiting power on reset and initialising SPI
28 |
29 | // The Radio control operational modes are following the description from
30 | // nRF24L01P Product Specification 1.0 page 21
31 |
32 | BYTE nRF_SetMode_PowerDown();
33 |
34 | BYTE nRF_SetMode_Standby_I();
35 |
36 | BYTE nRF_SetMode_RX();
37 |
38 | BYTE nRF_SetMode_TX();
39 |
40 | BYTE nRF_ClearStatus();
41 |
42 |
43 |
44 | //Global variable to manage the current mode
45 |
46 | extern BYTE nRF_Mode;
47 | extern BYTE ConfigVal;
48 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_Modes.h:
--------------------------------------------------------------------------------
1 | /** @file nRF_Modes.h
2 | *
3 | * @author Wassim FILALI
4 | * Directly inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * $Date: 12.12.2015
11 | * $Revision:
12 | *
13 | */
14 |
15 | //for BYTE
16 | #include "commonTypes.h"
17 |
18 |
19 | #define nRF_Mode_Uninitialised 0x00
20 | #define nRF_Mode_PowerDown 0x01
21 | #define nRF_Mode_Standby 0x02
22 | #define nRF_Mode_Tx 0x03
23 | #define nRF_Mode_Rx 0x04
24 |
25 | BYTE nRF_Config();
26 |
27 | BYTE nRF_Init();//Waiting power on reset and initialising SPI
28 |
29 | // The Radio control operational modes are following the description from
30 | // nRF24L01P Product Specification 1.0 page 21
31 |
32 | BYTE nRF_SetMode_PowerDown();
33 |
34 | BYTE nRF_SetMode_Standby_I();
35 |
36 | BYTE nRF_SetMode_RX();
37 |
38 | BYTE nRF_SetMode_TX();
39 |
40 | BYTE nRF_ClearStatus();
41 |
42 |
43 |
44 | //Global variable to manage the current mode
45 |
46 | extern BYTE nRF_Mode;
47 | extern BYTE ConfigVal;
48 |
--------------------------------------------------------------------------------
/07_Hello_Temperature/ClockUartLed.h:
--------------------------------------------------------------------------------
1 | /** @file ClockUartLed.h
2 | *
3 | * @author Wassim FILALI taken over from http://blog.mark-stevens.co.uk/
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 20.09.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 |
14 | #define delay_1us(); delay(0);
15 |
16 | #define delay_10us(); delay(18);
17 |
18 | #define delay_50us(); delay(98);
19 |
20 | #define delay_100us(); delay(198);
21 |
22 | #define delay_1ms(); delay(1998);
23 |
24 |
25 | void InitialiseUART();
26 |
27 | void UARTPrintf(char const *message);
28 |
29 | void UARTPrintfLn(char const *message);
30 |
31 | void UARTPrintfHex(unsigned char val);
32 |
33 | void UARTPrintfHexTable(unsigned char *pval,unsigned char length);
34 |
35 | void UARTPrintfHexLn(unsigned char val);
36 |
37 | void UARTPrintf_sint(signed int num);
38 |
39 | void UARTPrintf_uint(unsigned int num);
40 |
41 | void InitialiseSystemClock();
42 |
43 | void delay(unsigned int n);
44 |
45 |
46 | // L E D
47 | void Initialise_TestLed_GPIO_B5();
48 | void Test_Led_On();
49 | void Test_Led_Off();
50 |
51 |
--------------------------------------------------------------------------------
/04_HelloRF_NordicAPI/main.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 |
5 | #include "ClockUartLed.h"
6 |
7 | #include "nRF_SPI.h"
8 |
9 | int main( void )
10 | {
11 | InitialiseSystemClock();
12 |
13 | Initialise_TestLed_GPIO_B5();
14 |
15 | InitialiseUART();
16 |
17 | SPI_Init();
18 |
19 | UARTPrintf("\r\n_________________________\n\r");
20 | UARTPrintf("Hello from nRF STM8....\n\r");
21 |
22 | Test_Led_Off();
23 |
24 | for(int i=0;i>1;
45 | UARTPrintf("Rx Pipe Nb ");
46 | UARTPrintfHex(PipeNb);
47 | UARTPrintf(" ; ");
48 | }
49 | if(status & bit_TX_FULL)
50 | {
51 | UARTPrintf("TX Fifo Full;");
52 | }
53 | UARTPrintf("\n\r");
54 | }
55 |
56 | void nRF_PrintConfig()
57 | {
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_RegText.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.c
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "nRF_RegText.h"
13 | #include "nRF_SPI.h"
14 | #include "ClockUartLed.h"
15 |
16 | void nRF_PrintStatus(BYTE status)
17 | {
18 | UARTPrintf("STATUS: ");
19 | UARTPrintfHex(status);
20 | UARTPrintf(" : ");
21 |
22 | if(status & bit_RX_DR)
23 | {
24 | UARTPrintf("Data Ready i; ");
25 | }
26 | if(status & bit_TX_DS)
27 | {
28 | UARTPrintf("Data Sent i; ");
29 | }
30 | if(status & bit_MAX_RT)
31 | {
32 | UARTPrintf("Max Ret i; ");
33 | }
34 | if( (status & bit_Mask_RXPNO) == bit_RXPNO_NotUsed)
35 | {
36 | UARTPrintf("Rx Pipe not used ; ");
37 | }
38 | else if( (status & bit_Mask_RXPNO) == bit_RXPNO_RxFFEmpty)
39 | {
40 | //UARTPrintf("Rx Fifo Empty ; ");// this is the default state not log for it
41 | }
42 | else
43 | {
44 | BYTE PipeNb = (status & bit_Mask_RXPNO)>>1;
45 | UARTPrintf("Rx Pipe Nb ");
46 | UARTPrintfHex(PipeNb);
47 | UARTPrintf(" ; ");
48 | }
49 | if(status & bit_TX_FULL)
50 | {
51 | UARTPrintf("TX Fifo Full;");
52 | }
53 | UARTPrintf("\n\r");
54 | }
55 |
56 | void nRF_PrintConfig()
57 | {
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_RegText.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.c
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "nRF_RegText.h"
13 | #include "nRF_SPI.h"
14 | #include "ClockUartLed.h"
15 |
16 | void nRF_PrintStatus(BYTE status)
17 | {
18 | UARTPrintf("STATUS: ");
19 | UARTPrintfHex(status);
20 | UARTPrintf(" : ");
21 |
22 | if(status & bit_RX_DR)
23 | {
24 | UARTPrintf("Data Ready i; ");
25 | }
26 | if(status & bit_TX_DS)
27 | {
28 | UARTPrintf("Data Sent i; ");
29 | }
30 | if(status & bit_MAX_RT)
31 | {
32 | UARTPrintf("Max Ret i; ");
33 | }
34 | if( (status & bit_Mask_RXPNO) == bit_RXPNO_NotUsed)
35 | {
36 | UARTPrintf("Rx Pipe not used ; ");
37 | }
38 | else if( (status & bit_Mask_RXPNO) == bit_RXPNO_RxFFEmpty)
39 | {
40 | //UARTPrintf("Rx Fifo Empty ; ");// this is the default state not log for it
41 | }
42 | else
43 | {
44 | BYTE PipeNb = (status & bit_Mask_RXPNO)>>1;
45 | UARTPrintf("Rx Pipe Nb ");
46 | UARTPrintfHex(PipeNb);
47 | UARTPrintf(" ; ");
48 | }
49 | if(status & bit_TX_FULL)
50 | {
51 | UARTPrintf("TX Fifo Full;");
52 | }
53 | UARTPrintf("\n\r");
54 | }
55 |
56 | void nRF_PrintConfig()
57 | {
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/nRF_RegText.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.c
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "nRF_RegText.h"
13 | #include "nRF_SPI.h"
14 | #include "ClockUartLed.h"
15 |
16 | void nRF_PrintStatus(BYTE status)
17 | {
18 | UARTPrintf("STATUS: ");
19 | UARTPrintfHex(status);
20 | UARTPrintf(" : ");
21 |
22 | if(status & bit_RX_DR)
23 | {
24 | UARTPrintf("Data Ready i; ");
25 | }
26 | if(status & bit_TX_DS)
27 | {
28 | UARTPrintf("Data Sent i; ");
29 | }
30 | if(status & bit_MAX_RT)
31 | {
32 | UARTPrintf("Max Ret i; ");
33 | }
34 | if( (status & bit_Mask_RXPNO) == bit_RXPNO_NotUsed)
35 | {
36 | UARTPrintf("Rx Pipe not used ; ");
37 | }
38 | else if( (status & bit_Mask_RXPNO) == bit_RXPNO_RxFFEmpty)
39 | {
40 | //UARTPrintf("Rx Fifo Empty ; ");// this is the default state not log for it
41 | }
42 | else
43 | {
44 | BYTE PipeNb = (status & bit_Mask_RXPNO)>>1;
45 | UARTPrintf("Rx Pipe Nb ");
46 | UARTPrintfHex(PipeNb);
47 | UARTPrintf(" ; ");
48 | }
49 | if(status & bit_TX_FULL)
50 | {
51 | UARTPrintf("TX Fifo Full;");
52 | }
53 | UARTPrintf("\n\r");
54 | }
55 |
56 | void nRF_PrintConfig()
57 | {
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_RegText.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.c
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "nRF_RegText.h"
13 | #include "nRF_SPI.h"
14 | #include "ClockUartLed.h"
15 |
16 | void nRF_PrintStatus(BYTE status)
17 | {
18 | UARTPrintf("STATUS: ");
19 | UARTPrintfHex(status);
20 | UARTPrintf(" : ");
21 |
22 | if(status & bit_RX_DR)
23 | {
24 | UARTPrintf("Data Ready i; ");
25 | }
26 | if(status & bit_TX_DS)
27 | {
28 | UARTPrintf("Data Sent i; ");
29 | }
30 | if(status & bit_MAX_RT)
31 | {
32 | UARTPrintf("Max Ret i; ");
33 | }
34 | if( (status & bit_Mask_RXPNO) == bit_RXPNO_NotUsed)
35 | {
36 | UARTPrintf("Rx Pipe not used ; ");
37 | }
38 | else if( (status & bit_Mask_RXPNO) == bit_RXPNO_RxFFEmpty)
39 | {
40 | //UARTPrintf("Rx Fifo Empty ; ");// this is the default state not log for it
41 | }
42 | else
43 | {
44 | BYTE PipeNb = (status & bit_Mask_RXPNO)>>1;
45 | UARTPrintf("Rx Pipe Nb ");
46 | UARTPrintfHex(PipeNb);
47 | UARTPrintf(" ; ");
48 | }
49 | if(status & bit_TX_FULL)
50 | {
51 | UARTPrintf("TX Fifo Full;");
52 | }
53 | UARTPrintf("\n\r");
54 | }
55 |
56 | void nRF_PrintConfig()
57 | {
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_RegText.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_RegText.c
2 | *
3 | * @author Wassim FILALI
4 | *
5 | * @compiler IAR STM8
6 | *
7 | * $Date: 13.12.2015
8 | * $Revision:
9 | *
10 | */
11 |
12 | #include "nRF_RegText.h"
13 | #include "nRF_SPI.h"
14 | #include "ClockUartLed.h"
15 |
16 | void nRF_PrintStatus(BYTE status)
17 | {
18 | UARTPrintf("STATUS: ");
19 | UARTPrintfHex(status);
20 | UARTPrintf(" : ");
21 |
22 | if(status & bit_RX_DR)
23 | {
24 | UARTPrintf("Data Ready i; ");
25 | }
26 | if(status & bit_TX_DS)
27 | {
28 | UARTPrintf("Data Sent i; ");
29 | }
30 | if(status & bit_MAX_RT)
31 | {
32 | UARTPrintf("Max Ret i; ");
33 | }
34 | if( (status & bit_Mask_RXPNO) == bit_RXPNO_NotUsed)
35 | {
36 | UARTPrintf("Rx Pipe not used ; ");
37 | }
38 | else if( (status & bit_Mask_RXPNO) == bit_RXPNO_RxFFEmpty)
39 | {
40 | //UARTPrintf("Rx Fifo Empty ; ");// this is the default state not log for it
41 | }
42 | else
43 | {
44 | BYTE PipeNb = (status & bit_Mask_RXPNO)>>1;
45 | UARTPrintf("Rx Pipe Nb ");
46 | UARTPrintfHex(PipeNb);
47 | UARTPrintf(" ; ");
48 | }
49 | if(status & bit_TX_FULL)
50 | {
51 | UARTPrintf("TX Fifo Full;");
52 | }
53 | UARTPrintf("\n\r");
54 | }
55 |
56 | void nRF_PrintConfig()
57 | {
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/logs/20151213-20h30.txt:
--------------------------------------------------------------------------------
1 | _________________________
2 | STM8 Receiver, Node 2
3 | Config updated with : 0x73 ; reread 0x73 ; STATUS: 0x40 : Data Ready i; Rx Pipe Nb 0x00 ;
4 | Clearing the status, New STATUS: 0x00 : Rx Pipe Nb 0x00 ;
5 | SetMode_Rx: Config updated with : 0x73 ; reread 0x73 ; STATUS: 0x00 : Rx Pipe Nb 0x00 ;
6 | Rx counter loop: 0x01 ; CONFIG: 0x73 ; STATUS: 0x00 : Rx Pipe Nb 0x00 ;
7 | Rx counter loop: 0x02 ; CONFIG: 0x73 ; STATUS: 0x00 : Rx Pipe Nb 0x00 ;
8 | Rx counter loop: 0x03 ; CONFIG: 0x73 ; STATUS: 0x40 : Data Ready i; Rx Pipe Nb 0x00 ;
9 | Received Data: 0xF2
10 | Clearing the status, New STATUS: 0x00 : Rx Pipe Nb 0x00 ;
11 | FifoStatus: 0x10
12 | Data still in Fifo: 0x10
13 | Received more Data: 0xF3
14 | Rx counter loop: 0x04 ; CONFIG: 0x73 ; STATUS: 0x0E :
15 | Rx counter loop: 0x05 ; CONFIG: 0x73 ; STATUS: 0x0E :
16 | Rx counter loop: 0x06 ; CONFIG: 0x73 ; STATUS: 0x0E :
17 | Rx counter loop: 0x07 ; CONFIG: 0x73 ; STATUS: 0x0E :
18 | Rx counter loop: 0x08 ; CONFIG: 0x73 ; STATUS: 0x40 : Data Ready i; Rx Pipe Nb 0x00 ;
19 | Received Data: 0xF4
20 | Clearing the status, New STATUS: 0x0E :
21 | FifoStatus: 0x11
22 | Rx counter loop: 0x09 ; CONFIG: 0x73 ; STATUS: 0x0E :
23 | Rx counter loop: 0x0A ; CONFIG: 0x73 ; STATUS: 0x0E :
24 | Rx counter loop: 0x0B ; CONFIG: 0x73 ; STATUS: 0x0E :
25 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/WS2812B.h:
--------------------------------------------------------------------------------
1 | /** @file WS2812B.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 10.10.2015
11 | * this file was created for refactoring on 03.01.2016
12 | * $Date:
13 | * $Revision:
14 | *
15 | */
16 |
17 | #define NB_LEDS 60
18 | #define RGBLedPIN_A 2
19 |
20 | #include "commonTypes.h"
21 |
22 | typedef struct
23 | {
24 | BYTE R;
25 | BYTE G;
26 | BYTE B;
27 | }RGBColor_t;
28 |
29 |
30 | extern const RGBColor_t RED;
31 | extern const RGBColor_t GREEN;
32 | extern const RGBColor_t BLUE;
33 |
34 |
35 | // user configuration
36 |
37 | #define SwitchOffLed(); SendLedColor(0, 0, 0);
38 |
39 | // shared variables
40 |
41 | void RGBLeds_PIO_Init();
42 |
43 | void SetLedColor(BYTE LedId, BYTE R, BYTE G, BYTE B);
44 | void SetLedColors(BYTE LedId,RGBColor_t Color);
45 |
46 | void SendLedsArray();
47 |
48 | void RGB_SwitchOff(BYTE first,BYTE NbLeds);
49 |
50 | void SendLedColor(BYTE R, BYTE G, BYTE B);
51 |
52 | void RampColors(BYTE delay,BYTE RUp,BYTE GUp,BYTE BUp,BYTE R,BYTE G,BYTE B);
53 |
54 | void BlinkColors(BYTE R, BYTE G, BYTE B);
55 |
56 | RGBColor_t ColorScale(int iCount,int nbCount,RGBColor_t ColorStart,RGBColor_t ColorEnd);
57 |
58 | void ShadeLeds(BYTE LedStart, BYTE LedEnd, RGBColor_t ColorStart, RGBColor_t ColorEnd);
59 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/08_HelloRF_Transmitter.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\main.c
27 |
28 |
29 | $PROJ_DIR$\nRF_LowLevel.c
30 |
31 |
32 | $PROJ_DIR$\nRF_LowLevel.h
33 |
34 |
35 | $PROJ_DIR$\nRF_Modes.c
36 |
37 |
38 | $PROJ_DIR$\nRF_Modes.h
39 |
40 |
41 | $PROJ_DIR$\nRF_RegText.c
42 |
43 |
44 | $PROJ_DIR$\nRF_RegText.h
45 |
46 |
47 | $PROJ_DIR$\nRF_SPI.c
48 |
49 |
50 | $PROJ_DIR$\nRF_SPI.h
51 |
52 |
53 | $PROJ_DIR$\nRF_Tx.c
54 |
55 |
56 | $PROJ_DIR$\nRF_Tx.h
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/09_HelloRF_Receiver.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\main.c
30 |
31 |
32 | $PROJ_DIR$\nRF_LowLevel.c
33 |
34 |
35 | $PROJ_DIR$\nRF_LowLevel.h
36 |
37 |
38 | $PROJ_DIR$\nRF_Modes.c
39 |
40 |
41 | $PROJ_DIR$\nRF_Modes.h
42 |
43 |
44 | $PROJ_DIR$\nRF_RegText.c
45 |
46 |
47 | $PROJ_DIR$\nRF_RegText.h
48 |
49 |
50 | $PROJ_DIR$\nRF_SPI.c
51 |
52 |
53 | $PROJ_DIR$\nRF_SPI.h
54 |
55 |
56 | $PROJ_DIR$\nRF_Tx.c
57 |
58 |
59 | $PROJ_DIR$\nRF_Tx.h
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/main.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 |
5 | #include "ClockUartLed.h"
6 |
7 | //for direct SPI_Read_Register()
8 | #include "nRF_SPI.h"
9 |
10 | //for nRF_SetMode_TX()
11 | #include "nRF_Modes.h"
12 |
13 | #include "nRF_Tx.h"
14 | #include "nRF_RegText.h"
15 |
16 | #include "nRF_IRQ.h"
17 |
18 | void Print_ConfigAndStatus_Registers()
19 | {
20 | BYTE ConfigVal;
21 | UARTPrintf(" ");
22 | ConfigVal = SPI_Read_Register(CONFIG);
23 | UARTPrintf(" ; CONFIG: ");
24 | UARTPrintfHex(ConfigVal);
25 | UARTPrintf(" ; ");
26 | BYTE status = SPI_Read_Register(STATUS);
27 | nRF_PrintStatus(status);
28 | }
29 |
30 |
31 | int main( void )
32 | {
33 |
34 | BYTE counter = 0;
35 |
36 | InitialiseSystemClock();
37 |
38 | Initialise_TestLed_GPIO_B5();
39 |
40 | Test_Led_Off();
41 |
42 | InitialiseUART();
43 |
44 | UARTPrintf("\r\n_________________________\n\r");
45 | UARTPrintf("STM8 Receiver with (IRQ), Node 2\n\r");
46 |
47 | //Applies the compile time configured parameters from nRF_Configuration.h
48 | BYTE status = nRF_Config();
49 |
50 | //The RX Mode is independently set from nRF_Config() and can be changed on run time
51 | nRF_SetMode_RX();
52 |
53 | while (1)
54 | {
55 |
56 | counter++;
57 | UARTPrintf("loop Rx counter: ");
58 | UARTPrintfHex(counter);
59 |
60 | Print_ConfigAndStatus_Registers();
61 |
62 | Test_Led_Off();
63 | delay_1ms_Count(4900);
64 |
65 | Test_Led_On();
66 | delay_1ms_Count(100);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/pr00_LibraryCommon/WS2812B.h:
--------------------------------------------------------------------------------
1 | /** @file WS2812B.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 10.10.2015
11 | * this file was created for refactoring on 03.01.2016
12 | * $Date:
13 | * $Revision:
14 | *
15 | */
16 |
17 | #define NB_LEDS 60
18 | #define RGBLedPIN_A 2
19 |
20 | #include "commonTypes.h"
21 |
22 | typedef struct
23 | {
24 | BYTE R;
25 | BYTE G;
26 | BYTE B;
27 | }RGBColor_t;
28 |
29 |
30 | extern const RGBColor_t RED;
31 | extern const RGBColor_t GREEN;
32 | extern const RGBColor_t BLUE;
33 | extern const RGBColor_t BLACK;
34 | extern const RGBColor_t WHITE;
35 |
36 |
37 | // user configuration
38 |
39 | #define SwitchOffLed(); SendLedColor(0, 0, 0);
40 |
41 | // shared variables
42 |
43 | void RGBLeds_PIO_Init();
44 |
45 | void SetLedColor(BYTE LedId, BYTE R, BYTE G, BYTE B);
46 | void SetLedColors(BYTE LedId,RGBColor_t Color);
47 |
48 | void SendLedsArray();
49 |
50 | void RGB_SwitchOff(BYTE first,BYTE NbLeds);
51 |
52 | void SendLedColor(BYTE R, BYTE G, BYTE B);
53 | void SendLedColors(RGBColor_t Color);
54 |
55 |
56 | void RampColors(BYTE delay,BYTE RUp,BYTE GUp,BYTE BUp,BYTE R,BYTE G,BYTE B);
57 |
58 | void BlinkColors(BYTE R, BYTE G, BYTE B);
59 |
60 | void FlashColors(BYTE delay, RGBColor_t Color);
61 |
62 | RGBColor_t ColorScale(int iCount,int nbCount,RGBColor_t ColorStart,RGBColor_t ColorEnd);
63 |
64 | void ShadeLeds(BYTE LedStart, BYTE LedEnd, RGBColor_t ColorStart, RGBColor_t ColorEnd);
65 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/WS2812B.h:
--------------------------------------------------------------------------------
1 | /** @file WS2812B.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 10.10.2015
11 | * this file was created for refactoring on 03.01.2016
12 | * $Date:
13 | * $Revision:
14 | *
15 | */
16 |
17 | #define NB_LEDS 60
18 | #define RGBLedPIN_A 2
19 |
20 | #include "commonTypes.h"
21 |
22 | typedef struct
23 | {
24 | BYTE R;
25 | BYTE G;
26 | BYTE B;
27 | }RGBColor_t;
28 |
29 |
30 | extern const RGBColor_t RED;
31 | extern const RGBColor_t GREEN;
32 | extern const RGBColor_t BLUE;
33 | extern const RGBColor_t BLACK;
34 | extern const RGBColor_t WHITE;
35 |
36 |
37 | // user configuration
38 |
39 | #define SwitchOffLed(); SendLedColor(0, 0, 0);
40 |
41 | // shared variables
42 |
43 | void RGBLeds_PIO_Init();
44 |
45 | void SetLedColor(BYTE LedId, BYTE R, BYTE G, BYTE B);
46 | void SetLedColors(BYTE LedId,RGBColor_t Color);
47 |
48 | void SendLedsArray();
49 |
50 | void RGB_SwitchOff(BYTE first,BYTE NbLeds);
51 |
52 | void SendLedColor(BYTE R, BYTE G, BYTE B);
53 | void SendLedColors(RGBColor_t Color);
54 |
55 |
56 | void RampColors(BYTE delay,BYTE RUp,BYTE GUp,BYTE BUp,BYTE R,BYTE G,BYTE B);
57 |
58 | void BlinkColors(BYTE R, BYTE G, BYTE B);
59 |
60 | void FlashColors(BYTE delay, RGBColor_t Color);
61 |
62 | RGBColor_t ColorScale(int iCount,int nbCount,RGBColor_t ColorStart,RGBColor_t ColorEnd);
63 |
64 | void ShadeLeds(BYTE LedStart, BYTE LedEnd, RGBColor_t ColorStart, RGBColor_t ColorEnd);
65 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/WS2812B.h:
--------------------------------------------------------------------------------
1 | /** @file WS2812B.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 10.10.2015
11 | * this file was created for refactoring on 03.01.2016
12 | * $Date:
13 | * $Revision:
14 | *
15 | */
16 |
17 | #define NB_LEDS 60
18 | #define RGBLedPIN_A 2
19 |
20 | #include "commonTypes.h"
21 |
22 | typedef struct
23 | {
24 | BYTE R;
25 | BYTE G;
26 | BYTE B;
27 | }RGBColor_t;
28 |
29 |
30 | extern const RGBColor_t RED;
31 | extern const RGBColor_t GREEN;
32 | extern const RGBColor_t BLUE;
33 | extern const RGBColor_t BLACK;
34 | extern const RGBColor_t WHITE;
35 |
36 |
37 | // user configuration
38 |
39 | #define SwitchOffLed(); SendLedColor(0, 0, 0);
40 |
41 | // shared variables
42 |
43 | void RGBLeds_PIO_Init();
44 |
45 | void SetLedColor(BYTE LedId, BYTE R, BYTE G, BYTE B);
46 | void SetLedColors(BYTE LedId,RGBColor_t Color);
47 |
48 | void SendLedsArray();
49 |
50 | void RGB_SwitchOff(BYTE first,BYTE NbLeds);
51 |
52 | void SendLedColor(BYTE R, BYTE G, BYTE B);
53 | void SendLedColors(RGBColor_t Color);
54 |
55 |
56 | void RampColors(BYTE delay,BYTE RUp,BYTE GUp,BYTE BUp,BYTE R,BYTE G,BYTE B);
57 |
58 | void BlinkColors(BYTE R, BYTE G, BYTE B);
59 |
60 | void FlashColors(BYTE delay, RGBColor_t Color);
61 |
62 | RGBColor_t ColorScale(int iCount,int nbCount,RGBColor_t ColorStart,RGBColor_t ColorEnd);
63 |
64 | void ShadeLeds(BYTE LedStart, BYTE LedEnd, RGBColor_t ColorStart, RGBColor_t ColorEnd);
65 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/logs/20151213-20h37.txt:
--------------------------------------------------------------------------------
1 | _________________________
2 | STM8 Transmitter, Node 1
3 | Config updated with : 0x70 ; reread 0x70 ; STATUS: 0x0E :
4 | SetMode_Tx: Config updated with : 0x72 ; reread 0x72 ; STATUS: 0x0E :
5 | Transmitting: 0x01 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
6 | Clearing the status, New STATUS: 0x0E :
7 | Transmitting: 0x02 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
8 | Clearing the status, New STATUS: 0x0E :
9 | Transmitting: 0x03 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
10 | Clearing the status, New STATUS: 0x0E :
11 | Transmitting: 0x04 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
12 | Clearing the status, New STATUS: 0x0E :
13 | Transmitting: 0x05 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
14 | Clearing the status, New STATUS: 0x0E :
15 | Transmitting: 0x06 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
16 | Clearing the status, New STATUS: 0x0E :
17 | Transmitting: 0x07 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
18 | Clearing the status, New STATUS: 0x0E :
19 | Transmitting: 0x08 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
20 | Clearing the status, New STATUS: 0x0E :
21 | Transmitting: 0x09 ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
22 | Clearing the status, New STATUS: 0x0E :
23 | Transmitting: 0x0A ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
24 | Clearing the status, New STATUS: 0x0E :
25 | Transmitting: 0x0B ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
26 | Clearing the status, New STATUS: 0x0E :
27 | Transmitting: 0x0C ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
28 | Clearing the status, New STATUS: 0x0E :
29 | Transmitting: 0x0D ; CONFIG: 0x72 ; STATUS: 0x2E : Data Sent i;
30 |
--------------------------------------------------------------------------------
/05_Hello_RGBLeds/02_HelloUart.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 4241680732
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\Obj\hello_uart.o
10 | $PROJ_DIR$\Debug\Obj\hello_uart.pbi
11 | $PROJ_DIR$\Debug\Exe\templproj.out
12 | $PROJ_DIR$\Debug\Exe\02_HelloUart.hex
13 | $PROJ_DIR$\hello_uart.c
14 |
15 |
16 | $PROJ_DIR$\Debug\Exe\templproj.out
17 |
18 |
19 | OBJCOPY
20 | 3
21 |
22 |
23 |
24 |
25 | [ROOT_NODE]
26 |
27 |
28 | ILINK
29 | 2
30 |
31 |
32 |
33 |
34 | $PROJ_DIR$\hello_uart.c
35 |
36 |
37 | BICOMP
38 | 1
39 |
40 |
41 | ICCSTM8
42 | 0
43 |
44 |
45 |
46 |
47 | [MULTI_TOOL]
48 | ILINK
49 |
50 |
51 |
52 | Release
53 |
54 |
55 | [MULTI_TOOL]
56 | ILINK
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/02_HelloUart.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 4241680732
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\Obj\hello_uart.o
10 | $PROJ_DIR$\Debug\Obj\hello_uart.pbi
11 | $PROJ_DIR$\Debug\Exe\templproj.out
12 | $PROJ_DIR$\Debug\Exe\02_HelloUart.hex
13 | $PROJ_DIR$\hello_uart.c
14 |
15 |
16 | $PROJ_DIR$\Debug\Exe\templproj.out
17 |
18 |
19 | OBJCOPY
20 | 3
21 |
22 |
23 |
24 |
25 | [ROOT_NODE]
26 |
27 |
28 | ILINK
29 | 2
30 |
31 |
32 |
33 |
34 | $PROJ_DIR$\hello_uart.c
35 |
36 |
37 | BICOMP
38 | 1
39 |
40 |
41 | ICCSTM8
42 | 0
43 |
44 |
45 |
46 |
47 | [MULTI_TOOL]
48 | ILINK
49 |
50 |
51 |
52 | Release
53 |
54 |
55 | [MULTI_TOOL]
56 | ILINK
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/13_Hello_I2C_Master/main_i2c_Master.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 | // currently linked to http://creativecommons.org/licenses/by-sa/3.0/legalcode
5 |
6 | #include
7 | #include
8 |
9 | #include "ClockUartLed.h"
10 | #include "commonTypes.h"
11 | #include "i2c.h"
12 |
13 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size)
14 | {
15 | UARTPrintf("I2C Transaction complete, received:\n\r");
16 | UARTPrintfHexTable(userdata,size);
17 | UARTPrintf("\n\r");
18 | }
19 |
20 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size)
21 | {
22 | UARTPrintf("I2C Transaction complete, Transmitted:\n\r");
23 | UARTPrintfHexTable(userdata,size);
24 | UARTPrintf("\n\r");
25 | }
26 |
27 | void i2c_user_Error_Callback(BYTE l_sr2)
28 | {
29 | if(l_sr2 & 0x01)
30 | {
31 | UARTPrintf("[I2C Bus Error]\n\r");
32 | }
33 | if(l_sr2 & 0x02)
34 | {
35 | UARTPrintf("[I2C Arbitration Lost]\n\r");
36 | }
37 | if(l_sr2 & 0x04)
38 | {
39 | UARTPrintf("[I2C no Acknowledge]\n\r");//this is ok for the slave
40 | }
41 | if(l_sr2 & 0x08)
42 | {
43 | UARTPrintf("[I2C Bus Overrun]\n\r");
44 | }
45 | }
46 |
47 |
48 | int main( void )
49 | {
50 | BYTE userData[2];
51 | BYTE counter;
52 |
53 | InitialiseSystemClock();
54 |
55 | InitialiseUART();
56 |
57 | UARTPrintf("\r\n_________________________\n\r");
58 | UARTPrintf("STM8 I2C Master...\n\r");
59 |
60 | I2C_Init();
61 |
62 |
63 | __enable_interrupt();
64 |
65 | while (1)
66 | {
67 | //__wait_for_interrupt();
68 | I2C_Read(0x72, userData,2);
69 | delay_1ms_Count(500);
70 | counter++;
71 | UARTPrintf("master loop counter: ");
72 | UARTPrintfHexLn(counter);
73 | delay_1ms_Count(4500);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/05_Hello_RGBLeds/.Backups/02_HelloUart.dep{Rev 2015;10;09 18;21;56 PM}.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 4241680732
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\Obj\hello_uart.o
10 | $PROJ_DIR$\Debug\Obj\hello_uart.pbi
11 | $PROJ_DIR$\Debug\Exe\templproj.out
12 | $PROJ_DIR$\Debug\Exe\02_HelloUart.hex
13 | $PROJ_DIR$\hello_uart.c
14 |
15 |
16 | $PROJ_DIR$\Debug\Exe\templproj.out
17 |
18 |
19 | OBJCOPY
20 | 3
21 |
22 |
23 |
24 |
25 | [ROOT_NODE]
26 |
27 |
28 | ILINK
29 | 2
30 |
31 |
32 |
33 |
34 | $PROJ_DIR$\hello_uart.c
35 |
36 |
37 | BICOMP
38 | 1
39 |
40 |
41 | ICCSTM8
42 | 0
43 |
44 |
45 |
46 |
47 | [MULTI_TOOL]
48 | ILINK
49 |
50 |
51 |
52 | Release
53 |
54 |
55 | [MULTI_TOOL]
56 | ILINK
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/.Backups/02_HelloUart.dep{Rev 2015;10;09 18;21;56 PM}.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 4241680732
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\Obj\hello_uart.o
10 | $PROJ_DIR$\Debug\Obj\hello_uart.pbi
11 | $PROJ_DIR$\Debug\Exe\templproj.out
12 | $PROJ_DIR$\Debug\Exe\02_HelloUart.hex
13 | $PROJ_DIR$\hello_uart.c
14 |
15 |
16 | $PROJ_DIR$\Debug\Exe\templproj.out
17 |
18 |
19 | OBJCOPY
20 | 3
21 |
22 |
23 |
24 |
25 | [ROOT_NODE]
26 |
27 |
28 | ILINK
29 | 2
30 |
31 |
32 |
33 |
34 | $PROJ_DIR$\hello_uart.c
35 |
36 |
37 | BICOMP
38 | 1
39 |
40 |
41 | ICCSTM8
42 | 0
43 |
44 |
45 |
46 |
47 | [MULTI_TOOL]
48 | ILINK
49 |
50 |
51 |
52 | Release
53 |
54 |
55 | [MULTI_TOOL]
56 | ILINK
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/10_Hello_Receiver_IRQ.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | $PROJ_DIR$\ClockUartLed.c
21 |
22 |
23 | $PROJ_DIR$\ClockUartLed.h
24 |
25 |
26 | $PROJ_DIR$\commonTypes.h
27 |
28 |
29 | $PROJ_DIR$\main.c
30 |
31 |
32 | $PROJ_DIR$\nRF_Configuration.h
33 |
34 |
35 | $PROJ_DIR$\nRF_IRQ.c
36 |
37 |
38 | $PROJ_DIR$\nRF_IRQ.h
39 |
40 |
41 | $PROJ_DIR$\nRF_LowLevel.c
42 |
43 |
44 | $PROJ_DIR$\nRF_LowLevel.h
45 |
46 |
47 | $PROJ_DIR$\nRF_Modes.c
48 |
49 |
50 | $PROJ_DIR$\nRF_Modes.h
51 |
52 |
53 | $PROJ_DIR$\nRF_RegText.c
54 |
55 |
56 | $PROJ_DIR$\nRF_RegText.h
57 |
58 |
59 | $PROJ_DIR$\nRF_SPI.c
60 |
61 |
62 | $PROJ_DIR$\nRF_SPI.h
63 |
64 |
65 | $PROJ_DIR$\nRF_Tx.c
66 |
67 |
68 | $PROJ_DIR$\nRF_Tx.h
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/14_Hello_I2C_Slave/main_i2c_Slave.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 | // currently linked to http://creativecommons.org/licenses/by-sa/3.0/legalcode
5 |
6 |
7 | #include
8 | #include
9 |
10 | #include "ClockUartLed.h"
11 | #include "commonTypes.h"
12 | #include "i2c.h"
13 |
14 |
15 | void i2c_user_Slave_Rx_Callback(BYTE *userdata,BYTE size)
16 | {
17 | UARTPrintf("I2C Slave received :\n\r");
18 | UARTPrintfHexTable(userdata,size);
19 | UARTPrintf("\n\r");
20 | }
21 |
22 | void i2c_user_Slave_Tx_Callback(BYTE *userdata,BYTE size)
23 | {
24 | UARTPrintf("I2C Slave Tx Complete :\n\r");
25 | UARTPrintfHexTable(userdata,size);
26 | UARTPrintf("\n\r");
27 | }
28 |
29 | void i2c_user_Error_Callback(BYTE l_sr2)
30 | {
31 | if(l_sr2 & 0x01)
32 | {
33 | UARTPrintf("[I2C Bus Error]\n\r");
34 | }
35 | if(l_sr2 & 0x02)
36 | {
37 | UARTPrintf("[I2C Arbitration Lost]\n\r");
38 | }
39 | if(l_sr2 & 0x04)
40 | {
41 | //UARTPrintf("[no Ack]\n\r");//this is ok for the slave
42 | }
43 | if(l_sr2 & 0x08)
44 | {
45 | UARTPrintf("[I2C Bus Overrun]\n\r");
46 | }
47 | }
48 |
49 |
50 | int main( void )
51 | {
52 | BYTE userData[2];
53 | BYTE counter = 0;
54 |
55 | InitialiseSystemClock();
56 |
57 | InitialiseUART();
58 |
59 | UARTPrintf("\r\n_________________________\n\r");
60 | UARTPrintf("STM8 I2C Slave...\n\r");
61 |
62 | I2C_Init();//Start Listening as a slave
63 |
64 | I2C_Slave_Configure(0x72,userData,2);
65 |
66 | userData[0] = 0x55;
67 |
68 | __enable_interrupt();
69 |
70 | while (1)
71 | {
72 | //__wait_for_interrupt();
73 | counter++;
74 | userData[1] = counter;
75 | UARTPrintf("slave loop counter: ");
76 | UARTPrintfHexLn(counter);
77 | delay_1ms_Count(5000);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/22_Hello_AmbientLight_BH1750/main_i2c_AmbientLight.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 | // currently linked to http://creativecommons.org/licenses/by-sa/3.0/legalcode
5 |
6 | #include
7 | #include
8 |
9 | #include "ClockUartLed.h"
10 | #include "commonTypes.h"
11 | #include "i2c_m.h"
12 |
13 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size)
14 | {
15 | /*UARTPrintf("I2C Transaction complete, received:\n\r");
16 | UARTPrintfHexTable(userdata,size);
17 | UARTPrintf("\n\r");
18 | */
19 | }
20 |
21 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size)
22 | {
23 | /*UARTPrintf("I2C Transaction complete, Transmitted:\n\r");
24 | UARTPrintfHexTable(userdata,size);
25 | UARTPrintf("\n\r");
26 | */
27 | }
28 |
29 | void i2c_user_Error_Callback(BYTE l_sr2)
30 | {
31 | if(l_sr2 & 0x01)
32 | {
33 | UARTPrintf("[I2C Bus Error]\n\r");
34 | }
35 | if(l_sr2 & 0x02)
36 | {
37 | UARTPrintf("[I2C Arbitration Lost]\n\r");
38 | }
39 | if(l_sr2 & 0x04)
40 | {
41 | UARTPrintf("[I2C no Acknowledge]\n\r");//this is ok for the slave
42 | }
43 | if(l_sr2 & 0x08)
44 | {
45 | UARTPrintf("[I2C Bus Overrun]\n\r");
46 | }
47 | }
48 |
49 |
50 | int main( void )
51 | {
52 | BYTE userData[2];
53 | BYTE sensorData[2];
54 | BYTE counter = 0;
55 |
56 | sensorData[0] = 0xFF;
57 | sensorData[0] = 0xFF;
58 |
59 | InitialiseSystemClock();
60 |
61 | InitialiseUART();
62 |
63 | UARTPrintf("\r\n_________________________\n\r");
64 | UARTPrintf("STM8 I2C Ambient Light BH1750\n\r");
65 |
66 | I2C_Init();
67 |
68 |
69 | __enable_interrupt();
70 |
71 | while (1)
72 | {
73 | //__wait_for_interrupt();
74 | userData[0] = 0x10;//Continuously H Resolution mode
75 | I2C_Write(0x23, userData,1);//Slave Address 0100-0110;
76 |
77 | //UARTPrintf("Written Command H Res:\r\n");
78 | delay_1ms_Count(200);//max 180ms wait for read to complete
79 |
80 | I2C_Read(0x23, sensorData,2);//Slave Address 0100-0110;
81 | UARTPrintf("Read: ");
82 | UARTPrintfHexTable(sensorData,2);
83 | UARTPrintf("\n");
84 | delay_1ms_Count(200);//max 180ms wait for read to complete
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/15_Hello_STM8L_Signal/hello_led.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | // Delay loop
4 | //
5 | // Actual delay depends on clock settings
6 | // and compiler optimization settings.
7 | //
8 | void delay(unsigned int n)
9 | {
10 | while (n-- > 0);
11 | }
12 |
13 | #define delay_1ms(); delay(1998);
14 |
15 | #define Test_Led_PA2 PA_ODR_ODR2
16 |
17 | void SMT8L_Switch_ToHSI()
18 | {
19 | CLK_SWCR_SWEN = 1; // Enable switching.
20 | CLK_SWR = 0x01; // Use HSI as the clock source.
21 | while (CLK_SWCR_SWBSY != 0); // Pause while the clock switch is busy.
22 | }
23 |
24 | void Initialise_STM8L_Clock()
25 | {
26 | //Set Clock to full speed
27 | CLK_CKDIVR_CKM = 0; // Set to 0x00 => /1 ; Reset is 0x03 => /8
28 | unsigned char cal = CLK_HSICALR-45;//default is 0x66 lowered by 45
29 | //Unlock the trimming
30 | CLK_HSIUNLCKR = 0xAC;
31 | CLK_HSIUNLCKR = 0x35;
32 | CLK_HSITRIMR = cal;
33 |
34 | delay_1ms();
35 | }
36 | //
37 |
38 | void Initialise_Test_GPIO_B3()
39 | {
40 | // Data Direction Register
41 | //
42 | // 0: Input
43 | // 1: Output
44 | //
45 | PB_DDR_bit.DDR3 = 1;
46 |
47 | // Control Register 1
48 | // Output mode:
49 | // 0: Pseudo open drain
50 | // 1: Push-pull
51 | //
52 | PB_CR1_bit.C13 = 1;
53 |
54 | }
55 |
56 | void Initialise_Test_GPIO_A2()
57 | {
58 | PA_DDR_bit.DDR2 = 1;// 1: Output
59 | PA_CR1_bit.C12 = 1; // 1: Push-pull
60 | }
61 |
62 | void GPIO_B3_High()
63 | {
64 | PB_ODR_bit.ODR3 = 1;
65 | }
66 |
67 | void GPIO_B3_Low()
68 | {
69 | PB_ODR_bit.ODR3 = 0;
70 | }
71 |
72 |
73 | int main( void )
74 | {
75 | Initialise_STM8L_Clock();
76 |
77 | Initialise_Test_GPIO_B3();
78 |
79 | delay(10);
80 |
81 | GPIO_B3_High();
82 |
83 | delay(10);
84 |
85 | Initialise_Test_GPIO_A2();
86 | PA_ODR_bit.ODR2 = 1;
87 | delay(10);
88 | PA_ODR_bit.ODR2 = 0;
89 | delay(10);
90 |
91 | //
92 | // Main loop
93 | //
94 | while (1)
95 | {
96 | PB_ODR_bit.ODR3 = 0;
97 | delay_1ms();
98 | PB_ODR_bit.ODR3 = 1;
99 | delay_1ms();
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/05_Hello_RGBLeds/05_Hello_RGBLeds.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 1373646782
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\Exe\05_Hello_RGBLeds.out
10 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
11 | $PROJ_DIR$\Debug\Exe\05_Hello_RGBLeds.hex
12 | $PROJ_DIR$\hello_leds.c
13 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
14 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
15 | $PROJ_DIR$\Debug\Obj\hello_leds.pbi
16 | $PROJ_DIR$\Debug\Obj\hello_leds.o
17 | $TOOLKIT_DIR$\inc\io_macros.h
18 | $TOOLKIT_DIR$\lib\dlstm8smn.a
19 |
20 |
21 | $PROJ_DIR$\Debug\Exe\05_Hello_RGBLeds.out
22 |
23 |
24 | OBJCOPY
25 | 2
26 |
27 |
28 |
29 |
30 | ILINK
31 | 5 7 9 1
32 |
33 |
34 |
35 |
36 | $PROJ_DIR$\hello_leds.c
37 |
38 |
39 | BICOMP
40 | 6
41 |
42 |
43 | ICCSTM8
44 | 7
45 |
46 |
47 |
48 |
49 | BICOMP
50 | 8 4
51 |
52 |
53 | ICCSTM8
54 | 4 8
55 |
56 |
57 |
58 |
59 | [ROOT_NODE]
60 |
61 |
62 | ILINK
63 | 0
64 |
65 |
66 |
67 |
68 |
69 | Release
70 |
71 |
72 | [MULTI_TOOL]
73 | ILINK
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/05_Hello_RGBLeds.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 1373646782
6 |
7 | Debug
8 |
9 | $TOOLKIT_DIR$\lib\dlstm8smn.a
10 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
11 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
12 | $PROJ_DIR$\Debug\Obj\hello_leds.pbi
13 | $PROJ_DIR$\Debug\Obj\hello_leds.o
14 | $PROJ_DIR$\Debug\Exe\05_Hello_RGBLeds.out
15 | $PROJ_DIR$\Debug\Obj\05_Hello_RGBLeds.pbd
16 | $PROJ_DIR$\hello_leds.c
17 | $TOOLKIT_DIR$\inc\io_macros.h
18 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
19 | $PROJ_DIR$\Debug\Exe\05_Hello_RGBLeds.hex
20 |
21 |
22 | [ROOT_NODE]
23 |
24 |
25 | ILINK
26 | 5
27 |
28 |
29 |
30 |
31 | $PROJ_DIR$\Debug\Exe\05_Hello_RGBLeds.out
32 |
33 |
34 | OBJCOPY
35 | 10
36 |
37 |
38 |
39 |
40 | ILINK
41 | 1 4 0 2
42 |
43 |
44 |
45 |
46 | $PROJ_DIR$\hello_leds.c
47 |
48 |
49 | BICOMP
50 | 3
51 |
52 |
53 | ICCSTM8
54 | 4
55 |
56 |
57 |
58 |
59 | BICOMP
60 | 8 9
61 |
62 |
63 | ICCSTM8
64 | 9 8
65 |
66 |
67 |
68 |
69 |
70 | Release
71 |
72 |
73 | [MULTI_TOOL]
74 | ILINK
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/STM8Incremental.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $WS_DIR$\01_HelloLed\01_HelloLed.ewp
6 |
7 |
8 | $WS_DIR$\02_HelloUart\02_HelloUart.ewp
9 |
10 |
11 | $WS_DIR$\04_HelloRF_NordicAPI\04_HelloRF_NordicAPI.ewp
12 |
13 |
14 | $WS_DIR$\05_Hello_RGBLeds\05_Hello_RGBLeds.ewp
15 |
16 |
17 | $WS_DIR$\06_RGBLeds_24bitParam\06_Hello_RGBLeds_24BitsParam.ewp
18 |
19 |
20 | $WS_DIR$\07_Hello_Temperature\07_Hello_Temperature.ewp
21 |
22 |
23 | $WS_DIR$\08_HelloRF_Transmitter\08_HelloRF_Transmitter.ewp
24 |
25 |
26 | $WS_DIR$\09_HelloRF_Receiver\09_HelloRF_Receiver.ewp
27 |
28 |
29 | $WS_DIR$\10_HelloRF_Receiver_IRQ\10_Hello_Receiver_IRQ.ewp
30 |
31 |
32 | $WS_DIR$\11_HelloADC\11_HelloADC.ewp
33 |
34 |
35 | $WS_DIR$\12_Hello_AutoWakeUp\12_Hello_AutoWakeUp.ewp
36 |
37 |
38 | $WS_DIR$\13_Hello_I2C_Master\13_Hello_I2C_Master.ewp
39 |
40 |
41 | $WS_DIR$\14_Hello_I2C_Slave\14_Hello_I2C_Slave.ewp
42 |
43 |
44 | $WS_DIR$\15_Hello_STM8L_Signal\15_Hello_STM8L_Signal.ewp
45 |
46 |
47 | $WS_DIR$\16_HelloTrainUart\16_HelloTrainUart.ewp
48 |
49 |
50 | $WS_DIR$\17_STM8L_UART_HelloRF\17_STM8L_UART_HelloRF.ewp
51 |
52 |
53 | $WS_DIR$\18_STM8L_HelloI2C\18_STM8L_HelloI2C.ewp
54 |
55 |
56 | $WS_DIR$\19_STM8L_Hello_Battery\19_STM8L_Hello_Battery.ewp
57 |
58 |
59 | $WS_DIR$\20_Hello_LightDimmer\20_Hello_LightDimmer.ewp
60 |
61 |
62 | $WS_DIR$\21_STM8L_Hello_LowPower\21_STM8L_Hello_LowPower.ewp
63 |
64 |
65 | $WS_DIR$\22_Hello_AmbientLight_BH1750\22_Hello_AmbientLight_BH1750.ewp
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/01_HelloLed/01_HelloLed.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 3152102150
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\Exe\01_HelloLed.hex
10 | $PROJ_DIR$\Debug\List\templproj.map
11 | $PROJ_DIR$\Debug\Obj\hello_led.o
12 | $PROJ_DIR$\hello_led.c
13 | $PROJ_DIR$\Debug\Exe\templproj.out
14 | $TOOLKIT_DIR$\inc\io_macros.h
15 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
16 | $PROJ_DIR$\Debug\Obj\hello_led.pbi
17 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
18 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
19 | $TOOLKIT_DIR$\lib\dlstm8smn.a
20 |
21 |
22 | $PROJ_DIR$\hello_led.c
23 |
24 |
25 | BICOMP
26 | 7
27 |
28 |
29 | ICCSTM8
30 | 2
31 |
32 |
33 |
34 |
35 | BICOMP
36 | 5 6
37 |
38 |
39 | ICCSTM8
40 | 6 5
41 |
42 |
43 |
44 |
45 | $PROJ_DIR$\Debug\Exe\templproj.out
46 |
47 |
48 | OBJCOPY
49 | 0
50 |
51 |
52 | ILINK
53 | 1
54 |
55 |
56 |
57 |
58 | ILINK
59 | 9 2 10 8
60 |
61 |
62 |
63 |
64 | [ROOT_NODE]
65 |
66 |
67 | ILINK
68 | 1 4
69 |
70 |
71 |
72 |
73 |
74 | Release
75 |
76 |
77 | [MULTI_TOOL]
78 | ILINK
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/02_HelloUart/02_HelloUart.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 4241680732
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\List\templproj.map
10 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
11 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
12 | $PROJ_DIR$\hello_uart.c
13 | $PROJ_DIR$\Debug\Exe\02_HelloUart.hex
14 | $PROJ_DIR$\Debug\Obj\hello_uart.pbi
15 | $TOOLKIT_DIR$\lib\dlstm8smn.a
16 | $PROJ_DIR$\Debug\Obj\hello_uart.o
17 | $PROJ_DIR$\Debug\Exe\templproj.out
18 | $TOOLKIT_DIR$\inc\io_macros.h
19 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
20 |
21 |
22 | $PROJ_DIR$\hello_uart.c
23 |
24 |
25 | BICOMP
26 | 5
27 |
28 |
29 | ICCSTM8
30 | 7
31 |
32 |
33 |
34 |
35 | BICOMP
36 | 9 10
37 |
38 |
39 | ICCSTM8
40 | 10 9
41 |
42 |
43 |
44 |
45 | $PROJ_DIR$\Debug\Exe\templproj.out
46 |
47 |
48 | OBJCOPY
49 | 4
50 |
51 |
52 | ILINK
53 | 0
54 |
55 |
56 |
57 |
58 | ILINK
59 | 2 7 6 1
60 |
61 |
62 |
63 |
64 | [ROOT_NODE]
65 |
66 |
67 | ILINK
68 | 0 8
69 |
70 |
71 |
72 |
73 |
74 | Release
75 |
76 |
77 | [MULTI_TOOL]
78 | ILINK
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/17_STM8L_UART_HelloRF.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | pr00_LibraryCommon
21 |
22 | $PROJ_DIR$\pr00_LibraryCommon\commonTypes.h
23 |
24 |
25 | $PROJ_DIR$\pr00_LibraryCommon\nRF_IRQ.c
26 |
27 |
28 | $PROJ_DIR$\pr00_LibraryCommon\nRF_IRQ.h
29 |
30 |
31 | $PROJ_DIR$\pr00_LibraryCommon\nRF_LowLevel.c
32 |
33 |
34 | $PROJ_DIR$\pr00_LibraryCommon\nRF_LowLevel.h
35 |
36 |
37 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Modes.c
38 |
39 |
40 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Modes.h
41 |
42 |
43 | $PROJ_DIR$\pr00_LibraryCommon\nRF_RegText.c
44 |
45 |
46 | $PROJ_DIR$\pr00_LibraryCommon\nRF_RegText.h
47 |
48 |
49 | $PROJ_DIR$\pr00_LibraryCommon\nRF_SPI.c
50 |
51 |
52 | $PROJ_DIR$\pr00_LibraryCommon\nRF_SPI.h
53 |
54 |
55 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Tx.c
56 |
57 |
58 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Tx.h
59 |
60 |
61 | $PROJ_DIR$\pr00_LibraryCommon\temp_ds18b20.c
62 |
63 |
64 | $PROJ_DIR$\pr00_LibraryCommon\temp_ds18b20.h
65 |
66 |
67 | $PROJ_DIR$\pr00_LibraryCommon\WS2812B.c
68 |
69 |
70 | $PROJ_DIR$\pr00_LibraryCommon\WS2812B.h
71 |
72 |
73 |
74 | $PROJ_DIR$\ClockUartLed.c
75 |
76 |
77 | $PROJ_DIR$\ClockUartLed.h
78 |
79 |
80 | $PROJ_DIR$\main.c
81 |
82 |
83 | $PROJ_DIR$\nRF_Configuration.h
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/19_STM8L_Hello_Battery.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | pr00_LibraryCommon
21 |
22 | $PROJ_DIR$\pr00_LibraryCommon\commonTypes.h
23 |
24 |
25 | $PROJ_DIR$\pr00_LibraryCommon\nRF_IRQ.c
26 |
27 |
28 | $PROJ_DIR$\pr00_LibraryCommon\nRF_IRQ.h
29 |
30 |
31 | $PROJ_DIR$\pr00_LibraryCommon\nRF_LowLevel.c
32 |
33 |
34 | $PROJ_DIR$\pr00_LibraryCommon\nRF_LowLevel.h
35 |
36 |
37 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Modes.c
38 |
39 |
40 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Modes.h
41 |
42 |
43 | $PROJ_DIR$\pr00_LibraryCommon\nRF_RegText.c
44 |
45 |
46 | $PROJ_DIR$\pr00_LibraryCommon\nRF_RegText.h
47 |
48 |
49 | $PROJ_DIR$\pr00_LibraryCommon\nRF_SPI.c
50 |
51 |
52 | $PROJ_DIR$\pr00_LibraryCommon\nRF_SPI.h
53 |
54 |
55 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Tx.c
56 |
57 |
58 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Tx.h
59 |
60 |
61 | $PROJ_DIR$\pr00_LibraryCommon\temp_ds18b20.c
62 |
63 |
64 | $PROJ_DIR$\pr00_LibraryCommon\temp_ds18b20.h
65 |
66 |
67 | $PROJ_DIR$\pr00_LibraryCommon\WS2812B.c
68 |
69 |
70 | $PROJ_DIR$\pr00_LibraryCommon\WS2812B.h
71 |
72 |
73 |
74 | $PROJ_DIR$\ClockUartLed.c
75 |
76 |
77 | $PROJ_DIR$\ClockUartLed.h
78 |
79 |
80 | $PROJ_DIR$\main.c
81 |
82 |
83 | $PROJ_DIR$\nRF_Configuration.h
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/21_STM8L_Hello_LowPower.ewt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 |
13 | Release
14 |
15 | STM8
16 |
17 | 0
18 |
19 |
20 | pr00_LibraryCommon
21 |
22 | $PROJ_DIR$\pr00_LibraryCommon\commonTypes.h
23 |
24 |
25 | $PROJ_DIR$\pr00_LibraryCommon\nRF_IRQ.c
26 |
27 |
28 | $PROJ_DIR$\pr00_LibraryCommon\nRF_IRQ.h
29 |
30 |
31 | $PROJ_DIR$\pr00_LibraryCommon\nRF_LowLevel.c
32 |
33 |
34 | $PROJ_DIR$\pr00_LibraryCommon\nRF_LowLevel.h
35 |
36 |
37 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Modes.c
38 |
39 |
40 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Modes.h
41 |
42 |
43 | $PROJ_DIR$\pr00_LibraryCommon\nRF_RegText.c
44 |
45 |
46 | $PROJ_DIR$\pr00_LibraryCommon\nRF_RegText.h
47 |
48 |
49 | $PROJ_DIR$\pr00_LibraryCommon\nRF_SPI.c
50 |
51 |
52 | $PROJ_DIR$\pr00_LibraryCommon\nRF_SPI.h
53 |
54 |
55 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Tx.c
56 |
57 |
58 | $PROJ_DIR$\pr00_LibraryCommon\nRF_Tx.h
59 |
60 |
61 | $PROJ_DIR$\pr00_LibraryCommon\temp_ds18b20.c
62 |
63 |
64 | $PROJ_DIR$\pr00_LibraryCommon\temp_ds18b20.h
65 |
66 |
67 | $PROJ_DIR$\pr00_LibraryCommon\WS2812B.c
68 |
69 |
70 | $PROJ_DIR$\pr00_LibraryCommon\WS2812B.h
71 |
72 |
73 |
74 | $PROJ_DIR$\ClockUartLed.c
75 |
76 |
77 | $PROJ_DIR$\ClockUartLed.h
78 |
79 |
80 | $PROJ_DIR$\main.c
81 |
82 |
83 | $PROJ_DIR$\nRF_Configuration.h
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/15_Hello_STM8L_Signal/15_Hello_STM8L_Signal.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 219938128
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\Debug\Obj\15_Hello_STM8L_Signal.pbd
10 | $PROJ_DIR$\Debug\Exe\15_Hello_STM8L_Signal.hex
11 | $TOOLKIT_DIR$\lib\dlstm8smn.a
12 | $PROJ_DIR$\..\21_STM8L_Hello_LowPower\main.c
13 | $PROJ_DIR$\hello_led.c
14 | $PROJ_DIR$\Debug\Exe\15_Hello_STM8L_Signal.out
15 | $TOOLKIT_DIR$\config\lnkstm8l151f3.icf
16 | $PROJ_DIR$\Debug\Obj\hello_led.pbi
17 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
18 | $PROJ_DIR$\Debug\List\15_Hello_STM8L_Signal.map
19 | $TOOLKIT_DIR$\inc\iostm8l151f3.h
20 | $TOOLKIT_DIR$\inc\io_macros.h
21 | $PROJ_DIR$\Debug\Obj\hello_led.o
22 |
23 |
24 | $PROJ_DIR$\hello_led.c
25 |
26 |
27 | BICOMP
28 | 7
29 |
30 |
31 | ICCSTM8
32 | 12
33 |
34 |
35 |
36 |
37 | BICOMP
38 | 11 10
39 |
40 |
41 | ICCSTM8
42 | 10 11
43 |
44 |
45 |
46 |
47 | [ROOT_NODE]
48 |
49 |
50 | ILINK
51 | 9 5
52 |
53 |
54 |
55 |
56 | $PROJ_DIR$\Debug\Exe\15_Hello_STM8L_Signal.out
57 |
58 |
59 | OBJCOPY
60 | 1
61 |
62 |
63 | ILINK
64 | 9
65 |
66 |
67 |
68 |
69 | ILINK
70 | 6 12 2 8
71 |
72 |
73 |
74 |
75 |
76 | Release
77 |
78 |
79 | [MULTI_TOOL]
80 | ILINK
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/13_Hello_I2C_Master/log.txt:
--------------------------------------------------------------------------------
1 | _________________________
2 | STM8 I2C Master...
3 | I2C Transaction complete, received:
4 | 0x55 5F
5 | master loop counter: 0x02
6 | I2C Transaction complete, received:
7 | 0x55 60
8 | master loop counter: 0x03
9 | I2C Transaction complete, received:
10 | 0x55 61
11 | master loop counter: 0x04
12 | I2C Transaction complete, received:
13 | 0x55 61
14 | master loop counter: 0x05
15 | I2C Transaction complete, received:
16 | 0x55 62
17 | master loop counter: 0x06
18 | I2C Transaction complete, received:
19 | 0x55 63
20 | master loop counter: 0x07
21 | I2C Transaction complete, received:
22 | 0x55 64
23 | master loop counter: 0x08
24 | I2C Transaction complete, received:
25 | 0x55 65
26 | master loop counter: 0x09
27 | I2C Transaction complete, received:
28 | 0x55 66
29 | master loop counter: 0x0A
30 | I2C Transaction complete, received:
31 | 0x55 67
32 | master loop counter: 0x0B
33 | I2C Transaction complete, received:
34 | 0x55 68
35 | master loop counter: 0x0C
36 | I2C Transaction complete, received:
37 | 0x55 68
38 | master loop counter: 0x0D
39 | I2C Transaction complete, received:
40 | 0x55 69
41 | master loop counter: 0x0E
42 | I2C Transaction complete, received:
43 | 0x55 6A
44 | master loop counter: 0x0F
45 | I2C Transaction complete, received:
46 | 0x55 6B
47 | master loop counter: 0x10
48 | I2C Transaction complete, received:
49 | 0x55 6C
50 | master loop counter: 0x11
51 | I2C Transaction complete, received:
52 | 0x55 6D
53 | master loop counter: 0x12
54 | Not TRA, no RXNE and not StopF !
55 | [I2C no Acknowledge]
56 | master loop counter: 0x13
57 | I2C Transaction complete, received:
58 | 0x55 14
59 | master loop counter: 0x14
60 | I2C Transaction complete, received:
61 | 0x55 15
62 | master loop counter: 0x15
63 | I2C Transaction complete, received:
64 | 0x55 16
65 | master loop counter: 0x16
66 | I2C Transaction complete, received:
67 | 0x55 17
68 | master loop counter: 0x17
69 | I2C Transaction complete, received:
70 | 0x55 18
71 | master loop counter: 0x18
72 | I2C Transaction complete, received:
73 | 0x55 18
74 | master loop counter: 0x19
75 | I2C Transaction complete, received:
76 | 0x55 19
77 | master loop counter: 0x1A
78 | I2C Transaction complete, received:
79 | 0x55 1A
80 | master loop counter: 0x1B
81 | I2C Transaction complete, received:
82 | 0x55 1B
83 | master loop counter: 0x1C
84 | I2C Transaction complete, received:
85 | 0x55 1C
86 | master loop counter: 0x1D
87 | I2C Transaction complete, received:
88 | 0x55 1D
89 | master loop counter: 0x1E
90 | I2C Transaction complete, received:
91 | 0x55 1E
92 | master loop counter: 0x1F
93 | I2C Transaction complete, received:
94 | 0x55 1E
95 | master loop counter: 0x20
96 |
--------------------------------------------------------------------------------
/20_Hello_LightDimmer/main.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 | #include
5 | #include
6 |
7 | #include "ClockUartLed.h"
8 |
9 | unsigned char rxIndex;
10 | unsigned char rxTable[10];
11 | unsigned char cmd;
12 | unsigned char interruptJustHappened;
13 | #define RX_FRAME_SIZE 4
14 |
15 | #define PowerControl_PC5 PC_ODR_ODR5
16 |
17 | void PowerControl_On()
18 | {
19 | PC_DDR_DDR5 = 1;//1:output
20 | PowerControl_PC5 = 0;
21 | }
22 | void PowerControl_Off()
23 | {
24 | PowerControl_PC5 = 1;
25 | PC_DDR_DDR5 = 0;//0:input
26 | }
27 |
28 | void Initialise_PowerControl_C5()
29 | {
30 | PowerControl_Off();
31 | PC_DDR_DDR5 = 1;//1:output
32 | PC_CR1_C15 = 0;// 0: Pseudo open drain
33 | }
34 |
35 | void Initialise_Analog_D2()
36 | {
37 | PD_DDR_DDR2 = 0;//0:input
38 | PD_CR1_C12 = 0;// 0: Floating input
39 | }
40 |
41 | void check_Rx_Frame()
42 | {
43 | if(rxTable[0] == 'G')
44 | if(rxTable[1] == 'o')
45 | {
46 | if((rxTable[2] ^ rxTable[3]) == 0xFF)
47 | {
48 | cmd = rxTable[2];
49 | //Apply_Cmd_To_ULN_Output();
50 | UARTPrintf("Ack Rx ");
51 | UARTPrintfHex(rxTable[2]);
52 | UARTPrintf(" \n");
53 | }
54 | }
55 | }
56 |
57 | #pragma vector = UART1_R_RXNE_vector
58 | __interrupt void IRQHandler_UART(void)
59 | {
60 | unsigned char rx;
61 | while(UART1_SR_RXNE)
62 | {
63 | rx = UART1_DR;
64 | if(rxIndex<10)
65 | {
66 | rxTable[rxIndex++] = rx;
67 | }
68 | if(rxIndex == RX_FRAME_SIZE)
69 | {
70 | check_Rx_Frame();
71 | rxIndex = 0;
72 | }
73 | }
74 | if((UART1_SR&0x0F) != 0x00)//Any of the errors
75 | {
76 | UART1_SR = 0;
77 | rx = UART1_DR;//read DR to clear the errors
78 | }
79 | interruptJustHappened = 1;
80 | }
81 |
82 | int main( void )
83 | {
84 | rxIndex = 0;
85 | unsigned char index = 0;
86 | interruptJustHappened = 0;
87 | InitialiseSystemClock();
88 |
89 | Initialise_Analog_D2();
90 | Initialise_PowerControl_C5();
91 | Initialise_TestLed_GPIO_B5();
92 |
93 |
94 | InitialiseUART();
95 |
96 | UARTPrintf("\r\n_________________________\n\r");
97 | UARTPrintf("STM8 Light Dimmer...\n\r");
98 |
99 |
100 |
101 | while (1)
102 | {
103 | UARTPrintf("Ping Dimmer");
104 | UARTPrintf_uint(index++);
105 | UARTPrintf(" \n");
106 | Test_Led_Off();
107 | //PowerControl_Off();
108 | delay_1ms_Count(3000);
109 |
110 |
111 | Test_Led_On();
112 | PowerControl_On();
113 | delay_1ms_Count(1000);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Status
2 | - This repository was used for a bringup of STM8 and STM8L projects, it is no longer maintained.
3 | - For a latest status of a working and tested library and examples, please check the [IoT_STM8](https://github.com/HomeSmartMesh/IoT_STM8) repository where all examples are using the same libraries under the root folder\libs
4 |
5 |
6 | # See this firmware in action
7 | - [IoT_STM8](https://github.com/HomeSmartMesh/IoT_STM8) : working and tested firmware
8 | - [IoT_Frameworks (Sensor/Server/Client)](https://github.com/wassfila/IoT_Frameworks) : RF Network and raspberry pi environment
9 |
10 | # Hello world samples for the [STM8 IoT Boards](https://github.com/wassfila/STM8_IoT_Boards)
11 | This repository contains incremented projects that gradually cover hello world samples for :
12 | - Radio transceiver module
13 | - Weather sensors : temperature, humidity, air quality.
14 | - RGB Leds
15 | - Gyro / Accel
16 | - Ambient light and user gesture
17 |
18 | # Samples Overview
19 | ## 01_HelloLed
20 | Check if your compilation and flashing chain is running, the led should blink
21 |
22 | ## 02_HelloUart
23 | Check if your USB to UART connection is correctly configured with the right com port and speed
24 |
25 | ## 02_HelloRF_NordicAPI
26 | Check if your SPI connection to the nRF24L01+ is properly connected, it reads registers and displays them with their names and values on the UART console.
27 | Note that the register names were declared for easier debug through the console, the default values can be cross checked with the datasheet.
28 |
29 | ## 05_Hello_RGBLeds:
30 | C functions with nops to set a fixed value of RGB colors to some LEDs. The RGB values here can only be set on compile time.
31 |
32 | ## 06_Hello_RGBLeds_24BitsParam
33 | Assembler function that reads any RGB values list from an array in memory and serializes the data to the LEDs. The RGB values here can be changed on run time.
34 |
35 | ## 07_Hello_Temperature
36 | API draft for the DS18B20 to read the temperature. Note that there are two modes, the bus mode and the single sensor read.
37 | The _Single_ functions are to be used when a single sensor is connected. They are to be used to identify the sensor ID before using it in a bus or when a single sensor is used.
38 |
39 | # Licensing
40 | - By default and everywhere when nothing is mentionned : Sources are free to use for commercial and private purpose, share, copy partially or completely.
41 | - Unless a specific example is taken from another library where a different licensing model is explicitely mentionned : Due to switching the 'real' working repository to guthub, the Licensing is indeed more complex now as it is on a project subdirectory basis. Such snapshot libraries are not used for the purpose of this project but are here as a matter of comparision and criticism, which means that the final usage of such imported library depends on the purpose the end user will use them for.
42 |
--------------------------------------------------------------------------------
/01_HelloLed/hello_led.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void InitialiseSystemClock()
4 | {
5 | CLK_ICKR = 0; // Reset the Internal Clock Register.
6 | CLK_ICKR_HSIEN = 1; // Enable the HSI.
7 | CLK_ECKR = 0; // Disable the external clock.
8 | while (CLK_ICKR_HSIRDY == 0); // Wait for the HSI to be ready for use.
9 | CLK_CKDIVR = 0; // Ensure the clocks are running at full speed.
10 | CLK_PCKENR1 = 0xff; // Enable all peripheral clocks.
11 | CLK_PCKENR2 = 0xff; // Ditto.
12 | CLK_CCOR = 0; // Turn off CCO.
13 | CLK_HSITRIMR = 0; // Turn off any HSIU trimming.
14 | CLK_SWIMCCR = 0; // Set SWIM to run at clock / 2.
15 | CLK_SWR = 0xe1; // Use HSI as the clock source.
16 | CLK_SWCR = 0; // Reset the clock switch control register.
17 | CLK_SWCR_SWEN = 1; // Enable switching.
18 | while (CLK_SWCR_SWBSY != 0); // Pause while the clock switch is busy.
19 | }
20 | //
21 | // Delay loop
22 | //
23 | // Actual delay depends on clock settings
24 | // and compiler optimization settings.
25 | //
26 | void delay(unsigned int n)
27 | {
28 | while (n-- > 0);
29 | }
30 |
31 | #define Test_Led_PB5 PB_ODR_ODR5
32 |
33 | void Initialise_TestLed_GPIO_B5()
34 | {
35 | //D3 output
36 | //PD_DDR_bit.DDR3 = 1;
37 | //push pull
38 | //PD_CR1_bit.C13 = 1;
39 | //PD_ODR_bit.ODR3 = 1;
40 |
41 | //
42 | // Data Direction Register
43 | //
44 | // 0: Input
45 | // 1: Output
46 | //
47 | PB_DDR_bit.DDR5 = 1;
48 | //PC_DDR = 0xFF;
49 |
50 | //
51 | // Control Register 1
52 | //
53 | // Input mode:
54 | // 0: Floating input
55 | // 1: Input with pull-up
56 | //
57 | // Output mode:
58 | // 0: Pseudo open drain
59 | // 1: Push-pull
60 | //
61 | PB_CR1_bit.C15 = 0;
62 | //PC_CR1 = 0x00;
63 |
64 | //
65 | // Control Register 2
66 | //
67 | // Input mode:
68 | // 0: External interrupt disabled
69 | // 1: External interrupt enabled
70 | //
71 | // Output mode:
72 | // 0: Output speed up to 2 MHz
73 | // 1: Output speed up to 10 MHz
74 | //
75 | //PB_CR2_bit.C25 = 0;
76 | }
77 |
78 | int main( void )
79 | {
80 | InitialiseSystemClock();
81 |
82 | Initialise_TestLed_GPIO_B5();
83 |
84 | //Led Off
85 | Test_Led_PB5 = 1;
86 |
87 | //
88 | // Main loop
89 | //
90 | while (1)
91 | {
92 | //Off
93 | Test_Led_PB5 = 1;
94 | for(int i=0;i<10;i++)
95 | {
96 | delay(60000);
97 | }
98 | //On
99 | Test_Led_PB5 = 0;
100 | delay(10000);
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/04_HelloRF_NordicAPI/nRF_LowLevel.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 20.09.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | #include
14 |
15 | #include "nRF_LowLevel.h"
16 |
17 | //---------------------------------------------------------------------------------------
18 | // PC7 SPI_MISO
19 | // PC6 SPI_MOSI
20 | // PC5 SPI_SCK
21 | // PC4 GPIO_OUT CSN Chip Select Negative
22 | // PC3 GPIO_OUT CE Chip Enable
23 | //---------------------------------------------------------------------------------------
24 |
25 |
26 | void SPI_Init_ChipEnable_Pin()
27 | {
28 | //To be disabled before configuration Low is Disable
29 | PC_ODR_ODR3 = 0;
30 |
31 | // 0: Input 1: Output
32 | PC_DDR_DDR3 = 1;
33 |
34 | // 0: Pseudo open drain 1: Push-pull
35 | PC_CR1_C13 = 1;
36 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
37 | PC_CR2_C23 = 1;
38 | }
39 | void CE_Pin_LowDisable()
40 | {
41 | PC_ODR_ODR3 = 0;
42 | }
43 |
44 | void CE_Pin_HighEnable()
45 | {
46 | PC_ODR_ODR3 = 1;
47 | }
48 |
49 | void SPI_Init_ChipSelect_Pin()
50 | {
51 | //To be disabled before configuration High is Disable
52 | PC_ODR_ODR4 = 1;
53 | // 0: Input 1: Output
54 | PC_DDR_DDR4 = 1;
55 | // 0: Pseudo open drain 1: Push-pull
56 | PC_CR1_C14 = 1;
57 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
58 | PC_CR2_C24 = 1;
59 | }
60 |
61 | void CSN_Pin_LowSelect()
62 | {
63 | PC_ODR_ODR4 = 0;
64 | }
65 |
66 | void CSN_Pin_HighDisable()
67 | {
68 | PC_ODR_ODR4 = 1;
69 | }
70 |
71 | //Initialise the Configuration registers 1 and 2. Also resets the polynomial to the default
72 | void SPI_Init_Peripheral()
73 | {
74 | const BYTE SPI_CR1_BR_fDiv256 = 0x07;
75 |
76 | SPI_CR1 = 0x00;//default reset value
77 | //SPI_CR1_LSBFIRST = 0;
78 | SPI_CR1_BR = SPI_CR1_BR_fDiv256;
79 | //SPI_CR1_CPOL = 0; Low when Idle
80 | //SPI_CR1_CPHA = 0; 1st edge
81 |
82 | SPI_CR2 = 0x00;
83 | //SPI_CR2_BDM = 0;// 2 lines
84 | SPI_CR2_SSM = 1;//Software Slave Management Enabled
85 | SPI_CR2_SSI = 1;//Master Mode
86 |
87 | //Set the SPI in Master Mode
88 | SPI_CR1_MSTR = 1;
89 |
90 | SPI_CRCPR = 0x07;//CRC Polynomial reset value is 0x07
91 |
92 | //Enable the SPI Peripheral
93 | SPI_CR1_SPE = 1;
94 |
95 | }
96 |
97 | //RM0016 Note : Do not use the BSY flag to handle each data transmission or reception.
98 | //It is better to use TXE and RXNE flags instead.
99 | BYTE SPI_WriteRead(BYTE Data)
100 | {
101 | //Wait while (Tx Buffer not Empty);
102 | while(SPI_SR_TXE == 0);
103 | SPI_DR = Data;
104 | //while (SPI_GetFlagStatus(SPI_FLAG_BSY)== SET);// Do not use Busy Flag in every transaction
105 | //Wait while Rx Buffer Empty
106 | while(SPI_SR_RXNE == 0);
107 |
108 | return SPI_DR;
109 | }
110 |
--------------------------------------------------------------------------------
/11_HelloADC/11_HelloADC.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 490087602
6 |
7 | Debug
8 |
9 | $TOOLKIT_DIR$\lib\dlstm8smn.a
10 | $PROJ_DIR$\Debug\Obj\main.pbi
11 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
12 | $TOOLKIT_DIR$\inc\io_macros.h
13 | $PROJ_DIR$\Debug\Obj\ClockUartLed.o
14 | $PROJ_DIR$\ClockUartLed.h
15 | $PROJ_DIR$\Debug\Obj\ClockUartLed.pbi
16 | $PROJ_DIR$\main.c
17 | $PROJ_DIR$\Debug\Obj\main.o
18 | $PROJ_DIR$\Debug\Exe\11_HelloADC.out
19 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
20 | $PROJ_DIR$\ClockUartLed.c
21 | $PROJ_DIR$\commonTypes.h
22 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
23 |
24 |
25 | [ROOT_NODE]
26 |
27 |
28 | ILINK
29 | 9
30 |
31 |
32 |
33 |
34 | $PROJ_DIR$\main.c
35 |
36 |
37 | BICOMP
38 | 1
39 |
40 |
41 | ICCSTM8
42 | 8
43 |
44 |
45 |
46 |
47 | BICOMP
48 | 5 12
49 |
50 |
51 | ICCSTM8
52 | 5 12
53 |
54 |
55 |
56 |
57 | $PROJ_DIR$\Debug\Exe\11_HelloADC.out
58 |
59 |
60 | ILINK
61 | 13 4 8 0 2
62 |
63 |
64 |
65 |
66 | $PROJ_DIR$\ClockUartLed.c
67 |
68 |
69 | BICOMP
70 | 6
71 |
72 |
73 | ICCSTM8
74 | 4
75 |
76 |
77 |
78 |
79 | BICOMP
80 | 3 5 10
81 |
82 |
83 | ICCSTM8
84 | 5 10 3
85 |
86 |
87 |
88 |
89 |
90 | Release
91 |
92 |
93 | [MULTI_TOOL]
94 | ILINK
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/22_Hello_AmbientLight_BH1750/i2c_m.h:
--------------------------------------------------------------------------------
1 | /** @file i2c.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 04.01.2016
10 | * $Revision:
11 | *
12 | */
13 |
14 | #include "commonTypes.h"
15 |
16 | //------------------------------------------------------------------------------------------------------------------
17 | // User configuration
18 | //------------------------------------------------------------------------------------------------------------------
19 | #define Enable_Debug_I2C_IRQ 0
20 |
21 |
22 | //------------------------------------------------------------------------------------------------------------------
23 |
24 | //configuration application section, not to be edited
25 | //---------------------------------------------------------------------------------------------
26 | #if (Enable_Debug_I2C_IRQ == 1)
27 | #define I2C_IRQ_Printf(x) UARTPrintf(x)
28 | #define I2C_IRQ_PrintfHex(x) UARTPrintfHex(x)
29 | #define I2C_IRQ_PrintStatus(x) nRF_PrintStatus(x)
30 | #else
31 | #define I2C_IRQ_Printf(x) (void)0
32 | #define I2C_IRQ_PrintfHex(x) (void)0
33 | #define I2C_IRQ_PrintStatus(x) (void)0
34 | #endif
35 |
36 | //---------------------------------------------------------------------------------------------
37 |
38 |
39 | //------------------------------------------------------------------------------------------------------------------
40 | // I2C Registers
41 | //------------------------------------------------------------------------------------------------------------------
42 | // I2C_CR1 Control Register 1
43 | // I2C_CR2 Control Register 2
44 | // I2C_FREQR Frequency Register
45 | // I2C_OARL Own Address Register LSB
46 | // I2C_OARH Own Address Register MSB
47 | // I2C_DR Data Register
48 | // I2C_SR1 Status Register 1
49 | // I2C_SR2 Status Register 2
50 | // I2C_SR3 Status Register 3
51 | // I2C_ITR Interrupt Register
52 | // I2C_CCRL Clock Control Register Low
53 | // I2C_CCRH Clock Control Register High
54 | // I2C_TRISER Tristate Enable register
55 | // funny the I2C_PECR is documented in STM8S103F3 specification while the Packet Error Checking is not part of the S family
56 | //
57 | //all reset to 0
58 | //------------------------------------------------------------------------------------------------------------------
59 |
60 | //
61 | // STM8 I2C system.
62 | // default is slave, goes to master on Start and back to slave on stop
63 | // Addresses are 7/10 bits (one or two bytes), a Genral Call address can be enabled or disabled
64 | // 9th bit is acknowledge from the slave
65 | void I2C_Init();
66 |
67 | void I2C_Transaction(BYTE read,BYTE slaveAddress, BYTE* buffer,BYTE count);
68 |
69 | void I2C_Read(BYTE slaveAddress, BYTE* buffer,BYTE count);
70 |
71 | void I2C_Write(BYTE slaveAddress, BYTE* buffer,BYTE count);
72 |
73 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size);
74 |
75 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size);
76 |
77 |
78 | void i2c_user_Error_Callback(BYTE l_sr2);
79 |
--------------------------------------------------------------------------------
/20_Hello_LightDimmer/20_Hello_LightDimmer.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 3201038671
6 |
7 | Debug
8 |
9 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
10 | $TOOLKIT_DIR$\inc\c\intrinsics.h
11 | $PROJ_DIR$\ClockUartLed.c
12 | $PROJ_DIR$\main.c
13 | $PROJ_DIR$\Debug\Obj\ClockUartLed.pbi
14 | $PROJ_DIR$\Debug\Obj\ClockUartLed.o
15 | $TOOLKIT_DIR$\lib\dlstm8smn.a
16 | $PROJ_DIR$\Debug\Exe\20_Hello_LightDimmer.out
17 | $PROJ_DIR$\ClockUartLed.h
18 | $PROJ_DIR$\Debug\Obj\main.pbi
19 | $TOOLKIT_DIR$\inc\io_macros.h
20 | $PROJ_DIR$\Debug\Obj\main.o
21 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
22 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
23 |
24 |
25 | [ROOT_NODE]
26 |
27 |
28 | ILINK
29 | 7
30 |
31 |
32 |
33 |
34 | $PROJ_DIR$\ClockUartLed.c
35 |
36 |
37 | BICOMP
38 | 4
39 |
40 |
41 | ICCSTM8
42 | 5
43 |
44 |
45 |
46 |
47 | BICOMP
48 | 10 12 8
49 |
50 |
51 | ICCSTM8
52 | 8 12 10
53 |
54 |
55 |
56 |
57 | $PROJ_DIR$\main.c
58 |
59 |
60 | BICOMP
61 | 9
62 |
63 |
64 | ICCSTM8
65 | 11
66 |
67 |
68 |
69 |
70 | BICOMP
71 | 10 8 1 12
72 |
73 |
74 | ICCSTM8
75 | 12 10 1 8
76 |
77 |
78 |
79 |
80 | $PROJ_DIR$\Debug\Exe\20_Hello_LightDimmer.out
81 |
82 |
83 | ILINK
84 | 13 5 11 6 0
85 |
86 |
87 |
88 |
89 |
90 | Release
91 |
92 |
93 | [MULTI_TOOL]
94 | ILINK
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/nRF_LowLevel.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 20.09.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | #include
14 |
15 | #include "nRF_LowLevel.h"
16 |
17 | //----------------------------------------------------------------------------------------------------------
18 | // PC7 SPI_MISO
19 | // PC6 SPI_MOSI
20 | // PC5 SPI_SCK
21 | // PC4 GPIO_OUT CSN Chip Select Negative
22 | // PC3 GPIO_OUT CE Chip Enable (this signal is active high and used to activate the chip in RX or TX mode)
23 | //----------------------------------------------------------------------------------------------------------
24 |
25 |
26 | void SPI_Init_ChipEnable_Pin()
27 | {
28 | //To be disabled before configuration Low is Disable
29 | PC_ODR_ODR3 = 0;
30 |
31 | // 0: Input 1: Output
32 | PC_DDR_DDR3 = 1;
33 |
34 | // 0: Pseudo open drain 1: Push-pull
35 | PC_CR1_C13 = 1;
36 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
37 | PC_CR2_C23 = 1;
38 | }
39 | void CE_Pin_LowDisable()
40 | {
41 | PC_ODR_ODR3 = 0;
42 | }
43 |
44 | void CE_Pin_HighEnable()
45 | {
46 | PC_ODR_ODR3 = 1;
47 | }
48 |
49 | void SPI_Init_ChipSelect_Pin()
50 | {
51 | //To be disabled before configuration High is Disable
52 | PC_ODR_ODR4 = 1;
53 | // 0: Input 1: Output
54 | PC_DDR_DDR4 = 1;
55 | // 0: Pseudo open drain 1: Push-pull
56 | PC_CR1_C14 = 1;
57 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
58 | PC_CR2_C24 = 1;
59 | }
60 |
61 | void CSN_Pin_LowSelect()
62 | {
63 | PC_ODR_ODR4 = 0;
64 | }
65 |
66 | void CSN_Pin_HighDisable()
67 | {
68 | PC_ODR_ODR4 = 1;
69 | }
70 |
71 | //Initialise the Configuration registers 1 and 2. Also resets the polynomial to the default
72 | void SPI_Init_Peripheral()
73 | {
74 | const BYTE SPI_CR1_BR_fDiv256 = 0x07;
75 |
76 | SPI_CR1 = 0x00;//default reset value
77 | //SPI_CR1_LSBFIRST = 0;
78 | SPI_CR1_BR = SPI_CR1_BR_fDiv256;
79 | //SPI_CR1_CPOL = 0; Low when Idle
80 | //SPI_CR1_CPHA = 0; 1st edge
81 |
82 | SPI_CR2 = 0x00;
83 | //SPI_CR2_BDM = 0;// 2 lines
84 | SPI_CR2_SSM = 1;//Software Slave Management Enabled
85 | SPI_CR2_SSI = 1;//Master Mode
86 |
87 | //Set the SPI in Master Mode
88 | SPI_CR1_MSTR = 1;
89 |
90 | SPI_CRCPR = 0x07;//CRC Polynomial reset value is 0x07
91 |
92 | //Enable the SPI Peripheral
93 | SPI_CR1_SPE = 1;
94 |
95 | }
96 |
97 | //RM0016 Note : Do not use the BSY flag to handle each data transmission or reception.
98 | //It is better to use TXE and RXNE flags instead.
99 | BYTE SPI_WriteRead(BYTE Data)
100 | {
101 | //Wait while (Tx Buffer not Empty);
102 | while(SPI_SR_TXE == 0);
103 | SPI_DR = Data;
104 | //while (SPI_GetFlagStatus(SPI_FLAG_BSY)== SET);// Do not use Busy Flag in every transaction
105 | //Wait while Rx Buffer Empty
106 | while(SPI_SR_RXNE == 0);
107 |
108 | return SPI_DR;
109 | }
110 |
--------------------------------------------------------------------------------
/09_HelloRF_Receiver/nRF_LowLevel.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 20.09.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | #include
14 |
15 | #include "nRF_LowLevel.h"
16 |
17 | //----------------------------------------------------------------------------------------------------------
18 | // PC7 SPI_MISO
19 | // PC6 SPI_MOSI
20 | // PC5 SPI_SCK
21 | // PC4 GPIO_OUT CSN Chip Select Negative
22 | // PC3 GPIO_OUT CE Chip Enable (this signal is active high and used to activate the chip in RX or TX mode)
23 | //----------------------------------------------------------------------------------------------------------
24 |
25 |
26 | void SPI_Init_ChipEnable_Pin()
27 | {
28 | //To be disabled before configuration Low is Disable
29 | PC_ODR_ODR3 = 0;
30 |
31 | // 0: Input 1: Output
32 | PC_DDR_DDR3 = 1;
33 |
34 | // 0: Pseudo open drain 1: Push-pull
35 | PC_CR1_C13 = 1;
36 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
37 | PC_CR2_C23 = 1;
38 | }
39 | void CE_Pin_LowDisable()
40 | {
41 | PC_ODR_ODR3 = 0;
42 | }
43 |
44 | void CE_Pin_HighEnable()
45 | {
46 | PC_ODR_ODR3 = 1;
47 | }
48 |
49 | void SPI_Init_ChipSelect_Pin()
50 | {
51 | //To be disabled before configuration High is Disable
52 | PC_ODR_ODR4 = 1;
53 | // 0: Input 1: Output
54 | PC_DDR_DDR4 = 1;
55 | // 0: Pseudo open drain 1: Push-pull
56 | PC_CR1_C14 = 1;
57 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
58 | PC_CR2_C24 = 1;
59 | }
60 |
61 | void CSN_Pin_LowSelect()
62 | {
63 | PC_ODR_ODR4 = 0;
64 | }
65 |
66 | void CSN_Pin_HighDisable()
67 | {
68 | PC_ODR_ODR4 = 1;
69 | }
70 |
71 | //Initialise the Configuration registers 1 and 2. Also resets the polynomial to the default
72 | void SPI_Init_Peripheral()
73 | {
74 | const BYTE SPI_CR1_BR_fDiv256 = 0x07;
75 |
76 | SPI_CR1 = 0x00;//default reset value
77 | //SPI_CR1_LSBFIRST = 0;
78 | SPI_CR1_BR = SPI_CR1_BR_fDiv256;
79 | //SPI_CR1_CPOL = 0; Low when Idle
80 | //SPI_CR1_CPHA = 0; 1st edge
81 |
82 | SPI_CR2 = 0x00;
83 | //SPI_CR2_BDM = 0;// 2 lines
84 | SPI_CR2_SSM = 1;//Software Slave Management Enabled
85 | SPI_CR2_SSI = 1;//Master Mode
86 |
87 | //Set the SPI in Master Mode
88 | SPI_CR1_MSTR = 1;
89 |
90 | SPI_CRCPR = 0x07;//CRC Polynomial reset value is 0x07
91 |
92 | //Enable the SPI Peripheral
93 | SPI_CR1_SPE = 1;
94 |
95 | }
96 |
97 | //RM0016 Note : Do not use the BSY flag to handle each data transmission or reception.
98 | //It is better to use TXE and RXNE flags instead.
99 | BYTE SPI_WriteRead(BYTE Data)
100 | {
101 | //Wait while (Tx Buffer not Empty);
102 | while(SPI_SR_TXE == 0);
103 | SPI_DR = Data;
104 | //while (SPI_GetFlagStatus(SPI_FLAG_BSY)== SET);// Do not use Busy Flag in every transaction
105 | //Wait while Rx Buffer Empty
106 | while(SPI_SR_RXNE == 0);
107 |
108 | return SPI_DR;
109 | }
110 |
--------------------------------------------------------------------------------
/12_Hello_AutoWakeUp/12_Hello_AutoWakeUp.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 3136943516
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\commonTypes.h
10 | $PROJ_DIR$\Debug\Obj\main.o
11 | $TOOLKIT_DIR$\inc\c\intrinsics.h
12 | $PROJ_DIR$\ClockUartLed.h
13 | $PROJ_DIR$\main.c
14 | $PROJ_DIR$\ClockUartLed.c
15 | $PROJ_DIR$\Debug\Exe\12_Hello_AutoWakeUp.out
16 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
17 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
18 | $PROJ_DIR$\Debug\Obj\ClockUartLed.pbi
19 | $TOOLKIT_DIR$\inc\io_macros.h
20 | $TOOLKIT_DIR$\lib\dlstm8smn.a
21 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
22 | $PROJ_DIR$\Debug\Obj\ClockUartLed.o
23 | $PROJ_DIR$\Debug\Obj\main.pbi
24 |
25 |
26 | [ROOT_NODE]
27 |
28 |
29 | ILINK
30 | 6
31 |
32 |
33 |
34 |
35 | $PROJ_DIR$\main.c
36 |
37 |
38 | BICOMP
39 | 14
40 |
41 |
42 | ICCSTM8
43 | 1
44 |
45 |
46 |
47 |
48 | BICOMP
49 | 8 0 10 3 2
50 |
51 |
52 | ICCSTM8
53 | 3 0 8 10 2
54 |
55 |
56 |
57 |
58 | $PROJ_DIR$\ClockUartLed.c
59 |
60 |
61 | BICOMP
62 | 9
63 |
64 |
65 | ICCSTM8
66 | 13
67 |
68 |
69 |
70 |
71 | BICOMP
72 | 10 8 3
73 |
74 |
75 | ICCSTM8
76 | 3 8 10
77 |
78 |
79 |
80 |
81 | $PROJ_DIR$\Debug\Exe\12_Hello_AutoWakeUp.out
82 |
83 |
84 | ILINK
85 | 12 13 1 11 7
86 |
87 |
88 |
89 |
90 |
91 | Release
92 |
93 |
94 | [MULTI_TOOL]
95 | ILINK
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_LowLevel.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_LowLevel.h
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 20.09.2015
9 | * $Revision:
10 | *
11 | */
12 |
13 | #include
14 |
15 | #include "nRF_LowLevel.h"
16 |
17 | //----------------------------------------------------------------------------------------------------------
18 | // PC7 SPI_MISO
19 | // PC6 SPI_MOSI
20 | // PC5 SPI_SCK
21 | // PC4 GPIO_OUT CSN Chip Select Negative
22 | // PC3 GPIO_OUT CE Chip Enable (this signal is active high and used to activate the chip in RX or TX mode)
23 | //----------------------------------------------------------------------------------------------------------
24 |
25 |
26 | void SPI_Init_ChipEnable_Pin()
27 | {
28 | //To be disabled before configuration Low is Disable
29 | PC_ODR_ODR3 = 0;
30 |
31 | // 0: Input 1: Output
32 | PC_DDR_DDR3 = 1;
33 |
34 | // 0: Pseudo open drain 1: Push-pull
35 | PC_CR1_C13 = 1;
36 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
37 | PC_CR2_C23 = 1;
38 | }
39 | void CE_Pin_LowDisable()
40 | {
41 | PC_ODR_ODR3 = 0;
42 | }
43 |
44 | void CE_Pin_HighEnable()
45 | {
46 | PC_ODR_ODR3 = 1;
47 | }
48 |
49 | void SPI_Init_ChipSelect_Pin()
50 | {
51 | //To be disabled before configuration High is Disable
52 | PC_ODR_ODR4 = 1;
53 | // 0: Input 1: Output
54 | PC_DDR_DDR4 = 1;
55 | // 0: Pseudo open drain 1: Push-pull
56 | PC_CR1_C14 = 1;
57 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz
58 | PC_CR2_C24 = 1;
59 | }
60 |
61 | void CSN_Pin_LowSelect()
62 | {
63 | PC_ODR_ODR4 = 0;
64 | }
65 |
66 | void CSN_Pin_HighDisable()
67 | {
68 | PC_ODR_ODR4 = 1;
69 | }
70 |
71 | //Initialise the Configuration registers 1 and 2. Also resets the polynomial to the default
72 | void SPI_Init_Peripheral()
73 | {
74 | const BYTE SPI_CR1_BR_fDiv256 = 0x07;
75 |
76 | SPI_CR1 = 0x00;//default reset value
77 | //SPI_CR1_LSBFIRST = 0;
78 | SPI_CR1_BR = SPI_CR1_BR_fDiv256;
79 | //SPI_CR1_CPOL = 0; Low when Idle
80 | //SPI_CR1_CPHA = 0; 1st edge
81 |
82 | SPI_CR2 = 0x00;
83 | //SPI_CR2_BDM = 0;// 2 lines
84 | SPI_CR2_SSM = 1;//Software Slave Management Enabled
85 | SPI_CR2_SSI = 1;//Master Mode
86 |
87 | //Set the SPI in Master Mode
88 | SPI_CR1_MSTR = 1;
89 |
90 | SPI_CRCPR = 0x07;//CRC Polynomial reset value is 0x07
91 |
92 | //Enable the SPI Peripheral
93 | SPI_CR1_SPE = 1;
94 |
95 | }
96 |
97 | //RM0016 Note : Do not use the BSY flag to handle each data transmission or reception.
98 | //It is better to use TXE and RXNE flags instead.
99 | BYTE SPI_WriteRead(BYTE Data)
100 | {
101 | //Wait while (Tx Buffer not Empty);
102 | while(SPI_SR_TXE == 0);
103 | SPI_DR = Data;
104 | //while (SPI_GetFlagStatus(SPI_FLAG_BSY)== SET);// Do not use Busy Flag in every transaction
105 | //Wait while Rx Buffer Empty
106 | while(SPI_SR_RXNE == 0);
107 |
108 | return SPI_DR;
109 | }
110 |
--------------------------------------------------------------------------------
/17_STM8L_UART_HelloRF/main.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "nRF_SPI.h"
4 | //for nRF_SetMode_TX()
5 | #include "nRF_Modes.h"
6 |
7 | #include "nRF_Tx.h"
8 |
9 | #include "ClockUartLed.h"
10 |
11 | void SMT8L_Switch_ToHSI()
12 | {
13 | CLK_SWCR_SWEN = 1; // Enable switching.
14 | CLK_SWR = 0x01; // Use HSI as the clock source.
15 | while (CLK_SWCR_SWBSY != 0); // Pause while the clock switch is busy.
16 | }
17 |
18 | void Initialise_STM8L_Clock()
19 | {
20 | //Set Clock to full speed
21 | CLK_CKDIVR_CKM = 0; // Set to 0x00 => /1 ; Reset is 0x03 => /8
22 | //unsigned char cal = CLK_HSICALR-45;//default is 0x66 lowered by 45
23 | //Unlock the trimming
24 | /*CLK_HSIUNLCKR = 0xAC;
25 | CLK_HSIUNLCKR = 0x35;
26 | CLK_HSITRIMR = cal;
27 | */
28 | delay_1ms();
29 | }
30 | //
31 |
32 | void Init_Magnet_PB0()
33 | {
34 | PB_DDR_bit.DDR0 = 0;// 0: Input
35 | PB_CR1_bit.C10 = 0; // 0: Floating
36 | }
37 |
38 | void Init_Magnet_PD0()
39 | {
40 | PD_DDR_bit.DDR0 = 0;// 0: Input
41 | PD_CR1_bit.C10 = 0; // 0: Floating
42 | }
43 |
44 |
45 | void Initialise_Test_GPIO_A2()
46 | {
47 | PA_DDR_bit.DDR2 = 1;// 1: Output
48 | PA_CR1_bit.C12 = 1; // 1: Push-pull
49 | }
50 |
51 | void GPIO_B3_High()
52 | {
53 | PB_ODR_bit.ODR3 = 1;
54 | }
55 |
56 | void GPIO_B3_Low()
57 | {
58 | PB_ODR_bit.ODR3 = 0;
59 | }
60 |
61 | void PingColor()
62 | {
63 | unsigned char Tx_Data[5];
64 | Tx_Data[0]=128;
65 | Tx_Data[1]=255;
66 | Tx_Data[2]=100;
67 | Tx_Data[3]=0x59;
68 | nRF_Transmit(Tx_Data,4);
69 | }
70 | void PingUart(unsigned char index)
71 | {
72 | UARTPrintf("Ping Color STM8L ");
73 | UARTPrintf_uint(index);
74 | UARTPrintf(" \n");
75 | }
76 |
77 | void LogMagnets()
78 | {
79 | unsigned char Magnet_B0,Magnet_D0;
80 | Magnet_B0 = PB_IDR_IDR0;
81 | Magnet_D0 = PD_IDR_IDR0;
82 | UARTPrintf(" Magnets : LowVert D0 ");
83 | UARTPrintf_uint(Magnet_D0);
84 | UARTPrintf(" ; HighHor B0 ");
85 | UARTPrintf_uint(Magnet_B0);
86 | UARTPrintf("\n");
87 |
88 | }
89 |
90 | int main( void )
91 | {
92 | unsigned char index = 0;
93 | Initialise_STM8L_Clock();
94 |
95 | SYSCFG_RMPCR1_USART1TR_REMAP = 1; // Remap 01: USART1_TX on PA2 and USART1_RX on PA3
96 | InitialiseUART();//Tx only
97 |
98 | UARTPrintf("\r\n_________________________\n\r");
99 | UARTPrintf("Hello from STM8L RF Registers...\n\r");
100 | delay_1ms_Count(1000);
101 |
102 | //Applies the compile time configured parameters from nRF_Configuration.h
103 | nRF_Config();
104 |
105 | //The TX Mode is independently set from nRF_Config() and can be changed on run time
106 | nRF_SetMode_TX();
107 |
108 |
109 | Init_Magnet_PB0();
110 | Init_Magnet_PD0();
111 | //
112 | // Main loop
113 | //
114 | while (1)
115 | {
116 | //PingColor();
117 | PingUart(index++);
118 | LogMagnets();
119 | delay_1ms_Count(200);
120 |
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/10_HelloRF_Receiver_IRQ/nRF_IRQ.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_IRQ.c
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 14.12.2015
9 | * $Revision:
10 | *
11 | */
12 | #include
13 | #include
14 |
15 | #include "nRF_IRQ.h"
16 |
17 | #include "nRF_Configuration.h"
18 |
19 | #include "ClockUartLed.h"
20 | #include "commonTypes.h"
21 |
22 | //for direct SPI_Read_Register()
23 | #include "nRF_SPI.h"
24 |
25 | //for nRF_SetMode_TX()
26 | #include "nRF_Modes.h"
27 |
28 | #include "nRF_Tx.h"
29 | #include "nRF_RegText.h"
30 |
31 | //nRF24L01P module IRQ on pin8 of RF module and D2 on STM8
32 |
33 |
34 | BYTE RxData[RX_DataSize];
35 |
36 |
37 | //---------------------------------------------------------------------------------------------
38 | #if(Enable_RX_IRQ == 1)
39 | void ProcessUserData_inIRQ()
40 | {
41 | #if (Enable_Debug_IRQHandler_PortD_nRF == 1)
42 | IRQ_Printf(" Received Packet: ");
43 | UARTPrintfHexTable(RxData,RX_DataSize);
44 | IRQ_Printf("\n\r");
45 | #endif
46 |
47 | }
48 | #endif
49 | //---------------------------------------------------------------------------------------------
50 |
51 | #if(AtLeastOneIRQ_Is_Enabled == 1)
52 |
53 | void nRF_IRQ_Config()
54 | {
55 | __disable_interrupt();
56 |
57 | // 0: Input 1: Output
58 | PD_DDR_DDR2 = 0;
59 |
60 | // 0: Floating input 1: with pull-up
61 | PD_CR1_C12 = 0;
62 |
63 | // 0: External Interrupt Disabled 1: External Interrupt enabled
64 | PD_CR2_C22 = 1;
65 |
66 | // Set up the interrupt.
67 | EXTI_CR1_PDIS = 0; // Falling edge and low level
68 | EXTI_CR2_TLIS = 0; // Falling edge only.
69 | __enable_interrupt();
70 | }
71 |
72 |
73 | //interrupt vectors mapping in CD00226640 - STM8S103F3.pdf (DocID15441 Rev 12) Page 43
74 | //careful !!!! the IRQ number is not the vector number. The interrupt vector address = Interrupt vector number N * 4 + Interrupt base address
75 | //IRQ no6, EXTI3, PortD external interrupts, 0x00 8020 = Vector 8
76 | //EXTI2_vector = 8
77 | #pragma vector = EXTI3_vector
78 | __interrupt void IRQHandler_PortD_nRF(void)
79 | {
80 | IRQ_Printf("(IRQ)");
81 |
82 | BYTE status = SPI_Read_Register(STATUS);
83 | IRQ_PrintStatus(status);
84 |
85 | #if(Enable_RX_IRQ == 1)
86 | if(( status & (bit_RX_DR) ) != 0)//Rx IRQ was triggered
87 | {
88 | BYTE fifo_Status;
89 | do
90 | {
91 | SPI_Read_Buf(RD_RX_PLOAD,RxData,RX_DataSize);
92 | ProcessUserData_inIRQ();
93 |
94 | nRF_ClearStatus( bit_RX_DR );
95 |
96 | fifo_Status = SPI_Read_Register(FIFO_STATUS);
97 | IRQ_Printf(" FifoStatus: ");
98 | IRQ_PrintfHex(fifo_Status);
99 | IRQ_Printf("\n\r");
100 | }while((fifo_Status & 0x01) == 0 );
101 | }
102 | #endif
103 | #if(Enable_TX_IRQ == 1)
104 | if( ( status & (bit_TX_DS ) ) != 0 )
105 | {
106 | nRF_ClearStatus(bit_TX_DS);
107 | }
108 | #endif
109 | #if(Enable_RT_IRQ == 1)
110 | if( ( status & (bit_MAX_RT) ) != 0 )//check other IRQs
111 | {
112 | nRF_ClearStatus(bit_MAX_RT);
113 | }
114 | #endif
115 |
116 | }
117 |
118 | #endif /*(AtLeastOneIRQ_Is_Enabled == 1)*/
--------------------------------------------------------------------------------
/08_HelloRF_Transmitter/main.c:
--------------------------------------------------------------------------------
1 |
2 | //Test Led is Port B Pin 5
3 |
4 |
5 | #include "ClockUartLed.h"
6 |
7 | //for direct SPI_Read_Register()
8 | #include "nRF_SPI.h"
9 |
10 | //for nRF_SetMode_TX()
11 | #include "nRF_Modes.h"
12 |
13 | #include "nRF_Tx.h"
14 | #include "nRF_RegText.h"
15 |
16 | int main( void )
17 | {
18 | BYTE TxData[32];
19 | BYTE counter = 0;
20 |
21 | InitialiseSystemClock();
22 |
23 | Initialise_TestLed_GPIO_B5();
24 |
25 | InitialiseUART();
26 |
27 | //will wait 100 ms needed after Power On Reset, and intialise SPI
28 | //This call is optional, good for determinism, otherwise called by the library
29 | nRF_Init();
30 |
31 | Test_Led_Off();
32 |
33 | UARTPrintf("\r\n_________________________\n\r");
34 | UARTPrintf("STM8 Transmitter, Node 1\n\r");
35 |
36 | //This call is optional, good for determinism, otherwise called by the library
37 | BYTE status = nRF_Config();
38 | UARTPrintf("Config updated with : ");
39 | UARTPrintfHex(ConfigVal);
40 | UARTPrintf(" ; reread ");
41 | ConfigVal = SPI_Read_Register(CONFIG);
42 | UARTPrintfHex(ConfigVal);
43 | UARTPrintf(" ; ");
44 | nRF_PrintStatus(status);
45 |
46 | if( ( status & (bit_RX_DR | bit_TX_DS | bit_MAX_RT) ) != 0 )
47 | {
48 | UARTPrintf("Clearing the status, ");
49 | nRF_ClearStatus();
50 | UARTPrintf("New ");
51 | status = SPI_Read_Register(STATUS); nRF_PrintStatus(status);
52 | }
53 |
54 | nRF_SetMode_TX();
55 | UARTPrintf("SetMode_Tx: ");
56 | UARTPrintf("Config updated with : ");
57 | UARTPrintfHex(ConfigVal);
58 | UARTPrintf(" ; reread ");
59 | ConfigVal = SPI_Read_Register(CONFIG);
60 | UARTPrintfHex(ConfigVal);
61 | UARTPrintf(" ; ");
62 | status = SPI_Read_Register(STATUS); nRF_PrintStatus(status);
63 |
64 | while (1)
65 | {
66 | if( ( status & (bit_RX_DR | bit_TX_DS | bit_MAX_RT) ) != 0 )
67 | {
68 | UARTPrintf("Clearing the status, ");
69 | nRF_ClearStatus();
70 | UARTPrintf("New ");
71 | status = SPI_Read_Register(STATUS); nRF_PrintStatus(status);
72 | }
73 |
74 | counter++;
75 | TxData[0] = counter;
76 | //for(int i=0;i<32;i++) { TxData[i] = counter; }
77 |
78 | status = nRF_Transmit(TxData,1);
79 | UARTPrintf("Transmitting: ");
80 | UARTPrintfHex(counter);
81 | ConfigVal = SPI_Read_Register(CONFIG);
82 | UARTPrintf(" ; CONFIG: ");
83 | UARTPrintfHex(ConfigVal);
84 | UARTPrintf(" ; ");
85 | status = SPI_Read_Register(STATUS); nRF_PrintStatus(status);
86 |
87 | #ifdef DumpRegisters
88 | for(int i=0;i
13 | #include
14 |
15 | #include "nRF_IRQ.h"
16 |
17 | #include "nRF_Configuration.h"
18 |
19 | #include "ClockUartLed.h"
20 | #include "commonTypes.h"
21 |
22 | //for direct SPI_Read_Register()
23 | #include "nRF_SPI.h"
24 |
25 | //for nRF_SetMode_TX()
26 | #include "nRF_Modes.h"
27 |
28 | #include "nRF_Tx.h"
29 | #include "nRF_RegText.h"
30 |
31 | //nRF24L01P module IRQ on pin8 of RF module and D2 on STM8
32 |
33 | void userRxCallBack(BYTE *rxData,BYTE rx_DataSize);
34 |
35 | BYTE RxData[RX_DataSize];
36 |
37 |
38 | //---------------------------------------------------------------------------------------------
39 | #if(Enable_RX_IRQ == 1)
40 | void ProcessUserData_inIRQ()
41 | {
42 | userRxCallBack(RxData,RX_DataSize);
43 | #if (Enable_Debug_IRQHandler_PortD_nRF == 1)
44 | IRQ_Printf(" Received Packet: ");
45 | UARTPrintfHexTable(RxData,RX_DataSize);
46 | IRQ_Printf("\n\r");
47 | #endif
48 |
49 | }
50 | #endif
51 | //---------------------------------------------------------------------------------------------
52 |
53 | #if(AtLeastOneIRQ_Is_Enabled == 1)
54 |
55 | void nRF_IRQ_Config()
56 | {
57 | /*
58 | __disable_interrupt();
59 |
60 | // 0: Input 1: Output
61 | PC_DDR_DDR4 = 0;
62 |
63 | // 0: Floating input 1: with pull-up
64 | PC_CR1_C14 = 0;
65 |
66 | // 0: External Interrupt Disabled 1: External Interrupt enabled
67 | PC_CR2_C24 = 1;
68 |
69 | // Set up the interrupt.
70 | //EXTI_CR1_PCIS = 0; // Falling edge and low level
71 | //EXTI_CR2_TLIS = 0; // Falling edge only.
72 | __enable_interrupt();
73 | */
74 | }
75 |
76 |
77 | //interrupt vectors mapping in CD00226640 - STM8S103F3.pdf (DocID15441 Rev 12) Page 43
78 | //careful !!!! the IRQ number is not the vector number. The interrupt vector address = Interrupt vector number N * 4 + Interrupt base address
79 | //IRQ no6, EXTI3, PortD external interrupts, 0x00 8020 = Vector 8
80 | //EXTI2_vector = 8
81 | #pragma vector = EXTI3_vector
82 | __interrupt void IRQHandler_PortD_nRF(void)
83 | {
84 | IRQ_Printf("(IRQ)");
85 |
86 | BYTE status = SPI_Read_Register(STATUS);
87 | IRQ_PrintStatus(status);
88 |
89 | #if(Enable_RX_IRQ == 1)
90 | if(( status & (bit_RX_DR) ) != 0)//Rx IRQ was triggered
91 | {
92 | BYTE fifo_Status;
93 | do
94 | {
95 | //TODO check the size before reading the Hard coded value
96 | SPI_Read_Buf(RD_RX_PLOAD,RxData,RX_DataSize);
97 | ProcessUserData_inIRQ();
98 |
99 | nRF_ClearStatus( bit_RX_DR );
100 |
101 | fifo_Status = SPI_Read_Register(FIFO_STATUS);
102 | IRQ_Printf(" FifoStatus: ");
103 | IRQ_PrintfHex(fifo_Status);
104 | IRQ_Printf("\n\r");
105 | }while((fifo_Status & 0x01) == 0 );
106 | }
107 | #endif
108 | #if(Enable_TX_IRQ == 1)
109 | if( ( status & (bit_TX_DS ) ) != 0 )
110 | {
111 | nRF_ClearStatus(bit_TX_DS);
112 | }
113 | #endif
114 | #if(Enable_RT_IRQ == 1)
115 | if( ( status & (bit_MAX_RT) ) != 0 )//check other IRQs
116 | {
117 | nRF_ClearStatus(bit_MAX_RT);
118 | }
119 | #endif
120 |
121 | }
122 |
123 | #endif /*(AtLeastOneIRQ_Is_Enabled == 1)*/
--------------------------------------------------------------------------------
/19_STM8L_Hello_Battery/pr00_LibraryCommon/nRF_IRQ.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_IRQ.c
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 14.12.2015
9 | * $Revision:
10 | *
11 | */
12 | #include
13 | #include
14 |
15 | #include "nRF_IRQ.h"
16 |
17 | #include "nRF_Configuration.h"
18 |
19 | #include "ClockUartLed.h"
20 | #include "commonTypes.h"
21 |
22 | //for direct SPI_Read_Register()
23 | #include "nRF_SPI.h"
24 |
25 | //for nRF_SetMode_TX()
26 | #include "nRF_Modes.h"
27 |
28 | #include "nRF_Tx.h"
29 | #include "nRF_RegText.h"
30 |
31 | //nRF24L01P module IRQ on pin8 of RF module and D2 on STM8
32 |
33 | void userRxCallBack(BYTE *rxData,BYTE rx_DataSize);
34 |
35 | BYTE RxData[RX_DataSize];
36 |
37 |
38 | //---------------------------------------------------------------------------------------------
39 | #if(Enable_RX_IRQ == 1)
40 | void ProcessUserData_inIRQ()
41 | {
42 | userRxCallBack(RxData,RX_DataSize);
43 | #if (Enable_Debug_IRQHandler_PortD_nRF == 1)
44 | IRQ_Printf(" Received Packet: ");
45 | UARTPrintfHexTable(RxData,RX_DataSize);
46 | IRQ_Printf("\n\r");
47 | #endif
48 |
49 | }
50 | #endif
51 | //---------------------------------------------------------------------------------------------
52 |
53 | #if(AtLeastOneIRQ_Is_Enabled == 1)
54 |
55 | void nRF_IRQ_Config()
56 | {
57 | /*
58 | __disable_interrupt();
59 |
60 | // 0: Input 1: Output
61 | PC_DDR_DDR4 = 0;
62 |
63 | // 0: Floating input 1: with pull-up
64 | PC_CR1_C14 = 0;
65 |
66 | // 0: External Interrupt Disabled 1: External Interrupt enabled
67 | PC_CR2_C24 = 1;
68 |
69 | // Set up the interrupt.
70 | //EXTI_CR1_PCIS = 0; // Falling edge and low level
71 | //EXTI_CR2_TLIS = 0; // Falling edge only.
72 | __enable_interrupt();
73 | */
74 | }
75 |
76 |
77 | //interrupt vectors mapping in CD00226640 - STM8S103F3.pdf (DocID15441 Rev 12) Page 43
78 | //careful !!!! the IRQ number is not the vector number. The interrupt vector address = Interrupt vector number N * 4 + Interrupt base address
79 | //IRQ no6, EXTI3, PortD external interrupts, 0x00 8020 = Vector 8
80 | //EXTI2_vector = 8
81 | #pragma vector = EXTI3_vector
82 | __interrupt void IRQHandler_PortD_nRF(void)
83 | {
84 | IRQ_Printf("(IRQ)");
85 |
86 | BYTE status = SPI_Read_Register(STATUS);
87 | IRQ_PrintStatus(status);
88 |
89 | #if(Enable_RX_IRQ == 1)
90 | if(( status & (bit_RX_DR) ) != 0)//Rx IRQ was triggered
91 | {
92 | BYTE fifo_Status;
93 | do
94 | {
95 | //TODO check the size before reading the Hard coded value
96 | SPI_Read_Buf(RD_RX_PLOAD,RxData,RX_DataSize);
97 | ProcessUserData_inIRQ();
98 |
99 | nRF_ClearStatus( bit_RX_DR );
100 |
101 | fifo_Status = SPI_Read_Register(FIFO_STATUS);
102 | IRQ_Printf(" FifoStatus: ");
103 | IRQ_PrintfHex(fifo_Status);
104 | IRQ_Printf("\n\r");
105 | }while((fifo_Status & 0x01) == 0 );
106 | }
107 | #endif
108 | #if(Enable_TX_IRQ == 1)
109 | if( ( status & (bit_TX_DS ) ) != 0 )
110 | {
111 | nRF_ClearStatus(bit_TX_DS);
112 | }
113 | #endif
114 | #if(Enable_RT_IRQ == 1)
115 | if( ( status & (bit_MAX_RT) ) != 0 )//check other IRQs
116 | {
117 | nRF_ClearStatus(bit_MAX_RT);
118 | }
119 | #endif
120 |
121 | }
122 |
123 | #endif /*(AtLeastOneIRQ_Is_Enabled == 1)*/
--------------------------------------------------------------------------------
/21_STM8L_Hello_LowPower/pr00_LibraryCommon/nRF_IRQ.c:
--------------------------------------------------------------------------------
1 | /** @file nRF_IRQ.c
2 | *
3 | * @author Wassim FILALI, inspired from nRF24L01P-EK
4 | *
5 | * @compiler IAR STM8
6 | *
7 | *
8 | * $Date: 14.12.2015
9 | * $Revision:
10 | *
11 | */
12 | #include
13 | #include
14 |
15 | #include "nRF_IRQ.h"
16 |
17 | #include "nRF_Configuration.h"
18 |
19 | #include "ClockUartLed.h"
20 | #include "commonTypes.h"
21 |
22 | //for direct SPI_Read_Register()
23 | #include "nRF_SPI.h"
24 |
25 | //for nRF_SetMode_TX()
26 | #include "nRF_Modes.h"
27 |
28 | #include "nRF_Tx.h"
29 | #include "nRF_RegText.h"
30 |
31 | //nRF24L01P module IRQ on pin8 of RF module and D2 on STM8
32 |
33 | void userRxCallBack(BYTE *rxData,BYTE rx_DataSize);
34 |
35 | BYTE RxData[RX_DataSize];
36 |
37 |
38 | //---------------------------------------------------------------------------------------------
39 | #if(Enable_RX_IRQ == 1)
40 | void ProcessUserData_inIRQ()
41 | {
42 | userRxCallBack(RxData,RX_DataSize);
43 | #if (Enable_Debug_IRQHandler_PortD_nRF == 1)
44 | IRQ_Printf(" Received Packet: ");
45 | UARTPrintfHexTable(RxData,RX_DataSize);
46 | IRQ_Printf("\n\r");
47 | #endif
48 |
49 | }
50 | #endif
51 | //---------------------------------------------------------------------------------------------
52 |
53 | #if(AtLeastOneIRQ_Is_Enabled == 1)
54 |
55 | void nRF_IRQ_Config()
56 | {
57 | /*
58 | __disable_interrupt();
59 |
60 | // 0: Input 1: Output
61 | PC_DDR_DDR4 = 0;
62 |
63 | // 0: Floating input 1: with pull-up
64 | PC_CR1_C14 = 0;
65 |
66 | // 0: External Interrupt Disabled 1: External Interrupt enabled
67 | PC_CR2_C24 = 1;
68 |
69 | // Set up the interrupt.
70 | //EXTI_CR1_PCIS = 0; // Falling edge and low level
71 | //EXTI_CR2_TLIS = 0; // Falling edge only.
72 | __enable_interrupt();
73 | */
74 | }
75 |
76 |
77 | //interrupt vectors mapping in CD00226640 - STM8S103F3.pdf (DocID15441 Rev 12) Page 43
78 | //careful !!!! the IRQ number is not the vector number. The interrupt vector address = Interrupt vector number N * 4 + Interrupt base address
79 | //IRQ no6, EXTI3, PortD external interrupts, 0x00 8020 = Vector 8
80 | //EXTI2_vector = 8
81 | #pragma vector = EXTI3_vector
82 | __interrupt void IRQHandler_PortD_nRF(void)
83 | {
84 | IRQ_Printf("(IRQ)");
85 |
86 | BYTE status = SPI_Read_Register(STATUS);
87 | IRQ_PrintStatus(status);
88 |
89 | #if(Enable_RX_IRQ == 1)
90 | if(( status & (bit_RX_DR) ) != 0)//Rx IRQ was triggered
91 | {
92 | BYTE fifo_Status;
93 | do
94 | {
95 | //TODO check the size before reading the Hard coded value
96 | SPI_Read_Buf(RD_RX_PLOAD,RxData,RX_DataSize);
97 | ProcessUserData_inIRQ();
98 |
99 | nRF_ClearStatus( bit_RX_DR );
100 |
101 | fifo_Status = SPI_Read_Register(FIFO_STATUS);
102 | IRQ_Printf(" FifoStatus: ");
103 | IRQ_PrintfHex(fifo_Status);
104 | IRQ_Printf("\n\r");
105 | }while((fifo_Status & 0x01) == 0 );
106 | }
107 | #endif
108 | #if(Enable_TX_IRQ == 1)
109 | if( ( status & (bit_TX_DS ) ) != 0 )
110 | {
111 | nRF_ClearStatus(bit_TX_DS);
112 | }
113 | #endif
114 | #if(Enable_RT_IRQ == 1)
115 | if( ( status & (bit_MAX_RT) ) != 0 )//check other IRQs
116 | {
117 | nRF_ClearStatus(bit_MAX_RT);
118 | }
119 | #endif
120 |
121 | }
122 |
123 | #endif /*(AtLeastOneIRQ_Is_Enabled == 1)*/
--------------------------------------------------------------------------------
/07_Hello_Temperature/07_Hello_Temperature.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 3332150558
6 |
7 | Debug
8 |
9 | $PROJ_DIR$\hello_Temperature.c
10 | $PROJ_DIR$\ClockUartLed.c
11 | $PROJ_DIR$\ClockUartLed.h
12 | $PROJ_DIR$\Debug\Obj\ClockUartLed.pbi
13 | $PROJ_DIR$\Debug\Obj\main.o
14 | $PROJ_DIR$\Debug\Obj\hello_Temperature.pbi
15 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf
16 | $PROJ_DIR$\Debug\Obj\main.pbi
17 | $TOOLKIT_DIR$\inc\iostm8s103f3.h
18 | $TOOLKIT_DIR$\lib\dlstm8smn.a
19 | $PROJ_DIR$\Debug\Obj\ClockUartLed.o
20 | $PROJ_DIR$\Debug\Obj\hello_Temperature.o
21 | $TOOLKIT_DIR$\lib\dbgstm8smd.a
22 | $PROJ_DIR$\Debug\Exe\templproj.out
23 | $TOOLKIT_DIR$\inc\io_macros.h
24 | $PROJ_DIR$\main.c
25 |
26 |
27 | $PROJ_DIR$\hello_Temperature.c
28 |
29 |
30 | BICOMP
31 | 5
32 |
33 |
34 | ICCSTM8
35 | 11
36 |
37 |
38 |
39 |
40 | BICOMP
41 | 14 2 8
42 |
43 |
44 | ICCSTM8
45 | 8 14 2
46 |
47 |
48 |
49 |
50 | $PROJ_DIR$\ClockUartLed.c
51 |
52 |
53 | BICOMP
54 | 3
55 |
56 |
57 | ICCSTM8
58 | 10
59 |
60 |
61 |
62 |
63 | BICOMP
64 | 8 14
65 |
66 |
67 | ICCSTM8
68 | 8 14
69 |
70 |
71 |
72 |
73 | $PROJ_DIR$\Debug\Exe\templproj.out
74 |
75 |
76 | ILINK
77 | 6 10 11 9 12
78 |
79 |
80 |
81 |
82 | $PROJ_DIR$\main.c
83 |
84 |
85 | BICOMP
86 | 7
87 |
88 |
89 | ICCSTM8
90 | 4
91 |
92 |
93 |
94 |
95 | [ROOT_NODE]
96 |
97 |
98 | ILINK
99 | 13
100 |
101 |
102 |
103 |
104 |
105 | Release
106 |
107 |
108 | [MULTI_TOOL]
109 | ILINK
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/14_Hello_I2C_Slave/i2c.h:
--------------------------------------------------------------------------------
1 | /** @file i2c.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 04.01.2016
10 | * $Revision:
11 | *
12 | */
13 |
14 | #include "commonTypes.h"
15 |
16 | //------------------------------------------------------------------------------------------------------------------
17 | // User configuration
18 | //------------------------------------------------------------------------------------------------------------------
19 | #define Enable_Debug_I2C_IRQ 1
20 |
21 |
22 | #define I2C_Use_Master 0
23 | #define I2C_Use_Slave 1
24 | #define I2C_Use_MultiMaster 0
25 | //------------------------------------------------------------------------------------------------------------------
26 |
27 | //configuration application section, not to be edited
28 | //---------------------------------------------------------------------------------------------
29 | #if (Enable_Debug_I2C_IRQ == 1)
30 | #define I2C_IRQ_Printf(x) UARTPrintf(x)
31 | #define I2C_IRQ_PrintfHex(x) UARTPrintfHex(x)
32 | #define I2C_IRQ_PrintStatus(x) nRF_PrintStatus(x)
33 | #else
34 | #define I2C_IRQ_Printf(x) (void)0
35 | #define I2C_IRQ_PrintfHex(x) (void)0
36 | #define I2C_IRQ_PrintStatus(x) (void)0
37 | #endif
38 |
39 | #if (I2C_Use_MultiMaster == 1)
40 | #undef I2C_Use_Master
41 | #define I2C_Use_Master 1
42 | #undef I2C_Use_Slave
43 | #define I2C_Use_Slave 1
44 | #endif
45 | //---------------------------------------------------------------------------------------------
46 |
47 |
48 | //------------------------------------------------------------------------------------------------------------------
49 | // I2C Registers
50 | //------------------------------------------------------------------------------------------------------------------
51 | // I2C_CR1 Control Register 1
52 | // I2C_CR2 Control Register 2
53 | // I2C_FREQR Frequency Register
54 | // I2C_OARL Own Address Register LSB
55 | // I2C_OARH Own Address Register MSB
56 | // I2C_DR Data Register
57 | // I2C_SR1 Status Register 1
58 | // I2C_SR2 Status Register 2
59 | // I2C_SR3 Status Register 3
60 | // I2C_ITR Interrupt Register
61 | // I2C_CCRL Clock Control Register Low
62 | // I2C_CCRH Clock Control Register High
63 | // I2C_TRISER Tristate Enable register
64 | // funny the I2C_PECR is documented in STM8S103F3 specification while the Packet Error Checking is not part of the S family
65 | //
66 | //all reset to 0
67 | //------------------------------------------------------------------------------------------------------------------
68 |
69 | //
70 | // STM8 I2C system.
71 | // default is slave, goes to master on Start and back to slave on stop
72 | // Addresses are 7/10 bits (one or two bytes), a Genral Call address can be enabled or disabled
73 | // 9th bit is acknowledge from the slave
74 | void I2C_Init();
75 |
76 | #if(I2C_Use_Master == 1)
77 | void I2C_Transaction(BYTE read,BYTE slaveAddress, BYTE* buffer,BYTE count);
78 |
79 | void I2C_Read(BYTE slaveAddress, BYTE* buffer,BYTE count);
80 |
81 | void I2C_Write(BYTE slaveAddress, BYTE* buffer,BYTE count);
82 |
83 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size);
84 |
85 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size);
86 | #endif
87 |
88 | #if(I2C_Use_Slave == 1)
89 | void I2C_Slave_Configure(BYTE ownSlaveAddress, BYTE* buffer, BYTE size);
90 |
91 | void i2c_user_Slave_Rx_Callback(BYTE *userdata,BYTE size);
92 |
93 | void i2c_user_Slave_Tx_Callback(BYTE *userdata,BYTE size);
94 | #endif
95 |
96 |
97 | void i2c_user_Error_Callback(BYTE l_sr2);
98 |
--------------------------------------------------------------------------------
/18_STM8L_HelloI2C/i2c.h:
--------------------------------------------------------------------------------
1 | /** @file i2c.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 04.01.2016
10 | * $Revision:
11 | *
12 | */
13 |
14 | #include "commonTypes.h"
15 |
16 | //------------------------------------------------------------------------------------------------------------------
17 | // User configuration
18 | //------------------------------------------------------------------------------------------------------------------
19 | #define Enable_Debug_I2C_IRQ 1
20 |
21 |
22 | #define I2C_Use_Master 1
23 | #define I2C_Use_Slave 1
24 | #define I2C_Use_MultiMaster 0
25 | //------------------------------------------------------------------------------------------------------------------
26 |
27 | //configuration application section, not to be edited
28 | //---------------------------------------------------------------------------------------------
29 | #if (Enable_Debug_I2C_IRQ == 1)
30 | #define I2C_IRQ_Printf(x) UARTPrintf(x)
31 | #define I2C_IRQ_PrintfHex(x) UARTPrintfHex(x)
32 | #define I2C_IRQ_PrintStatus(x) nRF_PrintStatus(x)
33 | #else
34 | #define I2C_IRQ_Printf(x) (void)0
35 | #define I2C_IRQ_PrintfHex(x) (void)0
36 | #define I2C_IRQ_PrintStatus(x) (void)0
37 | #endif
38 |
39 | #if (I2C_Use_MultiMaster == 1)
40 | #undef I2C_Use_Master
41 | #define I2C_Use_Master 1
42 | #undef I2C_Use_Slave
43 | #define I2C_Use_Slave 1
44 | #endif
45 | //---------------------------------------------------------------------------------------------
46 |
47 |
48 | //------------------------------------------------------------------------------------------------------------------
49 | // I2C Registers
50 | //------------------------------------------------------------------------------------------------------------------
51 | // I2C_CR1 Control Register 1
52 | // I2C_CR2 Control Register 2
53 | // I2C_FREQR Frequency Register
54 | // I2C_OARL Own Address Register LSB
55 | // I2C_OARH Own Address Register MSB
56 | // I2C_DR Data Register
57 | // I2C_SR1 Status Register 1
58 | // I2C_SR2 Status Register 2
59 | // I2C_SR3 Status Register 3
60 | // I2C_ITR Interrupt Register
61 | // I2C_CCRL Clock Control Register Low
62 | // I2C_CCRH Clock Control Register High
63 | // I2C_TRISER Tristate Enable register
64 | // funny the I2C_PECR is documented in STM8S103F3 specification while the Packet Error Checking is not part of the S family
65 | //
66 | //all reset to 0
67 | //------------------------------------------------------------------------------------------------------------------
68 |
69 | //
70 | // STM8 I2C system.
71 | // default is slave, goes to master on Start and back to slave on stop
72 | // Addresses are 7/10 bits (one or two bytes), a Genral Call address can be enabled or disabled
73 | // 9th bit is acknowledge from the slave
74 | void I2C_Init();
75 |
76 | #if(I2C_Use_Master == 1)
77 | void I2C_Transaction(BYTE read,BYTE slaveAddress, BYTE* buffer,BYTE count);
78 |
79 | void I2C_Read(BYTE slaveAddress, BYTE* buffer,BYTE count);
80 |
81 | void I2C_Write(BYTE slaveAddress, BYTE* buffer,BYTE count);
82 |
83 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size);
84 |
85 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size);
86 | #endif
87 |
88 | #if(I2C_Use_Slave == 1)
89 | void I2C_Slave_Configure(BYTE ownSlaveAddress, BYTE* buffer, BYTE size);
90 |
91 | void i2c_user_Slave_Rx_Callback(BYTE *userdata,BYTE size);
92 |
93 | void i2c_user_Slave_Tx_Callback(BYTE *userdata,BYTE size);
94 | #endif
95 |
96 |
97 | void i2c_user_Error_Callback(BYTE l_sr2);
98 |
--------------------------------------------------------------------------------
/13_Hello_I2C_Master/i2c.h:
--------------------------------------------------------------------------------
1 | /** @file i2c.h
2 | *
3 | * @author Wassim FILALI
4 | *
5 | *
6 | * @compiler IAR STM8
7 | *
8 | *
9 | * $Date: 04.01.2016
10 | * $Revision:
11 | *
12 | */
13 |
14 | #include "commonTypes.h"
15 |
16 | //------------------------------------------------------------------------------------------------------------------
17 | // User configuration
18 | //------------------------------------------------------------------------------------------------------------------
19 | #define Enable_Debug_I2C_IRQ 1
20 |
21 |
22 | #define I2C_Use_Master 1
23 | #define I2C_Use_Slave 0
24 | #define I2C_Use_MultiMaster 0
25 | //------------------------------------------------------------------------------------------------------------------
26 |
27 | //configuration application section, not to be edited
28 | //---------------------------------------------------------------------------------------------
29 | #if (Enable_Debug_I2C_IRQ == 1)
30 | #define I2C_IRQ_Printf(x) UARTPrintf(x)
31 | #define I2C_IRQ_PrintfHex(x) UARTPrintfHex(x)
32 | #define I2C_IRQ_PrintStatus(x) nRF_PrintStatus(x)
33 | #else
34 | #define I2C_IRQ_Printf(x) (void)0
35 | #define I2C_IRQ_PrintfHex(x) (void)0
36 | #define I2C_IRQ_PrintStatus(x) (void)0
37 | #endif
38 |
39 | #if (I2C_Use_MultiMaster == 1)
40 | #undef I2C_Use_Master
41 | #define I2C_Use_Master 1
42 | #undef I2C_Use_Slave
43 | #define I2C_Use_Slave 1
44 | #endif
45 | //---------------------------------------------------------------------------------------------
46 |
47 |
48 | //------------------------------------------------------------------------------------------------------------------
49 | // I2C Registers
50 | //------------------------------------------------------------------------------------------------------------------
51 | // I2C_CR1 Control Register 1
52 | // I2C_CR2 Control Register 2
53 | // I2C_FREQR Frequency Register
54 | // I2C_OARL Own Address Register LSB
55 | // I2C_OARH Own Address Register MSB
56 | // I2C_DR Data Register
57 | // I2C_SR1 Status Register 1
58 | // I2C_SR2 Status Register 2
59 | // I2C_SR3 Status Register 3
60 | // I2C_ITR Interrupt Register
61 | // I2C_CCRL Clock Control Register Low
62 | // I2C_CCRH Clock Control Register High
63 | // I2C_TRISER Tristate Enable register
64 | // funny the I2C_PECR is documented in STM8S103F3 specification while the Packet Error Checking is not part of the S family
65 | //
66 | //all reset to 0
67 | //------------------------------------------------------------------------------------------------------------------
68 |
69 | //
70 | // STM8 I2C system.
71 | // default is slave, goes to master on Start and back to slave on stop
72 | // Addresses are 7/10 bits (one or two bytes), a Genral Call address can be enabled or disabled
73 | // 9th bit is acknowledge from the slave
74 | void I2C_Init();
75 |
76 | #if(I2C_Use_Master == 1)
77 | void I2C_Transaction(BYTE read,BYTE slaveAddress, BYTE* buffer,BYTE count);
78 |
79 | void I2C_Read(BYTE slaveAddress, BYTE* buffer,BYTE count);
80 |
81 | void I2C_Write(BYTE slaveAddress, BYTE* buffer,BYTE count);
82 |
83 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size);
84 |
85 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size);
86 | #endif
87 |
88 | #if(I2C_Use_Slave == 1)
89 | void I2C_Slave_Configure(BYTE ownSlaveAddress, BYTE* buffer, BYTE size);
90 |
91 | void i2c_user_Slave_Rx_Callback(BYTE *userdata,BYTE size);
92 |
93 | void i2c_user_Slave_Tx_Callback(BYTE *userdata,BYTE size);
94 | #endif
95 |
96 |
97 | void i2c_user_Error_Callback(BYTE l_sr2);
98 |
--------------------------------------------------------------------------------
/06_RGBLeds_24bitParam/hello_leds_24bits.c:
--------------------------------------------------------------------------------
1 | /** @file WS2812B.h
2 | *
3 | * @author Wassim FILALI
4 | * Inferred from the Datasheet
5 | *
6 | *
7 | * @compiler IAR STM8
8 | *
9 | *
10 | * started on local project on 10.10.2015
11 | * this file was created for refactoring on 03.01.2016
12 | * $Date:
13 | * $Revision:
14 | *
15 | */
16 |
17 | #include
18 |
19 | #include "commonTypes.h"
20 | #include "ClockUartLed.h"
21 |
22 | #include "WS2812B.h"
23 |
24 | void TestColors()
25 | {
26 | BlinkColors(1,0,0);//Blink Red
27 | BlinkColors(1,0,0);//Twice
28 | BlinkColors(0,1,0);//Blink Green
29 | BlinkColors(0,1,0);//Twice
30 | BlinkColors(0,0,1);//Blink Blue
31 | BlinkColors(0,0,1);//Twice
32 | delay_1ms_Count(500);//rest a while
33 |
34 | BlinkColors(1,1,0);//Blink RG
35 | BlinkColors(0,1,1);//Blink GB
36 | BlinkColors(1,0,1);//Blink RB
37 |
38 | delay_1ms_Count(500);//rest a while
39 |
40 | RampColors(5,1,1,1,0,0,0);//All Up
41 | RampColors(5,2,2,2,0,0,0);//All Down
42 |
43 | SwitchOffLed();
44 | delay_1ms_Count(500);//rest a while
45 |
46 | //Red Stays 0, Green stays 100, Blue Goes Up then Down
47 | //Flash strange
48 | RampColors(0,0,0,1,20,100,0);
49 | RampColors(0,0,0,2,20,100,0);
50 | SwitchOffLed();
51 | delay_1ms_Count(500);
52 | //replay the Flash strange in slow motion
53 | RampColors(5,0,0,1,20,100,0);
54 | RampColors(5,0,0,2,20,100,0);
55 | SwitchOffLed();
56 | }
57 |
58 | void Loop60LedsBlueRedBlue()
59 | {
60 | RGBColor_t ColorStart, ColorEnd;
61 | ColorStart = GREEN;
62 | ColorEnd = RED;
63 | UARTPrintf("Color Loop. 60 Leds GREEN to BLUE then to RED \r\n");
64 | for(int t=0;t<256;t++)
65 | {
66 | ColorStart = GREEN;
67 | ColorEnd = ColorScale(t,256,BLUE,RED);
68 | ShadeLeds(0,60,ColorStart,ColorEnd);
69 | SendLedsArray();
70 | delay_1ms_Count(20);
71 | }
72 | for(int t=0;t<256;t++)
73 | {
74 | ColorStart = GREEN;
75 | ColorEnd = ColorScale(t,256,RED,BLUE);
76 | ShadeLeds(0,60,ColorStart,ColorEnd);
77 | SendLedsArray();
78 | delay_1ms_Count(20);
79 | }
80 | }
81 |
82 | void Loop3LedsBlueRedBlue()
83 | {
84 | RGBColor_t ColorStart, ColorEnd;
85 | ColorStart = GREEN;
86 | ColorEnd = RED;
87 | UARTPrintf("Color Loop. 3 Leds GREEN to BLUE then to RED \r\n");
88 | for(int t=0;t<256;t++)
89 | {
90 | ColorStart = GREEN;
91 | ColorEnd = ColorScale(t,256,BLUE,RED);
92 | ShadeLeds(0,3,ColorStart,ColorEnd);
93 | SendLedsArray();
94 | delay_1ms_Count(4);
95 | }
96 | for(int t=0;t<256;t++)
97 | {
98 | ColorStart = GREEN;
99 | ColorEnd = ColorScale(t,256,RED,BLUE);
100 | ShadeLeds(0,3,ColorStart,ColorEnd);
101 | SendLedsArray();
102 | delay_1ms_Count(4);
103 | }
104 | }
105 |
106 | int main( void )
107 | {
108 |
109 | InitialiseSystemClock();
110 |
111 | Initialise_TestLed_GPIO_B5();
112 | Test_Led_Off();
113 |
114 | InitialiseUART();
115 |
116 | RGBLeds_PIO_Init();
117 |
118 | SwitchOffLed();//Switch Off on startup
119 |
120 | UARTPrintf("Hello from my RGB Leds on Pin A ");
121 | UARTPrintf_uint(RGBLedPIN_A);
122 | UARTPrintf(" ...\n\r");
123 |
124 | RGB_SwitchOff(0,60);
125 |
126 | //TestColors();//Flashing colors on one led
127 |
128 |
129 | while (1)
130 | {
131 | Loop3LedsBlueRedBlue();
132 | }
133 | }
134 |
--------------------------------------------------------------------------------