Basic code for writing to EEPROM.

This commit is contained in:
David Žaitlík 2021-09-09 19:19:20 +02:00
parent 7b0ad1fd65
commit 17286806fb
7 changed files with 418 additions and 76317 deletions

File diff suppressed because it is too large Load Diff

View File

@ -95,63 +95,63 @@ $EndComp
$Comp
L HD_MCUs:STM32L011F4U6TR U3
U 1 1 6023FF82
P 4875 2275
F 0 "U3" H 4575 2875 50 0000 C CNN
F 1 "STM32L011F4U6TR" H 5325 2875 50 0000 C CNN
F 2 "HD_DFN_QFN:ST_UFQFPN-20_3x3mm_P0.5mm" H 4875 1525 50 0001 C CNN
F 3 "https://www.st.com/resource/en/datasheet/stm32l011f3.pdf" H 4825 3075 50 0001 C CNN
F 4 "STMicroelectronics" H 4875 1425 50 0001 C CNN "Manufacturer"
F 5 "STM32L011F4U6TR" H 4875 1325 50 0001 C CNN "Code"
F 6 "497-17478-1-ND" H 4875 1225 50 0001 C CNN "Digikey"
F 7 "511-STM32L011F4U6TR" H 4875 1125 50 0001 C CNN "Mouser"
F 8 "2851005" H 4875 1025 50 0001 C CNN "Farnell"
F 9 "STM32L011F4U6TR" H 4875 925 50 0001 C CNN "TME"
1 4875 2275
P 4925 1925
F 0 "U3" H 4625 2525 50 0000 C CNN
F 1 "STM32L011F4U6TR" H 5375 2525 50 0000 C CNN
F 2 "HD_DFN_QFN:ST_UFQFPN-20_3x3mm_P0.5mm" H 4925 1175 50 0001 C CNN
F 3 "https://www.st.com/resource/en/datasheet/stm32l011f3.pdf" H 4875 2725 50 0001 C CNN
F 4 "STMicroelectronics" H 4925 1075 50 0001 C CNN "Manufacturer"
F 5 "STM32L011F4U6TR" H 4925 975 50 0001 C CNN "Code"
F 6 "497-17478-1-ND" H 4925 875 50 0001 C CNN "Digikey"
F 7 "511-STM32L011F4U6TR" H 4925 775 50 0001 C CNN "Mouser"
F 8 "2851005" H 4925 675 50 0001 C CNN "Farnell"
F 9 "STM32L011F4U6TR" H 4925 575 50 0001 C CNN "TME"
1 4925 1925
1 0 0 -1
$EndComp
Text Label 5725 1825 2 50 ~ 0
Text Label 5775 1475 2 50 ~ 0
RX
Text Label 5725 1925 2 50 ~ 0
Text Label 5775 1575 2 50 ~ 0
TX
Text Label 4025 2425 0 50 ~ 0
Text Label 4075 2075 0 50 ~ 0
DE
Text Label 5725 2425 2 50 ~ 0
Text Label 5775 2075 2 50 ~ 0
SCL
Text Label 5725 2525 2 50 ~ 0
Text Label 5775 2175 2 50 ~ 0
SDA
$Comp
L HD_Power_Symbols:+3V3 #PWR020
U 1 1 6025EC34
P 4825 1425
F 0 "#PWR020" H 4825 1275 50 0001 C CNN
F 1 "+3V3" H 4840 1598 50 0000 C CNN
F 2 "" H 4825 1425 50 0001 C CNN
F 3 "" H 4825 1425 50 0001 C CNN
1 4825 1425
P 4875 1075
F 0 "#PWR020" H 4875 925 50 0001 C CNN
F 1 "+3V3" H 4890 1248 50 0000 C CNN
F 2 "" H 4875 1075 50 0001 C CNN
F 3 "" H 4875 1075 50 0001 C CNN
1 4875 1075
1 0 0 -1
$EndComp
Wire Wire Line
4825 1425 4825 1525
4875 1075 4875 1175
Wire Wire Line
4825 1525 4925 1525
4875 1175 4975 1175
Wire Wire Line
4925 1525 4925 1625
Connection ~ 4825 1525
4975 1175 4975 1275
Connection ~ 4875 1175
Wire Wire Line
4825 1525 4825 1625
4875 1175 4875 1275
$Comp
L HD_Power_Symbols:GND #PWR021
U 1 1 60261F2E
P 4825 3025
F 0 "#PWR021" H 4825 2775 50 0001 C CNN
F 1 "GND" H 4830 2852 50 0000 C CNN
F 2 "" H 4825 3025 50 0001 C CNN
F 3 "" H 4825 3025 50 0001 C CNN
1 4825 3025
P 4875 2675
F 0 "#PWR021" H 4875 2425 50 0001 C CNN
F 1 "GND" H 4880 2502 50 0000 C CNN
F 2 "" H 4875 2675 50 0001 C CNN
F 3 "" H 4875 2675 50 0001 C CNN
1 4875 2675
1 0 0 -1
$EndComp
Wire Wire Line
4825 3025 4825 2925
4875 2675 4875 2575
Text Notes 650 5600 0 50 ~ 0
I2C ADDR:
Wire Notes Line
@ -162,66 +162,66 @@ Wire Notes Line
2100 6850 2100 5600
Wire Notes Line
2100 5600 650 5600
Text Label 5725 2725 2 50 ~ 0
Text Label 5775 2375 2 50 ~ 0
SWCLK
Text Label 5725 2625 2 50 ~ 0
Text Label 5775 2275 2 50 ~ 0
SWDIO
Wire Wire Line
5725 2625 5325 2625
5775 2275 5375 2275
Wire Wire Line
5325 2725 5725 2725
5375 2375 5775 2375
Wire Wire Line
4025 1825 4425 1825
Text Label 4025 1825 0 50 ~ 0
4075 1475 4475 1475
Text Label 4075 1475 0 50 ~ 0
NRST
Wire Wire Line
8225 1775 8625 1775
Text Label 8225 1775 0 50 ~ 0
8125 1475 8525 1475
Text Label 8125 1475 0 50 ~ 0
NRST
Wire Wire Line
8225 1675 8625 1675
8125 1375 8525 1375
Wire Wire Line
8225 1575 8625 1575
Text Label 8225 1575 0 50 ~ 0
8125 1275 8525 1275
Text Label 8125 1275 0 50 ~ 0
SWDIO
Text Label 8225 1675 0 50 ~ 0
Text Label 8125 1375 0 50 ~ 0
SWCLK
$Comp
L HD_Power_Symbols:GND #PWR025
U 1 1 602AA5AC
P 8125 1875
F 0 "#PWR025" H 8125 1625 50 0001 C CNN
F 1 "GND" H 8130 1702 50 0000 C CNN
F 2 "" H 8125 1875 50 0001 C CNN
F 3 "" H 8125 1875 50 0001 C CNN
1 8125 1875
P 8025 1575
F 0 "#PWR025" H 8025 1325 50 0001 C CNN
F 1 "GND" H 8030 1402 50 0000 C CNN
F 2 "" H 8025 1575 50 0001 C CNN
F 3 "" H 8025 1575 50 0001 C CNN
1 8025 1575
1 0 0 -1
$EndComp
Wire Wire Line
8125 1875 8125 1475
8025 1575 8025 1175
Wire Wire Line
8125 1475 8625 1475
8025 1175 8525 1175
Wire Wire Line
8625 1375 8125 1375
8525 1075 8025 1075
Wire Wire Line
8125 1375 8125 1275
8025 1075 8025 975
$Comp
L HD_Power_Symbols:+3V3 #PWR024
U 1 1 602AD6BB
P 8125 1275
F 0 "#PWR024" H 8125 1125 50 0001 C CNN
F 1 "+3V3" H 8140 1448 50 0000 C CNN
F 2 "" H 8125 1275 50 0001 C CNN
F 3 "" H 8125 1275 50 0001 C CNN
1 8125 1275
P 8025 975
F 0 "#PWR024" H 8025 825 50 0001 C CNN
F 1 "+3V3" H 8040 1148 50 0000 C CNN
F 2 "" H 8025 975 50 0001 C CNN
F 3 "" H 8025 975 50 0001 C CNN
1 8025 975
1 0 0 -1
$EndComp
Wire Wire Line
4025 2425 4425 2425
4075 2075 4475 2075
Wire Wire Line
5325 1825 5725 1825
5375 1475 5775 1475
Wire Wire Line
5325 1925 5725 1925
5375 1575 5775 1575
Text Notes 2200 5500 0 50 ~ 10
SCD40 CO2 Sensor
Text Notes 2200 5600 0 50 ~ 0
@ -230,24 +230,24 @@ Text Notes 3750 5500 0 50 ~ 10
SPS30 Dust Particles Sensor Connector
Text Notes 3750 5600 0 50 ~ 0
I2C ADDR:
Text Label 7800 2625 0 50 ~ 0
Text Label 7700 2425 0 50 ~ 0
LED_R
Text Label 7800 2825 0 50 ~ 0
Text Label 7700 2625 0 50 ~ 0
LED_G
Text Label 7800 3025 0 50 ~ 0
Text Label 7700 2825 0 50 ~ 0
LED_B
Wire Wire Line
7800 2625 8200 2625
7700 2425 8100 2425
Wire Wire Line
7800 2825 8200 2825
7700 2625 8100 2625
Wire Wire Line
7800 3025 8200 3025
7700 2825 8100 2825
Wire Notes Line
2200 5600 3650 5600
Wire Notes Line
3750 5600 5200 5600
NoConn ~ 4425 2125
NoConn ~ 4425 2225
NoConn ~ 4475 1775
NoConn ~ 4475 1875
Text Label 2500 1275 2 50 ~ 0
RS485B
Text Label 2500 1175 2 50 ~ 0
@ -281,35 +281,35 @@ Wire Wire Line
$Comp
L HD_Power_Symbols:GND #PWR016
U 1 1 60205BF4
P 4325 3025
F 0 "#PWR016" H 4325 2775 50 0001 C CNN
F 1 "GND" H 4330 2852 50 0000 C CNN
F 2 "" H 4325 3025 50 0001 C CNN
F 3 "" H 4325 3025 50 0001 C CNN
1 4325 3025
P 4375 2675
F 0 "#PWR016" H 4375 2425 50 0001 C CNN
F 1 "GND" H 4380 2502 50 0000 C CNN
F 2 "" H 4375 2675 50 0001 C CNN
F 3 "" H 4375 2675 50 0001 C CNN
1 4375 2675
1 0 0 -1
$EndComp
Wire Wire Line
4325 3025 4325 2725
4375 2675 4375 2375
Wire Wire Line
4325 2725 4425 2725
Text Notes 4325 3025 1 50 ~ 0
4375 2375 4475 2375
Text Notes 4375 2675 1 50 ~ 0
BOOT0
NoConn ~ 4425 2525
NoConn ~ 4425 2625
NoConn ~ 4475 2175
NoConn ~ 4475 2275
$Comp
L HD_Connectors:SWD_Connector SWD0
U 1 1 6021959B
P 8725 1575
F 0 "SWD0" H 8750 1900 50 0000 L CNN
F 1 "SWD_Connector" V 9050 1300 50 0000 L CNN
F 2 "HD_Connectors:SWD_Connector_for_PogoHeader" H 8775 1175 50 0001 C CNN
F 3 "" H 8275 1275 50 0001 C CNN
F 4 "X" H 8775 975 50 0001 C CNN "Mouser"
F 5 "X" H 8775 875 50 0001 C CNN "Farnell"
F 6 "X" H 8775 775 50 0001 C CNN "TME"
F 7 "X" H 8775 1075 50 0001 C CNN "Digikey"
1 8725 1575
P 8625 1275
F 0 "SWD0" H 8650 1600 50 0000 L CNN
F 1 "SWD_Connector" V 8950 1000 50 0000 L CNN
F 2 "HD_Connectors:SWD_Connector_for_PogoHeader" H 8675 875 50 0001 C CNN
F 3 "" H 8175 975 50 0001 C CNN
F 4 "X" H 8675 675 50 0001 C CNN "Mouser"
F 5 "X" H 8675 575 50 0001 C CNN "Farnell"
F 6 "X" H 8675 475 50 0001 C CNN "TME"
F 7 "X" H 8675 775 50 0001 C CNN "Digikey"
1 8625 1275
1 0 0 -1
$EndComp
$Comp
@ -548,41 +548,41 @@ $EndComp
$Comp
L HD_Diodes:ASMB-KTF0-0A306 LD1
U 1 1 60321348
P 8900 2825
F 0 "LD1" H 8900 3340 50 0000 C CNN
F 1 "ASMB-KTF0-0A306" H 8900 3249 50 0000 C CNN
F 2 "HD_Diodes:LED_ASMB-KTF0-0A306" H 8900 2375 50 0001 C CNN
F 3 "https://www.tme.eu/Document/a4f5bbd3d29209f65332dc3bddaa72c4/RF-W2SA50TS-A39R.pdf" H 8900 1825 50 0001 C CNN
F 4 "Broadcom Limited" H 8900 2275 50 0001 C CNN "Manufacturer"
F 5 "ASMB-KTF0-0A306" H 8900 2175 50 0001 C CNN "Code"
F 6 "516-3906-1-ND" H 8900 2075 50 0001 C CNN "Digikey"
F 7 "630-ASMB-KTF0-0A306" H 8900 1975 50 0001 C CNN "Mouser"
F 8 "2858363" H 8900 1875 50 0001 C CNN "Farnell"
F 9 "X" H 8900 1775 50 0001 C CNN "TME"
1 8900 2825
P 8800 2625
F 0 "LD1" H 8800 3140 50 0000 C CNN
F 1 "ASMB-KTF0-0A306" H 8800 3049 50 0000 C CNN
F 2 "HD_Diodes:LED_ASMB-KTF0-0A306" H 8800 2175 50 0001 C CNN
F 3 "https://www.tme.eu/Document/a4f5bbd3d29209f65332dc3bddaa72c4/RF-W2SA50TS-A39R.pdf" H 8800 1625 50 0001 C CNN
F 4 "Broadcom Limited" H 8800 2075 50 0001 C CNN "Manufacturer"
F 5 "ASMB-KTF0-0A306" H 8800 1975 50 0001 C CNN "Code"
F 6 "516-3906-1-ND" H 8800 1875 50 0001 C CNN "Digikey"
F 7 "630-ASMB-KTF0-0A306" H 8800 1775 50 0001 C CNN "Mouser"
F 8 "2858363" H 8800 1675 50 0001 C CNN "Farnell"
F 9 "X" H 8800 1575 50 0001 C CNN "TME"
1 8800 2625
1 0 0 -1
$EndComp
Wire Wire Line
8500 2625 8600 2625
8400 2425 8500 2425
Wire Wire Line
8500 2825 8600 2825
8400 2625 8500 2625
Wire Wire Line
8500 3025 8600 3025
8400 2825 8500 2825
$Comp
L HD_Power_Symbols:+3V3 #PWR042
U 1 1 60346D90
P 9300 2725
F 0 "#PWR042" H 9300 2575 50 0001 C CNN
F 1 "+3V3" H 9315 2898 50 0000 C CNN
F 2 "" H 9300 2725 50 0001 C CNN
F 3 "" H 9300 2725 50 0001 C CNN
1 9300 2725
P 9200 2525
F 0 "#PWR042" H 9200 2375 50 0001 C CNN
F 1 "+3V3" H 9215 2698 50 0000 C CNN
F 2 "" H 9200 2525 50 0001 C CNN
F 3 "" H 9200 2525 50 0001 C CNN
1 9200 2525
1 0 0 -1
$EndComp
Wire Wire Line
9300 2725 9300 2825
9200 2525 9200 2625
Wire Wire Line
9300 2825 9200 2825
9200 2625 9100 2625
$Comp
L HD_Sensors:SCD40-D-R2 U5
U 1 1 603C0A5F
@ -781,9 +781,9 @@ Wire Wire Line
7175 4075 7475 4075
Connection ~ 7475 4075
Wire Wire Line
5725 2425 5325 2425
5775 2075 5375 2075
Wire Wire Line
5325 2525 5725 2525
5375 2175 5775 2175
Text Label 7175 4825 0 50 ~ 0
SDA
Wire Wire Line
@ -867,67 +867,67 @@ $EndComp
$Comp
L HD_Resistors:R0402_1k_1%_1d16W R34
U 1 1 6019EF2A
P 8350 2825
F 0 "R34" V 8300 2625 50 0000 C CNN
F 1 "R0402_1k_1%_1d16W" H 8350 2625 50 0001 C CNN
F 2 "HD_Resistors:R0402" H 8350 2525 50 0001 C CNN
F 3 "https://www.yageo.com/upload/media/product/productsearch/datasheet/rchip/PYu-AC_51_RoHS_L_7.pdf" H 8350 2825 50 0001 C CNN
F 4 "1k" V 8300 2975 50 0000 C CNN "Resistance"
F 5 "1/16W" H 8650 2875 50 0001 C CNN "Power"
F 6 "1%" H 8650 2775 50 0001 C CNN "Precision"
F 7 "Yageo" H 8350 2425 50 0001 C CNN "Manufacturer"
F 8 "AC0402FR-071KL" H 8350 2325 50 0001 C CNN "Code"
F 9 "TE Connectivity Passive Product" H 9150 2425 50 0001 C CNN "Alt_Manufacturer"
F 10 "CRGCQ0402F1K0" H 9150 2325 50 0001 C CNN "Alt_Code"
F 11 "311-1KLBCT-ND" H 8350 2225 50 0001 C CNN "Digikey"
F 12 "603-RC0402JR-131KL" H 8350 2125 50 0001 C CNN "Mouser"
F 13 "3495181" H 8350 2025 50 0001 C CNN "Farnell"
F 14 "SMD0402-1K" H 8350 1925 50 0001 C CNN "TME"
1 8350 2825
P 8250 2625
F 0 "R34" V 8200 2425 50 0000 C CNN
F 1 "R0402_1k_1%_1d16W" H 8250 2425 50 0001 C CNN
F 2 "HD_Resistors:R0402" H 8250 2325 50 0001 C CNN
F 3 "https://www.yageo.com/upload/media/product/productsearch/datasheet/rchip/PYu-AC_51_RoHS_L_7.pdf" H 8250 2625 50 0001 C CNN
F 4 "1k" V 8200 2775 50 0000 C CNN "Resistance"
F 5 "1/16W" H 8550 2675 50 0001 C CNN "Power"
F 6 "1%" H 8550 2575 50 0001 C CNN "Precision"
F 7 "Yageo" H 8250 2225 50 0001 C CNN "Manufacturer"
F 8 "AC0402FR-071KL" H 8250 2125 50 0001 C CNN "Code"
F 9 "TE Connectivity Passive Product" H 9050 2225 50 0001 C CNN "Alt_Manufacturer"
F 10 "CRGCQ0402F1K0" H 9050 2125 50 0001 C CNN "Alt_Code"
F 11 "311-1KLBCT-ND" H 8250 2025 50 0001 C CNN "Digikey"
F 12 "603-RC0402JR-131KL" H 8250 1925 50 0001 C CNN "Mouser"
F 13 "3495181" H 8250 1825 50 0001 C CNN "Farnell"
F 14 "SMD0402-1K" H 8250 1725 50 0001 C CNN "TME"
1 8250 2625
0 1 1 0
$EndComp
$Comp
L HD_Resistors:R0402_1k_1%_1d16W R33
U 1 1 6019EACD
P 8350 2625
F 0 "R33" V 8300 2425 50 0000 C CNN
F 1 "R0402_1k_1%_1d16W" H 8350 2425 50 0001 C CNN
F 2 "HD_Resistors:R0402" H 8350 2325 50 0001 C CNN
F 3 "https://www.yageo.com/upload/media/product/productsearch/datasheet/rchip/PYu-AC_51_RoHS_L_7.pdf" H 8350 2625 50 0001 C CNN
F 4 "1k" V 8300 2775 50 0000 C CNN "Resistance"
F 5 "1/16W" H 8650 2675 50 0001 C CNN "Power"
F 6 "1%" H 8650 2575 50 0001 C CNN "Precision"
F 7 "Yageo" H 8350 2225 50 0001 C CNN "Manufacturer"
F 8 "AC0402FR-071KL" H 8350 2125 50 0001 C CNN "Code"
F 9 "TE Connectivity Passive Product" H 9150 2225 50 0001 C CNN "Alt_Manufacturer"
F 10 "CRGCQ0402F1K0" H 9150 2125 50 0001 C CNN "Alt_Code"
F 11 "311-1KLBCT-ND" H 8350 2025 50 0001 C CNN "Digikey"
F 12 "603-RC0402JR-131KL" H 8350 1925 50 0001 C CNN "Mouser"
F 13 "3495181" H 8350 1825 50 0001 C CNN "Farnell"
F 14 "SMD0402-1K" H 8350 1725 50 0001 C CNN "TME"
1 8350 2625
P 8250 2425
F 0 "R33" V 8200 2225 50 0000 C CNN
F 1 "R0402_1k_1%_1d16W" H 8250 2225 50 0001 C CNN
F 2 "HD_Resistors:R0402" H 8250 2125 50 0001 C CNN
F 3 "https://www.yageo.com/upload/media/product/productsearch/datasheet/rchip/PYu-AC_51_RoHS_L_7.pdf" H 8250 2425 50 0001 C CNN
F 4 "1k" V 8200 2575 50 0000 C CNN "Resistance"
F 5 "1/16W" H 8550 2475 50 0001 C CNN "Power"
F 6 "1%" H 8550 2375 50 0001 C CNN "Precision"
F 7 "Yageo" H 8250 2025 50 0001 C CNN "Manufacturer"
F 8 "AC0402FR-071KL" H 8250 1925 50 0001 C CNN "Code"
F 9 "TE Connectivity Passive Product" H 9050 2025 50 0001 C CNN "Alt_Manufacturer"
F 10 "CRGCQ0402F1K0" H 9050 1925 50 0001 C CNN "Alt_Code"
F 11 "311-1KLBCT-ND" H 8250 1825 50 0001 C CNN "Digikey"
F 12 "603-RC0402JR-131KL" H 8250 1725 50 0001 C CNN "Mouser"
F 13 "3495181" H 8250 1625 50 0001 C CNN "Farnell"
F 14 "SMD0402-1K" H 8250 1525 50 0001 C CNN "TME"
1 8250 2425
0 1 1 0
$EndComp
$Comp
L HD_Resistors:R0402_1k_1%_1d16W R35
U 1 1 6019D468
P 8350 3025
F 0 "R35" V 8300 2825 50 0000 C CNN
F 1 "R0402_1k_1%_1d16W" H 8350 2825 50 0001 C CNN
F 2 "HD_Resistors:R0402" H 8350 2725 50 0001 C CNN
F 3 "https://www.yageo.com/upload/media/product/productsearch/datasheet/rchip/PYu-AC_51_RoHS_L_7.pdf" H 8350 3025 50 0001 C CNN
F 4 "1k" V 8300 3175 50 0000 C CNN "Resistance"
F 5 "1/16W" H 8650 3075 50 0001 C CNN "Power"
F 6 "1%" H 8650 2975 50 0001 C CNN "Precision"
F 7 "Yageo" H 8350 2625 50 0001 C CNN "Manufacturer"
F 8 "AC0402FR-071KL" H 8350 2525 50 0001 C CNN "Code"
F 9 "TE Connectivity Passive Product" H 9150 2625 50 0001 C CNN "Alt_Manufacturer"
F 10 "CRGCQ0402F1K0" H 9150 2525 50 0001 C CNN "Alt_Code"
F 11 "311-1KLBCT-ND" H 8350 2425 50 0001 C CNN "Digikey"
F 12 "603-RC0402JR-131KL" H 8350 2325 50 0001 C CNN "Mouser"
F 13 "3495181" H 8350 2225 50 0001 C CNN "Farnell"
F 14 "SMD0402-1K" H 8350 2125 50 0001 C CNN "TME"
1 8350 3025
P 8250 2825
F 0 "R35" V 8200 2625 50 0000 C CNN
F 1 "R0402_1k_1%_1d16W" H 8250 2625 50 0001 C CNN
F 2 "HD_Resistors:R0402" H 8250 2525 50 0001 C CNN
F 3 "https://www.yageo.com/upload/media/product/productsearch/datasheet/rchip/PYu-AC_51_RoHS_L_7.pdf" H 8250 2825 50 0001 C CNN
F 4 "1k" V 8200 2975 50 0000 C CNN "Resistance"
F 5 "1/16W" H 8550 2875 50 0001 C CNN "Power"
F 6 "1%" H 8550 2775 50 0001 C CNN "Precision"
F 7 "Yageo" H 8250 2425 50 0001 C CNN "Manufacturer"
F 8 "AC0402FR-071KL" H 8250 2325 50 0001 C CNN "Code"
F 9 "TE Connectivity Passive Product" H 9050 2425 50 0001 C CNN "Alt_Manufacturer"
F 10 "CRGCQ0402F1K0" H 9050 2325 50 0001 C CNN "Alt_Code"
F 11 "311-1KLBCT-ND" H 8250 2225 50 0001 C CNN "Digikey"
F 12 "603-RC0402JR-131KL" H 8250 2125 50 0001 C CNN "Mouser"
F 13 "3495181" H 8250 2025 50 0001 C CNN "Farnell"
F 14 "SMD0402-1K" H 8250 1925 50 0001 C CNN "TME"
1 8250 2825
0 1 1 0
$EndComp
$Comp
@ -972,13 +972,13 @@ F 11 "X" H 1600 725 50 0001 C CNN "TME"
1 0 0 -1
$EndComp
Wire Wire Line
5725 2325 5325 2325
5775 1975 5375 1975
Wire Wire Line
5725 2225 5325 2225
5775 1875 5375 1875
Wire Wire Line
5725 2125 5325 2125
5775 1775 5375 1775
Wire Wire Line
5725 2025 5325 2025
5775 1675 5375 1675
$Comp
L HD_Connectors:JST_ZH5_Side_Entry_S5B-ZR-SM4A-TF J2
U 1 1 60434D59
@ -994,16 +994,16 @@ F 7 "S5B-ZR-SM4A-TF" H 4600 5400 50 0001 C CNN "TME"
1 4550 6200
1 0 0 -1
$EndComp
Text Label 5725 2125 2 50 ~ 0
Text Label 5775 1775 2 50 ~ 0
LED_B
Text Label 5725 2325 2 50 ~ 0
Text Label 5775 1975 2 50 ~ 0
LED_R
Text Label 5725 2225 2 50 ~ 0
Text Label 5775 1875 2 50 ~ 0
LED_G
Wire Wire Line
3150 6200 3150 6100
Connection ~ 3150 6100
NoConn ~ 5725 2025
NoConn ~ 5775 1675
$Comp
L HD_Connectors:Sullins_SWR204-NRTN-D02-RA-GA J1
U 1 1 606D54B3
@ -1772,133 +1772,133 @@ Text Notes 8200 3400 0 50 Italic 0
$Comp
L HD_Power_Symbols:+3V3 #PWR026
U 1 1 60270BC3
P 6175 875
F 0 "#PWR026" H 6175 725 50 0001 C CNN
F 1 "+3V3" H 6190 1048 50 0000 C CNN
F 2 "" H 6175 875 50 0001 C CNN
F 3 "" H 6175 875 50 0001 C CNN
1 6175 875
P 7025 1625
F 0 "#PWR026" H 7025 1475 50 0001 C CNN
F 1 "+3V3" H 7040 1798 50 0000 C CNN
F 2 "" H 7025 1625 50 0001 C CNN
F 3 "" H 7025 1625 50 0001 C CNN
1 7025 1625
1 0 0 -1
$EndComp
$Comp
L HD_Power_Symbols:GND #PWR027
U 1 1 60270BBD
P 6175 1175
F 0 "#PWR027" H 6175 925 50 0001 C CNN
F 1 "GND" H 6180 1002 50 0000 C CNN
F 2 "" H 6175 1175 50 0001 C CNN
F 3 "" H 6175 1175 50 0001 C CNN
1 6175 1175
P 7025 1925
F 0 "#PWR027" H 7025 1675 50 0001 C CNN
F 1 "GND" H 7030 1752 50 0000 C CNN
F 2 "" H 7025 1925 50 0001 C CNN
F 3 "" H 7025 1925 50 0001 C CNN
1 7025 1925
1 0 0 -1
$EndComp
$Comp
L HD_Capacitors:C0402_100nF_50V_X7R C33
U 1 1 60270BB7
P 6175 1025
F 0 "C33" H 6290 1116 50 0000 L CNN
F 1 "C0402_100nF_50V_X7R" H 6175 825 50 0001 C CNN
F 2 "HD_Capacitors:C0402" H 6175 725 50 0001 C CNN
F 3 "https://search.murata.co.jp/Ceramy/image/img/A01X/G101/ENG/GRM155R71H104KE14-01.pdf" H 6175 1025 50 0001 C CNN
F 4 "100nF" H 6290 1025 50 0000 L CNN "Capacitance"
F 5 "50V" H 6290 934 50 0000 L CNN "Voltage"
F 6 "X7R" H 6175 1025 50 0001 C CNN "Dielectric"
F 7 "Murata Electronics" H 6175 625 50 0001 C CNN "Manufacturer"
F 8 "GRM155R71H104KE14D" H 6175 525 50 0001 C CNN "Code"
F 9 "490-10700-1-ND" H 6175 425 50 0001 C CNN "Digikey"
F 10 "81-GRM155R71H104KE4D" H 6175 325 50 0001 C CNN "Mouser"
F 11 "2611912" H 6175 225 50 0001 C CNN "Farnell"
F 12 "GRM155R71H104KE14D" H 6175 125 50 0001 C CNN "TME"
F 13 "TDK Corporation" H 7075 625 50 0001 C CNN "Alt_Manufacturer"
F 14 "C1005X7R1H104K050BB" H 7075 525 50 0001 C CNN "Alt_Code"
1 6175 1025
P 7025 1775
F 0 "C33" H 7140 1866 50 0000 L CNN
F 1 "C0402_100nF_50V_X7R" H 7025 1575 50 0001 C CNN
F 2 "HD_Capacitors:C0402" H 7025 1475 50 0001 C CNN
F 3 "https://search.murata.co.jp/Ceramy/image/img/A01X/G101/ENG/GRM155R71H104KE14-01.pdf" H 7025 1775 50 0001 C CNN
F 4 "100nF" H 7140 1775 50 0000 L CNN "Capacitance"
F 5 "50V" H 7140 1684 50 0000 L CNN "Voltage"
F 6 "X7R" H 7025 1775 50 0001 C CNN "Dielectric"
F 7 "Murata Electronics" H 7025 1375 50 0001 C CNN "Manufacturer"
F 8 "GRM155R71H104KE14D" H 7025 1275 50 0001 C CNN "Code"
F 9 "490-10700-1-ND" H 7025 1175 50 0001 C CNN "Digikey"
F 10 "81-GRM155R71H104KE4D" H 7025 1075 50 0001 C CNN "Mouser"
F 11 "2611912" H 7025 975 50 0001 C CNN "Farnell"
F 12 "GRM155R71H104KE14D" H 7025 875 50 0001 C CNN "TME"
F 13 "TDK Corporation" H 7925 1375 50 0001 C CNN "Alt_Manufacturer"
F 14 "C1005X7R1H104K050BB" H 7925 1275 50 0001 C CNN "Alt_Code"
1 7025 1775
1 0 0 -1
$EndComp
$Comp
L HD_Power_Symbols:+3V3 #PWR022
U 1 1 6026E972
P 5675 875
F 0 "#PWR022" H 5675 725 50 0001 C CNN
F 1 "+3V3" H 5690 1048 50 0000 C CNN
F 2 "" H 5675 875 50 0001 C CNN
F 3 "" H 5675 875 50 0001 C CNN
1 5675 875
P 6525 1625
F 0 "#PWR022" H 6525 1475 50 0001 C CNN
F 1 "+3V3" H 6540 1798 50 0000 C CNN
F 2 "" H 6525 1625 50 0001 C CNN
F 3 "" H 6525 1625 50 0001 C CNN
1 6525 1625
1 0 0 -1
$EndComp
$Comp
L HD_Power_Symbols:GND #PWR023
U 1 1 6026E44F
P 5675 1175
F 0 "#PWR023" H 5675 925 50 0001 C CNN
F 1 "GND" H 5680 1002 50 0000 C CNN
F 2 "" H 5675 1175 50 0001 C CNN
F 3 "" H 5675 1175 50 0001 C CNN
1 5675 1175
P 6525 1925
F 0 "#PWR023" H 6525 1675 50 0001 C CNN
F 1 "GND" H 6530 1752 50 0000 C CNN
F 2 "" H 6525 1925 50 0001 C CNN
F 3 "" H 6525 1925 50 0001 C CNN
1 6525 1925
1 0 0 -1
$EndComp
$Comp
L HD_Capacitors:C0402_100nF_50V_X7R C32
U 1 1 6026D99D
P 5675 1025
F 0 "C32" H 5790 1116 50 0000 L CNN
F 1 "C0402_100nF_50V_X7R" H 5675 825 50 0001 C CNN
F 2 "HD_Capacitors:C0402" H 5675 725 50 0001 C CNN
F 3 "https://search.murata.co.jp/Ceramy/image/img/A01X/G101/ENG/GRM155R71H104KE14-01.pdf" H 5675 1025 50 0001 C CNN
F 4 "100nF" H 5790 1025 50 0000 L CNN "Capacitance"
F 5 "50V" H 5790 934 50 0000 L CNN "Voltage"
F 6 "X7R" H 5675 1025 50 0001 C CNN "Dielectric"
F 7 "Murata Electronics" H 5675 625 50 0001 C CNN "Manufacturer"
F 8 "GRM155R71H104KE14D" H 5675 525 50 0001 C CNN "Code"
F 9 "490-10700-1-ND" H 5675 425 50 0001 C CNN "Digikey"
F 10 "81-GRM155R71H104KE4D" H 5675 325 50 0001 C CNN "Mouser"
F 11 "2611912" H 5675 225 50 0001 C CNN "Farnell"
F 12 "GRM155R71H104KE14D" H 5675 125 50 0001 C CNN "TME"
F 13 "TDK Corporation" H 6575 625 50 0001 C CNN "Alt_Manufacturer"
F 14 "C1005X7R1H104K050BB" H 6575 525 50 0001 C CNN "Alt_Code"
1 5675 1025
P 6525 1775
F 0 "C32" H 6640 1866 50 0000 L CNN
F 1 "C0402_100nF_50V_X7R" H 6525 1575 50 0001 C CNN
F 2 "HD_Capacitors:C0402" H 6525 1475 50 0001 C CNN
F 3 "https://search.murata.co.jp/Ceramy/image/img/A01X/G101/ENG/GRM155R71H104KE14-01.pdf" H 6525 1775 50 0001 C CNN
F 4 "100nF" H 6640 1775 50 0000 L CNN "Capacitance"
F 5 "50V" H 6640 1684 50 0000 L CNN "Voltage"
F 6 "X7R" H 6525 1775 50 0001 C CNN "Dielectric"
F 7 "Murata Electronics" H 6525 1375 50 0001 C CNN "Manufacturer"
F 8 "GRM155R71H104KE14D" H 6525 1275 50 0001 C CNN "Code"
F 9 "490-10700-1-ND" H 6525 1175 50 0001 C CNN "Digikey"
F 10 "81-GRM155R71H104KE4D" H 6525 1075 50 0001 C CNN "Mouser"
F 11 "2611912" H 6525 975 50 0001 C CNN "Farnell"
F 12 "GRM155R71H104KE14D" H 6525 875 50 0001 C CNN "TME"
F 13 "TDK Corporation" H 7425 1375 50 0001 C CNN "Alt_Manufacturer"
F 14 "C1005X7R1H104K050BB" H 7425 1275 50 0001 C CNN "Alt_Code"
1 6525 1775
1 0 0 -1
$EndComp
$Comp
L HD_Power_Symbols:GND #PWR018
U 1 1 6026CD8B
P 5175 1175
F 0 "#PWR018" H 5175 925 50 0001 C CNN
F 1 "GND" H 5180 1002 50 0000 C CNN
F 2 "" H 5175 1175 50 0001 C CNN
F 3 "" H 5175 1175 50 0001 C CNN
1 5175 1175
P 6025 1925
F 0 "#PWR018" H 6025 1675 50 0001 C CNN
F 1 "GND" H 6030 1752 50 0000 C CNN
F 2 "" H 6025 1925 50 0001 C CNN
F 3 "" H 6025 1925 50 0001 C CNN
1 6025 1925
1 0 0 -1
$EndComp
$Comp
L HD_Power_Symbols:+3V3 #PWR017
U 1 1 6026C580
P 5175 875
F 0 "#PWR017" H 5175 725 50 0001 C CNN
F 1 "+3V3" H 5190 1048 50 0000 C CNN
F 2 "" H 5175 875 50 0001 C CNN
F 3 "" H 5175 875 50 0001 C CNN
1 5175 875
P 6025 1625
F 0 "#PWR017" H 6025 1475 50 0001 C CNN
F 1 "+3V3" H 6040 1798 50 0000 C CNN
F 2 "" H 6025 1625 50 0001 C CNN
F 3 "" H 6025 1625 50 0001 C CNN
1 6025 1625
1 0 0 -1
$EndComp
$Comp
L HD_Capacitors:C0603_10uF_16V_X5R C31
U 1 1 6026BA20
P 5175 1025
F 0 "C31" H 5290 1116 50 0000 L CNN
F 1 "C0603_10uF_16V_X5R" H 5175 825 50 0001 C CNN
F 2 "HD_Capacitors:C0603" H 5175 725 50 0001 C CNN
F 3 "*" H 5175 1025 50 0001 C CNN
F 4 "10uF" H 5290 1025 50 0000 L CNN "Capacitance"
F 5 "16V" H 5290 934 50 0000 L CNN "Voltage"
F 6 "X5R" H 5175 1025 50 0001 C CNN "Dielectric"
F 7 "Taiyo Yuden" H 5175 625 50 0001 C CNN "Manufacturer"
F 8 "EMK107BBJ106MA-T" H 5175 525 50 0001 C CNN "Code"
F 9 "587-3238-1-ND" H 5175 425 50 0001 C CNN "Digikey"
F 10 "963-EMK107BBJ106MA-T" H 5175 325 50 0001 C CNN "Mouser"
F 11 "2779064" H 5175 225 50 0001 C CNN "Farnell"
F 12 "CL10A106MO8NQNC" H 5175 125 50 0001 C CNN "TME"
F 13 "Murata Electronics" H 6125 625 50 0001 C CNN "Alt_Manufacturer"
F 14 "GRM188R61C106MA73D" H 6125 525 50 0001 C CNN "Alt_Code"
1 5175 1025
P 6025 1775
F 0 "C31" H 6140 1866 50 0000 L CNN
F 1 "C0603_10uF_16V_X5R" H 6025 1575 50 0001 C CNN
F 2 "HD_Capacitors:C0603" H 6025 1475 50 0001 C CNN
F 3 "*" H 6025 1775 50 0001 C CNN
F 4 "10uF" H 6140 1775 50 0000 L CNN "Capacitance"
F 5 "16V" H 6140 1684 50 0000 L CNN "Voltage"
F 6 "X5R" H 6025 1775 50 0001 C CNN "Dielectric"
F 7 "Taiyo Yuden" H 6025 1375 50 0001 C CNN "Manufacturer"
F 8 "EMK107BBJ106MA-T" H 6025 1275 50 0001 C CNN "Code"
F 9 "587-3238-1-ND" H 6025 1175 50 0001 C CNN "Digikey"
F 10 "963-EMK107BBJ106MA-T" H 6025 1075 50 0001 C CNN "Mouser"
F 11 "2779064" H 6025 975 50 0001 C CNN "Farnell"
F 12 "CL10A106MO8NQNC" H 6025 875 50 0001 C CNN "TME"
F 13 "Murata Electronics" H 6975 1375 50 0001 C CNN "Alt_Manufacturer"
F 14 "GRM188R61C106MA73D" H 6975 1275 50 0001 C CNN "Alt_Code"
1 6025 1775
1 0 0 -1
$EndComp
Wire Notes Line
@ -1946,23 +1946,23 @@ Sensors
Text Notes 3800 550 0 50 ~ 10
Microcontroller
Wire Notes Line
9450 3200 7700 3200
9350 3100 7600 3100
Wire Notes Line
7700 3200 7700 2250
7600 1950 9350 1950
Wire Notes Line
7700 2250 9450 2250
7600 1850 9350 1850
Wire Notes Line
9450 2250 9450 3200
9350 1850 9350 700
Wire Notes Line
7700 2150 9450 2150
9350 700 7600 700
Wire Notes Line
9450 2150 9450 1000
Wire Notes Line
9450 1000 7700 1000
Wire Notes Line
7700 1000 7700 2150
Text Notes 7700 1000 0 50 ~ 0
7600 700 7600 1850
Text Notes 7600 700 0 50 ~ 0
Programming Connector
Text Notes 7700 2250 0 50 ~ 0
Text Notes 7600 1950 0 50 ~ 0
Signal LED
Wire Notes Line
9350 1950 9350 3100
Wire Notes Line
7600 1950 7600 3100
$EndSCHEMATC

View File

@ -11,6 +11,7 @@
/* TODO: add comments to everything */
#include "stdint.h"
#include "stm32l0xx.h"
#define VENDOR_NAME_LENGTH 64
#define PRODUCT_CODE_LENGTH 64
@ -18,9 +19,22 @@
#define REVISION_LENGTH 16
#define SERIAL_NUMBER_LENGTH 64
#define DATA_EEPROM_BASE_ADDR ((uint32_t)0x08080000) /* Data EEPROM base address */
#define DATA_EEPROM_END_ADDR ((uint32_t)0x080801FF) /* Data EEPROM end address */
#define FLASH_PEKEY1 0x89ABCDEF
#define FLASH_PEKEY2 0x02030405
#define CONFIG_OK 0
#define CONFIG_ERROR -1
#define EEPROM_OK 0
#define EEPROM_ERROR -1
#define EEPROM_UNLOCK_ERROR -2
#define EEPROM_LOCK_ERROR -3
#define EEPROM_WRITE_ERROR -4
typedef struct
{
@ -37,9 +51,15 @@ typedef struct
uint16_t led_co2_alert_limit2;
} config_t;
int8_t read_config(config_t *config);
int8_t config_read(config_t *config);
int8_t write_config(config_t *config);
int8_t config_write(config_t *config);
static int8_t eeprom_lock(void);
static int8_t eeprom_unlock(void);
static int8_t eeprom_program_byte(uint32_t addr, uint8_t ee_data);
static int8_t eeprom_program_halfword(uint32_t addr, uint16_t ee_data);
static int8_t eeprom_program_word(uint32_t addr, uint32_t ee_data);
#endif /* INC_CONFIG_H_ */

View File

@ -53,6 +53,7 @@ extern "C" {
#include "sht4x.h"
#include "sps30.h"
#include "modbus.h"
#include "config.h"
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/

View File

@ -7,12 +7,118 @@
#include "config.h"
int8_t read_config(config_t *config)
int8_t config_read(config_t *config)
{
return CONFIG_OK;
}
int8_t write_config(config_t *config)
int8_t config_write(config_t *config)
{
/* Unlock the EEPROM */
if (eeprom_unlock() != EEPROM_OK)
{
return EEPROM_UNLOCK_ERROR;
}
/* Reset the ERASE and DATA bits in the FLASH_PECR register to disable any residual erase */
FLASH->PECR = FLASH->PECR & ~(FLASH_PECR_ERASE | FLASH_PECR_DATA);
if (eeprom_program_byte(DATA_EEPROM_BASE_ADDR, 0xab) != EEPROM_OK)
{
return EEPROM_WRITE_ERROR;
}
if (eeprom_program_halfword(DATA_EEPROM_BASE_ADDR+2, 0x4321) != EEPROM_OK)
{
return EEPROM_WRITE_ERROR;
}
if (eeprom_program_word(DATA_EEPROM_BASE_ADDR + (4), 0x12345678) != EEPROM_OK)
{
return EEPROM_WRITE_ERROR;
}
for (uint8_t i = 0; i < 16; i ++)
{
eeprom_program_byte(DATA_EEPROM_BASE_ADDR + 8 + i, i+1);
}
if (eeprom_lock() != EEPROM_OK)
{
return EEPROM_LOCK_ERROR;
}
return CONFIG_OK;
}
static int8_t eeprom_lock(void)
{
while ((FLASH->SR & FLASH_SR_BSY) != 0) /* Wait for FLASH to be free */
{
/* TODO: insert timeout test */
}
FLASH->PECR = FLASH->PECR & ~(FLASH_PECR_ERRIE | FLASH_PECR_EOPIE); /* disable flash interrupts */
FLASH->PECR = FLASH->PECR | FLASH_PECR_PELOCK; /* Lock memory with PELOCK */
return EEPROM_OK;
}
/* Unlock the EEPROM: */
static int8_t eeprom_unlock(void)
{
while ((FLASH->SR & FLASH_SR_BSY) != 0) /* Wait for FLASH to be free */
{
/* TODO: insert timeout test */
}
if ((FLASH->PECR & FLASH_PECR_PELOCK) != 0) /* If PELOCK is locked */
{
/* Unlock PELOCK */
FLASH->PEKEYR = FLASH_PEKEY1; /* PEKEY1 */
FLASH->PEKEYR = FLASH_PEKEY2; /* PEKEY2 */
}
FLASH->PECR = FLASH->PECR | (FLASH_PECR_ERRIE | FLASH_PECR_EOPIE); /* enable flash interrupts */
return EEPROM_OK;
}
/**
* Brief This function programs a word of data EEPROM.
* The ERASE bit and DATA bit are cleared in PECR at the beginning
* words are automatically erased if required before programming
* Param addr is the 32-bit EEPROM address to program, data is the 32 bit word to program
* Retval None
*/
/* NOTE: The EEPROM must be unlocked and the flash interrupts must have been enabled prior to calling this function.*/
static int8_t eeprom_program_byte(uint32_t addr, uint8_t ee_data)
{
*(uint8_t *)(addr) = ee_data; /* write data to EEPROM */
//__WFI();
if (*(uint8_t *)(addr) != ee_data)
{
return EEPROM_WRITE_ERROR;
}
return EEPROM_OK;
}
static int8_t eeprom_program_halfword(uint32_t addr, uint16_t ee_data)
{
*(uint16_t *)(addr) = ee_data; /* write data to EEPROM */
//__WFI();
if (*(uint16_t *)(addr) != ee_data)
{
return EEPROM_WRITE_ERROR;
}
return EEPROM_OK;
}
static int8_t eeprom_program_word(uint32_t addr, uint32_t ee_data)
{
*(uint32_t *)(addr) = ee_data; /* write data to EEPROM */
//__WFI();
if (*(uint32_t *)(addr) != ee_data)
{
return EEPROM_WRITE_ERROR;
}
return EEPROM_OK;
}

View File

@ -196,6 +196,14 @@ int main(void)
scd4x_start_periodic_measurement();
uint8_t scd4x_is_connected = 1;
uint8_t sps30_is_connected = 0;
config_t dummy_config;
int8_t config_write_err = config_write(&dummy_config);
uint32_t eeprom_dato1 = *(uint8_t *)(DATA_EEPROM_BASE_ADDR);
uint32_t eeprom_dato2 = *(uint16_t *)(DATA_EEPROM_BASE_ADDR+2);
uint32_t eeprom_dato3 = *(uint32_t *)(DATA_EEPROM_BASE_ADDR+4);
/* USER CODE END 2 */
/* Infinite loop */

View File

@ -68,6 +68,6 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;&#10;"/>
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
</launchConfiguration>