Compare commits
4 Commits
e94f5e7dec
...
ad4621cb2e
Author | SHA1 | Date |
---|---|---|
|
ad4621cb2e | |
|
d6402ff656 | |
|
f185f281e7 | |
|
43992205f7 |
|
@ -1 +1,3 @@
|
|||
*-backups/
|
||||
build/
|
||||
hostbuild/
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
set(PICO_BOARD walkie_talkies)
|
||||
set(PICO_BOARD_HEADER_DIRS ${CMAKE_SOURCE_DIR}/boards/)
|
||||
|
||||
# Pull in SDK (must be before project)
|
||||
include(pico_sdk_import.cmake)
|
||||
|
||||
project(walkie_talkies)
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
add_executable(uart_test
|
||||
src/uart_test.c
|
||||
)
|
||||
|
||||
target_link_libraries(uart_test pico_stdlib)
|
||||
|
||||
pico_enable_stdio_usb(uart_test 1)
|
||||
pico_enable_stdio_uart(uart_test 0)
|
||||
|
||||
pico_add_extra_outputs(uart_test)
|
||||
|
||||
add_executable(blink_test
|
||||
src/blink_test.c
|
||||
)
|
||||
|
||||
target_link_libraries(blink_test pico_stdlib)
|
||||
|
||||
pico_enable_stdio_usb(blink_test 1)
|
||||
pico_enable_stdio_uart(blink_test 0)
|
||||
|
||||
pico_add_extra_outputs(blink_test)
|
||||
|
||||
add_executable(spi_test
|
||||
src/spi_test.c
|
||||
)
|
||||
|
||||
target_link_libraries(spi_test
|
||||
pico_stdlib
|
||||
hardware_spi
|
||||
)
|
||||
|
||||
pico_enable_stdio_usb(spi_test 1)
|
||||
pico_enable_stdio_uart(spi_test 0)
|
||||
|
||||
pico_add_extra_outputs(spi_test)
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef _BOARDS_WALKIE_TALKIES
|
||||
#define _BOARDS_WALKIE_TALKIES
|
||||
|
||||
#define PICO_FLASH_SIZE_BYTES (16*1024*1024)
|
||||
|
||||
#define PICO_DEFAULT_SPI 0
|
||||
#define PICO_DEFAULT_SPI_SCK_PIN 1
|
||||
#define PICO_DEFAULT_SPI_TX_PIN 3
|
||||
#define PICO_DEFAULT_SPI_RX_PIN 0
|
||||
#define PICO_DEFAULT_SPI_CSN_PIN 2
|
||||
|
||||
#include "boards/pico.h"
|
||||
|
||||
#undef PICO_BOOT_STAGE2_CHOOSE_W25Q080
|
||||
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
|
||||
//#define PICO_BOOT_STAGE2_CHOOSE_IS25LP080 1
|
||||
//#define PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H 1
|
||||
|
||||
#undef PICO_SMPS_MODE_PIN
|
||||
|
||||
#endif
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
project(walkie_talkies_host)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
add_executable(spi_parse_test
|
||||
../src/spi_parser_test.c
|
||||
)
|
|
@ -1396,6 +1396,9 @@
|
|||
(property "Datasheet" "https://www.ti.com/lit/ds/symlink/tlv741p.pdf" (id 3) (at 104.14 146.05 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Digikey" "296-48986-1-ND" (id 4) (at 104.14 147.32 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 03ca257d-c37d-4f89-8f88-108981faff99))
|
||||
(pin "2" (uuid 3090edf3-0928-40e3-83dc-92489002d5d2))
|
||||
(pin "3" (uuid df5e4459-0197-4781-a952-526d1afa9f65))
|
||||
|
@ -1414,7 +1417,7 @@
|
|||
(property "Datasheet" "~" (id 3) (at 237.49 100.33 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Digikey" "" (id 4) (at 237.49 100.33 0)
|
||||
(property "Digikey" "900-5034800440TR-ND" (id 4) (at 237.49 100.33 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 02eec477-7899-469a-af1d-219ae64ff28a))
|
||||
|
@ -1516,6 +1519,9 @@
|
|||
(property "Datasheet" "" (id 3) (at 116.84 63.5 0)
|
||||
(effects (font (size 1.524 1.524)))
|
||||
)
|
||||
(property "Digikey" "MAX9860ETG+-ND" (id 4) (at 116.84 63.5 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 5af55ce7-848c-409c-8e01-2c0a97c2def1))
|
||||
(pin "10" (uuid 6ba8d3ba-24ba-4f21-b08c-62bb95c989a7))
|
||||
(pin "11" (uuid 252bbab8-1da9-4321-b0b2-74eb5e0817f2))
|
||||
|
@ -1636,6 +1642,9 @@
|
|||
(property "Datasheet" "https://www.ti.com/lit/ds/symlink/tlv741p.pdf" (id 3) (at 102.87 124.46 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Digikey" "296-48986-1-ND" (id 4) (at 102.87 125.73 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 2238ffc7-b57a-496c-8602-6e141fca129d))
|
||||
(pin "2" (uuid bde1a70d-d7ba-4d89-899e-458fc42430b7))
|
||||
(pin "3" (uuid 0edafc8e-6fe7-46a4-9652-e1131a3d7946))
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,57 @@
|
|||
import argparse
|
||||
import csv
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Generates a Digikey BOM from Joost's KiCAD BOM")
|
||||
parser.add_argument("input", help="input BOM")
|
||||
parser.add_argument("output", help="output BOM")
|
||||
parser.add_argument("--m", help="quantity multiplier", default="1")
|
||||
|
||||
args = parser.parse_args()
|
||||
multiplier = 1 if args.m is None else int(args.m)
|
||||
|
||||
print("multiplier: {}".format(multiplier))
|
||||
|
||||
digikey_idx = None
|
||||
count_idx = None
|
||||
components = []
|
||||
# TODO skip until it sees "Collated Components"
|
||||
with open(args.input, 'r') as f:
|
||||
reader = csv.reader(f)
|
||||
found_start = False
|
||||
for line_number, line in enumerate(reader):
|
||||
if not found_start:
|
||||
if any(["Collated" in p for p in line]):
|
||||
#print("header at {}".format(line_number + 1))
|
||||
found_start = True
|
||||
continue
|
||||
if digikey_idx is None or count_idx is None:
|
||||
for i, part in enumerate(line):
|
||||
if 'Digikey' == part:
|
||||
digikey_idx = i
|
||||
elif 'Qty' == part:
|
||||
count_idx = i
|
||||
continue
|
||||
if len(line) < max(digikey_idx, count_idx):
|
||||
print("[WARN] line {} is missing fields".format(line_number + 1))
|
||||
continue
|
||||
part_num = line[digikey_idx]
|
||||
count = line[count_idx]
|
||||
if len(part_num) == 0:
|
||||
print("[WARN] line {} is missing part number".format(line_number + 1))
|
||||
print(parts)
|
||||
continue
|
||||
if count == 0:
|
||||
print("[WARN] line {} has zero quantity".format(line_number + 1))
|
||||
if part_num == 'NoPart':
|
||||
continue
|
||||
components.append((part_num, count))
|
||||
|
||||
with open(args.output, 'w') as f:
|
||||
# header is necessary if you don't want to miss the first part
|
||||
f.write("Digikey,Quantity\n")
|
||||
for c in components:
|
||||
f.write("\"{}\",{}\n".format(c[0], multiplier*int(c[1])))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,35 @@
|
|||
Digikey,Quantity
|
||||
"1276-1102-1-ND",19
|
||||
"1276-1043-1-ND",19
|
||||
"490-14443-1-ND",2
|
||||
"1276-1625-2-ND",2
|
||||
"712-1615-1-ND",2
|
||||
"1276-1784-1-ND",1
|
||||
"1276-1274-1-ND",1
|
||||
"587-1430-1-ND",1
|
||||
"2616-SK14-ND",1
|
||||
"732-2366-1-ND",3
|
||||
"26-DF12NC(3.0)-30DS-0.5V(51)TR-ND",1
|
||||
"H11891TR-ND",3
|
||||
"900-1051330031TR-ND",1
|
||||
"900-5034800440TR-ND",1
|
||||
"490-1140-1-ND",1
|
||||
"587-2100-2-ND",1
|
||||
"RMCF0402JT100KCT-ND",4
|
||||
"RMCF0402FT10K0CT-ND",9
|
||||
"RR05P1.0KDCT-ND",2
|
||||
"YAG3085CT-ND",2
|
||||
"A130034CT-ND",1
|
||||
"CAY16-103J4LFCT-ND",1
|
||||
"CKN11021CT-ND",1
|
||||
"EG1918-ND",1
|
||||
"AT86RF215-ZU-ND",1
|
||||
"712-1591-1-ND",1
|
||||
"712-1541-1-ND",1
|
||||
"W25Q128JVSIQ-ND",1
|
||||
"2648-SC0914(13)TR-ND",1
|
||||
"175-MAX25231ATCB/V+-ND",1
|
||||
"296-48986-1-ND",2
|
||||
"MAX9860ETG+-ND",1
|
||||
"50-ECS-260-12-37B2-CKM-TRCT-ND",1
|
||||
"XC1022CT-ND",1
|
|
|
@ -998,6 +998,9 @@
|
|||
(property "Datasheet" "" (id 3) (at 118.11 88.9 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Digikey" "175-MAX25231ATCB/V+-ND" (id 4) (at 118.11 88.9 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 4e5670bf-46e8-4d7e-bb09-cbdcb257ffeb))
|
||||
(pin "10" (uuid 4b570374-5261-476d-a4e2-0ba90f67f49e))
|
||||
(pin "11" (uuid 102b0a7d-bcfa-420e-88fc-f953a2ef4426))
|
||||
|
|
|
@ -2646,6 +2646,9 @@
|
|||
(property "Datasheet" "~" (id 3) (at 148.59 74.93 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Digikey" "26-DF12NC(3.0)-30DS-0.5V(51)TR-ND" (id 4) (at 148.59 74.93 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 5f6dca9f-981a-4233-9841-931e0614bcc8))
|
||||
(pin "10" (uuid 21b39a56-f290-494a-b9c7-29522dc3b7f3))
|
||||
(pin "11" (uuid 3e0579b5-cbd4-4ffb-98ea-79c17739a37d))
|
||||
|
@ -2885,6 +2888,9 @@
|
|||
(property "Datasheet" "" (id 3) (at 44.45 25.4 0)
|
||||
(effects (font (size 1.524 1.524)))
|
||||
)
|
||||
(property "Digikey" "AT86RF215-ZU-ND" (id 4) (at 44.45 25.4 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 0f0b79e6-3c26-4abf-8024-b8773d4a0d31))
|
||||
(pin "11" (uuid 44294ee8-9176-4b65-8a51-cb4ca41bc1e7))
|
||||
(pin "12" (uuid b177f8c0-85e5-46b1-b6ac-34a209745e8e))
|
||||
|
@ -3257,6 +3263,9 @@
|
|||
(property "Datasheet" "" (id 3) (at 66.04 101.6 0)
|
||||
(effects (font (size 1.524 1.524)))
|
||||
)
|
||||
(property "Digikey" "AT86RF215-ZU-ND" (id 4) (at 66.04 101.6 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "10" (uuid ba43296b-ec09-41d4-9482-36c1195c6913))
|
||||
(pin "14" (uuid 96b708ad-4f06-4ff0-8559-2dabe64e292c))
|
||||
(pin "15" (uuid 71e16bd7-c6bf-4cc2-961a-efdf6e1cc576))
|
||||
|
|
|
@ -2404,6 +2404,9 @@
|
|||
(property "Datasheet" "" (id 3) (at 114.3 97.79 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Digikey" "2648-SC0914(13)TR-ND" (id 4) (at 133.35 97.79 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 58209fb2-ce4b-46ce-9479-b7402ad02863))
|
||||
(pin "10" (uuid ff6482ac-2950-4e52-87a4-1263b803b77c))
|
||||
(pin "11" (uuid f1755ee6-a35d-4029-90f0-56cb0c5c0ec9))
|
||||
|
@ -2934,6 +2937,9 @@
|
|||
(property "Datasheet" "http://www.winbond.com/resource-files/w25q128jv_dtr%20revc%2003272018%20plus.pdf" (id 3) (at 71.12 74.93 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Digikey" "W25Q128JVSIQ-ND" (id 4) (at 71.12 74.93 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 68374977-0bf4-4f5f-9a24-10e90e77e966))
|
||||
(pin "2" (uuid 6e45137f-97cf-4685-844e-92b6b1cb6bda))
|
||||
(pin "3" (uuid e1bb86da-0f84-4bb2-87fd-d817a3054056))
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
"Source:","/home/kelvin/src/walkie-talkies/main/walkie-talkies.kicad_sch"
|
||||
"Date:","Mon 28 Feb 2022 08:42:39 AM EST"
|
||||
"Tool:","Eeschema (6.0.1)"
|
||||
"Generator:","/usr/share/kicad/plugins/bom_csv_grouped_by_value.py"
|
||||
"Component Count:","105"
|
||||
|
||||
"Individual Components:"
|
||||
|
||||
"Item","Qty","Reference(s)","Value","LibPart","Footprint","Datasheet","Digikey"
|
||||
"","","BT401","9V","Device:Battery","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~","NoPart"
|
||||
"","","C201","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C202","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C203","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C204","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C205","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C206","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C207","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C208","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C209","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C210","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C211","14 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","490-14443-1-ND"
|
||||
"","","C212","14 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","490-14443-1-ND"
|
||||
"","","C213","10 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1625-2-ND"
|
||||
"","","C214","10 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1625-2-ND"
|
||||
"","","C215","TBD","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","NoPart"
|
||||
"","","C301","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C302","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C303","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C304","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C305","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C306","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C307","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C308","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C309","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C310","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C311","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C312","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C313","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C314","8.2 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","712-1615-1-ND"
|
||||
"","","C315","8.2 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","712-1615-1-ND"
|
||||
"","","C401","4.7 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1784-1-ND"
|
||||
"","","C402","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C403","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C404","22 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1274-1-ND"
|
||||
"","","C501","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C502","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C503","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C504","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"","","C505","2.2 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","587-1430-1-ND"
|
||||
"","","C506","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C507","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C508","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C509","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C510","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C511","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C512","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C513","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C514","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"","","C515","DNP","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","NoPart"
|
||||
"","","D401","SK14","Device:D_Schottky","Diode_SMD:D_SMA","~","2616-SK14-ND"
|
||||
"","","FB201","120R","Device:FerriteBead_Small","Capacitor_SMD:C_0402_1005Metric","~","732-2366-1-ND"
|
||||
"","","FB301","120R","Device:FerriteBead_Small","Capacitor_SMD:C_0402_1005Metric","~","732-2366-1-ND"
|
||||
"","","FB501","120R","Device:FerriteBead_Small","Capacitor_SMD:C_0402_1005Metric","~","732-2366-1-ND"
|
||||
"","","H101","MountingHole_Pad","Mechanical:MountingHole_Pad","MountingHole:MountingHole_2.2mm_M2_ISO14580_Pad","~","NoPart"
|
||||
"","","H102","MountingHole_Pad","Mechanical:MountingHole_Pad","MountingHole:MountingHole_2.2mm_M2_ISO14580_Pad","~","NoPart"
|
||||
"","","H103","MountingHole_Pad","Mechanical:MountingHole_Pad","MountingHole:MountingHole_2.2mm_M2_ISO14580_Pad","~","NoPart"
|
||||
"","","H104","MountingHole_Pad","Mechanical:MountingHole_Pad","MountingHole:MountingHole_2.2mm_M2_ISO14580_Pad","~","NoPart"
|
||||
"","","J201","Conn_02x15_Top_Bottom","Connector_Generic:Conn_02x15_Top_Bottom","Connector_Hirose:Hirose_DF12_DF12C3.0-30DS-0.5V_2x15_P0.50mm_Vertical","~","26-DF12NC(3.0)-30DS-0.5V(51)TR-ND"
|
||||
"","","J202","UFL","Connector:Conn_Coaxial","Connector_Coaxial:U.FL_Hirose_U.FL-R-SMT-1_Vertical"," ~","H11891TR-ND"
|
||||
"","","J203","Conn_01x04","Connector_Generic:Conn_01x04","Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical","~","NoPart"
|
||||
"","","J204","UFL","Connector:Conn_Coaxial","Connector_Coaxial:U.FL_Hirose_U.FL-R-SMT-1_Vertical"," ~","H11891TR-ND"
|
||||
"","","J205","UFL","Connector:Conn_Coaxial","Connector_Coaxial:U.FL_Hirose_U.FL-R-SMT-1_Vertical"," ~","H11891TR-ND"
|
||||
"","","J301","USB_B_Micro","Connector:USB_B_Micro","Connector_USB:USB_Micro-B_Molex-105133-0031","~","900-1051330031TR-ND"
|
||||
"","","J302","Conn_02x06_Counter_Clockwise","Connector_Generic:Conn_02x06_Counter_Clockwise","Connector_PinSocket_2.54mm:PinSocket_2x06_P2.54mm_Vertical","~","NoPart"
|
||||
"","","J303","Conn_01x04","Connector_Generic:Conn_01x04","Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical","~","NoPart"
|
||||
"","","J304","Conn_02x03_Counter_Clockwise","Connector_Generic:Conn_02x03_Counter_Clockwise","Connector_PinSocket_2.54mm:PinSocket_2x03_P2.54mm_Vertical","~","NoPart"
|
||||
"","","J501","Conn_01x04","Connector_Generic:Conn_01x04","walkie-talkies:503480-0440","~","900-5034800440TR-ND"
|
||||
"","","L201","5.1 nH","Device:L_Small","Capacitor_SMD:C_0402_1005Metric","~","490-1140-1-ND"
|
||||
"","","L202","TBD","Device:L_Small","Capacitor_SMD:C_0402_1005Metric","~","NoPart"
|
||||
"","","L401","4.7 uH","Device:L_Small","Inductor_SMD:L_Taiyo-Yuden_NR-60xx_HandSoldering","~","587-2100-2-ND"
|
||||
"","","LS501","Speaker","Device:Speaker","Connector_PinHeader_2.00mm:PinHeader_1x02_P2.00mm_Vertical","~","NoPart"
|
||||
"","","R201","100kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402JT100KCT-ND"
|
||||
"","","R202","100kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402JT100KCT-ND"
|
||||
"","","R203","100kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402JT100KCT-ND"
|
||||
"","","R204","100kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402JT100KCT-ND"
|
||||
"","","R301","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R302","1kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RR05P1.0KDCT-ND"
|
||||
"","","R303","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R304","27R4","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","YAG3085CT-ND"
|
||||
"","","R305","27R4","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","YAG3085CT-ND"
|
||||
"","","R306","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R307","1kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RR05P1.0KDCT-ND"
|
||||
"","","R308","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R309","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R401","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R501","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R502","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R503","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"","","R504","4R7","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","A130034CT-ND"
|
||||
"","","RN301","10kR","Device:R_Pack04_SIP_Split","walkie-talkies:R_Array_Convex_0612","http://www.vishay.com/docs/31509/csc.pdf","CAY16-103J4LFCT-ND"
|
||||
"","","SW301","SW_Push","Switch:SW_Push","Button_Switch_SMD:SW_Push_1P1T_NO_CK_KMR2","~","CKN11021CT-ND"
|
||||
"","","SW401","EG1271","Switch:SW_SPDT","Button_Switch_THT:SW_E-Switch_EG1271_DPDT","~","EG1918-ND"
|
||||
"","","TP301","TestPoint_2Pole","Connector:TestPoint_2Pole","Connector_PinSocket_2.54mm:PinSocket_1x02_P2.54mm_Vertical","~","NoPart"
|
||||
"","","U201","AT86RF215-ZU","2022-01-19_02-44-53:AT86RF215-ZU","footprints2:AT86RF215-ZU","","AT86RF215-ZU-ND"
|
||||
"","","U202","1720BL15B0050E","Transformer:0915BM15A0001","RF_Converter:Balun_Johanson_0896BM15A0001","https://www.johansontechnology.com/datasheets/1720BL15B0050/1720BL15B0050.pdf","712-1591-1-ND"
|
||||
"","","U203","0915BM15A0001","Transformer:0915BM15A0001","RF_Converter:Balun_Johanson_0896BM15A0001","https://www.johansontechnology.com/datasheets/0915BM15A0001/0915BM15A0001.pdf","712-1541-1-ND"
|
||||
"","","U301","W25Q128JVS","Memory_Flash:W25Q128JVS","Package_SO:SOIC-8_5.23x5.23mm_P1.27mm","http://www.winbond.com/resource-files/w25q128jv_dtr%20revc%2003272018%20plus.pdf","W25Q128JVSIQ-ND"
|
||||
"","","U302","RP2040","MCU_RaspberryPi_and_Boards:RP2040","MCU_RaspberryPi_and_Boards:RP2040-QFN-56","","2648-SC0914(13)TR-ND"
|
||||
"","","U401","MAX25231ATCB","parts:MAX25231ATCB","Package_DFN_QFN:DFN-12-1EP_3x3mm_P0.45mm_EP1.66x2.38mm","","175-MAX25231ATCB/V+-ND"
|
||||
"","","U501","TLV74118PDBV","parts:TLV74118PDBV","Package_TO_SOT_SMD:SOT-23-5","https://www.ti.com/lit/ds/symlink/tlv741p.pdf","296-48986-1-ND"
|
||||
"","","U502","TLV74118PDBV","parts:TLV74118PDBV","Package_TO_SOT_SMD:SOT-23-5","https://www.ti.com/lit/ds/symlink/tlv741p.pdf","296-48986-1-ND"
|
||||
"","","U503","max9860etg+","2022-01-19_01-49-32:max9860etg+","footprints:max9860etg&plus_","","MAX9860ETG+-ND"
|
||||
"","","Y201","26 MHz 20ppm max","Device:Crystal_GND24_Small","Crystal:Crystal_SMD_2016-4Pin_2.0x1.6mm","~","50-ECS-260-12-37B2-CKM-TRCT-ND"
|
||||
"","","Y301","12 MHz ESR <50 30ppm","Device:Crystal_GND24_Small","Crystal:Crystal_SMD_0603-4Pin_6.0x3.5mm","~","XC1022CT-ND"
|
||||
|
||||
|
||||
|
||||
"Collated Components:"
|
||||
|
||||
"Item","Qty","Reference(s)","Value","LibPart","Footprint","Datasheet","Digikey"
|
||||
"1","1","BT401","9V","Device:Battery","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~","NoPart"
|
||||
"2","19","C201, C203, C208, C210, C303, C313, C403, C501, C502, C503, C506, C507, C508, C509, C510, C511, C512, C513, C514","1 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1102-1-ND"
|
||||
"3","19","C202, C204, C205, C206, C207, C209, C301, C302, C304, C305, C306, C307, C308, C309, C310, C311, C312, C402, C504","0.1 uF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1043-1-ND"
|
||||
"4","2","C211, C212","14 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","490-14443-1-ND"
|
||||
"5","2","C213, C214","10 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","1276-1625-2-ND"
|
||||
"6","1","C215","TBD","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","NoPart"
|
||||
"7","2","C314, C315","8.2 pF","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","712-1615-1-ND"
|
||||
"8","1","C401","4.7 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1784-1-ND"
|
||||
"9","1","C404","22 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","1276-1274-1-ND"
|
||||
"10","1","C505","2.2 uF","Device:C_Small","Capacitor_SMD:C_0603_1608Metric","~","587-1430-1-ND"
|
||||
"11","1","C515","DNP","Device:C_Small","Capacitor_SMD:C_0402_1005Metric","~","NoPart"
|
||||
"12","1","D401","SK14","Device:D_Schottky","Diode_SMD:D_SMA","~","2616-SK14-ND"
|
||||
"13","3","FB201, FB301, FB501","120R","Device:FerriteBead_Small","Capacitor_SMD:C_0402_1005Metric","~","732-2366-1-ND"
|
||||
"14","4","H101, H102, H103, H104","MountingHole_Pad","Mechanical:MountingHole_Pad","MountingHole:MountingHole_2.2mm_M2_ISO14580_Pad","~","NoPart"
|
||||
"15","1","J201","Conn_02x15_Top_Bottom","Connector_Generic:Conn_02x15_Top_Bottom","Connector_Hirose:Hirose_DF12_DF12C3.0-30DS-0.5V_2x15_P0.50mm_Vertical","~","26-DF12NC(3.0)-30DS-0.5V(51)TR-ND"
|
||||
"16","3","J202, J204, J205","UFL","Connector:Conn_Coaxial","Connector_Coaxial:U.FL_Hirose_U.FL-R-SMT-1_Vertical"," ~","H11891TR-ND"
|
||||
"17","2","J203, J303","Conn_01x04","Connector_Generic:Conn_01x04","Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical","~","NoPart"
|
||||
"18","1","J301","USB_B_Micro","Connector:USB_B_Micro","Connector_USB:USB_Micro-B_Molex-105133-0031","~","900-1051330031TR-ND"
|
||||
"19","1","J302","Conn_02x06_Counter_Clockwise","Connector_Generic:Conn_02x06_Counter_Clockwise","Connector_PinSocket_2.54mm:PinSocket_2x06_P2.54mm_Vertical","~","NoPart"
|
||||
"20","1","J304","Conn_02x03_Counter_Clockwise","Connector_Generic:Conn_02x03_Counter_Clockwise","Connector_PinSocket_2.54mm:PinSocket_2x03_P2.54mm_Vertical","~","NoPart"
|
||||
"21","1","J501","Conn_01x04","Connector_Generic:Conn_01x04","walkie-talkies:503480-0440","~","900-5034800440TR-ND"
|
||||
"22","1","L201","5.1 nH","Device:L_Small","Capacitor_SMD:C_0402_1005Metric","~","490-1140-1-ND"
|
||||
"23","1","L202","TBD","Device:L_Small","Capacitor_SMD:C_0402_1005Metric","~","NoPart"
|
||||
"24","1","L401","4.7 uH","Device:L_Small","Inductor_SMD:L_Taiyo-Yuden_NR-60xx_HandSoldering","~","587-2100-2-ND"
|
||||
"25","1","LS501","Speaker","Device:Speaker","Connector_PinHeader_2.00mm:PinHeader_1x02_P2.00mm_Vertical","~","NoPart"
|
||||
"26","4","R201, R202, R203, R204","100kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402JT100KCT-ND"
|
||||
"27","9","R301, R303, R306, R308, R309, R401, R501, R502, R503","10kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RMCF0402FT10K0CT-ND"
|
||||
"28","2","R302, R307","1kR","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","RR05P1.0KDCT-ND"
|
||||
"29","2","R304, R305","27R4","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","YAG3085CT-ND"
|
||||
"30","1","R504","4R7","Device:R_Small","Resistor_SMD:R_0402_1005Metric","~","A130034CT-ND"
|
||||
"31","1","RN301","10kR","Device:R_Pack04_SIP_Split","walkie-talkies:R_Array_Convex_0612","http://www.vishay.com/docs/31509/csc.pdf","CAY16-103J4LFCT-ND"
|
||||
"32","1","SW301","SW_Push","Switch:SW_Push","Button_Switch_SMD:SW_Push_1P1T_NO_CK_KMR2","~","CKN11021CT-ND"
|
||||
"33","1","SW401","EG1271","Switch:SW_SPDT","Button_Switch_THT:SW_E-Switch_EG1271_DPDT","~","EG1918-ND"
|
||||
"34","1","TP301","TestPoint_2Pole","Connector:TestPoint_2Pole","Connector_PinSocket_2.54mm:PinSocket_1x02_P2.54mm_Vertical","~","NoPart"
|
||||
"35","1","U201","AT86RF215-ZU","2022-01-19_02-44-53:AT86RF215-ZU","footprints2:AT86RF215-ZU","","AT86RF215-ZU-ND"
|
||||
"36","1","U202","1720BL15B0050E","Transformer:0915BM15A0001","RF_Converter:Balun_Johanson_0896BM15A0001","https://www.johansontechnology.com/datasheets/1720BL15B0050/1720BL15B0050.pdf","712-1591-1-ND"
|
||||
"37","1","U203","0915BM15A0001","Transformer:0915BM15A0001","RF_Converter:Balun_Johanson_0896BM15A0001","https://www.johansontechnology.com/datasheets/0915BM15A0001/0915BM15A0001.pdf","712-1541-1-ND"
|
||||
"38","1","U301","W25Q128JVS","Memory_Flash:W25Q128JVS","Package_SO:SOIC-8_5.23x5.23mm_P1.27mm","http://www.winbond.com/resource-files/w25q128jv_dtr%20revc%2003272018%20plus.pdf","W25Q128JVSIQ-ND"
|
||||
"39","1","U302","RP2040","MCU_RaspberryPi_and_Boards:RP2040","MCU_RaspberryPi_and_Boards:RP2040-QFN-56","","2648-SC0914(13)TR-ND"
|
||||
"40","1","U401","MAX25231ATCB","parts:MAX25231ATCB","Package_DFN_QFN:DFN-12-1EP_3x3mm_P0.45mm_EP1.66x2.38mm","","175-MAX25231ATCB/V+-ND"
|
||||
"41","2","U501, U502","TLV74118PDBV","parts:TLV74118PDBV","Package_TO_SOT_SMD:SOT-23-5","https://www.ti.com/lit/ds/symlink/tlv741p.pdf","296-48986-1-ND"
|
||||
"42","1","U503","max9860etg+","2022-01-19_01-49-32:max9860etg+","footprints:max9860etg&plus_","","MAX9860ETG+-ND"
|
||||
"43","1","Y201","26 MHz 20ppm max","Device:Crystal_GND24_Small","Crystal:Crystal_SMD_2016-4Pin_2.0x1.6mm","~","50-ECS-260-12-37B2-CKM-TRCT-ND"
|
||||
"44","1","Y301","12 MHz ESR <50 30ppm","Device:Crystal_GND24_Small","Crystal:Crystal_SMD_0603-4Pin_6.0x3.5mm","~","XC1022CT-ND"
|
Can't render this file because it has a wrong number of fields in line 7.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,62 @@
|
|||
# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
|
||||
|
||||
# This can be dropped into an external project to help locate this SDK
|
||||
# It should be include()ed prior to project()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
|
||||
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
|
||||
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
|
||||
set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
|
||||
message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
|
||||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
|
||||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
|
||||
|
||||
if (NOT PICO_SDK_PATH)
|
||||
if (PICO_SDK_FETCH_FROM_GIT)
|
||||
include(FetchContent)
|
||||
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
|
||||
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
||||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||
endif ()
|
||||
FetchContent_Declare(
|
||||
pico_sdk
|
||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||
GIT_TAG master
|
||||
)
|
||||
if (NOT pico_sdk)
|
||||
message("Downloading Raspberry Pi Pico SDK")
|
||||
FetchContent_Populate(pico_sdk)
|
||||
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
|
||||
endif ()
|
||||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||
else ()
|
||||
message(FATAL_ERROR
|
||||
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||
if (NOT EXISTS ${PICO_SDK_PATH})
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
||||
|
||||
include(${PICO_SDK_INIT_CMAKE_FILE})
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
#define TEST_GPIO 8
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
gpio_init(TEST_GPIO);
|
||||
gpio_set_dir(TEST_GPIO, GPIO_OUT);
|
||||
bool val = true;
|
||||
while (true) {
|
||||
gpio_put(TEST_GPIO, val);
|
||||
val = !val;
|
||||
sleep_ms(25);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
#ifndef SPI_PARSER_H_
|
||||
#define SPI_PARSER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
// probably should include stdint but I'm not sure how that'd
|
||||
// interact with Pico SDK's stuff, so I'll leave it out
|
||||
|
||||
static int maybe_nibble(char c) {
|
||||
if ((c >= 'a') && (c <= 'f')) {
|
||||
return c - 'a' + 10;
|
||||
}
|
||||
if ((c >= '0') && (c <= '9')) {
|
||||
return c - '0';
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static void spi_register_write(uint16_t address, const uint8_t *buf, uint16_t len);
|
||||
static void spi_register_read(uint16_t address, uint8_t *buf, uint16_t len);
|
||||
|
||||
static void parse_and_execute_cmd(const uint8_t* s, int c_len) {
|
||||
if (c_len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int is_write = (s[0] == 'w');
|
||||
int is_read = (s[0] == 'r');
|
||||
if (!is_write && !is_read) {
|
||||
puts("invalid cmd; no r/w");
|
||||
return;
|
||||
}
|
||||
|
||||
int offset = 1;
|
||||
|
||||
uint16_t addr = 0;
|
||||
int len = 0;
|
||||
uint8_t buf[64];
|
||||
|
||||
for (int i = 0; i < 4 && (i + 1) < c_len; i++) {
|
||||
int mn = maybe_nibble(s[i + offset]);
|
||||
if (mn < 0) {
|
||||
puts("invalid cmd; bad addr");
|
||||
return;
|
||||
}
|
||||
addr = (addr << 4) | (mn & 0xf);
|
||||
}
|
||||
|
||||
offset += 4;
|
||||
offset += 1; // skip a character, some kind of whitespace is allowed
|
||||
// variable length entry, read until
|
||||
int readlen = 0;
|
||||
int mn = maybe_nibble(s[offset]);
|
||||
while ((mn >= 0) && (offset < c_len)) {
|
||||
len = (len << 4) | (mn & 0xf);
|
||||
++offset;
|
||||
mn = maybe_nibble(s[offset]);
|
||||
}
|
||||
|
||||
if (len > sizeof(buf)) {
|
||||
len = sizeof(buf);
|
||||
}
|
||||
|
||||
const uint8_t tohex[] = "0123456789abcdef";
|
||||
|
||||
if (is_read) {
|
||||
// we're good, time to execute
|
||||
spi_register_read(addr, buf, len);
|
||||
uint8_t output_str[3*sizeof(buf) + 1];
|
||||
for (int i = 0; i < len; i++) {
|
||||
output_str[3*i] = tohex[(buf[i] >> 4) & 0xf];
|
||||
output_str[3*i + 1] = tohex[buf[i] & 0xf];
|
||||
output_str[3*i + 2] = ' ';
|
||||
}
|
||||
output_str[3*len - 1] = '\n';
|
||||
output_str[3*len] = 0;
|
||||
puts(output_str);
|
||||
return;
|
||||
}
|
||||
++offset; // skip whitespace character
|
||||
|
||||
if (is_write) {
|
||||
// parse write data one nibble at a time until it reaches the end
|
||||
// or len characters have been read
|
||||
int nibble_count = 0;
|
||||
int cur_byte = 0;
|
||||
for (; (nibble_count < 2*len) && (offset < c_len); offset++) {
|
||||
int mn = maybe_nibble(s[offset]);
|
||||
if (mn >= 0) {
|
||||
cur_byte = (cur_byte << 4) | (mn & 0xf);
|
||||
++nibble_count;
|
||||
if ((nibble_count % 2) == 0) {
|
||||
buf[(nibble_count/2) - 1] = cur_byte & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nibble_count < 2*len) {
|
||||
puts("parse error: not enough data for write\n");
|
||||
return;
|
||||
}
|
||||
|
||||
spi_register_write(addr, buf, len);
|
||||
uint8_t output_s[3*sizeof(buf) + 4 + 9];
|
||||
output_s[0] = 'w';
|
||||
output_s[1] = ' ';
|
||||
for (int i = 0; i < 4; i++) {
|
||||
output_s[2+i] = tohex[(addr >> (4*(3-i))) & 0xf];
|
||||
}
|
||||
output_s[2+4] = ' ';
|
||||
|
||||
uint8_t* output_str = output_s + 7;
|
||||
for (int i = 0; i < len; i++) {
|
||||
output_str[3*i] = tohex[(buf[i] >> 4) & 0xf];
|
||||
output_str[3*i + 1] = tohex[buf[i] & 0xf];
|
||||
output_str[3*i + 2] = ' ';
|
||||
}
|
||||
output_str[3*len - 1] = '\n';
|
||||
output_str[3*len] = 0;
|
||||
|
||||
puts(output_s);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // SPI_PARSER_H_
|
|
@ -0,0 +1,107 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "spi_parser.h"
|
||||
|
||||
int reg_written = 0;
|
||||
int reg_read = 0;
|
||||
|
||||
int reg_addr = 0;
|
||||
int reg_len = 0;
|
||||
uint8_t reg_buf[64];
|
||||
|
||||
static void spi_register_write(
|
||||
uint16_t address, const uint8_t *buf, uint16_t len) {
|
||||
reg_written = 1;
|
||||
reg_addr = address;
|
||||
reg_len = len;
|
||||
memcpy(reg_buf, buf, len);
|
||||
}
|
||||
|
||||
static void spi_register_read(uint16_t address, uint8_t *buf, uint16_t len) {
|
||||
reg_read = 1;
|
||||
reg_addr = address;
|
||||
reg_len = len;
|
||||
}
|
||||
|
||||
static void reset_reg() {
|
||||
reg_written = 0;
|
||||
reg_read = 0;
|
||||
reg_addr = 0;
|
||||
reg_len = 0;
|
||||
}
|
||||
|
||||
struct test_case {
|
||||
const uint8_t* s;
|
||||
int s_len;
|
||||
int is_read;
|
||||
int is_write;
|
||||
int addr;
|
||||
int len;
|
||||
const uint8_t* expected;
|
||||
};
|
||||
|
||||
static int check_reg(struct test_case* tc) {
|
||||
if (tc->is_read) {
|
||||
return reg_read && (reg_addr == tc->addr) && (reg_len == tc->len);
|
||||
} else if (tc->is_write) {
|
||||
return reg_written && (reg_addr == tc->addr) && (reg_len == tc->len) && (memcmp(reg_buf, tc->expected, tc->len) == 0);
|
||||
}
|
||||
return !reg_read && !reg_written;
|
||||
}
|
||||
|
||||
static void dump_expected(struct test_case* tc) {
|
||||
if (tc->is_read && !reg_read) {
|
||||
printf("read bit not set, ");
|
||||
} else if (tc->is_write && !reg_written) {
|
||||
printf("write bit not set, ");
|
||||
} else {
|
||||
if (reg_read) {
|
||||
printf("read bit SET, should\'nt be \n");
|
||||
return;
|
||||
}
|
||||
if (reg_written) {
|
||||
printf("read bit SET, should\'nt be \n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (tc->addr != reg_addr) {
|
||||
printf("got addr %04x, expected %04x, ", reg_addr, tc->addr);
|
||||
}
|
||||
if (tc->len != reg_len) {
|
||||
printf("got len %04x, expected %04x, ", reg_len, tc->len);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
const uint8_t test0[] = "r0102 1\n";
|
||||
const uint8_t test1[] = "r1234 1a\n";
|
||||
const uint8_t test2[] = "wffe7 3 11 22 33\n";
|
||||
const uint8_t test2_buf[] = {0x11, 0x22, 0x33};
|
||||
const uint8_t test3[] = "\n";
|
||||
const uint8_t test4[] = "w1ae7 8 1122 3344 ffee e0 f5\n";
|
||||
const uint8_t test4_buf[] = {0x11, 0x22, 0x33, 0x44, 0xff, 0xee, 0xe0, 0xf5};
|
||||
struct test_case cases[] = {
|
||||
{test0, sizeof(test0), 1, 0, 0x0102, 1, NULL},
|
||||
{test1, sizeof(test1), 1, 0, 0x1234, 0x1a, NULL},
|
||||
{test2, sizeof(test2), 0, 1, 0xffe7, 0x3, test2_buf},
|
||||
{test3, sizeof(test3), 0, 0, 0, 0, NULL},
|
||||
{test4, sizeof(test4), 0, 1, 0x1ae7, 8, test4_buf},
|
||||
};
|
||||
|
||||
for (int i = 0; i < sizeof(cases)/sizeof(cases[0]); i++) {
|
||||
reset_reg();
|
||||
parse_and_execute_cmd(cases[i].s, cases[i].s_len);
|
||||
if (!check_reg(&cases[i])) {
|
||||
printf("E: test failed\n");
|
||||
dump_expected(&cases[i]);
|
||||
return -1;
|
||||
} else {
|
||||
printf("I: test %d passed\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
#include "hardware/spi.h"
|
||||
|
||||
#include "spi_parser.h"
|
||||
|
||||
#define AT86_RSTN 7
|
||||
|
||||
static void cs_select() {
|
||||
asm volatile("nop \n nop \n nop");
|
||||
gpio_put(PICO_DEFAULT_SPI_CSN_PIN, 0); // Active low
|
||||
asm volatile("nop \n nop \n nop");
|
||||
}
|
||||
|
||||
static void cs_deselect() {
|
||||
asm volatile("nop \n nop \n nop");
|
||||
gpio_put(PICO_DEFAULT_SPI_CSN_PIN, 1);
|
||||
asm volatile("nop \n nop \n nop");
|
||||
}
|
||||
|
||||
static void spi_register_write(uint16_t address, const uint8_t *buf, uint16_t len) {
|
||||
uint8_t cmd[2] = { address >> 8, address };
|
||||
cmd[0] &= ~(3 << 6); // mask out top two bits
|
||||
// to set MODE to read
|
||||
cs_select();
|
||||
spi_write_blocking(PICO_DEFAULT_SPI, cmd, 2);
|
||||
spi_write_blocking(PICO_DEFAULT_SPI, buf, len);
|
||||
cs_deselect();
|
||||
}
|
||||
|
||||
static void spi_register_read(uint16_t address, uint8_t *buf, uint16_t len) {
|
||||
uint8_t cmd[2] = { address >> 8, address };
|
||||
cmd[0] &= ~(3 << 6); // mask out top two bits
|
||||
cmd[0] |= (2 << 6);
|
||||
// set MODE[0] to set to write
|
||||
cs_select();
|
||||
spi_write_blocking(PICO_DEFAULT_SPI, cmd, 2);
|
||||
spi_read_blocking(PICO_DEFAULT_SPI, 0, buf, len);
|
||||
cs_deselect();
|
||||
}
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
// 10 MHz
|
||||
spi_init(PICO_DEFAULT_SPI, 10*1000*1000);
|
||||
gpio_set_function(PICO_DEFAULT_SPI_RX_PIN, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PICO_DEFAULT_SPI_SCK_PIN, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PICO_DEFAULT_SPI_TX_PIN, GPIO_FUNC_SPI);
|
||||
|
||||
gpio_init(PICO_DEFAULT_SPI_CSN_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_SPI_CSN_PIN, GPIO_OUT);
|
||||
gpio_put(PICO_DEFAULT_SPI_CSN_PIN, 1);
|
||||
|
||||
gpio_set_dir(AT86_RSTN, GPIO_OUT);
|
||||
gpio_put(AT86_RSTN, 1);
|
||||
|
||||
uint8_t cmd[64];
|
||||
int cmd_idx = 0;
|
||||
while (true) {
|
||||
if (stdio_usb_connected()) {
|
||||
// UART parse loop
|
||||
int maybe_ch = getchar_timeout_us(1000);
|
||||
if (maybe_ch != PICO_ERROR_TIMEOUT) {
|
||||
if (maybe_ch == 0x0a) {
|
||||
cmd[cmd_idx] = 0;
|
||||
putchar(maybe_ch);
|
||||
// process command
|
||||
parse_and_execute_cmd(cmd, cmd_idx);
|
||||
cmd_idx = 0;
|
||||
} else if (maybe_ch == 0x1b) {
|
||||
putchar('^');
|
||||
putchar('\n');
|
||||
cmd_idx = 0;
|
||||
} else {
|
||||
putchar(maybe_ch);
|
||||
cmd[cmd_idx] = maybe_ch;
|
||||
if (cmd_idx < sizeof(cmd)-1) {
|
||||
++cmd_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sleep_ms(10);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
while (true) {
|
||||
printf("test!\n");
|
||||
sleep_ms(250);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue