├── LICENSE ├── README.md ├── attic └── old_tensigral_lamp_2 │ ├── MT2492.dcm │ ├── MT2492.lib │ ├── ZTS6011E-MICROPHONE.pretty │ └── ZTS6011E.kicad_mod │ ├── fp-info-cache │ ├── fp-lib-table │ ├── sepic_sim │ ├── diodes.lib │ ├── irf540.lib │ ├── sepic_sim-cache.lib │ ├── sepic_sim.kicad_pcb │ ├── sepic_sim.pro │ ├── sepic_sim.sch │ ├── sepic_sim.sch-bak │ └── sim.wbk │ ├── sym-lib-table │ ├── tensigral_lamp_hardware-cache.lib │ ├── tensigral_lamp_hardware-rescue.dcm │ ├── tensigral_lamp_hardware-rescue.lib │ ├── tensigral_lamp_hardware.kicad_pcb │ ├── tensigral_lamp_hardware.kicad_pcb-bak │ ├── tensigral_lamp_hardware.net │ ├── tensigral_lamp_hardware.pro │ ├── tensigral_lamp_hardware.sch │ ├── tensigral_lamp_hardware.sch-bak │ └── tensigral_lamp_hardware.xml ├── structuregen ├── Tensegrity.c ├── Tensegrity.exe ├── Tensegrity.svg ├── compile.bat └── drawing.svg ├── tensigral_lamp_1 ├── MT2492.dcm ├── MT2492.lib ├── firmware │ ├── Makefile │ ├── README.md │ ├── STM32F0xx_StdPeriph_Driver │ │ ├── MCD-ST Liberty SW License Agreement V2.pdf │ │ ├── Release_Notes.html │ │ ├── inc │ │ │ ├── stm32f0xx_adc.h │ │ │ ├── stm32f0xx_can.h │ │ │ ├── stm32f0xx_cec.h │ │ │ ├── stm32f0xx_comp.h │ │ │ ├── stm32f0xx_crc.h │ │ │ ├── stm32f0xx_crs.h │ │ │ ├── stm32f0xx_dac.h │ │ │ ├── stm32f0xx_dbgmcu.h │ │ │ ├── stm32f0xx_dma.h │ │ │ ├── stm32f0xx_exti.h │ │ │ ├── stm32f0xx_flash.h │ │ │ ├── stm32f0xx_gpio.h │ │ │ ├── stm32f0xx_i2c.h │ │ │ ├── stm32f0xx_iwdg.h │ │ │ ├── stm32f0xx_misc.h │ │ │ ├── stm32f0xx_pwr.h │ │ │ ├── stm32f0xx_rcc.h │ │ │ ├── stm32f0xx_rtc.h │ │ │ ├── stm32f0xx_spi.h │ │ │ ├── stm32f0xx_syscfg.h │ │ │ ├── stm32f0xx_tim.h │ │ │ ├── stm32f0xx_usart.h │ │ │ └── stm32f0xx_wwdg.h │ │ └── src │ │ │ ├── stm32f0xx_adc.c │ │ │ ├── stm32f0xx_can.c │ │ │ ├── stm32f0xx_cec.c │ │ │ ├── stm32f0xx_comp.c │ │ │ ├── stm32f0xx_crc.c │ │ │ ├── stm32f0xx_crs.c │ │ │ ├── stm32f0xx_dac.c │ │ │ ├── stm32f0xx_dbgmcu.c │ │ │ ├── stm32f0xx_dma.c │ │ │ ├── stm32f0xx_exti.c │ │ │ ├── stm32f0xx_flash.c │ │ │ ├── stm32f0xx_gpio.c │ │ │ ├── stm32f0xx_i2c.c │ │ │ ├── stm32f0xx_iwdg.c │ │ │ ├── stm32f0xx_misc.c │ │ │ ├── stm32f0xx_pwr.c │ │ │ ├── stm32f0xx_rcc.c │ │ │ ├── stm32f0xx_rtc.c │ │ │ ├── stm32f0xx_spi.c │ │ │ ├── stm32f0xx_syscfg.c │ │ │ ├── stm32f0xx_tim.c │ │ │ ├── stm32f0xx_usart.c │ │ │ └── stm32f0xx_wwdg.c │ ├── adc.c │ ├── adc.h │ ├── flash.cfg │ ├── lib │ │ ├── core_cm0.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── flash.ld │ │ ├── startup_stm32f042.s │ │ ├── startup_stm32f072.s │ │ ├── startup_stm32f0xx.s │ │ ├── stm32f0xx.h │ │ ├── system_stm32f0xx.c │ │ ├── system_stm32f0xx.h │ │ └── usb_defs.h │ ├── main.bin │ ├── main.c │ ├── systems.c │ ├── systems.h │ ├── terminal.cfg │ ├── tester │ │ ├── CNFGFunctions.c │ │ ├── CNFGFunctions.h │ │ ├── CNFGWinDriver.c │ │ ├── CNFGXDriver.c │ │ ├── Makefile │ │ ├── compile.bat │ │ ├── hidapi.c │ │ ├── hidapi.h │ │ ├── hidtest.c │ │ ├── hidtest.exe │ │ ├── os_generic.c │ │ └── os_generic.h │ ├── touch.c │ ├── touch.h │ ├── usb.c │ ├── usb.h │ ├── usbconfig.h │ ├── ws2812.c │ └── ws2812.h ├── fp-info-cache ├── tensigral_lamp_hardware-cache.lib ├── tensigral_lamp_hardware.kicad_pcb ├── tensigral_lamp_hardware.kicad_pcb-bak ├── tensigral_lamp_hardware.net ├── tensigral_lamp_hardware.pro ├── tensigral_lamp_hardware.sch ├── tensigral_lamp_hardware.sch-bak ├── tensigral_lamp_hardware.xml ├── tensigral_lamp_hardware_rev-.zip └── tensigral_lamp_hardware_rev- │ ├── render.png │ ├── tensigral_lamp_hardware-B_Cu.gbr │ ├── tensigral_lamp_hardware-B_Mask.gbr │ ├── tensigral_lamp_hardware-B_Paste.gbr │ ├── tensigral_lamp_hardware-B_SilkS.gbr │ ├── tensigral_lamp_hardware-Edge_Cuts.gbr │ ├── tensigral_lamp_hardware-F_Cu.gbr │ ├── tensigral_lamp_hardware-F_Mask.gbr │ ├── tensigral_lamp_hardware-F_Paste.gbr │ ├── tensigral_lamp_hardware-F_SilkS.gbr │ ├── tensigral_lamp_hardware-NPTH-drl_map.gbr │ ├── tensigral_lamp_hardware-NPTH.drl │ ├── tensigral_lamp_hardware-PTH-drl_map.gbr │ ├── tensigral_lamp_hardware-PTH.drl │ ├── tensigral_lamp_hardware-bottom.pos │ ├── tensigral_lamp_hardware-top.pos │ └── tensigral_lamp_hardware.csv └── tensigral_lamp_2 ├── MT2492.dcm ├── MT2492.lib ├── ZTS6011E-MICROPHONE.pretty └── ZTS6011E.kicad_mod ├── firmware ├── Makefile ├── README.md ├── STM32F0xx_StdPeriph_Driver │ ├── MCD-ST Liberty SW License Agreement V2.pdf │ ├── Release_Notes.html │ ├── inc │ │ ├── stm32f0xx_adc.h │ │ ├── stm32f0xx_can.h │ │ ├── stm32f0xx_cec.h │ │ ├── stm32f0xx_comp.h │ │ ├── stm32f0xx_crc.h │ │ ├── stm32f0xx_crs.h │ │ ├── stm32f0xx_dac.h │ │ ├── stm32f0xx_dbgmcu.h │ │ ├── stm32f0xx_dma.h │ │ ├── stm32f0xx_exti.h │ │ ├── stm32f0xx_flash.h │ │ ├── stm32f0xx_gpio.h │ │ ├── stm32f0xx_i2c.h │ │ ├── stm32f0xx_iwdg.h │ │ ├── stm32f0xx_misc.h │ │ ├── stm32f0xx_pwr.h │ │ ├── stm32f0xx_rcc.h │ │ ├── stm32f0xx_rtc.h │ │ ├── stm32f0xx_spi.h │ │ ├── stm32f0xx_syscfg.h │ │ ├── stm32f0xx_tim.h │ │ ├── stm32f0xx_usart.h │ │ └── stm32f0xx_wwdg.h │ └── src │ │ ├── stm32f0xx_adc.c │ │ ├── stm32f0xx_can.c │ │ ├── stm32f0xx_cec.c │ │ ├── stm32f0xx_comp.c │ │ ├── stm32f0xx_crc.c │ │ ├── stm32f0xx_crs.c │ │ ├── stm32f0xx_dac.c │ │ ├── stm32f0xx_dbgmcu.c │ │ ├── stm32f0xx_dma.c │ │ ├── stm32f0xx_exti.c │ │ ├── stm32f0xx_flash.c │ │ ├── stm32f0xx_gpio.c │ │ ├── stm32f0xx_i2c.c │ │ ├── stm32f0xx_iwdg.c │ │ ├── stm32f0xx_misc.c │ │ ├── stm32f0xx_pwr.c │ │ ├── stm32f0xx_rcc.c │ │ ├── stm32f0xx_rtc.c │ │ ├── stm32f0xx_spi.c │ │ ├── stm32f0xx_syscfg.c │ │ ├── stm32f0xx_tim.c │ │ ├── stm32f0xx_usart.c │ │ └── stm32f0xx_wwdg.c ├── adc.c ├── adc.h ├── flash.cfg ├── lib │ ├── core_cm0.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── flash.ld │ ├── startup_stm32f042.s │ ├── startup_stm32f072.s │ ├── startup_stm32f0xx.s │ ├── stm32f0xx.h │ ├── system_stm32f0xx.c │ ├── system_stm32f0xx.h │ └── usb_defs.h ├── main.bin ├── main.c ├── main.out ├── systems.c ├── systems.h ├── terminal.cfg ├── tester │ ├── CNFGFunctions.c │ ├── CNFGFunctions.h │ ├── CNFGFunctions.o │ ├── CNFGWinDriver.c │ ├── CNFGXDriver.c │ ├── CNFGXDriver.o │ ├── Makefile │ ├── compile.bat │ ├── hidapi.c │ ├── hidapi.h │ ├── hidapi.o │ ├── hidtest │ ├── hidtest.c │ ├── hidtest.exe │ ├── hidtest.o │ ├── os_generic.c │ ├── os_generic.h │ └── os_generic.o ├── touch.c ├── touch.h ├── usb.c ├── usb.h ├── usbconfig.h ├── ws2812.c └── ws2812.h ├── fp-info-cache ├── fp-lib-table ├── sym-lib-table ├── tensigral_lamp_hardware-cache.lib ├── tensigral_lamp_hardware-rescue.dcm ├── tensigral_lamp_hardware-rescue.lib ├── tensigral_lamp_hardware.kicad_pcb ├── tensigral_lamp_hardware.kicad_pcb-bak ├── tensigral_lamp_hardware.net ├── tensigral_lamp_hardware.pro ├── tensigral_lamp_hardware.sch ├── tensigral_lamp_hardware.sch-bak └── tensigral_lamp_hardware.xml /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 CNLohr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tensigral_lamp 2 | My PCB Tensegrity structure lamp. 3 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/MT2492.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | #End Doc Library 4 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/MT2492.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.4 2 | #encoding utf-8 3 | # 4 | # MT2492 5 | # 6 | DEF MT2492 U 0 40 Y Y 1 F N 7 | F0 "U" 0 200 50 H V C CNN 8 | F1 "MT2492" 0 -200 50 H V C CNN 9 | F2 "" 0 0 50 H I C CNN 10 | F3 "" 0 0 50 H I C CNN 11 | DRAW 12 | S -150 150 150 -150 0 1 0 f 13 | X BS 1 -250 100 100 R 50 50 1 1 I 14 | X GND 2 -250 0 100 R 50 50 1 1 I 15 | X FB 3 -250 -100 100 R 50 50 1 1 I 16 | X EN 4 250 -100 100 L 50 50 1 1 I 17 | X IN 5 250 0 100 L 50 50 1 1 I 18 | X SW 6 250 100 100 L 50 50 1 1 I 19 | ENDDRAW 20 | ENDDEF 21 | # 22 | #End Library 23 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/ZTS6011E-MICROPHONE.pretty/ZTS6011E.kicad_mod: -------------------------------------------------------------------------------- 1 | (module ZTS6011E (layer F.Cu) (tedit 5ECA24BE) 2 | (fp_text reference REF** (at 0 3) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value ZTS6011E (at 0 -2) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -2 1.5) (end -2 -1.5) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 2 -1.5) (end 2 1.5) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start -2 -1.5) (end -2.5 -1.5) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start -2.5 -1.5) (end -2.5 -1) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -2.5 -1) (end -2 -1) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -2.5 -1.5) (end -2 -1) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -2 -1) (end -2 -1.5) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start -2 -1.5) (end -2.5 -1) (layer F.SilkS) (width 0.12)) 16 | (pad 1 smd circle (at -1.2 -0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 17 | (pad 2 smd circle (at 1.2 -0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 18 | (pad 3 smd circle (at 1.2 0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 19 | (pad 4 smd circle (at -1.2 0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 20 | ) 21 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/fp-lib-table: -------------------------------------------------------------------------------- 1 | (fp_lib_table 2 | (lib (name ZTS6011E-MICROPHONE)(type KiCad)(uri ${KIPRJMOD}/ZTS6011E-MICROPHONE.pretty)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/sepic_sim/diodes.lib: -------------------------------------------------------------------------------- 1 | 2 | 3 | .MODEL D1n4007 d 4 | +IS=7.02767e-09 RS=0.0341512 N=1.80803 EG=1.05743 5 | +XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 6 | +VJ=0.7 M=0.5 FC=0.5 TT=1e-07 7 | +KF=0 AF=1 8 | 9 | 10 | 11 | 12 | .model Z5p6 D 13 | +Is=1.5n Rs=.5 Cjo=185p nbv=3 bv=6.8 Ibv=1m 14 | 15 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/sepic_sim/irf540.lib: -------------------------------------------------------------------------------- 1 | .SUBCKT irf5nj540 1 2 3 2 | ************************************** 3 | * Model Generated by MODPEX * 4 | *Copyright(c) Symmetry Design Systems* 5 | * All Rights Reserved * 6 | * UNPUBLISHED LICENSED SOFTWARE * 7 | * Contains Proprietary Information * 8 | * Which is The Property of * 9 | * SYMMETRY OR ITS LICENSORS * 10 | *Commercial Use or Resale Restricted * 11 | * by Symmetry License Agreement * 12 | ************************************** 13 | * Model generated on Nov 26, 01 14 | * MODEL FORMAT: SPICE3 15 | * Symmetry POWER MOS Model (Version 1.0) 16 | * External Node Designations 17 | * Node 1 -> Drain 18 | * Node 2 -> Gate 19 | * Node 3 -> Source 20 | M1 9 7 8 8 MM L=100u W=100u 21 | .MODEL MM NMOS LEVEL=1 IS=1e-32 22 | +VTO=4.30281 LAMBDA=0.358584 KP=38.2823 23 | +CGSO=1.31227e-05 CGDO=7.02817e-07 24 | RS 8 3 0.0398646 25 | D1 3 1 MD 26 | .MODEL MD D IS=8.24365e-12 RS=0.00750597 N=1.11224 BV=100 27 | +IBV=0.00025 EG=1.2 XTI=4 TT=0 28 | +CJO=9.16368e-10 VJ=0.748335 M=0.467972 FC=0.5 29 | RDS 3 1 1e+06 30 | RD 9 1 0.0001 31 | RG 2 7 4.87532 32 | D2 4 5 MD1 33 | * Default values used in MD1: 34 | * RS=0 EG=1.11 XTI=3.0 TT=0 35 | * BV=infinite IBV=1mA 36 | .MODEL MD1 D IS=1e-32 N=50 37 | +CJO=2.4738e-09 VJ=0.5 M=0.782135 FC=1e-08 38 | D3 0 5 MD2 39 | * Default values used in MD2: 40 | * EG=1.11 XTI=3.0 TT=0 CJO=0 41 | * BV=infinite IBV=1mA 42 | .MODEL MD2 D IS=1e-10 N=0.4 RS=3e-06 43 | RL 5 10 1 44 | FI2 7 9 VFI2 -1 45 | VFI2 4 0 0 46 | EV16 10 0 9 7 1 47 | CAP 11 10 4.837e-09 48 | FI1 7 9 VFI1 -1 49 | VFI1 11 6 0 50 | RCAP 6 10 1 51 | D4 0 6 MD3 52 | * Default values used in MD3: 53 | * EG=1.11 XTI=3.0 TT=0 CJO=0 54 | * RS=0 BV=infinite IBV=1mA 55 | .MODEL MD3 D IS=1e-10 N=0.4 56 | .ENDS irf5nj540 -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/sepic_sim/sepic_sim-cache.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.4 2 | #encoding utf-8 3 | # 4 | # Device_Q_NMOS_DGS 5 | # 6 | DEF Device_Q_NMOS_DGS Q 0 0 Y N 1 F N 7 | F0 "Q" 200 50 50 H V L CNN 8 | F1 "Device_Q_NMOS_DGS" 200 -50 50 H V L CNN 9 | F2 "" 200 100 50 H I C CNN 10 | F3 "" 0 0 50 H I C CNN 11 | DRAW 12 | C 65 0 110 0 1 10 N 13 | C 100 -70 10 0 1 0 F 14 | C 100 70 10 0 1 0 F 15 | P 2 0 1 0 10 0 -100 0 N 16 | P 2 0 1 10 10 75 10 -75 N 17 | P 2 0 1 10 30 -50 30 -90 N 18 | P 2 0 1 10 30 20 30 -20 N 19 | P 2 0 1 10 30 90 30 50 N 20 | P 2 0 1 0 100 100 100 70 N 21 | P 3 0 1 0 100 -100 100 0 30 0 N 22 | P 4 0 1 0 30 -70 130 -70 130 70 30 70 N 23 | P 4 0 1 0 40 0 80 15 80 -15 40 0 F 24 | P 4 0 1 0 110 20 115 15 145 15 150 10 N 25 | P 4 0 1 0 130 15 115 -10 145 -10 130 15 N 26 | X D 1 100 200 100 D 50 50 1 1 P 27 | X G 2 -200 0 100 R 50 50 1 1 I 28 | X S 3 100 -200 100 U 50 50 1 1 P 29 | ENDDRAW 30 | ENDDEF 31 | # 32 | # pspice_0 33 | # 34 | DEF pspice_0 #GND 0 0 Y Y 1 F P 35 | F0 "#GND" 0 -100 50 H I C CNN 36 | F1 "pspice_0" 0 -70 50 H V C CNN 37 | F2 "" 0 0 50 H I C CNN 38 | F3 "" 0 0 50 H I C CNN 39 | DRAW 40 | P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N 41 | X 0 1 0 0 0 R 40 40 1 1 W N 42 | ENDDRAW 43 | ENDDEF 44 | # 45 | # pspice_C 46 | # 47 | DEF pspice_C C 0 10 Y Y 1 F N 48 | F0 "C" 100 150 50 V V C CNN 49 | F1 "pspice_C" 100 -150 50 V V C CNN 50 | F2 "" 0 0 50 H I C CNN 51 | F3 "" 0 0 50 H I C CNN 52 | ALIAS C 53 | DRAW 54 | P 2 0 1 0 -150 -50 150 -50 N 55 | P 2 0 1 0 -150 50 150 50 N 56 | X ~ 1 0 250 200 D 40 40 1 1 P 57 | X ~ 2 0 -250 200 U 40 40 1 1 P 58 | ENDDRAW 59 | ENDDEF 60 | # 61 | # pspice_DIODE 62 | # 63 | DEF pspice_DIODE D 0 40 Y N 1 F N 64 | F0 "D" 0 150 50 H V C CNN 65 | F1 "pspice_DIODE" 0 -175 50 H V C CNN 66 | F2 "" 0 0 50 H I C CNN 67 | F3 "" 0 0 50 H I C CNN 68 | DRAW 69 | P 2 0 1 0 75 100 75 -100 N 70 | P 3 0 1 0 -75 100 -75 -100 75 0 F 71 | X K 1 -200 0 150 R 50 50 1 1 I 72 | X A 2 200 0 150 L 50 50 1 1 I 73 | ENDDRAW 74 | ENDDEF 75 | # 76 | # pspice_INDUCTOR 77 | # 78 | DEF pspice_INDUCTOR L 0 0 N Y 1 F N 79 | F0 "L" 0 100 50 H V C CNN 80 | F1 "pspice_INDUCTOR" 0 -50 50 H V C CNN 81 | F2 "" 0 0 50 H I C CNN 82 | F3 "" 0 0 50 H I C CNN 83 | DRAW 84 | A -150 0 50 1 1799 0 1 0 N -100 0 -200 0 85 | A -50 0 50 1 1799 0 1 0 N 0 0 -100 0 86 | A 50 0 50 1 1799 0 1 0 N 100 0 0 0 87 | A 150 0 50 1 1799 0 1 0 N 200 0 100 0 88 | X 1 1 -250 0 50 R 30 30 1 1 I 89 | X 2 2 250 0 50 L 30 30 1 1 I 90 | ENDDRAW 91 | ENDDEF 92 | # 93 | # pspice_R 94 | # 95 | DEF pspice_R R 0 0 N Y 1 F N 96 | F0 "R" 80 0 50 V V C CNN 97 | F1 "pspice_R" 0 0 50 V V C CNN 98 | F2 "" 0 0 50 H I C CNN 99 | F3 "" 0 0 50 H I C CNN 100 | DRAW 101 | S -40 150 40 -150 0 1 0 N 102 | X ~ 1 0 250 100 D 50 50 1 1 P 103 | X ~ 2 0 -250 100 U 50 50 1 1 P 104 | ENDDRAW 105 | ENDDEF 106 | # 107 | # pspice_VSOURCE 108 | # 109 | DEF pspice_VSOURCE V 0 40 Y Y 1 F N 110 | F0 "V" -250 300 50 H V C CNN 111 | F1 "pspice_VSOURCE" 0 0 50 H V C CNN 112 | F2 "" 0 0 50 H I C CNN 113 | F3 "" 0 0 50 H I C CNN 114 | DRAW 115 | C 0 0 200 0 1 0 N 116 | T 0 -320 -10 50 0 0 1 V Normal 0 C C 117 | P 2 0 1 0 -250 -250 -250 150 F 118 | P 3 0 1 0 -300 150 -250 250 -200 150 F 119 | X E1 1 0 300 100 D 50 50 1 1 I 120 | X E2 2 0 -300 100 U 50 50 1 1 I 121 | ENDDRAW 122 | ENDDEF 123 | # 124 | #End Library 125 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/sepic_sim/sepic_sim.kicad_pcb: -------------------------------------------------------------------------------- 1 | (kicad_pcb (version 4) (host kicad "dummy file") ) 2 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/sepic_sim/sepic_sim.pro: -------------------------------------------------------------------------------- 1 | update=22/05/2015 07:44:53 2 | version=1 3 | last_client=kicad 4 | [general] 5 | version=1 6 | RootSch= 7 | BoardNm= 8 | [pcbnew] 9 | version=1 10 | LastNetListRead= 11 | UseCmpFile=1 12 | PadDrill=0.600000000000 13 | PadDrillOvalY=0.600000000000 14 | PadSizeH=1.500000000000 15 | PadSizeV=1.500000000000 16 | PcbTextSizeV=1.500000000000 17 | PcbTextSizeH=1.500000000000 18 | PcbTextThickness=0.300000000000 19 | ModuleTextSizeV=1.000000000000 20 | ModuleTextSizeH=1.000000000000 21 | ModuleTextSizeThickness=0.150000000000 22 | SolderMaskClearance=0.000000000000 23 | SolderMaskMinWidth=0.000000000000 24 | DrawSegmentWidth=0.200000000000 25 | BoardOutlineThickness=0.100000000000 26 | ModuleOutlineThickness=0.150000000000 27 | [cvpcb] 28 | version=1 29 | NetIExt=net 30 | [eeschema] 31 | version=1 32 | LibDir= 33 | [eeschema/libraries] 34 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/sepic_sim/sim.wbk: -------------------------------------------------------------------------------- 1 | 1 2 | 9 3 | .tran 10n 100u 4 | 2 5 | 1 6 | Net-(Cmid-Pad2) 7 | V 8 | 1 9 | Net-(Cout-Pad1) 10 | V 11 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/sym-lib-table: -------------------------------------------------------------------------------- 1 | (sym_lib_table 2 | (lib (name tensigral_lamp_hardware-rescue)(type Legacy)(uri ${KIPRJMOD}/tensigral_lamp_hardware-rescue.lib)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/tensigral_lamp_hardware-rescue.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | #End Doc Library 4 | -------------------------------------------------------------------------------- /attic/old_tensigral_lamp_2/tensigral_lamp_hardware.pro: -------------------------------------------------------------------------------- 1 | update=12/24/2019 4:36:54 PM 2 | version=1 3 | last_client=kicad 4 | [general] 5 | version=1 6 | RootSch= 7 | BoardNm= 8 | [cvpcb] 9 | version=1 10 | NetIExt=net 11 | [eeschema] 12 | version=1 13 | LibDir= 14 | [eeschema/libraries] 15 | [schematic_editor] 16 | version=1 17 | PageLayoutDescrFile= 18 | PlotDirectoryName= 19 | SubpartIdSeparator=0 20 | SubpartFirstId=65 21 | NetFmtName=Pcbnew 22 | SpiceAjustPassiveValues=0 23 | LabSize=50 24 | ERC_TestSimilarLabels=1 25 | [pcbnew] 26 | version=1 27 | PageLayoutDescrFile= 28 | LastNetListRead=tensigral_lamp_hardware.net 29 | CopperLayerCount=2 30 | BoardThickness=1.6 31 | AllowMicroVias=0 32 | AllowBlindVias=0 33 | RequireCourtyardDefinitions=0 34 | ProhibitOverlappingCourtyards=1 35 | MinTrackWidth=0.3 36 | MinViaDiameter=0.4 37 | MinViaDrill=0.3 38 | MinMicroViaDiameter=0.2 39 | MinMicroViaDrill=0.09999999999999999 40 | MinHoleToHole=0.25 41 | TrackWidth1=0.3 42 | ViaDiameter1=0.8 43 | ViaDrill1=0.4 44 | dPairWidth1=0.3 45 | dPairGap1=0.25 46 | dPairViaGap1=0.25 47 | SilkLineWidth=0.12 48 | SilkTextSizeV=1 49 | SilkTextSizeH=1 50 | SilkTextSizeThickness=0.15 51 | SilkTextItalic=0 52 | SilkTextUpright=1 53 | CopperLineWidth=0.2 54 | CopperTextSizeV=1.5 55 | CopperTextSizeH=1.5 56 | CopperTextThickness=0.3 57 | CopperTextItalic=0 58 | CopperTextUpright=1 59 | EdgeCutLineWidth=0.05 60 | CourtyardLineWidth=0.05 61 | OthersLineWidth=0.15 62 | OthersTextSizeV=1 63 | OthersTextSizeH=1 64 | OthersTextSizeThickness=0.15 65 | OthersTextItalic=0 66 | OthersTextUpright=1 67 | SolderMaskClearance=0.051 68 | SolderMaskMinWidth=0.25 69 | SolderPasteClearance=0 70 | SolderPasteRatio=-0 71 | [pcbnew/Layer.F.Cu] 72 | Name=F.Cu 73 | Type=0 74 | Enabled=1 75 | [pcbnew/Layer.In1.Cu] 76 | Name=In1.Cu 77 | Type=0 78 | Enabled=0 79 | [pcbnew/Layer.In2.Cu] 80 | Name=In2.Cu 81 | Type=0 82 | Enabled=0 83 | [pcbnew/Layer.In3.Cu] 84 | Name=In3.Cu 85 | Type=0 86 | Enabled=0 87 | [pcbnew/Layer.In4.Cu] 88 | Name=In4.Cu 89 | Type=0 90 | Enabled=0 91 | [pcbnew/Layer.In5.Cu] 92 | Name=In5.Cu 93 | Type=0 94 | Enabled=0 95 | [pcbnew/Layer.In6.Cu] 96 | Name=In6.Cu 97 | Type=0 98 | Enabled=0 99 | [pcbnew/Layer.In7.Cu] 100 | Name=In7.Cu 101 | Type=0 102 | Enabled=0 103 | [pcbnew/Layer.In8.Cu] 104 | Name=In8.Cu 105 | Type=0 106 | Enabled=0 107 | [pcbnew/Layer.In9.Cu] 108 | Name=In9.Cu 109 | Type=0 110 | Enabled=0 111 | [pcbnew/Layer.In10.Cu] 112 | Name=In10.Cu 113 | Type=0 114 | Enabled=0 115 | [pcbnew/Layer.In11.Cu] 116 | Name=In11.Cu 117 | Type=0 118 | Enabled=0 119 | [pcbnew/Layer.In12.Cu] 120 | Name=In12.Cu 121 | Type=0 122 | Enabled=0 123 | [pcbnew/Layer.In13.Cu] 124 | Name=In13.Cu 125 | Type=0 126 | Enabled=0 127 | [pcbnew/Layer.In14.Cu] 128 | Name=In14.Cu 129 | Type=0 130 | Enabled=0 131 | [pcbnew/Layer.In15.Cu] 132 | Name=In15.Cu 133 | Type=0 134 | Enabled=0 135 | [pcbnew/Layer.In16.Cu] 136 | Name=In16.Cu 137 | Type=0 138 | Enabled=0 139 | [pcbnew/Layer.In17.Cu] 140 | Name=In17.Cu 141 | Type=0 142 | Enabled=0 143 | [pcbnew/Layer.In18.Cu] 144 | Name=In18.Cu 145 | Type=0 146 | Enabled=0 147 | [pcbnew/Layer.In19.Cu] 148 | Name=In19.Cu 149 | Type=0 150 | Enabled=0 151 | [pcbnew/Layer.In20.Cu] 152 | Name=In20.Cu 153 | Type=0 154 | Enabled=0 155 | [pcbnew/Layer.In21.Cu] 156 | Name=In21.Cu 157 | Type=0 158 | Enabled=0 159 | [pcbnew/Layer.In22.Cu] 160 | Name=In22.Cu 161 | Type=0 162 | Enabled=0 163 | [pcbnew/Layer.In23.Cu] 164 | Name=In23.Cu 165 | Type=0 166 | Enabled=0 167 | [pcbnew/Layer.In24.Cu] 168 | Name=In24.Cu 169 | Type=0 170 | Enabled=0 171 | [pcbnew/Layer.In25.Cu] 172 | Name=In25.Cu 173 | Type=0 174 | Enabled=0 175 | [pcbnew/Layer.In26.Cu] 176 | Name=In26.Cu 177 | Type=0 178 | Enabled=0 179 | [pcbnew/Layer.In27.Cu] 180 | Name=In27.Cu 181 | Type=0 182 | Enabled=0 183 | [pcbnew/Layer.In28.Cu] 184 | Name=In28.Cu 185 | Type=0 186 | Enabled=0 187 | [pcbnew/Layer.In29.Cu] 188 | Name=In29.Cu 189 | Type=0 190 | Enabled=0 191 | [pcbnew/Layer.In30.Cu] 192 | Name=In30.Cu 193 | Type=0 194 | Enabled=0 195 | [pcbnew/Layer.B.Cu] 196 | Name=B.Cu 197 | Type=0 198 | Enabled=1 199 | [pcbnew/Layer.B.Adhes] 200 | Enabled=1 201 | [pcbnew/Layer.F.Adhes] 202 | Enabled=1 203 | [pcbnew/Layer.B.Paste] 204 | Enabled=1 205 | [pcbnew/Layer.F.Paste] 206 | Enabled=1 207 | [pcbnew/Layer.B.SilkS] 208 | Enabled=1 209 | [pcbnew/Layer.F.SilkS] 210 | Enabled=1 211 | [pcbnew/Layer.B.Mask] 212 | Enabled=1 213 | [pcbnew/Layer.F.Mask] 214 | Enabled=1 215 | [pcbnew/Layer.Dwgs.User] 216 | Enabled=1 217 | [pcbnew/Layer.Cmts.User] 218 | Enabled=1 219 | [pcbnew/Layer.Eco1.User] 220 | Enabled=1 221 | [pcbnew/Layer.Eco2.User] 222 | Enabled=1 223 | [pcbnew/Layer.Edge.Cuts] 224 | Enabled=1 225 | [pcbnew/Layer.Margin] 226 | Enabled=1 227 | [pcbnew/Layer.B.CrtYd] 228 | Enabled=1 229 | [pcbnew/Layer.F.CrtYd] 230 | Enabled=1 231 | [pcbnew/Layer.B.Fab] 232 | Enabled=1 233 | [pcbnew/Layer.F.Fab] 234 | Enabled=1 235 | [pcbnew/Layer.Rescue] 236 | Enabled=0 237 | [pcbnew/Netclasses] 238 | [pcbnew/Netclasses/Default] 239 | Name=Default 240 | Clearance=0.199 241 | TrackWidth=0.3 242 | ViaDiameter=0.8 243 | ViaDrill=0.4 244 | uViaDiameter=0.3 245 | uViaDrill=0.1 246 | dPairWidth=0.3 247 | dPairGap=0.25 248 | dPairViaGap=0.25 249 | -------------------------------------------------------------------------------- /structuregen/Tensegrity.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define TAU (6.2831853) 5 | #define ETCH "stroke=\"#ff0000\" fill=\"none\" stroke-width=\".05mm\"" 6 | #define CUT "stroke=\"#0000ff\" fill=\"none\" stroke-width=\".05mm\"" 7 | #define MATERIAL_THICKNESS 1.6 8 | #define SWIRVINESS 14.0 9 | #define SUPPORTSY 1.1 10 | #define SUPPORTSX 1.0 11 | #define SWEEPSQUASH .88 12 | #define TIGHTEN -.1 //For offsetting sockets to make them tighter. 13 | 14 | float rs[] = { 58, 82, 86, 110 }; 15 | 16 | //CNLohr's Super Basic SVG Toolkit. 17 | int inpath = 0; 18 | int started = 0; 19 | const char * lastcolor = "black"; 20 | float centerx, centery; 21 | void StartSVG( float width, float height ) { printf( "\n" ); printf( "\n", width, height, width, height ); } 22 | void PathClose() { if( !inpath ) return; printf( "Z\" />\n" ); inpath = 0; } 23 | void PathStart( const char * props ) { if( inpath ) PathClose(); lastcolor = props; printf( "\n", x+centerx, y+centery, r, props ); } 29 | void EndSVG() { PathClose(); printf( "" ); } 30 | 31 | float smooth( float t ) { return t / sqrt(t*t+1.); } 32 | float lerp( float a, float b, float t ) { return a * (1.-t) + b * t; } 33 | void Scale2d( float * out, float * a, float scale ) { out[0] = a[0] * scale; out[1] = a[1] * scale; } 34 | void Sub2d( float * out, float * a, float * b ) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; } 35 | void Add2d( float * out, float * a, float * b ) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; } 36 | void Normalize2d( float * out, float * in ) { float mag = 1./sqrt( in[0] * in[0] + in[1] * in[1] ); Scale2d( out, in, mag ); } 37 | void Normal2d( float * out, float * in ) { out[0] = -in[1]; out[1] = in[0]; } 38 | 39 | int main() 40 | { 41 | float width = 100; 42 | float height = 100; 43 | float centerx = width/2-13; 44 | float centery = height/2; 45 | StartSVG( width, height ); 46 | 47 | int i, k; 48 | 49 | float circleposes[6]; 50 | 51 | float rotates[2] = { -38, 94.5 }; 52 | //The two arms 53 | for(k = 0; k < 2; k++ ) 54 | { 55 | float keyposx = (k?4.5:-18.5) + centerx; 56 | float keyposy = (k?-96.8:36) + centery; 57 | float ofs = k?-1.5707:0; 58 | //First make the toothed part. 59 | float am0 = rs[k*2+0]/2.0; 60 | float bm0 = rs[k*2+1]/2.0; 61 | float am = keyposx + am0; 62 | float bm = keyposx + bm0; 63 | float ha = keyposy - MATERIAL_THICKNESS/2.0; 64 | float hb = keyposy + MATERIAL_THICKNESS/2.0; 65 | 66 | printf( "\n", rotates[k] ); 67 | PathStart( CUT ); 68 | PathM( lerp( am, bm, 0.0 ), ha ); 69 | PathL( lerp( am, bm, 0.2 ), ha ); 70 | PathL( lerp( am, bm, 0.2 ), hb ); 71 | PathL( lerp( am, bm, 0.4 ), hb ); 72 | PathL( lerp( am, bm, 0.4 ), ha ); 73 | PathL( lerp( am, bm, 0.6 ), ha ); 74 | PathL( lerp( am, bm, 0.6 ), hb ); 75 | PathL( lerp( am, bm, 0.8 ), hb ); 76 | PathL( lerp( am, bm, 0.8 ), ha ); 77 | PathL( lerp( am, bm, 1.0 ), ha ); 78 | 79 | if( k == 0 ) 80 | { 81 | circleposes[k*2+0] = lerp( am, bm, 0.5 ); 82 | circleposes[k*2+1] = ha - 4; 83 | } 84 | 85 | //Then make the smooth part. 86 | for( i = 0; i < 90; i++ ) 87 | { 88 | float ai = (i)/90.0; 89 | float ang = (sin( ai * 3.14159 ) ) * 1.5707; //Goes 0...1.5707...0 90 | ang *= SWEEPSQUASH; //Don't make it a full sweep. 91 | float smoothai = smooth( (ai*2.0-1.0)*5.0 ); 92 | //smoothai needs to have bit of a bump in the middle, near zero 93 | float r = lerp( bm0, am0, smoothai * 0.5 + 0.5 ); 94 | float xv = cos(ang)*r; 95 | //fprintf( stderr, "%f %d %f\n", ai, i, r ); 96 | xv /= (1.0+ang*.1); 97 | PathL( keyposx+xv*SUPPORTSX, ha-sin(ang)*r*SUPPORTSY ); 98 | if( i == 33 ) 99 | { 100 | float lr = (bm0+am0)/2.0; 101 | float xv = cos(ang)*lr; 102 | xv /= (1.0+ang*.1); 103 | circleposes[k*2+2] = keyposx+xv*SUPPORTSX; 104 | circleposes[k*2+3] = ha-sin(ang)*lr*SUPPORTSY; 105 | } 106 | } 107 | PathClose(); 108 | printf( "\n" ); 109 | } 110 | 111 | printf( "\n", rotates[0] ); 112 | Circle( CUT, circleposes[0], circleposes[1], 2 ); 113 | Circle( CUT, circleposes[2], circleposes[3], 2 ); 114 | printf( "\n" ); 115 | printf( "\n", rotates[1] ); 116 | Circle( CUT, circleposes[4], circleposes[5], 2 ); 117 | printf( "\n" ); 118 | 119 | for( k = 0; k < 2; k++ ) 120 | { 121 | float r0 = rs[k*2+0]; 122 | float r1 = rs[k*2+1]; 123 | float tr = (r0+r1)/2; 124 | tr = tr/2.0; 125 | 126 | for( i = 0; i < 3; i++ ) 127 | { 128 | float d0 = (i+0.75)/3.0*TAU; 129 | if( i == 0 && k == 0 ) continue; 130 | Circle( CUT, sin(d0)*tr + centerx, cos(d0)*tr + centery, 2 ); 131 | } 132 | } 133 | 134 | //The insertion points in the main planes. 135 | for( i = 0; i < 2; i++ ) 136 | { 137 | float am = centerx+(i?(-rs[i*2+0]/2.0+SWIRVINESS*2):(rs[i*2+0]/2.0)); 138 | float bm = centerx+(i?(-rs[i*2+1]/2.0+SWIRVINESS*2):(rs[i*2+1]/2.0)); 139 | float ha = centery - MATERIAL_THICKNESS/2.0 + TIGHTEN; 140 | float hb = centery + MATERIAL_THICKNESS/2.0 - TIGHTEN; 141 | 142 | float ltighten = (i?1:-1) * TIGHTEN; 143 | PathStart( CUT ); 144 | PathM( lerp( am, bm, 0.2 ) - ltighten, ha ); 145 | PathL( lerp( am, bm, 0.2 ) - ltighten, hb ); 146 | PathL( lerp( am, bm, 0.4 ) + ltighten, hb ); 147 | PathL( lerp( am, bm, 0.4 ) + ltighten, ha ); 148 | PathClose(); 149 | PathStart( CUT ); 150 | PathM( lerp( am, bm, 0.6 ) - ltighten, ha ); 151 | PathL( lerp( am, bm, 0.6 ) - ltighten, hb ); 152 | PathL( lerp( am, bm, 0.8 ) + ltighten, hb ); 153 | PathL( lerp( am, bm, 0.8 ) + ltighten, ha ); 154 | PathClose(); 155 | } 156 | 157 | //The circles 158 | for( k = 1; k < 4; k++ ) 159 | { 160 | int i; 161 | float r = rs[k]; 162 | PathStart( CUT ); 163 | for( i = 0; i < 180; i++ ) 164 | { 165 | float d0 = (i+0)/180.0*TAU; 166 | float d1 = (i+1)/180.0*TAU; 167 | float r0 = r / 2.0 + cos( d0*3 ) * SWIRVINESS - SWIRVINESS; 168 | float r1 = r / 2.0 + cos( d1*3 ) * SWIRVINESS - SWIRVINESS; 169 | if( i == 0 ) PathM( r0 * cos( d0 ) + centerx, r0 * sin( d0 ) + centery ); 170 | PathL( r1 * cos( d1 ) + centerx, r1 * sin( d1 ) + centery ); 171 | } 172 | PathClose(); 173 | } 174 | 175 | 176 | EndSVG(); 177 | 178 | } 179 | -------------------------------------------------------------------------------- /structuregen/Tensegrity.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/structuregen/Tensegrity.exe -------------------------------------------------------------------------------- /structuregen/compile.bat: -------------------------------------------------------------------------------- 1 | c:\tcc\tcc Tensegrity.c -o Tensegrity.exe 2 | Tensegrity.exe > Tensegrity.svg 3 | -------------------------------------------------------------------------------- /tensigral_lamp_1/MT2492.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | #End Doc Library 4 | -------------------------------------------------------------------------------- /tensigral_lamp_1/MT2492.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.4 2 | #encoding utf-8 3 | # 4 | # MT2492 5 | # 6 | DEF MT2492 U 0 40 Y Y 1 F N 7 | F0 "U" 0 200 50 H V C CNN 8 | F1 "MT2492" 0 -200 50 H V C CNN 9 | F2 "" 0 0 50 H I C CNN 10 | F3 "" 0 0 50 H I C CNN 11 | DRAW 12 | S -150 150 150 -150 0 1 0 f 13 | X BS 1 -250 100 100 R 50 50 1 1 I 14 | X GND 2 -250 0 100 R 50 50 1 1 I 15 | X FB 3 -250 -100 100 R 50 50 1 1 I 16 | X EN 4 250 -100 100 L 50 50 1 1 I 17 | X IN 5 250 0 100 L 50 50 1 1 I 18 | X SW 6 250 100 100 L 50 50 1 1 I 19 | ENDDRAW 20 | ENDDEF 21 | # 22 | #End Library 23 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=main 2 | all: burn 3 | 4 | PREFIX=arm-none-eabi 5 | 6 | CC=$(PREFIX)-gcc 7 | LD=$(PREFIX)-gcc 8 | AS=$(PREFIX)-as 9 | CP=$(PREFIX)-objcopy 10 | OD=$(PREFIX)-objdump 11 | 12 | 13 | OBJCOPYFLAGS = -O binary 14 | 15 | BIN=$(CP) -O ihex 16 | 17 | DEFS = -DSTM32F042 18 | #DEFS := $(DEFS) -DDEBUG 19 | 20 | MCU = cortex-m0 21 | MCFLAGS = -mcpu=$(MCU) 22 | 23 | # -mthumb -mlittle-endian -mthumb-interwork 24 | 25 | STM32_INCLUDES = -Ilib -I. -ISTM32F0xx_StdPeriph_Driver/inc 26 | 27 | OPTIMIZE = -O2 -Wall # -flto -ffunction-sections -fdata-sections -Wl,--relax 28 | 29 | CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) \ 30 | -I. \ 31 | $(STM32_INCLUDES) \ 32 | -I../embeddedcommon \ 33 | -Wl,-T,lib/flash.ld 34 | 35 | CFLAGS+=-I. 36 | 37 | AFLAGS = $(MCFLAGS) 38 | 39 | SRC = main.c \ 40 | systems.c \ 41 | lib/system_stm32f0xx.c \ 42 | usb.c \ 43 | touch.c \ 44 | adc.c \ 45 | ws2812.c \ 46 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_rcc.c \ 47 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_adc.c \ 48 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_gpio.c \ 49 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_misc.c \ 50 | lib/startup_stm32f042.s 51 | 52 | 53 | burn : $(TARGET).bin 54 | openocd -f flash.cfg #-d3 55 | 56 | terminal : 57 | openocd -f terminal.cfg 58 | 59 | $(TARGET).bin : $(TARGET).out 60 | $(PREFIX)-size $^ 61 | $(CP) $(OBJCOPYFLAGS) $< $@ 62 | 63 | $(TARGET).hex: $(EXECUTABLE) 64 | $(CP) -O ihex $^ $@ 65 | 66 | $(TARGET).out : $(SRC) 67 | $(CC) $(CFLAGS) $^ -lm -lc -lnosys -o $@ 68 | 69 | clean: 70 | rm -f $(TARGET).lst $(TARGET).out $(TARGET).hex $(TARGET).bin $(TARGET).map $(EXECUTABLE) 71 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/README.md: -------------------------------------------------------------------------------- 1 | # Tensigral lamp firmware demo 2 | 3 | For operation on an STM32F042 with the tensigral lamp firmware, using SK6812-RGBW LEDs. 4 | 5 | # Prerequisites 6 | 7 | sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi openocd 8 | 9 | # Copyright Notice 10 | 11 | The code in this repository (except for ARM-only code) is Copyright 2017-2020 <>< Charles Lohr. 12 | 13 | I hope to update this license later, but I think it's going to be all 100% MIT/x11 14 | 15 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/MCD-ST Liberty SW License Agreement V2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/MCD-ST Liberty SW License Agreement V2.pdf -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/Release_Notes.html -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_CRC_H 31 | #define __STM32F0XX_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /*!< Includes ----------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup CRC_ReverseInputData 52 | * @{ 53 | */ 54 | #define CRC_ReverseInputData_No ((uint32_t)0x00000000) /*!< No reverse operation of Input Data */ 55 | #define CRC_ReverseInputData_8bits CRC_CR_REV_IN_0 /*!< Reverse operation of Input Data on 8 bits */ 56 | #define CRC_ReverseInputData_16bits CRC_CR_REV_IN_1 /*!< Reverse operation of Input Data on 16 bits */ 57 | #define CRC_ReverseInputData_32bits CRC_CR_REV_IN /*!< Reverse operation of Input Data on 32 bits */ 58 | 59 | #define IS_CRC_REVERSE_INPUT_DATA(DATA) (((DATA) == CRC_ReverseInputData_No) || \ 60 | ((DATA) == CRC_ReverseInputData_8bits) || \ 61 | ((DATA) == CRC_ReverseInputData_16bits) || \ 62 | ((DATA) == CRC_ReverseInputData_32bits)) 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup CRC_PolynomialSize 69 | * @brief Only applicable for STM32F042 and STM32F072 devices 70 | * @{ 71 | */ 72 | #define CRC_PolSize_7 CRC_CR_POLSIZE /*!< 7-bit polynomial for CRC calculation */ 73 | #define CRC_PolSize_8 CRC_CR_POLSIZE_1 /*!< 8-bit polynomial for CRC calculation */ 74 | #define CRC_PolSize_16 CRC_CR_POLSIZE_0 /*!< 16-bit polynomial for CRC calculation */ 75 | #define CRC_PolSize_32 ((uint32_t)0x00000000)/*!< 32-bit polynomial for CRC calculation */ 76 | 77 | #define IS_CRC_POL_SIZE(SIZE) (((SIZE) == CRC_PolSize_7) || \ 78 | ((SIZE) == CRC_PolSize_8) || \ 79 | ((SIZE) == CRC_PolSize_16) || \ 80 | ((SIZE) == CRC_PolSize_32)) 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /* Exported macro ------------------------------------------------------------*/ 87 | /* Exported functions ------------------------------------------------------- */ 88 | /* Configuration of the CRC computation unit **********************************/ 89 | void CRC_DeInit(void); 90 | void CRC_ResetDR(void); 91 | void CRC_PolynomialSizeSelect(uint32_t CRC_PolSize); /*!< Only applicable for STM32F042 and STM32F072 devices */ 92 | void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData); 93 | void CRC_ReverseOutputDataCmd(FunctionalState NewState); 94 | void CRC_SetInitRegister(uint32_t CRC_InitValue); 95 | void CRC_SetPolynomial(uint32_t CRC_Pol); /*!< Only applicable for STM32F042 and STM32F072 devices */ 96 | 97 | /* CRC computation ************************************************************/ 98 | uint32_t CRC_CalcCRC(uint32_t CRC_Data); 99 | uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data); /*!< Only applicable for STM32F042 and STM32F072 devices */ 100 | uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data); /*!< Only applicable for STM32F042 and STM32F072 devices */ 101 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 102 | uint32_t CRC_GetCRC(void); 103 | 104 | /* Independent register (IDR) access (write/read) *****************************/ 105 | void CRC_SetIDRegister(uint8_t CRC_IDValue); 106 | uint8_t CRC_GetIDRegister(void); 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* __STM32F0XX_CRC_H */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_DBGMCU_H 31 | #define __STM32F0XX_DBGMCU_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup DBGMCU 45 | * @{ 46 | */ 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | 51 | /** @defgroup DBGMCU_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | #define DBGMCU_STOP DBGMCU_CR_DBG_STOP 56 | #define DBGMCU_STANDBY DBGMCU_CR_DBG_STANDBY 57 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF9) == 0x00) && ((PERIPH) != 0x00)) 58 | 59 | #define DBGMCU_TIM2_STOP DBGMCU_APB1_FZ_DBG_TIM2_STOP /*!< Not applicable for STM32F030 devices */ 60 | #define DBGMCU_TIM3_STOP DBGMCU_APB1_FZ_DBG_TIM3_STOP 61 | #define DBGMCU_TIM6_STOP DBGMCU_APB1_FZ_DBG_TIM6_STOP 62 | #define DBGMCU_TIM7_STOP DBGMCU_APB1_FZ_DBG_TIM7_STOP /*!< Only applicable for STM32F072 devices */ 63 | #define DBGMCU_TIM14_STOP DBGMCU_APB1_FZ_DBG_TIM14_STOP 64 | #define DBGMCU_RTC_STOP DBGMCU_APB1_FZ_DBG_RTC_STOP 65 | #define DBGMCU_WWDG_STOP DBGMCU_APB1_FZ_DBG_WWDG_STOP 66 | #define DBGMCU_IWDG_STOP DBGMCU_APB1_FZ_DBG_IWDG_STOP 67 | #define DBGMCU_I2C1_SMBUS_TIMEOUT DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT 68 | #define DBGMCU_CAN1_STOP DBGMCU_APB1_FZ_DBG_CAN1_STOP /*!< Only applicable for STM32F042 and STM32F072 devices */ 69 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xFDDFE2CC) == 0x00) && ((PERIPH) != 0x00)) 70 | 71 | #define DBGMCU_TIM1_STOP DBGMCU_APB2_FZ_DBG_TIM1_STOP 72 | #define DBGMCU_TIM15_STOP DBGMCU_APB2_FZ_DBG_TIM15_STOP 73 | #define DBGMCU_TIM16_STOP DBGMCU_APB2_FZ_DBG_TIM16_STOP 74 | #define DBGMCU_TIM17_STOP DBGMCU_APB2_FZ_DBG_TIM17_STOP 75 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8F7FF) == 0x00) && ((PERIPH) != 0x00)) 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /* Exported macro ------------------------------------------------------------*/ 82 | /* Exported functions ------------------------------------------------------- */ 83 | 84 | /* Device and Revision ID management functions ********************************/ 85 | uint32_t DBGMCU_GetREVID(void); 86 | uint32_t DBGMCU_GetDEVID(void); 87 | 88 | /* Peripherals Configuration functions ****************************************/ 89 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 90 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 91 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* __STM32F0XX_DBGMCU_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 108 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_iwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_IWDG_H 31 | #define __STM32F0XX_IWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup IWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup IWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup IWDG_WriteAccess 56 | * @{ 57 | */ 58 | 59 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 60 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 61 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 62 | ((ACCESS) == IWDG_WriteAccess_Disable)) 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup IWDG_prescaler 68 | * @{ 69 | */ 70 | 71 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 72 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 73 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 74 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 75 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 76 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 77 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 78 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 79 | ((PRESCALER) == IWDG_Prescaler_8) || \ 80 | ((PRESCALER) == IWDG_Prescaler_16) || \ 81 | ((PRESCALER) == IWDG_Prescaler_32) || \ 82 | ((PRESCALER) == IWDG_Prescaler_64) || \ 83 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 84 | ((PRESCALER) == IWDG_Prescaler_256)) 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup IWDG_Flag 90 | * @{ 91 | */ 92 | 93 | #define IWDG_FLAG_PVU IWDG_SR_PVU 94 | #define IWDG_FLAG_RVU IWDG_SR_RVU 95 | #define IWDG_FLAG_WVU IWDG_SR_WVU 96 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU) || \ 97 | ((FLAG) == IWDG_FLAG_WVU)) 98 | 99 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 100 | 101 | #define IS_IWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0xFFF) 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /* Exported macro ------------------------------------------------------------*/ 111 | /* Exported functions ------------------------------------------------------- */ 112 | 113 | /* Prescaler and Counter configuration functions ******************************/ 114 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 115 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 116 | void IWDG_SetReload(uint16_t Reload); 117 | void IWDG_ReloadCounter(void); 118 | void IWDG_SetWindowValue(uint16_t WindowValue); 119 | 120 | /* IWDG activation function ***************************************************/ 121 | void IWDG_Enable(void); 122 | 123 | /* Flag management function ***************************************************/ 124 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* __STM32F0XX_IWDG_H */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 141 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_misc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_MISC_H 31 | #define __STM32F0XX_MISC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup MISC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | /** 51 | * @brief NVIC Init Structure definition 52 | */ 53 | 54 | typedef struct 55 | { 56 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 57 | This parameter can be a value of @ref IRQn_Type 58 | (For the complete STM32 Devices IRQ Channels list, 59 | please refer to stm32f0xx.h file) */ 60 | 61 | uint8_t NVIC_IRQChannelPriority; /*!< Specifies the priority level for the IRQ channel specified 62 | in NVIC_IRQChannel. This parameter can be a value 63 | between 0 and 3. */ 64 | 65 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 66 | will be enabled or disabled. 67 | This parameter can be set either to ENABLE or DISABLE */ 68 | } NVIC_InitTypeDef; 69 | 70 | /** 71 | * 72 | @verbatim 73 | 74 | @endverbatim 75 | */ 76 | 77 | /* Exported constants --------------------------------------------------------*/ 78 | 79 | /** @defgroup MISC_Exported_Constants 80 | * @{ 81 | */ 82 | 83 | /** @defgroup MISC_System_Low_Power 84 | * @{ 85 | */ 86 | 87 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 88 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 89 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 90 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 91 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 92 | ((LP) == NVIC_LP_SLEEPONEXIT)) 93 | /** 94 | * @} 95 | */ 96 | 97 | /** @defgroup MISC_Preemption_Priority_Group 98 | * @{ 99 | */ 100 | #define IS_NVIC_PRIORITY(PRIORITY) ((PRIORITY) < 0x04) 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | /** @defgroup MISC_SysTick_clock_source 107 | * @{ 108 | */ 109 | 110 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 111 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 112 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 113 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Exported macro ------------------------------------------------------------*/ 123 | /* Exported functions ------------------------------------------------------- */ 124 | 125 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 126 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 127 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif /* __STM32F0XX_MISC_H */ 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 144 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_wwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the WWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_WWDG_H 31 | #define __STM32F0XX_WWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup WWDG 45 | * @{ 46 | */ 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /* Exported macro ------------------------------------------------------------*/ 78 | /* Exported functions ------------------------------------------------------- */ 79 | /* Function used to set the WWDG configuration to the default reset state ****/ 80 | void WWDG_DeInit(void); 81 | 82 | /* Prescaler, Refresh window and Counter configuration functions **************/ 83 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 84 | void WWDG_SetWindowValue(uint8_t WindowValue); 85 | void WWDG_EnableIT(void); 86 | void WWDG_SetCounter(uint8_t Counter); 87 | 88 | /* WWDG activation functions **************************************************/ 89 | void WWDG_Enable(uint8_t Counter); 90 | 91 | /* Interrupts and flags management functions **********************************/ 92 | FlagStatus WWDG_GetFlagStatus(void); 93 | void WWDG_ClearFlag(void); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* __STM32F0XX_WWDG_H */ 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 110 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_misc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_misc.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file provides all the miscellaneous firmware functions (add-on 8 | * to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f0xx_misc.h" 31 | 32 | /** @addtogroup STM32F0xx_StdPeriph_Driver 33 | * @{ 34 | */ 35 | 36 | /** @defgroup MISC 37 | * @brief MISC driver modules 38 | * @{ 39 | */ 40 | 41 | /* Private typedef -----------------------------------------------------------*/ 42 | /* Private define ------------------------------------------------------------*/ 43 | /* Private macro -------------------------------------------------------------*/ 44 | /* Private variables ---------------------------------------------------------*/ 45 | /* Private function prototypes -----------------------------------------------*/ 46 | /* Private functions ---------------------------------------------------------*/ 47 | 48 | /** @defgroup MISC_Private_Functions 49 | * @{ 50 | */ 51 | /** 52 | * 53 | @verbatim 54 | ******************************************************************************* 55 | ##### Interrupts configuration functions ##### 56 | ******************************************************************************* 57 | [..] This section provide functions allowing to configure the NVIC interrupts 58 | (IRQ). The Cortex-M0 exceptions are managed by CMSIS functions. 59 | (#) Enable and Configure the priority of the selected IRQ Channels. 60 | The priority can be 0..3. 61 | 62 | -@- Lower priority values gives higher priority. 63 | -@- Priority Order: 64 | (#@) Lowest priority. 65 | (#@) Lowest hardware priority (IRQn position). 66 | 67 | @endverbatim 68 | */ 69 | 70 | /** 71 | * @brief Initializes the NVIC peripheral according to the specified 72 | * parameters in the NVIC_InitStruct. 73 | * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains 74 | * the configuration information for the specified NVIC peripheral. 75 | * @retval None 76 | */ 77 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct) 78 | { 79 | uint32_t tmppriority = 0x00; 80 | 81 | /* Check the parameters */ 82 | assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd)); 83 | assert_param(IS_NVIC_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPriority)); 84 | 85 | if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE) 86 | { 87 | /* Compute the Corresponding IRQ Priority --------------------------------*/ 88 | tmppriority = NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02]; 89 | tmppriority &= (uint32_t)(~(((uint32_t)0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8))); 90 | tmppriority |= (uint32_t)((((uint32_t)NVIC_InitStruct->NVIC_IRQChannelPriority << 6) & 0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8)); 91 | 92 | NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02] = tmppriority; 93 | 94 | /* Enable the Selected IRQ Channels --------------------------------------*/ 95 | NVIC->ISER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 96 | } 97 | else 98 | { 99 | /* Disable the Selected IRQ Channels -------------------------------------*/ 100 | NVIC->ICER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 101 | } 102 | } 103 | 104 | /** 105 | * @brief Selects the condition for the system to enter low power mode. 106 | * @param LowPowerMode: Specifies the new mode for the system to enter low power mode. 107 | * This parameter can be one of the following values: 108 | * @arg NVIC_LP_SEVONPEND: Low Power SEV on Pend. 109 | * @arg NVIC_LP_SLEEPDEEP: Low Power DEEPSLEEP request. 110 | * @arg NVIC_LP_SLEEPONEXIT: Low Power Sleep on Exit. 111 | * @param NewState: new state of LP condition. 112 | * This parameter can be: ENABLE or DISABLE. 113 | * @retval None 114 | */ 115 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState) 116 | { 117 | /* Check the parameters */ 118 | assert_param(IS_NVIC_LP(LowPowerMode)); 119 | 120 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 121 | 122 | if (NewState != DISABLE) 123 | { 124 | SCB->SCR |= LowPowerMode; 125 | } 126 | else 127 | { 128 | SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode); 129 | } 130 | } 131 | 132 | /** 133 | * @brief Configures the SysTick clock source. 134 | * @param SysTick_CLKSource: specifies the SysTick clock source. 135 | * This parameter can be one of the following values: 136 | * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. 137 | * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source. 138 | * @retval None 139 | */ 140 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) 141 | { 142 | /* Check the parameters */ 143 | assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource)); 144 | 145 | if (SysTick_CLKSource == SysTick_CLKSource_HCLK) 146 | { 147 | SysTick->CTRL |= SysTick_CLKSource_HCLK; 148 | } 149 | else 150 | { 151 | SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8; 152 | } 153 | } 154 | 155 | /** 156 | * @} 157 | */ 158 | 159 | /** 160 | * @} 161 | */ 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 168 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/adc.c: -------------------------------------------------------------------------------- 1 | #include "adc.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | /* 11 | #define ADC_IT_ADRDY ADC_IER_ADRDYIE // Doesn't trigger? 12 | #define ADC_IT_EOSMP ADC_IER_EOSMPIE //Triggers/ 13 | #define ADC_IT_EOC ADC_IER_EOCIE //Triggers. 14 | #define ADC_IT_EOSEQ ADC_IER_EOSEQIE //BINGO 15 | #define ADC_IT_OVR ADC_IER_OVRIE 16 | #define ADC_IT_AWD ADC_IER_AWDIE 17 | */ 18 | //#define ADCINT ADC_IT_EOSEQ || ADC_IT_EOSMP 19 | 20 | volatile uint16_t adcreads = 0; 21 | volatile static int adcstate = 0; 22 | volatile uint8_t adc_done = 0; 23 | volatile uint16_t ADCs[4]; 24 | 25 | 26 | #define ADCCHANS 3 //Base, 3.6v and Temp. 27 | 28 | void setup_adcs() 29 | { 30 | //int i; 31 | 32 | //From http://hung2492.blogspot.com/2015/02/lesson-5-adcdac-stm32f0.html 33 | 34 | GPIO_InitTypeDef GPIO_InitStructure; 35 | ADC_InitTypeDef ADC_InitStructure; 36 | 37 | //(#) Enable the ADC interface clock using 38 | // RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); 39 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); 40 | 41 | //(#) ADC pins configuration 42 | // (++) Enable the clock for the ADC GPIOs using the following function: 43 | // RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOx, ENABLE); 44 | // (++) Configure these ADC pins in analog mode using GPIO_Init(); 45 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); 46 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); 47 | 48 | GPIO_InitStructure.GPIO_Pin = 1<<2; //PA2 49 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; 50 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; 51 | GPIO_Init(GPIOA, &GPIO_InitStructure); 52 | 53 | GPIO_InitStructure.GPIO_Pin = 1; //PB0 (5V rail) 54 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; 55 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; 56 | GPIO_Init(GPIOB, &GPIO_InitStructure); 57 | 58 | //(#) Configure the ADC conversion resolution, data alignment, external 59 | // trigger and edge, scan direction and Enable/Disable the continuous mode 60 | // using the ADC_Init() function. 61 | ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; 62 | ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; 63 | ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; 64 | ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_TRGO; 65 | ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; 66 | ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Upward; 67 | ADC_Init(ADC1, &ADC_InitStructure); 68 | 69 | ADC_TempSensorCmd( ENABLE ); 70 | ADC_ChannelConfig(ADC1, 2, ADC_SampleTime_13_5Cycles); 71 | 72 | // Calibrate ADC before enabling 73 | ADC_GetCalibrationFactor(ADC1); 74 | //(#) Activate the ADC peripheral using ADC_Cmd() function. 75 | ADC_Cmd(ADC1, ENABLE); 76 | 77 | // Wait until ADC enabled 78 | while(ADC_GetFlagStatus(ADC1, ADC_FLAG_ADEN) == RESET); 79 | 80 | NVIC_InitTypeDef NVIC_InitStructure; 81 | NVIC_InitStructure.NVIC_IRQChannel = ADC1_IRQn; 82 | NVIC_InitStructure.NVIC_IRQChannelPriority = 3; 83 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 84 | NVIC_Init(&NVIC_InitStructure); 85 | 86 | // Enable Watchdog interrupt 87 | ADC_ITConfig(ADC1, ADC_IT_EOSEQ | ADC_IT_EOSMP, ENABLE); //Enable for end-of-conversion. 88 | 89 | adc_done = 1; 90 | 91 | send_text( "ADC Setup\n" ); 92 | } 93 | 94 | int initialize_adc_start() 95 | { 96 | if( !adc_done ) 97 | { 98 | return -1; 99 | } 100 | 101 | adc_done = 0; 102 | 103 | adcstate = 0; 104 | ADC1->CHSELR = 2; 105 | ADC_StartOfConversion(ADC1); 106 | 107 | adcstate = 1; 108 | return 0; 109 | } 110 | 111 | void __attribute__ ((interrupt("IRQ"))) ADC1_IRQHandler(void) 112 | { 113 | if(ADC1->ISR & ADC_IT_EOSMP) 114 | { 115 | //End of sample? Could switch to another mux. 116 | ADC_ClearFlag( ADC1, ADC_IT_EOSMP ); 117 | } 118 | if( ADC1->ISR & ADC_IT_EOSEQ ) 119 | { 120 | 121 | //Careful: Take as much time as possible between changing the mux values and the below part. 122 | //This gives time for the mux to switch over. 123 | 124 | ADC_ClearFlag( ADC1, ADC_IT_EOSEQ ); 125 | adcreads++; 126 | 127 | //uint8_t gotval = adcstate-1; 128 | uint16_t val = ADC1->DR; //ADC_GetConversionValue(ADC1); 129 | //uint8_t triple = (gotval>>1) * 3; 130 | 131 | //XXX Tricky: Get temperature state 132 | if( adcstate == ADCCHANS ) 133 | { 134 | #define TEMP110_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7C2)) 135 | #define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7B8)) 136 | #define VDD_CALIB ((uint16_t) (330)) 137 | #define VDD_APPLI ((uint16_t) (360)) 138 | int32_t temperature; /* will contain the temperature in degrees Celsius */ 139 | temperature = (((int32_t) val * VDD_APPLI / VDD_CALIB) - (int32_t) *TEMP30_CAL_ADDR ); 140 | temperature = temperature * (int32_t)(110 - 30) * 10; 141 | temperature = temperature / (int32_t)(*TEMP110_CAL_ADDR - *TEMP30_CAL_ADDR); 142 | val = temperature + 300; 143 | } 144 | 145 | //XXX Your value is in "val" 146 | ADCs[adcstate] = val; 147 | 148 | if( adcstate >= ADCCHANS ) 149 | { 150 | adc_done = 1; 151 | return; 152 | } 153 | 154 | adc_done = 1; 155 | ADC1->CHSELR = 2; 156 | ADC_StartOfConversion(ADC1); 157 | 158 | adcstate++; 159 | } 160 | } 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/adc.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADC_H 2 | #define _ADC_H 3 | 4 | #include 5 | 6 | void setup_adcs(); 7 | 8 | int initialize_adc_start(); 9 | 10 | extern volatile uint16_t adcreads; 11 | extern volatile uint8_t adc_done; 12 | extern volatile uint16_t ADCs[4]; 13 | 14 | #endif 15 | 16 | 17 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/flash.cfg: -------------------------------------------------------------------------------- 1 | source [find interface/stlink-v2.cfg] 2 | source [find target/stm32f0x.cfg] 3 | 4 | #reset_config none separate 5 | #reset_config srst_push_pull 6 | #separate trst_push_pull 7 | #reset_config srst_nogate 8 | 9 | init 10 | reset halt 11 | halt 20 12 | reset 13 | sleep 10 14 | reset halt 15 | flash write_image erase main.bin 0x08000000 16 | sleep 10 17 | reset 18 | sleep 10 19 | arm semihosting enable 20 | reset run 21 | sleep 10 22 | 23 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/lib/flash.ld: -------------------------------------------------------------------------------- 1 | /* Entry Point */ 2 | ENTRY(Reset_Handler) 3 | 4 | /* Tweaked for the STM32F042, 32kB of Flash + 6kB of ram! */ 5 | 6 | /* Highest address of the user mode stack */ 7 | _estack = 0x200017FF; /* end of RAM */ 8 | 9 | /* Generate a link error if heap and stack don't fit into RAM */ 10 | _Min_Heap_Size = 0x000; /* required amount of heap */ 11 | _Min_Stack_Size = 0x100; /* required amount of stack */ 12 | 13 | /* Specify the memory areas */ 14 | MEMORY 15 | { 16 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K 17 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 6K 18 | } 19 | 20 | /* Define output sections */ 21 | SECTIONS 22 | { 23 | /* The startup code goes first into FLASH */ 24 | .isr_vector : 25 | { 26 | . = ALIGN(4); 27 | KEEP(*(.isr_vector)) /* Startup code */ 28 | . = ALIGN(4); 29 | } >FLASH 30 | 31 | /* The program code and other data goes into FLASH */ 32 | .text : 33 | { 34 | . = ALIGN(4); 35 | *(.text) /* .text sections (code) */ 36 | *(.text*) /* .text* sections (code) */ 37 | *(.glue_7) /* glue arm to thumb code */ 38 | *(.glue_7t) /* glue thumb to arm code */ 39 | *(.eh_frame) 40 | 41 | KEEP (*(.init)) 42 | KEEP (*(.fini)) 43 | 44 | . = ALIGN(4); 45 | _etext = .; /* define a global symbols at end of code */ 46 | } >FLASH 47 | 48 | /* Constant data goes into FLASH */ 49 | .rodata : 50 | { 51 | . = ALIGN(4); 52 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 53 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 54 | . = ALIGN(4); 55 | } >FLASH 56 | 57 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 58 | .ARM : { 59 | __exidx_start = .; 60 | *(.ARM.exidx*) 61 | __exidx_end = .; 62 | } >FLASH 63 | 64 | .preinit_array : 65 | { 66 | PROVIDE_HIDDEN (__preinit_array_start = .); 67 | KEEP (*(.preinit_array*)) 68 | PROVIDE_HIDDEN (__preinit_array_end = .); 69 | } >FLASH 70 | .init_array : 71 | { 72 | PROVIDE_HIDDEN (__init_array_start = .); 73 | KEEP (*(SORT(.init_array.*))) 74 | KEEP (*(.init_array*)) 75 | PROVIDE_HIDDEN (__init_array_end = .); 76 | } >FLASH 77 | .fini_array : 78 | { 79 | PROVIDE_HIDDEN (__fini_array_start = .); 80 | KEEP (*(.fini_array*)) 81 | KEEP (*(SORT(.fini_array.*))) 82 | PROVIDE_HIDDEN (__fini_array_end = .); 83 | } >FLASH 84 | 85 | /* used by the startup to initialize data */ 86 | _sidata = LOADADDR(.data); 87 | 88 | /* Initialized data sections goes into RAM, load LMA copy after code */ 89 | .data : 90 | { 91 | . = ALIGN(4); 92 | _sdata = .; /* create a global symbol at data start */ 93 | *(.data) /* .data sections */ 94 | *(.data*) /* .data* sections */ 95 | 96 | . = ALIGN(4); 97 | _edata = .; /* define a global symbol at data end */ 98 | } >RAM AT> FLASH 99 | 100 | /* Uninitialized data section */ 101 | . = ALIGN(4); 102 | .bss : 103 | { 104 | /* This is used by the startup in order to initialize the .bss secion */ 105 | _sbss = .; /* define a global symbol at bss start */ 106 | __bss_start__ = _sbss; 107 | *(.bss) 108 | *(.bss*) 109 | *(COMMON) 110 | 111 | . = ALIGN(4); 112 | _ebss = .; /* define a global symbol at bss end */ 113 | __bss_end__ = _ebss; 114 | } >RAM 115 | 116 | /* User_heap_stack section, used to check that there is enough RAM left */ 117 | ._user_heap_stack : 118 | { 119 | . = ALIGN(4); 120 | PROVIDE ( end = . ); 121 | PROVIDE ( _end = . ); 122 | . = . + _Min_Heap_Size; 123 | . = . + _Min_Stack_Size; 124 | . = ALIGN(4); 125 | } >RAM 126 | 127 | 128 | /* Remove information from the standard libraries */ 129 | /DISCARD/ : 130 | { 131 | libc.a ( * ) 132 | libm.a ( * ) 133 | libgcc.a ( * ) 134 | } 135 | 136 | .ARM.attributes 0 : { *(.ARM.attributes) } 137 | } 138 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/lib/system_stm32f0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f0xx.h 4 | * @author MCD Application Team 5 | * @version V1.3.2 6 | * @date 27-March-2014 7 | * @brief CMSIS Cortex-M0 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32f0xx_system 33 | * @{ 34 | */ 35 | 36 | /** 37 | * @brief Define to prevent recursive inclusion 38 | */ 39 | #ifndef __SYSTEM_STM32F0XX_H 40 | #define __SYSTEM_STM32F0XX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @addtogroup STM32F0xx_System_Includes 47 | * @{ 48 | */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @addtogroup STM32F0xx_System_Exported_types 56 | * @{ 57 | */ 58 | 59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @addtogroup STM32F0xx_System_Exported_Constants 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @addtogroup STM32F0xx_System_Exported_Macros 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @addtogroup STM32F0xx_System_Exported_Functions 82 | * @{ 83 | */ 84 | 85 | extern void SystemInit(void); 86 | extern void SystemCoreClockUpdate(void); 87 | /** 88 | * @} 89 | */ 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /*__SYSTEM_STM32F0XX_H */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/main.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_1/firmware/main.bin -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/main.c: -------------------------------------------------------------------------------- 1 | // Copyright 2017, 2020 <>< Charles Lohr. See README.md for copyright details. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "touch.h" 9 | #include 10 | #include 11 | 12 | RCC_ClocksTypeDef RCC_Clocks; 13 | 14 | volatile int r; 15 | 16 | void SysTick_Handler(void) 17 | { 18 | r++; 19 | } 20 | 21 | void SystemBootFault( uint32_t HSEStatus, uint32_t Timeout ) 22 | { 23 | send_text( "No external oscillator.\n" ); 24 | while(1); 25 | // send_text_value( "HSEStatus:", HSEStatus ); 26 | // send_text_value( "Timeout:", Timeout ); 27 | // send_text_value( "RCC->CFGR:", RCC->CFGR ); 28 | // send_text_value( "RCC->CR:", RCC->CR ); 29 | 30 | // while(1); 31 | } 32 | 33 | void assert_param( int x ) 34 | { 35 | if( !x ) 36 | { 37 | send_text( "ASSERT\n" ); 38 | while(1); 39 | } 40 | } 41 | 42 | //All data is assumed 64-byte chunks. 43 | 44 | void CBHIDSetup( uint16_t length, uint8_t code ) 45 | { 46 | //Don't care about initial packet showing start of control transfer. 47 | 48 | //send_text_value( "L: ", length ); 49 | //send_text_value( "C: ", code ); 50 | } 51 | 52 | volatile int do_trigger_leds = 0; 53 | 54 | void CBHIDData( uint8_t paklen, uint8_t * data ) 55 | { 56 | #if 0 57 | //Byte 1 = MSB = Launch when done. --- LSBs = length of this packet in LEDs 58 | //Byte 2 = Offset, LEDs 59 | 60 | UpdateLEDs( data[1], &data[2], data[0] & 0x7f ); 61 | // send_text_value( "TV:", data[1] ); 62 | if( data[0] & 0x80 ) 63 | { 64 | TriggerDMA(); 65 | } 66 | #endif 67 | //Seems unreliable. 68 | } 69 | 70 | void CBHIDInterruptIn( uint8_t paklen, uint8_t * data ) 71 | { 72 | //Byte 1 = MSB = Launch when done. --- LSBs = length of this packet in LEDs 73 | //Byte 2 = Offset, LEDs 74 | 75 | // send_text_value( "SVD: ", data[0] ); 76 | 77 | UpdateLEDs( data[1], &data[2], data[0] & 0x7f ); 78 | // send_text_value( "TV:", data[1] ); 79 | if( data[0] & 0x80 ) 80 | { 81 | TriggerDMA(); 82 | } 83 | } 84 | 85 | 86 | uint8_t senddata[64]; 87 | 88 | int main() 89 | { 90 | int i; 91 | SystemCoreClockUpdate(); 92 | RCC_GetClocksFreq( &RCC_Clocks ); 93 | SysTick_Config( RCC_Clocks.SYSCLK_Frequency/100 ); //100 Hz. 94 | #if 0 95 | send_text_value( "SYSCLK_Frequency: ", RCC_Clocks.SYSCLK_Frequency ); 96 | send_text_value( "HCLK_Frequency: ", RCC_Clocks.HCLK_Frequency ); 97 | send_text_value( "PCLK_Frequency: ", RCC_Clocks.PCLK_Frequency ); 98 | send_text_value( "ADCCLK_Frequency: ", RCC_Clocks.ADCCLK_Frequency ); 99 | send_text_value( "CECCLK_Frequency: ", RCC_Clocks.CECCLK_Frequency ); 100 | send_text_value( "I2C1CLK_Frequency: ", RCC_Clocks.I2C1CLK_Frequency ); 101 | send_text_value( "USART1CLK_Frequency: ", RCC_Clocks.USART1CLK_Frequency ); 102 | send_text_value( "USART2CLK_Frequency: ", RCC_Clocks.USART2CLK_Frequency ); 103 | send_text_value( "USBCLK_Frequency: ", RCC_Clocks.USBCLK_Frequency ); 104 | send_text_value( "SYSCLK_Frequency: ", RCC_Clocks.SYSCLK_Frequency ); 105 | send_text_value( "RCC->CFGR:", RCC->CFGR ); 106 | send_text_value( "RCC->CR:", RCC->CR ); 107 | send_text_value( "SWS:",RCC->CFGR & RCC_CFGR_SWS); 108 | #endif 109 | 110 | ConfigureGPIO( 0x05, INOUT_OUT ); //Also do this first to enable port A. 111 | init_touch(); 112 | 113 | setup_adcs(); 114 | 115 | initialize_adc_start(); 116 | InitWSDMA(); 117 | 118 | init_usb(); 119 | 120 | for( i = 0; i < 20; i++ ) 121 | { 122 | UpdateLEDs( i, (uint8_t*)"\x60\x00\x80\xff", 1 ); 123 | } 124 | 125 | TriggerDMA(); 126 | 127 | uint8_t counts[3]; 128 | 129 | while(1) 130 | { 131 | // GPIOLatch( 0x00 ) &= ~(1<<6); 132 | //GPIOOn( 0x06 ); 133 | 134 | //GPIOOff( 0x06 ); 135 | 136 | if( usbDataOkToRead ) 137 | { 138 | CBHIDInterruptIn( 64, usb_get_out_ep_buffer() ); 139 | usb_release_out_ep_buffer(); 140 | usbDataOkToRead = 0; 141 | } 142 | if( usbDataOkToSend && adc_done ) 143 | { 144 | for( i = 0; i < 3; i++ ) 145 | { 146 | senddata[4+i*2+0] = ADCs[i] & 0xff; 147 | senddata[4+i*2+1] = (ADCs[i] >> 8) & 0xff; 148 | } 149 | 150 | senddata[0] = adcreads>>8; 151 | senddata[1] = adcreads; 152 | senddata[2]++; 153 | senddata[20] = counts[0]; 154 | senddata[21] = counts[1]; 155 | senddata[22] = counts[2]; 156 | usb_data( senddata, ENDPOINT1_SIZE ); 157 | initialize_adc_start(); 158 | 159 | run_touch( counts ); 160 | } 161 | //GPIOOn( 0x05 ); 162 | //GPIOOff( 0x05 ); 163 | //GPIOOn( 0x05 ); 164 | //GPIOOff( 0x05 ); 165 | } 166 | } 167 | 168 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/systems.c: -------------------------------------------------------------------------------- 1 | // Copyright 2017 <>< Charles Lohr. This file may be licensed under the MIT/x11 license or the NewBSD license. 2 | //Partially from colorchord. 3 | 4 | #include 5 | #include "systems.h" 6 | #include 7 | #ifdef STM32F042 8 | #include 9 | #include 10 | #include 11 | #elif defined( STM32F30X ) 12 | #include 13 | #include 14 | #include 15 | #elif defined( STM32F40_41xxx ) 16 | #include 17 | #include 18 | #include 19 | #endif 20 | 21 | #ifdef STM32F042 22 | #include 23 | #else 24 | #include 25 | #include 26 | #endif 27 | 28 | extern RCC_ClocksTypeDef RCC_Clocks; 29 | 30 | 31 | char hexfrom1( uint8_t val ) 32 | { 33 | if( val < 10 ) return '0' + val; 34 | if( val < 16 ) return 'a' - 10 + val; 35 | return '-'; 36 | } 37 | 38 | 39 | void send_openocd_command(int command, void *message) 40 | { 41 | #ifdef DEBUG 42 | asm("mov r0, %[cmd];" 43 | "mov r1, %[msg];" 44 | "bkpt #0xAB" 45 | : 46 | : [cmd] "r" (command), [msg] "r" (message) 47 | : "r0", "r1", "memory"); 48 | #endif 49 | } 50 | 51 | 52 | #ifdef DEBUG 53 | void send_text( const char * text ) 54 | { 55 | uint32_t m[] = { 2, (uint32_t)text, strlen(text) }; 56 | send_openocd_command(0x05, m); 57 | } 58 | 59 | void send_text_value( const char * text, uint32_t val ) 60 | { 61 | int len = strlen( text ); 62 | uint8_t markdata[len+14]; 63 | memcpy( markdata, text, len ); 64 | uint32_t place = 1000000000; 65 | int hit = 0; 66 | int mdp = len; 67 | while( place ) 68 | { 69 | int r = val / place; 70 | if( r || hit ) 71 | { 72 | hit = 1; 73 | markdata[mdp++] = '0' + r; 74 | val -= r * place; 75 | } 76 | place /= 10; 77 | } 78 | if( !hit ) 79 | markdata[mdp++] = '0'; 80 | markdata[mdp++] = '\n'; 81 | markdata[mdp] = 0; 82 | uint32_t m[] = { 2, (uint32_t)markdata, mdp }; 83 | send_openocd_command(0x05, m); 84 | } 85 | #endif 86 | 87 | int __attribute__((used)) _write (int fd, const void *buf, size_t count) 88 | { 89 | uint32_t m[] = { 2, (uint32_t)buf, count }; 90 | send_openocd_command(0x05, m); 91 | return count; 92 | } 93 | 94 | void __attribute__((used)) * _sbrk(int incr) { 95 | extern char _ebss; // Defined by the linker 96 | static char *heap_end; 97 | char *prev_heap_end; 98 | 99 | 100 | if (heap_end == 0) { 101 | heap_end = &_ebss; 102 | } 103 | prev_heap_end = heap_end; 104 | 105 | char * stack = (char*) __get_MSP(); 106 | if (heap_end + incr > stack) 107 | { 108 | return (void*)(-1); 109 | } 110 | 111 | heap_end += incr; 112 | 113 | return (void*) prev_heap_end; 114 | } 115 | 116 | #ifdef STM32F042 117 | void _delay_us(uint32_t us) { 118 | asm( " mov r0, %[num];" 119 | "1: sub r0, r0, #1;" 120 | " bne 1b" 121 | : 122 | : [num] "r" (us*(RCC_Clocks.HCLK_Frequency/4000000)) ); 123 | } 124 | 125 | #else 126 | //Not available on Cortex-M0 127 | //For precise timing. 128 | volatile unsigned int *DWT_CYCCNT = (volatile unsigned int *)0xE0001004; //address of the register 129 | volatile unsigned int *SCB_DEMCR = (volatile unsigned int *)0xE000EDFC; //address of the register 130 | volatile unsigned int *DWT_CONTROL = (volatile unsigned int *)0xE0001000; //address of the register 131 | 132 | void _delay_us(uint32_t us) { 133 | if( us ) us--; //Approximate extra overhead time. 134 | us *= RCC_Clocks.HCLK_Frequency/1000000; 135 | *SCB_DEMCR = *SCB_DEMCR | 0x01000000; 136 | *DWT_CYCCNT = 0; // reset the counter 137 | *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter 138 | while( *DWT_CYCCNT < us ); 139 | } 140 | #endif 141 | 142 | #ifndef STM32F042 143 | void ConfigureLED() 144 | { 145 | ConfigureGPIO( LEDPIN, INOUT_OUT ); 146 | } 147 | #endif 148 | 149 | uint8_t GetGPIOFromString( const char * str ) 150 | { 151 | int mode = 0; 152 | int port = -1; 153 | int pin = -1; 154 | const char * st = str; 155 | for( ; *st; st++ ) 156 | { 157 | char c = *st; 158 | if( mode == 0 ) 159 | { 160 | if( c >= 'A' && c <= 'F' ) 161 | { 162 | port = c - 'A'; 163 | mode = 2; 164 | } 165 | else if( c >= 'a' && c <= 'f' ) 166 | { 167 | port = c - 'a'; 168 | mode = 2; 169 | } 170 | } 171 | else if( mode == 2 ) 172 | { 173 | if( c >= '0' && c <= '9' ) 174 | { 175 | pin = 0; 176 | mode = 3; 177 | } 178 | } 179 | 180 | if( mode == 3 ) 181 | { 182 | if( c >= '0' && c <= '9' ) 183 | { 184 | pin = pin * 10; 185 | pin+= c - '0'; 186 | } 187 | else 188 | { 189 | break; 190 | } 191 | } 192 | } 193 | 194 | if( port > 0 && pin > 0 && port <= 6 && pin <= 15) 195 | { 196 | return (port<<4)|pin; 197 | } 198 | else 199 | { 200 | return 0xff; 201 | } 202 | } 203 | 204 | 205 | void ConfigureGPIO( uint8_t gpio, int parameters ) 206 | { 207 | GPIO_InitTypeDef GPIO_InitStructure; 208 | 209 | #ifdef STM32F30X 210 | 211 | /* Enable the GPIO_LED Clock */ 212 | RCC_AHBPeriphClockCmd( 1<<(17+(gpio>>4)), ENABLE); 213 | 214 | if( parameters & DEFAULT_VALUE_FLAG ) 215 | { 216 | GPIOOn( gpio ); 217 | } 218 | else 219 | { 220 | GPIOOff( gpio ); 221 | } 222 | 223 | /* Configure the GPIO_LED pin */ 224 | GPIO_InitStructure.GPIO_Pin = 1<<(gpio&0xf); 225 | GPIO_InitStructure.GPIO_Mode = (parameters&INOUT_FLAG)?GPIO_Mode_OUT:GPIO_Mode_IN; 226 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 227 | GPIO_InitStructure.GPIO_PuPd = (parameters&PUPD_FLAG)?( (parameters&PUPD_UP)?GPIO_PuPd_UP:GPIO_PuPd_DOWN ):GPIO_PuPd_NOPULL; 228 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 229 | GPIO_Init(GPIOOf(gpio), &GPIO_InitStructure); 230 | 231 | #elif defined( STM32F40_41xxx ) 232 | 233 | 234 | /* Enable the GPIO_LED Clock */ 235 | RCC_AHB1PeriphClockCmd( 1<<((gpio>>4)), ENABLE); 236 | 237 | if( parameters & DEFAULT_VALUE_FLAG ) 238 | { 239 | GPIOOn( gpio ); 240 | } 241 | else 242 | { 243 | GPIOOff( gpio ); 244 | } 245 | 246 | /* Configure the GPIO_LED pin */ 247 | GPIO_InitStructure.GPIO_Pin = 1<<(gpio&0xf); 248 | GPIO_InitStructure.GPIO_Mode = (parameters&INOUT_FLAG)?GPIO_Mode_OUT:GPIO_Mode_IN; 249 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 250 | GPIO_InitStructure.GPIO_PuPd = (parameters&PUPD_FLAG)?( (parameters&PUPD_UP)?GPIO_PuPd_UP:GPIO_PuPd_DOWN ):GPIO_PuPd_NOPULL; 251 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 252 | GPIO_Init(GPIOOf(gpio), &GPIO_InitStructure); 253 | 254 | #elif defined( STM32F042 ) 255 | 256 | RCC_AHBPeriphClockCmd( (gpio&0x10)?RCC_AHBPeriph_GPIOB:RCC_AHBPeriph_GPIOA, ENABLE ); 257 | if( parameters & DEFAULT_VALUE_FLAG ) 258 | { 259 | GPIOOn( gpio ); 260 | } 261 | else 262 | { 263 | GPIOOff( gpio ); 264 | } 265 | 266 | /* Configure the GPIO_LED pin */ 267 | GPIO_InitStructure.GPIO_Pin = 1<<(gpio&0xf); 268 | GPIO_InitStructure.GPIO_Mode = (parameters&INOUT_FLAG)?GPIO_Mode_OUT:GPIO_Mode_IN; 269 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 270 | GPIO_InitStructure.GPIO_PuPd = (parameters&PUPD_FLAG)?( (parameters&PUPD_UP)?GPIO_PuPd_UP:GPIO_PuPd_DOWN ):GPIO_PuPd_NOPULL; 271 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 272 | GPIO_Init(GPIOOf(gpio), &GPIO_InitStructure); 273 | 274 | #else 275 | #error Undefined processor. 276 | #endif 277 | 278 | } 279 | 280 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/systems.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 <>< Charles Lohr. This file may be licensed under the MIT/x11 license or the NewBSD license. 2 | 3 | //Partially from colorchord. 4 | 5 | #ifndef _SYSTEMS_H 6 | #define _SYSTEMS_H 7 | 8 | 9 | #ifdef STM32F30X 10 | #include 11 | #elif defined( STM32F40_41xxx ) 12 | #include 13 | #elif defined( STM32F042 ) 14 | #include 15 | #endif 16 | 17 | 18 | void send_openocd_command(int command, void *message); 19 | 20 | #ifdef DEBUG 21 | void send_text( const char * text ); 22 | void send_text_value( const char * text, uint32_t val ); 23 | #else 24 | //No debug = no printfing. 25 | #define send_text( x ) 26 | #define send_text_value( x, y ) 27 | #endif 28 | 29 | void _delay_us( uint32_t us); 30 | char hexfrom1( uint8_t val ); 31 | 32 | 33 | typedef uint8_t gpio; 34 | 35 | gpio GetGPIOFromString( const char * str ); //i.e. "A4" or "PA5" or "B.7" 36 | #define GPIO_FROM_NUMS( port, pin ) (((port)<<4 ) | (pin)) 37 | 38 | #define DEFAULT_VALUE_FLAG 0x00000001 39 | #define DEFAULT_ON 0x00000001 40 | #define DEFAULT_OFF 0x00000000 41 | 42 | #define INOUT_FLAG 0x00000002 43 | #define INOUT_OUT 0x00000002 44 | #define INOUT_IN 0x00000000 45 | 46 | #define PUPD_FLAG 0x0000000C 47 | #define PUPD_NONE 0x00000000 48 | #define PUPD_UP 0x00000004 49 | #define PUPD_DOWN 0x00000008 50 | 51 | #define GPALTFUNCTION_FLAGS 0x0000ff00 52 | 53 | void ConfigureGPIO( gpio gpio, int parameters ); 54 | 55 | 56 | 57 | #ifdef STM32F30X 58 | #define GPIOOf(x) ((GPIO_TypeDef *) ((((x)>>4)<=6)?(AHB2PERIPH_BASE+0x400*((x)>>4)):0x60000000) ) 59 | #elif defined( STM32F40_41xxx ) 60 | #define GPIOOf(x) ((GPIO_TypeDef *) ((((x)>>4)<=6)?(AHB1PERIPH_BASE+0x400*((x)>>4)):0x60000000) ) 61 | #elif defined( STM32F042 ) 62 | #define GPIOOf(x) ((GPIO_TypeDef *) ((AHB2PERIPH_BASE + 0x00000400 * ((x)>>4) )) ) 63 | #endif 64 | 65 | #define GPIOPin(x) ((1<<((x)&0x0f))) 66 | #define GPIOLatch(x) GPIOOf(x)->ODR 67 | 68 | #ifdef STM32F30X 69 | #define GPIOOn(x) GPIOOf(x)->BSRR = (1<<((x)&0x0f)); 70 | #define GPIOOff(x) GPIOOf(x)->BRR = (1<<((x)&0x0f)); 71 | #elif defined( STM32F40_41xxx ) 72 | #define GPIOOn(x) GPIOOf(x)->BSRRH = (1<<((x)&0x0f)); 73 | #define GPIOOff(x) GPIOOf(x)->BSRRL = (1<<((x)&0x0f)); 74 | #elif defined( STM32F042 ) 75 | #define GPIOOn(x) GPIOOf(x)->BSRR = (1<<((x)&0x0f)); 76 | #define GPIOOff(x) GPIOOf(x)->BRR = (1<<((x)&0x0f)); 77 | #else 78 | #error Undefined architecture 79 | #endif 80 | 81 | #ifndef STM32F042 82 | 83 | #ifdef STM32F30X 84 | #define LEDPIN 0x18 85 | #elif defined( STM32F40_41xxx ) 86 | #define LEDPIN 0x3f 87 | #endif 88 | 89 | void ConfigureLED(); 90 | #define LED_TOGGLE {GPIOOf(LEDPIN)->ODR^=(1<<((LEDPIN)&0x0f));} 91 | #define LED_ON GPIOOn(LEDPIN) 92 | #define LED_OFF GPIOOff(LEDPIN) 93 | 94 | #endif 95 | 96 | #ifndef _BV 97 | #define _BV(x) (1<<(x)) 98 | #endif 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/terminal.cfg: -------------------------------------------------------------------------------- 1 | source [find interface/stlink-v2.cfg] 2 | source [find target/stm32f0x.cfg] 3 | 4 | #reset_config none separate 5 | #reset_config srst_push_pull 6 | #separate trst_push_pull 7 | 8 | reset_config srst_nogate 9 | init 10 | 11 | #to manually recover, unplug, connect reset hard to ground. 12 | # replug. 13 | # 'reset halt'. 14 | # unplug reset, plug into programmer's reset. 15 | 16 | # flash erase_sector 0 0 100 17 | # flash write_image erase main.bin 0x08000000 18 | 19 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/tester/CNFGFunctions.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2011, 2017 <>< Charles Lohr - Under the MIT/x11 or NewBSD License you choose. 2 | 3 | #ifndef _DRAWFUCNTIONS_H 4 | #define _DRAWFUCNTIONS_H 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #include 11 | 12 | typedef struct { 13 | short x, y; 14 | } RDPoint; 15 | 16 | extern int CNFGPenX, CNFGPenY; 17 | extern uint32_t CNFGBGColor; 18 | extern uint32_t CNFGLastColor; 19 | extern uint32_t CNFGDialogColor; //background for boxes 20 | 21 | void CNFGDrawText( const char * text, int scale ); 22 | void CNFGDrawBox( int x1, int y1, int x2, int y2 ); 23 | void CNFGGetTextExtents( const char * text, int * w, int * h, int textsize ); 24 | void CNFGDrawTextbox( int x, int y, const char * text, int textsize ); //ignores pen. 25 | 26 | //To be provided by driver. 27 | uint32_t CNFGColor( uint32_t RGB ); 28 | void CNFGUpdateScreenWithBitmap( unsigned long * data, int w, int h ); 29 | void CNFGTackPixel( short x1, short y1 ); 30 | void CNFGTackSegment( short x1, short y1, short x2, short y2 ); 31 | void CNFGTackRectangle( short x1, short y1, short x2, short y2 ); 32 | void CNFGTackPoly( RDPoint * points, int verts ); 33 | void CNFGClearFrame(); 34 | void CNFGSwapBuffers(); 35 | 36 | void CNFGGetDimensions( short * x, short * y ); 37 | void CNFGSetup( const char * WindowName, int w, int h ); 38 | void CNFGSetupFullscreen( const char * WindowName, int screen_number ); 39 | void CNFGHandleInput(); 40 | 41 | 42 | //You must provide: 43 | void HandleKey( int keycode, int bDown ); 44 | void HandleButton( int x, int y, int button, int bDown ); 45 | void HandleMotion( int x, int y, int mask ); 46 | void HandleDestroy(); 47 | 48 | 49 | //Internal function for resizing rasterizer for rasterizer-mode. 50 | void CNFGInternalResize( short x, short y ); //don't call this. 51 | 52 | //Not available on all systems. Use The OGL portion with care. 53 | #ifdef CNFGOGL 54 | void CNFGSetVSync( int vson ); 55 | void * CNFGGetExtension( const char * extname ); 56 | #endif 57 | 58 | #ifdef __cplusplus 59 | }; 60 | #endif 61 | 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/tester/Makefile: -------------------------------------------------------------------------------- 1 | all : hidtest hidtest.exe 2 | 3 | hidtest.exe : hidtest.c hidapi.c os_generic.c CNFGFunctions.c CNFGWinDriver.c 4 | i686-w64-mingw32-gcc -o $@ $^ $(CFLAGS) -lsetupapi -lgdi32 5 | 6 | hidtest : hidtest.o hidapi.o os_generic.o CNFGFunctions.o CNFGXDriver.o 7 | g++ -o $@ $^ -lusb-1.0 -ludev -lpthread -lX11 8 | 9 | clean : 10 | rm -rf *.o *~ hidtest 11 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/tester/compile.bat: -------------------------------------------------------------------------------- 1 | c:\tcc\tcc.exe -o hidtest.exe hidtest.c hidapi.c CNFGFunctions.c CNFGWinDriver.c os_generic.c -DWINDOWS -DTCC -lgdi32 -lsetupapi -luser32 2 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/tester/hidtest.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_1/firmware/tester/hidtest.exe -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/tester/os_generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _OS_GENERIC_H 2 | #define _OS_GENERIC_H 3 | 4 | #if defined( WIN32 ) || defined (WINDOWS) || defined( _WIN32) 5 | #define USE_WINDOWS 6 | #endif 7 | 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | //Things that shouldn't be macro'd 14 | double OGGetAbsoluteTime(); 15 | void OGSleep( int is ); 16 | void OGUSleep( int ius ); 17 | double OGGetFileTime( const char * file ); 18 | 19 | //Threads and Mutices 20 | typedef void* og_thread_t; 21 | typedef void* og_mutex_t; 22 | typedef void* og_sema_t; 23 | 24 | og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ); 25 | void * OGJoinThread( og_thread_t ot ); 26 | void OGCancelThread( og_thread_t ot ); 27 | 28 | //Always a recursive mutex. 29 | og_mutex_t OGCreateMutex(); 30 | void OGLockMutex( og_mutex_t om ); 31 | void OGUnlockMutex( og_mutex_t om ); 32 | void OGDeleteMutex( og_mutex_t om ); 33 | 34 | //Always a semaphore 35 | og_sema_t OGCreateSema(); //Create a semaphore, comes locked initially. NOTE: Max count is 32767 36 | void OGLockSema( og_sema_t os ); 37 | int OGGetSema( og_sema_t os ); //if <0 there was a failure. 38 | void OGUnlockSema( og_sema_t os ); 39 | void OGDeleteSema( og_sema_t os ); 40 | 41 | #ifdef __cplusplus 42 | }; 43 | #endif 44 | 45 | 46 | 47 | #endif 48 | 49 | 50 | //Date Stamp: 2012-02-15 51 | 52 | /* 53 | NOTE: Portions (namely the top section) are part of headers from other 54 | sources. 55 | 56 | Copyright (c) 2011-2012 <>< Charles Lohr 57 | 58 | Permission is hereby granted, free of charge, to any person obtaining a 59 | copy of this software and associated documentation files (the "Software"), 60 | to deal in the Software without restriction, including without limitation 61 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 62 | and/or sell copies of the Software, and to permit persons to whom the 63 | Software is furnished to do so, subject to the following conditions: 64 | 65 | The above copyright notice and this permission notice shall be included in 66 | all copies or substantial portions of this file. 67 | 68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 70 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 71 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 72 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 73 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 74 | IN THE SOFTWARE. 75 | */ 76 | 77 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/touch.c: -------------------------------------------------------------------------------- 1 | #include "touch.h" 2 | #include "systems.h" 3 | 4 | uint8_t touch_calib[3]; 5 | uint8_t done_startup; 6 | 7 | //DO_PD means we use the internal pull-down resistors to measure the capacitance 8 | //if we define this to be 0, then it will use the internal pull-up resistors. 9 | //I am still experimenting with both options to see which is better overall and 10 | //in a lot of situations. 11 | 12 | #define DO_PD 1 13 | 14 | 15 | //The methodology is we are trying to measure the capacitance of a pad. This is 16 | //done by driving the pad high, then, releasing the pad. If the capacitance is 17 | //low, then, the pad's voltage will very quickly drop. If the capacitance is high 18 | //then the pad's voltage will drop much more slowly. If your finger is not present 19 | //then the voltage will cross the 0 threshhold very quicky. If your finger is present 20 | //it will take much longer, sometimes as long as a microsecond! 21 | // 22 | // v Stop driving pin high 23 | // V ------ 24 | // O | 25 | // L \ 26 | // T \ 27 | // A \ 28 | // G \ 29 | // E ------------------------------- Threshhold for measuring zero 30 | // \ 31 | // \ 32 | // ^ ------- ^ The time we're measuring 33 | 34 | void init_touch() 35 | { 36 | //This demo shows the use of 3 touch buttons, but really, an unlimited number 37 | //of touch buttons can be used using this method as long as they're all on the 38 | //same IO section. I.e. This demo uses Port A. 39 | 40 | //I use "systems.c" of which an example can be found in the ColorChord Embedded 41 | //codebase. The rest of this specific project will be made public soon. But 42 | //you can use the HAL if you absolutely need to. This is just to turn on the 43 | //port's AHB, and enable the IO as an IO push-pull port will pull-down or pull 44 | //up resistors. 45 | #if DO_PD 46 | ConfigureGPIO( 0x00, INOUT_IN | PUPD_DOWN | DEFAULT_ON ); //T0 47 | ConfigureGPIO( 0x01, INOUT_IN | PUPD_DOWN | DEFAULT_ON ); //T1 48 | ConfigureGPIO( 0x03, INOUT_IN | PUPD_DOWN | DEFAULT_ON ); //T2 49 | #else 50 | ConfigureGPIO( 0x00, INOUT_IN | PUPD_UP | DEFAULT_OFF ); //T0 51 | ConfigureGPIO( 0x01, INOUT_IN | PUPD_UP | DEFAULT_OFF ); //T1 52 | ConfigureGPIO( 0x03, INOUT_IN | PUPD_UP | DEFAULT_OFF ); //T2 53 | #endif 54 | 55 | //We run the algorithm twice. The very first time, something is always 56 | //askew with the pads, not sure why, but the second run is 100% 57 | run_touch( touch_calib ); 58 | run_touch( touch_calib ); 59 | done_startup = 1; 60 | } 61 | 62 | 63 | void run_touch( uint8_t * counts ) 64 | { 65 | counts[0] = counts[1] = counts[2] = 0; 66 | 67 | //For this tiny period of time, we disable interrupts because timing matters. 68 | __disable_irq(); 69 | 70 | //We stop driving the pin here, and let it float down. 71 | GPIOOf(0)->MODER = (GPIOOf(0)->MODER & ~(0x000cf)); 72 | uint32_t idrcheck[32]; 73 | uint32_t *idrcheckmark = idrcheck; 74 | int i; 75 | 76 | //We read the value of IDR for the port. This will make it so 77 | //we can read every IO on the port at exactly the same time. This 78 | //makes it very convenient to synchronously read many touch sensors. 79 | 80 | //You can think of this a little bit like running a logic analyzer 81 | //for a very short period of time over every pin on a given port. 82 | *(idrcheckmark++) = GPIOOf(0)->IDR; 83 | *(idrcheckmark++) = GPIOOf(0)->IDR; 84 | *(idrcheckmark++) = GPIOOf(0)->IDR; 85 | *(idrcheckmark++) = GPIOOf(0)->IDR; 86 | *(idrcheckmark++) = GPIOOf(0)->IDR; 87 | *(idrcheckmark++) = GPIOOf(0)->IDR; 88 | *(idrcheckmark++) = GPIOOf(0)->IDR; 89 | *(idrcheckmark++) = GPIOOf(0)->IDR; 90 | *(idrcheckmark++) = GPIOOf(0)->IDR; 91 | *(idrcheckmark++) = GPIOOf(0)->IDR; 92 | *(idrcheckmark++) = GPIOOf(0)->IDR; 93 | *(idrcheckmark++) = GPIOOf(0)->IDR; 94 | *(idrcheckmark++) = GPIOOf(0)->IDR; 95 | *(idrcheckmark++) = GPIOOf(0)->IDR; 96 | *(idrcheckmark++) = GPIOOf(0)->IDR; 97 | *(idrcheckmark++) = GPIOOf(0)->IDR; 98 | *(idrcheckmark++) = GPIOOf(0)->IDR; 99 | *(idrcheckmark++) = GPIOOf(0)->IDR; 100 | *(idrcheckmark++) = GPIOOf(0)->IDR; 101 | *(idrcheckmark++) = GPIOOf(0)->IDR; 102 | *(idrcheckmark++) = GPIOOf(0)->IDR; 103 | *(idrcheckmark++) = GPIOOf(0)->IDR; 104 | *(idrcheckmark++) = GPIOOf(0)->IDR; 105 | *(idrcheckmark++) = GPIOOf(0)->IDR; 106 | *(idrcheckmark++) = GPIOOf(0)->IDR; 107 | *(idrcheckmark++) = GPIOOf(0)->IDR; 108 | *(idrcheckmark++) = GPIOOf(0)->IDR; 109 | *(idrcheckmark++) = GPIOOf(0)->IDR; 110 | *(idrcheckmark++) = GPIOOf(0)->IDR; 111 | *(idrcheckmark++) = GPIOOf(0)->IDR; 112 | *(idrcheckmark++) = GPIOOf(0)->IDR; 113 | *(idrcheckmark++) = GPIOOf(0)->IDR; 114 | 115 | //Once we've spent about 2 microseconds or so reading the ports, we 116 | //then go back to driving the ports high. 117 | GPIOOf(0)->MODER = (GPIOOf(0)->MODER | (0x00045)); 118 | 119 | //Because we're messing with MODER here, we probably don't want to let 120 | //an interrupt fire before we set it back, otherwise we might corrupt 121 | //it's value. 122 | __enable_irq(); 123 | 124 | 125 | //Now, that we have our data of what the 126 | counts[0] = counts[1] = counts[2] = 0; 127 | for( i = 0; i < 32; i++ ) 128 | { 129 | #if DO_PD 130 | //The &1 selects PinA.0, &2 selects PinA.1 and &8 selects PinA.3 131 | if( ( idrcheck[i] & 1 ) ) counts[0]++; 132 | if( ( idrcheck[i] & 2 ) ) counts[1]++; 133 | if( ( idrcheck[i] & 8 ) ) counts[2]++; 134 | #else 135 | if( !( idrcheck[i] & 1 ) ) counts[0]++; 136 | if( !( idrcheck[i] & 2 ) ) counts[1]++; 137 | if( !( idrcheck[i] & 8 ) ) counts[2]++; 138 | #endif 139 | } 140 | 141 | //Potentially write calibration data, and/or subtract out 142 | //our calibration data as being our reference "zero" pressure. 143 | 144 | //If the read value every drops very percipitiously, then, it 145 | //may be because the user had pressed the button at boot. This 146 | //will allow it to reset back down. 147 | 148 | //XXX TODO: Don't allow the calibration to reset down super fast 149 | //because there is theoretically (thouh I could not make it happen) 150 | //a possibility that ESD could make there be some sort of transient. 151 | for( i = 0; i < 3; i++ ) 152 | { 153 | if( done_startup ) 154 | { 155 | if( counts[i] < touch_calib[i] ) 156 | touch_calib[i] = counts[i]; 157 | counts[i] = counts[i] - touch_calib[i]; 158 | } 159 | else 160 | { 161 | touch_calib[i] = counts[i]; 162 | } 163 | } 164 | } 165 | 166 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/touch.h: -------------------------------------------------------------------------------- 1 | #ifndef _TOUCH_H 2 | #define _TOUCH_H 3 | #include 4 | 5 | void init_touch(); 6 | void run_touch( uint8_t * out ); 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/usb.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_H 2 | #define _USB_H 3 | 4 | #include 5 | 6 | extern volatile int usbDataOkToSend; 7 | extern volatile int usbDataOkToRead; 8 | 9 | void init_usb(); 10 | void usb_data( uint8_t * data, int len ); 11 | 12 | uint8_t * usb_get_out_ep_buffer(); 13 | void usb_release_out_ep_buffer(); 14 | 15 | //'length' is the size of the payload. 16 | //'code' is the HID wValue. This is usually the first byte in the HIDAPI stuff. 17 | //It is STRONGLY recommended you use 0 as the first byte. Experimentally, other values are NOT platform-safe. 18 | void CBHIDSetup( uint16_t length, uint8_t code ); 19 | void CBHIDData( uint8_t paksize, uint8_t * data ); 20 | void CBHIDInterruptIn( uint8_t paklen, uint8_t * data ); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/usbconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_CONFIG_H 2 | #define _USB_CONFIG_H 3 | 4 | #include 5 | //#include 6 | 7 | // You can change these to give your code its own name. 8 | #define STR_MANUFACTURER { 'm', 0, 'f', 0, 'g', 0 } 9 | #define STR_PRODUCT { 'p', 0, 'r', 0, 'd', 0 } 10 | #define STR_PRODUCT_LEN (6+1) 11 | #define STR_MANUFACTURER_LEN (6+1) 12 | 13 | #define VENDOR_ID 0xabcd 14 | #define PRODUCT_ID 0xf410 15 | 16 | #define HARDWARE_INTERFACE 0 17 | 18 | #define ENDPOINT0_SIZE CONTROL_MAX_PACKET_SIZE 19 | #define ENDPOINT1_SIZE 64 20 | #define ENDPOINT2_SIZE 64 21 | 22 | 23 | #define LSB(x) ((x)&0xff) 24 | #define MSB(x) ((x)>>8) 25 | 26 | 27 | const static uint8_t hid_report_desc[] = { 28 | 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined) 29 | 0x09, 0x04, // Usage 0x04 30 | 0xA1, 0x5C, // Collection 0x5C 31 | 0x75, 0x08, // report size = 8 bits (global) 32 | 0x15, 0x00, // logical minimum = 0 (global) 33 | 0x26, 0xFF, 0x00, // logical maximum = 255 (global) 34 | 0x95, 64, // report count (global) 64 bytes. 35 | 0x09, 0x75, // usage (local) 36 | 0x81, 0x02, // Input 37 | 0x95, 64, // report count (global) INPUT REPORT SIZE 38 | 0x09, 0x76, // usage (local) 39 | 0x91, 0x02, // Output 40 | 0x95, 64, // report count (global) OUTPUT REPORT SIZE [64] (0x96, 0x00, 0x02,=512) 41 | 0x09, 0x76, // usage (local) 42 | 0xB1, 0x02, // Feature 43 | 0xC0 // end collection 44 | 45 | }; 46 | 47 | 48 | const static uint8_t device_descriptor[] = { 49 | 18, // bLength 50 | 1, // bDescriptorType 51 | 0x10, 0x01, // bcdUSB 52 | 0, // bDeviceClass 53 | 0, // bDeviceSubClass 54 | 0, // bDeviceProtocol 55 | ENDPOINT0_SIZE, // bMaxPacketSize0 56 | LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor 57 | LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct 58 | 0x01, 0x01, // bcdDevice 59 | 1, // iManufacturer 60 | 2, // iProduct 61 | 3, // iSerialNumber 62 | 1 // bNumConfigurations 63 | }; 64 | 65 | #define CONFIG_DESCRIPTOR_SIZE (9+9+9+7+7) 66 | #define HID_DESC_OFFSET (9+9) 67 | 68 | const static uint8_t config_descriptor[CONFIG_DESCRIPTOR_SIZE] = { 69 | // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10 70 | 9, // bLength; 71 | 2, // bDescriptorType; 72 | LSB(CONFIG_DESCRIPTOR_SIZE), // wTotalLength 73 | MSB(CONFIG_DESCRIPTOR_SIZE), 74 | 1, // bNumInterfaces 75 | 1, // bConfigurationValue 76 | 0, // iConfiguration 77 | 0x80, // bmAttributes (0xC0 is self-powered) 78 | 20, // bMaxPower 79 | 80 | 9, // bLength 81 | 4, // bDescriptorType 82 | HARDWARE_INTERFACE, // bInterfaceNumber (unused, would normally be used for HID) 83 | 0, // bAlternateSetting 84 | 2, // bNumEndpoints 85 | 3, // bInterfaceClass 86 | 0xff, // bInterfaceSubClass (Was 0xff) 1 = Boot device subclass. 87 | 0xff, // bInterfaceProtocol (Was 0xff) 1 = keyboard, 2 = mouse. 88 | 0, // iInterface 89 | 90 | 91 | 9, // bLength 92 | 0x21, // bDescriptorType [33] 93 | 0x01, 0x01, // bcdHID 94 | 0, // bCountryCode 95 | 1, // bNumDescriptors 96 | 0x22, // bDescriptorType (Normally 0x22) 97 | LSB(sizeof(hid_report_desc)), // wDescriptorLength 98 | MSB(sizeof(hid_report_desc)), 99 | 100 | 101 | 7, // bLength 102 | 5, // bDescriptorType 103 | IN_ENDPOINT_ADDRESS, // bEndpointAddress (IN, 1) 104 | 0x03, // bmAttributes 105 | LSB(ENDPOINT1_SIZE), MSB(ENDPOINT1_SIZE), // wMaxPacketSize 106 | 1, // bInterval */ 107 | 108 | 109 | 7, // bLength 110 | 5, // bDescriptorType 111 | OUT_ENDPOINT_ADDRESS, // bEndpointAddress (OUT, 2) 112 | 0x03, // bmAttributes (Interrupt) 113 | LSB(ENDPOINT2_SIZE), MSB(ENDPOINT2_SIZE), // wMaxPacketSize 114 | 1, // bInterval 115 | }; 116 | 117 | 118 | 119 | // If you're desperate for a little extra code memory, these strings 120 | // can be completely removed if iManufacturer, iProduct, iSerialNumber 121 | // in the device desciptor are changed to zeros. 122 | struct usb_string_descriptor_struct { 123 | uint8_t bLength; 124 | uint8_t bDescriptorType; 125 | uint8_t wString[]; 126 | }; 127 | 128 | 129 | static const struct usb_string_descriptor_struct string0 = { 130 | 4, 131 | 3, 132 | //L"\x0409" 133 | { 0x09, 0x04, 0x00, 0x00 } 134 | }; 135 | static const struct usb_string_descriptor_struct string1 = { 136 | STR_MANUFACTURER_LEN, 137 | 3, 138 | STR_MANUFACTURER 139 | }; 140 | 141 | static const struct usb_string_descriptor_struct string2 = { 142 | STR_PRODUCT_LEN, 143 | 3, 144 | STR_PRODUCT 145 | }; 146 | static struct usb_string_descriptor_struct string3 = { 147 | 16, 148 | 3, 149 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00 } //This will be filled in with the UID on boot. 150 | }; 151 | 152 | 153 | // This table defines which descriptor data is sent for each specific 154 | // request from the host (in wValue and wIndex). 155 | const static struct descriptor_list_struct { 156 | uint16_t wValue; 157 | uint16_t wIndex; 158 | const uint8_t *addr; 159 | uint8_t length; 160 | } descriptor_list[] = { 161 | {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)}, 162 | {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)}, 163 | {0x2200, HARDWARE_INTERFACE, hid_report_desc, sizeof(hid_report_desc)}, 164 | {0x2100, HARDWARE_INTERFACE, config_descriptor+HID_DESC_OFFSET, 9}, 165 | {0x0300, 0x0000, (const uint8_t *)&string0, 4}, 166 | {0x0301, 0x0409, (const uint8_t *)&string1, STR_MANUFACTURER_LEN}, 167 | {0x0302, 0x0409, (const uint8_t *)&string2, STR_PRODUCT_LEN}, 168 | {0x0303, 0x0409, (const uint8_t *)&string3, 16} 169 | }; 170 | #define NUM_DESC_LIST (sizeof(descriptor_list)/sizeof(struct descriptor_list_struct)) 171 | 172 | 173 | #endif 174 | 175 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/ws2812.c: -------------------------------------------------------------------------------- 1 | #include "ws2812.h" 2 | #include 3 | #include 4 | 5 | //based off of https://github.com/fduignan/NucleoF042_DMAandSPItoWS2812Bs/blob/master/spi.c 6 | 7 | uint32_t rawwsdata[WSLEDS*4+12]; //12 buffer for resetting LEDs 8 | 9 | void InitWSDMA() 10 | { 11 | int i; 12 | 13 | //PB5 = SPI1_MOSI -> LED2 14 | //PB4 = SPI1_MISO 15 | //PB3 = SPI1_SCK 16 | 17 | // Turn on the clock for the SPI interface 18 | RCC->APB2ENR |= _BV(12); 19 | 20 | // Turn on PORT B 21 | // RCC->AHBENR |= _BV(18); 22 | 23 | ConfigureGPIO( GPIO_FROM_NUMS( 0, 7 ), 0b11 ); //Just for the sake of testing/setting the port up. 24 | 25 | for( i = 0; i < WSLEDS*4+12; i++ ) 26 | { 27 | rawwsdata[i] = 0; 28 | } 29 | 30 | // Configure the pins 31 | // GPIOB->MODER |= _BV(11); //GPIO B5 AF 32 | // GPIOB->MODER &= ~_BV(10); 33 | // GPIOB->AFR[0] &= ~(_BV(20) | _BV(21) | _BV(22) | _BV(23)); //Set AFMode 0. 34 | 35 | GPIOA->MODER |= _BV(15); //GPIO A7 AF 36 | GPIOA->MODER &= ~_BV(14); 37 | GPIOA->AFR[0] &= ~(_BV(28) | _BV(29) | _BV(30) | _BV(31)); //Set AFMode 0. 38 | 39 | SPI1->CR1 = SPI1->CR2 = 0; 40 | 41 | SPI1->CR1 |= SPI_CR1_CPHA; // set CPHA to ensure MOSI is low when idle 42 | SPI1->CR1 |= SPI_CR1_MSTR; // select master mode 43 | SPI1->CR1 |= (3 << 3); // select divider of 16. 48MHz/16 = 3MHz. 3 bits per WS2812 bit so: 1 Million WSbits/second : Within range of 1.53MHz to 540kHz 44 | SPI1->CR1 |= SPI_CR1_SSI | SPI_CR1_SSM; // select software slave management and drive SSI high (not relevant in TI mode and not output to pins) 45 | 46 | SPI1->CR2 |= (7 << 8); // select 8 bit data transfer size 47 | SPI1->CR2 |= SPI_CR2_TXDMAEN; // enable transmit DMA 48 | 49 | SPI1->CR1 |= SPI_CR1_SPE; // enable SPI1 50 | 51 | 52 | RCC->AHBENR |= RCC_AHBENR_DMAEN; // enable clocks for DMA controller 53 | 54 | DMA1_Channel3->CPAR = (uint32_t)(&(SPI1->DR)); 55 | // Select high priority, 8 bits, Memory increment mode (only), Read from memory, enable 56 | DMA1_Channel3->CCR = 57 | _BV(13) | _BV(12) | //Very high priority 58 | //MSIZE = PSIZE = 0 = 8 bit operations. TODO Consider trying to do it with 16-bit-wide registers. WARNING: This did not work. Don't know why. 59 | _BV(7) | //Memory increment mode 60 | //No circular mode. 61 | _BV(4) | 62 | 0; 63 | } 64 | 65 | 66 | void TriggerDMA() 67 | { 68 | // if( DMA1_Channel3->CCR != 12433 ) 69 | // send_text_value( "CDMA", DMA1_Channel3->CCR ); 70 | //send_text_value( "DMA: ", DMA1_Channel3->CCR ); 71 | DMA1_Channel3->CCR &= ~_BV(0); // disable DMA 72 | DMA1->IFCR = 0x0f00; // clear any pending interrupts XXX Fix this later. 73 | DMA1_Channel3->CPAR = (uint32_t)(&(SPI1->DR)); 74 | DMA1_Channel3->CMAR = (uint32_t)&rawwsdata; // Don't know what to send yet 75 | DMA1_Channel3->CNDTR = sizeof(rawwsdata)+1; // No bytes yet 76 | DMA1_Channel3->CCR |= _BV(0); // re-enable DMA 77 | } 78 | 79 | void UpdateLEDs( int ledstart, uint8_t * leddata, int lengthleds ) 80 | { 81 | 82 | static const uint16_t CodeData[4*4] = { 83 | 0x8888, 0x8e88, 0xe888, 0xee88, 84 | 0x888e, 0x8e8e, 0xe88e, 0xee8e, 85 | 0x88e8, 0x8ee8, 0xe8e8, 0xeee8, 86 | 0x88ee, 0x8eee, 0xe8ee, 0xeeee 87 | }; 88 | 89 | if( ledstart + lengthleds > WSLEDS ) 90 | { 91 | lengthleds = WSLEDS - ledstart; 92 | } 93 | 94 | int inmark = ledstart * 4; //Prefix zero data 95 | int bytes = lengthleds * 4; 96 | int i; 97 | for( i = 0; i < bytes; i++ ) 98 | { 99 | int8_t color = leddata[i]; 100 | //Word-on-wire order: (Determined experiomentally) 101 | //LSByte first. MSBit first. 102 | if( i + inmark >= WSLEDS*4 ) break; 103 | rawwsdata[i+inmark+12] = CodeData[(color>>4)&0xf] | (CodeData[(color)&0xf]<<16); 104 | } 105 | } 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /tensigral_lamp_1/firmware/ws2812.h: -------------------------------------------------------------------------------- 1 | #ifndef _WS2812_H 2 | #define _WS2812_H 3 | 4 | #define WSLEDS 20 5 | 6 | #include 7 | 8 | //Initialize DMA, etc. 9 | void InitWSDMA( ); 10 | void TriggerDMA( ); 11 | void UpdateLEDs( int ledstart, uint8_t * leddata, int lengthleds ); 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /tensigral_lamp_1/fp-info-cache: -------------------------------------------------------------------------------- 1 | 53182246169268 2 | Connector_USB 3 | USB3_A_Molex_48393-001 4 | USB 3.0, type A, right angle (http://www.molex.com/pdm_docs/sd/483930003_sd.pdf) 5 | USB 3.0 type A right angle 6 | 0 7 | 13 8 | 10 9 | Connector_USB 10 | USB3_A_Plug_Wuerth_692112030100_Horizontal 11 | USB type A Plug, Horizontal, http://katalog.we-online.de/em/datasheet/692112030100.pdf 12 | usb A plug horizontal 13 | 0 14 | 11 15 | 10 16 | Connector_USB 17 | USB_A_CNCTech_1001-011-01101_Horizontal 18 | http://cnctech.us/pdfs/1001-011-01101.pdf 19 | USB-A 20 | 0 21 | 6 22 | 5 23 | Connector_USB 24 | USB_A_Molex_105057_Vertical 25 | https://www.molex.com/pdm_docs/sd/1050570001_sd.pdf 26 | USB A Vertical 27 | 0 28 | 7 29 | 5 30 | Connector_USB 31 | USB_A_Stewart_SS-52100-001_Horizontal 32 | USB A connector https://belfuse.com/resources/drawings/stewartconnector/dr-stw-ss-52100-001.pdf 33 | USB_A Female Connector receptacle 34 | 0 35 | 6 36 | 5 37 | Connector_USB 38 | USB_A_Wuerth_61400826021_Horizontal_Stacked 39 | Stacked USB A connector http://katalog.we-online.de/em/datasheet/61400826021.pdf 40 | Wuerth stacked USB_A 41 | 0 42 | 12 43 | 9 44 | Connector_USB 45 | USB_B_Amphenol_MUSB-D511_Vertical_Rugged 46 | A,phenol MUSB_D511, USB B female connector, straight, rugged, https://www.amphenolcanada.com/ProductSearch/drawings/AC/MUSBD511XX.pdf 47 | USB_B_MUSB_Straight female connector straight rugged MUSB D511 48 | 0 49 | 6 50 | 5 51 | Connector_USB 52 | USB_B_OST_USB-B1HSxx_Horizontal 53 | USB B receptacle, Horizontal, through-hole, http://www.on-shore.com/wp-content/uploads/2015/09/usb-b1hsxx.pdf 54 | USB-B receptacle horizontal through-hole 55 | 0 56 | 6 57 | 5 58 | Connector_USB 59 | USB_B_TE_5787834_Vertical 60 | http://www.mouser.com/ds/2/418/NG_CD_5787834_A4-669110.pdf 61 | USB_B USB B vertical female connector 62 | 0 63 | 6 64 | 5 65 | Connector_USB 66 | USB_C_Plug_Molex_105444 67 | Universal Serial Bus (USB) Shielded I/O Plug, Type C, Right Angle, Surface Mount, http://www.molex.com/pdm_docs/sd/1054440001_sd.pdf 68 | USB Type-C Plug Edge Mount 69 | 0 70 | 24 71 | 23 72 | Connector_USB 73 | USB_C_Receptacle_Amphenol_12401548E4-2A 74 | USB TYPE C, RA RCPT PCB, Hybrid, https://www.amphenolcanada.com/StockAvailabilityPrice.aspx?From=&PartNum=12401548E4%7e2A 75 | USB C Type-C Receptacle Hybrid 76 | 0 77 | 28 78 | 25 79 | Connector_USB 80 | USB_C_Receptacle_Amphenol_12401548E4-2A_CircularHoles 81 | USB TYPE C, RA RCPT PCB, Hybrid, https://www.amphenolcanada.com/StockAvailabilityPrice.aspx?From=&PartNum=12401548E4%7e2A 82 | USB C Type-C Receptacle Hybrid 83 | 0 84 | 28 85 | 25 86 | Connector_USB 87 | USB_C_Receptacle_Amphenol_12401610E4-2A 88 | USB TYPE C, RA RCPT PCB, SMT, https://www.amphenolcanada.com/StockAvailabilityPrice.aspx?From=&PartNum=12401610E4%7e2A 89 | USB C Type-C Receptacle SMD 90 | 0 91 | 28 92 | 25 93 | Connector_USB 94 | USB_C_Receptacle_Amphenol_12401610E4-2A_CircularHoles 95 | USB TYPE C, RA RCPT PCB, SMT, https://www.amphenolcanada.com/StockAvailabilityPrice.aspx?From=&PartNum=12401610E4%7e2A 96 | USB C Type-C Receptacle SMD 97 | 0 98 | 28 99 | 25 100 | Connector_USB 101 | USB_C_Receptacle_GCT_USB4085 102 | USB 2.0 Type C Receptacle, https://gct.co/Files/Drawings/USB4085.pdf 103 | USB Type-C Receptacle Through-hole Right angle 104 | 0 105 | 20 106 | 17 107 | Connector_USB 108 | USB_C_Receptacle_JAE_DX07S024WJ1R350 109 | http://www.jae.com/z-en/pdf_download_exec.cfm?param=SJ117219.pdf 110 | USB C Type-C Receptacle SMD 111 | 0 112 | 30 113 | 25 114 | Connector_USB 115 | USB_C_Receptacle_JAE_DX07S024WJ3R400 116 | USB TYPE C, VERT RCPT PCB, SMT, http://www.jae.com/z-en/pdf_download_exec.cfm?param=SJ117928.pdf 117 | USB C Type-C Receptacle SMD 118 | 0 119 | 28 120 | 25 121 | Connector_USB 122 | USB_C_Receptacle_Palconn_UTC16-G 123 | http://www.palpilot.com/wp-content/uploads/2017/05/UTC027-GKN-OR-Rev-A.pdf 124 | USB C Type-C Receptacle USB2.0 125 | 0 126 | 20 127 | 17 128 | Connector_USB 129 | USB_Micro-B_Amphenol_10103594-0001LF_Horizontal 130 | Micro USB Type B 10103594-0001LF, http://cdn.amphenol-icc.com/media/wysiwyg/files/drawing/10103594.pdf 131 | USB USB_B USB_micro USB_OTG 132 | 0 133 | 17 134 | 6 135 | Connector_USB 136 | USB_Micro-B_GCT_USB3076-30-A 137 | GCT Micro USB https://gct.co/files/drawings/usb3076.pdf 138 | Micro-USB SMD Typ-B GCT 139 | 0 140 | 11 141 | 6 142 | Connector_USB 143 | USB_Micro-B_Molex-105017-0001 144 | http://www.molex.com/pdm_docs/sd/1050170001_sd.pdf 145 | Micro-USB SMD Typ-B 146 | 0 147 | 13 148 | 6 149 | Connector_USB 150 | USB_Micro-B_Molex-105133-0001 151 | Molex Vertical Micro USB Typ-B (http://www.molex.com/pdm_docs/sd/1051330001_sd.pdf) 152 | Micro-USB SMD Typ-B Vertical 153 | 0 154 | 8 155 | 6 156 | Connector_USB 157 | USB_Micro-B_Molex-105133-0031 158 | Molex Vertical Micro USB Typ-B (http://www.molex.com/pdm_docs/sd/1051330031_sd.pdf) 159 | Micro-USB SMD Typ-B Vertical 160 | 0 161 | 8 162 | 6 163 | Connector_USB 164 | USB_Micro-B_Molex_47346-0001 165 | Micro USB B receptable with flange, bottom-mount, SMD, right-angle (http://www.molex.com/pdm_docs/sd/473460001_sd.pdf) 166 | Micro B USB SMD 167 | 0 168 | 11 169 | 6 170 | Connector_USB 171 | USB_Micro-B_Tensility_54-00023_Vertical 172 | http://www.tensility.com/pdffiles/54-00023.pdf 173 | usb mini receptacle vertical 174 | 0 175 | 7 176 | 6 177 | Connector_USB 178 | USB_Micro-B_Tensility_54-00023_Vertical_CircularHoles 179 | http://www.tensility.com/pdffiles/54-00023.pdf 180 | usb mini receptacle vertical 181 | 0 182 | 7 183 | 6 184 | Connector_USB 185 | USB_Micro-B_Wuerth_614105150721_Vertical 186 | USB Micro-B receptacle, through-hole, vertical, http://katalog.we-online.de/em/datasheet/614105150721.pdf 187 | usb micro receptacle vertical 188 | 0 189 | 7 190 | 6 191 | Connector_USB 192 | USB_Micro-B_Wuerth_614105150721_Vertical_CircularHoles 193 | USB Micro-B receptacle, through-hole, vertical, http://katalog.we-online.de/em/datasheet/614105150721.pdf 194 | usb micro receptacle vertical 195 | 0 196 | 7 197 | 6 198 | Connector_USB 199 | USB_Micro-B_Wuerth_629105150521 200 | USB Micro-B receptacle, http://www.mouser.com/ds/2/445/629105150521-469306.pdf 201 | usb micro receptacle 202 | 0 203 | 9 204 | 6 205 | Connector_USB 206 | USB_Micro-B_Wuerth_629105150521_CircularHoles 207 | USB Micro-B receptacle, http://www.mouser.com/ds/2/445/629105150521-469306.pdf 208 | usb micro receptacle 209 | 0 210 | 9 211 | 6 212 | Connector_USB 213 | USB_Mini-B_AdamTech_MUSB-B5-S-VT-TSMT-1_SMD_Vertical 214 | http://www.adam-tech.com/upload/MUSB-B5-S-VT-TSMT-1.pdf 215 | USB Mini-B 216 | 0 217 | 7 218 | 6 219 | Connector_USB 220 | USB_Mini-B_Lumberg_2486_01_Horizontal 221 | USB Mini-B 5-pin SMD connector, http://downloads.lumberg.com/datenblaetter/en/2486_01.pdf 222 | USB USB_B USB_Mini connector 223 | 0 224 | 9 225 | 6 226 | Connector_USB 227 | USB_Mini-B_Tensility_54-00023_Vertical 228 | http://www.tensility.com/pdffiles/54-00023.pdf 229 | usb mini receptacle vertical 230 | 0 231 | 7 232 | 6 233 | Connector_USB 234 | USB_Mini-B_Tensility_54-00023_Vertical_CircularHoles 235 | http://www.tensility.com/pdffiles/54-00023.pdf 236 | usb mini receptacle vertical 237 | 0 238 | 7 239 | 6 240 | -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware.pro: -------------------------------------------------------------------------------- 1 | update=12/24/2019 4:36:54 PM 2 | version=1 3 | last_client=kicad 4 | [general] 5 | version=1 6 | RootSch= 7 | BoardNm= 8 | [cvpcb] 9 | version=1 10 | NetIExt=net 11 | [eeschema] 12 | version=1 13 | LibDir= 14 | [eeschema/libraries] 15 | [schematic_editor] 16 | version=1 17 | PageLayoutDescrFile= 18 | PlotDirectoryName= 19 | SubpartIdSeparator=0 20 | SubpartFirstId=65 21 | NetFmtName=Pcbnew 22 | SpiceAjustPassiveValues=0 23 | LabSize=50 24 | ERC_TestSimilarLabels=1 25 | [pcbnew] 26 | version=1 27 | PageLayoutDescrFile= 28 | LastNetListRead=tensigral_lamp_hardware.net 29 | CopperLayerCount=2 30 | BoardThickness=1.6 31 | AllowMicroVias=0 32 | AllowBlindVias=0 33 | RequireCourtyardDefinitions=0 34 | ProhibitOverlappingCourtyards=1 35 | MinTrackWidth=0.3 36 | MinViaDiameter=0.4 37 | MinViaDrill=0.3 38 | MinMicroViaDiameter=0.2 39 | MinMicroViaDrill=0.09999999999999999 40 | MinHoleToHole=0.25 41 | TrackWidth1=0.3 42 | ViaDiameter1=0.8 43 | ViaDrill1=0.4 44 | dPairWidth1=0.3 45 | dPairGap1=0.25 46 | dPairViaGap1=0.25 47 | SilkLineWidth=0.12 48 | SilkTextSizeV=1 49 | SilkTextSizeH=1 50 | SilkTextSizeThickness=0.15 51 | SilkTextItalic=0 52 | SilkTextUpright=1 53 | CopperLineWidth=0.2 54 | CopperTextSizeV=1.5 55 | CopperTextSizeH=1.5 56 | CopperTextThickness=0.3 57 | CopperTextItalic=0 58 | CopperTextUpright=1 59 | EdgeCutLineWidth=0.05 60 | CourtyardLineWidth=0.05 61 | OthersLineWidth=0.15 62 | OthersTextSizeV=1 63 | OthersTextSizeH=1 64 | OthersTextSizeThickness=0.15 65 | OthersTextItalic=0 66 | OthersTextUpright=1 67 | SolderMaskClearance=0.051 68 | SolderMaskMinWidth=0.25 69 | SolderPasteClearance=0 70 | SolderPasteRatio=-0 71 | [pcbnew/Layer.F.Cu] 72 | Name=F.Cu 73 | Type=0 74 | Enabled=1 75 | [pcbnew/Layer.In1.Cu] 76 | Name=In1.Cu 77 | Type=0 78 | Enabled=0 79 | [pcbnew/Layer.In2.Cu] 80 | Name=In2.Cu 81 | Type=0 82 | Enabled=0 83 | [pcbnew/Layer.In3.Cu] 84 | Name=In3.Cu 85 | Type=0 86 | Enabled=0 87 | [pcbnew/Layer.In4.Cu] 88 | Name=In4.Cu 89 | Type=0 90 | Enabled=0 91 | [pcbnew/Layer.In5.Cu] 92 | Name=In5.Cu 93 | Type=0 94 | Enabled=0 95 | [pcbnew/Layer.In6.Cu] 96 | Name=In6.Cu 97 | Type=0 98 | Enabled=0 99 | [pcbnew/Layer.In7.Cu] 100 | Name=In7.Cu 101 | Type=0 102 | Enabled=0 103 | [pcbnew/Layer.In8.Cu] 104 | Name=In8.Cu 105 | Type=0 106 | Enabled=0 107 | [pcbnew/Layer.In9.Cu] 108 | Name=In9.Cu 109 | Type=0 110 | Enabled=0 111 | [pcbnew/Layer.In10.Cu] 112 | Name=In10.Cu 113 | Type=0 114 | Enabled=0 115 | [pcbnew/Layer.In11.Cu] 116 | Name=In11.Cu 117 | Type=0 118 | Enabled=0 119 | [pcbnew/Layer.In12.Cu] 120 | Name=In12.Cu 121 | Type=0 122 | Enabled=0 123 | [pcbnew/Layer.In13.Cu] 124 | Name=In13.Cu 125 | Type=0 126 | Enabled=0 127 | [pcbnew/Layer.In14.Cu] 128 | Name=In14.Cu 129 | Type=0 130 | Enabled=0 131 | [pcbnew/Layer.In15.Cu] 132 | Name=In15.Cu 133 | Type=0 134 | Enabled=0 135 | [pcbnew/Layer.In16.Cu] 136 | Name=In16.Cu 137 | Type=0 138 | Enabled=0 139 | [pcbnew/Layer.In17.Cu] 140 | Name=In17.Cu 141 | Type=0 142 | Enabled=0 143 | [pcbnew/Layer.In18.Cu] 144 | Name=In18.Cu 145 | Type=0 146 | Enabled=0 147 | [pcbnew/Layer.In19.Cu] 148 | Name=In19.Cu 149 | Type=0 150 | Enabled=0 151 | [pcbnew/Layer.In20.Cu] 152 | Name=In20.Cu 153 | Type=0 154 | Enabled=0 155 | [pcbnew/Layer.In21.Cu] 156 | Name=In21.Cu 157 | Type=0 158 | Enabled=0 159 | [pcbnew/Layer.In22.Cu] 160 | Name=In22.Cu 161 | Type=0 162 | Enabled=0 163 | [pcbnew/Layer.In23.Cu] 164 | Name=In23.Cu 165 | Type=0 166 | Enabled=0 167 | [pcbnew/Layer.In24.Cu] 168 | Name=In24.Cu 169 | Type=0 170 | Enabled=0 171 | [pcbnew/Layer.In25.Cu] 172 | Name=In25.Cu 173 | Type=0 174 | Enabled=0 175 | [pcbnew/Layer.In26.Cu] 176 | Name=In26.Cu 177 | Type=0 178 | Enabled=0 179 | [pcbnew/Layer.In27.Cu] 180 | Name=In27.Cu 181 | Type=0 182 | Enabled=0 183 | [pcbnew/Layer.In28.Cu] 184 | Name=In28.Cu 185 | Type=0 186 | Enabled=0 187 | [pcbnew/Layer.In29.Cu] 188 | Name=In29.Cu 189 | Type=0 190 | Enabled=0 191 | [pcbnew/Layer.In30.Cu] 192 | Name=In30.Cu 193 | Type=0 194 | Enabled=0 195 | [pcbnew/Layer.B.Cu] 196 | Name=B.Cu 197 | Type=0 198 | Enabled=1 199 | [pcbnew/Layer.B.Adhes] 200 | Enabled=1 201 | [pcbnew/Layer.F.Adhes] 202 | Enabled=1 203 | [pcbnew/Layer.B.Paste] 204 | Enabled=1 205 | [pcbnew/Layer.F.Paste] 206 | Enabled=1 207 | [pcbnew/Layer.B.SilkS] 208 | Enabled=1 209 | [pcbnew/Layer.F.SilkS] 210 | Enabled=1 211 | [pcbnew/Layer.B.Mask] 212 | Enabled=1 213 | [pcbnew/Layer.F.Mask] 214 | Enabled=1 215 | [pcbnew/Layer.Dwgs.User] 216 | Enabled=1 217 | [pcbnew/Layer.Cmts.User] 218 | Enabled=1 219 | [pcbnew/Layer.Eco1.User] 220 | Enabled=1 221 | [pcbnew/Layer.Eco2.User] 222 | Enabled=1 223 | [pcbnew/Layer.Edge.Cuts] 224 | Enabled=1 225 | [pcbnew/Layer.Margin] 226 | Enabled=1 227 | [pcbnew/Layer.B.CrtYd] 228 | Enabled=1 229 | [pcbnew/Layer.F.CrtYd] 230 | Enabled=1 231 | [pcbnew/Layer.B.Fab] 232 | Enabled=1 233 | [pcbnew/Layer.F.Fab] 234 | Enabled=1 235 | [pcbnew/Layer.Rescue] 236 | Enabled=0 237 | [pcbnew/Netclasses] 238 | [pcbnew/Netclasses/Default] 239 | Name=Default 240 | Clearance=0.199 241 | TrackWidth=0.3 242 | ViaDiameter=0.8 243 | ViaDrill=0.4 244 | uViaDiameter=0.3 245 | uViaDrill=0.1 246 | dPairWidth=0.3 247 | dPairGap=0.25 248 | dPairViaGap=0.25 249 | -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_1/tensigral_lamp_hardware_rev-.zip -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-/render.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_1/tensigral_lamp_hardware_rev-/render.png -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-/tensigral_lamp_hardware-B_Paste.gbr: -------------------------------------------------------------------------------- 1 | G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.1.4)-1* 2 | G04 #@! TF.CreationDate,2019-12-24T18:48:46-08:00* 3 | G04 #@! TF.ProjectId,tensigral_lamp_hardware,74656e73-6967-4726-916c-5f6c616d705f,rev?* 4 | G04 #@! TF.SameCoordinates,Original* 5 | G04 #@! TF.FileFunction,Paste,Bot* 6 | G04 #@! TF.FilePolarity,Positive* 7 | %FSLAX46Y46*% 8 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 9 | G04 Created by KiCad (PCBNEW (5.1.4)-1) date 2019-12-24 18:48:46* 10 | %MOMM*% 11 | %LPD*% 12 | G04 APERTURE LIST* 13 | G04 APERTURE END LIST* 14 | M02* 15 | -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-/tensigral_lamp_hardware-B_SilkS.gbr: -------------------------------------------------------------------------------- 1 | G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.1.4)-1* 2 | G04 #@! TF.CreationDate,2019-12-24T18:48:46-08:00* 3 | G04 #@! TF.ProjectId,tensigral_lamp_hardware,74656e73-6967-4726-916c-5f6c616d705f,rev?* 4 | G04 #@! TF.SameCoordinates,Original* 5 | G04 #@! TF.FileFunction,Legend,Bot* 6 | G04 #@! TF.FilePolarity,Positive* 7 | %FSLAX46Y46*% 8 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 9 | G04 Created by KiCad (PCBNEW (5.1.4)-1) date 2019-12-24 18:48:46* 10 | %MOMM*% 11 | %LPD*% 12 | G04 APERTURE LIST* 13 | %ADD10C,0.120000*% 14 | G04 APERTURE END LIST* 15 | D10* 16 | X69215000Y-106680000D02* 17 | X69215000Y-105410000D01* 18 | X68580000Y-107315000D02* 19 | X69215000Y-106680000D01* 20 | X67945000Y-107315000D02* 21 | X68580000Y-107315000D01* 22 | X67945000Y-106680000D02* 23 | X67945000Y-107315000D01* 24 | X68580000Y-106045000D02* 25 | X67945000Y-106680000D01* 26 | X69850000Y-106045000D02* 27 | X68580000Y-106045000D01* 28 | X69215000Y-105410000D02* 29 | X69850000Y-106045000D01* 30 | M02* 31 | -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-/tensigral_lamp_hardware-NPTH.drl: -------------------------------------------------------------------------------- 1 | M48 2 | ; DRILL file {KiCad (5.1.4)-1} date 12/24/2019 6:48:47 PM 3 | ; FORMAT={-:-/ absolute / inch / decimal} 4 | ; #@! TF.CreationDate,2019-12-24T18:48:47-08:00 5 | ; #@! TF.GenerationSoftware,Kicad,Pcbnew,(5.1.4)-1 6 | ; #@! TF.FileFunction,NonPlated,1,2,NPTH 7 | FMAT,2 8 | INCH 9 | % 10 | G90 11 | G05 12 | T0 13 | M30 14 | -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-/tensigral_lamp_hardware-PTH.drl: -------------------------------------------------------------------------------- 1 | M48 2 | ; DRILL file {KiCad (5.1.4)-1} date 12/24/2019 6:48:47 PM 3 | ; FORMAT={-:-/ absolute / inch / decimal} 4 | ; #@! TF.CreationDate,2019-12-24T18:48:47-08:00 5 | ; #@! TF.GenerationSoftware,Kicad,Pcbnew,(5.1.4)-1 6 | ; #@! TF.FileFunction,Plated,1,2,PTH 7 | FMAT,2 8 | INCH 9 | T1C0.0157 10 | T2C0.0232 11 | T3C0.0315 12 | T4C0.0394 13 | T5C0.0394 14 | % 15 | G90 16 | G05 17 | T1 18 | X1.2539Y-2.9469 19 | X1.4685Y-3.063 20 | X1.5374Y-2.2933 21 | X1.5689Y-2.6772 22 | X1.5866Y-2.752 23 | X1.5945Y-2.8346 24 | X1.6339Y-2.2067 25 | X1.6634Y-2.8012 26 | X1.7Y-2.725 27 | X1.725Y-3.525 28 | X1.7421Y-2.9134 29 | X1.8622Y-2.1535 30 | X1.8878Y-2.5453 31 | X1.9291Y-3.2972 32 | X1.9606Y-2.8425 33 | X2.0039Y-1.9705 34 | X2.0335Y-2.2323 35 | X2.0472Y-2.8031 36 | X2.0512Y-2.4803 37 | X2.0571Y-3.3169 38 | X2.15Y-2.825 39 | X2.1732Y-2.975 40 | X2.175Y-2.7 41 | X2.222Y-2.384 42 | X2.2661Y-4.4649 43 | X2.3346Y-2.2972 44 | X2.3602Y-2.4528 45 | X2.3622Y-2.372 46 | X2.3661Y-2.4134 47 | X2.374Y-2.3327 48 | X2.4803Y-2.5315 49 | X2.5787Y-2.2756 50 | X2.6378Y-2.313 51 | X2.6654Y-2.9567 52 | X2.6673Y-2.4803 53 | X2.6772Y-2.4331 54 | X2.9094Y-2.6654 55 | X3.0138Y-1.2106 56 | X3.063Y-2.4882 57 | X3.3366Y-1.378 58 | X3.3543Y-1.5433 59 | X3.3563Y-1.3169 60 | X3.5827Y-1.5197 61 | X3.622Y-1.6772 62 | X3.6378Y-1.3425 63 | X3.7598Y-1.5846 64 | X3.8858Y-1.6083 65 | X4.0098Y-1.7579 66 | X4.054Y-1.9753 67 | X4.0945Y-1.7126 68 | X4.1831Y-1.7343 69 | X4.1969Y-1.9961 70 | X4.3681Y-1.8681 71 | T2 72 | X1.4117Y-2.9267 73 | X1.5293Y-2.805 74 | T3 75 | X3.2579Y-2.7697 76 | X3.4823Y-2.4429 77 | T4 78 | X3.0Y-3.0 79 | X3.0966Y-2.9741 80 | X3.1932Y-2.9482 81 | T5 82 | X3.9508Y-2.5709 83 | X2.3445Y-4.2815 84 | X1.0571Y-4.2421 85 | X1.3327Y-1.3799 86 | X4.313Y-2.998 87 | X1.0551Y-0.9035 88 | X1.3327Y-3.7657 89 | X4.2087Y-3.2441 90 | X2.561Y-1.3996 91 | T0 92 | M30 93 | -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-/tensigral_lamp_hardware-bottom.pos: -------------------------------------------------------------------------------- 1 | ### Module positions - created on 12/24/2019 6:48:54 PM ### 2 | ### Printed by Pcbnew version kicad (5.1.4)-1 3 | ## Unit = mm, Angle = deg. 4 | ## Side : bottom 5 | # Ref Val Package PosX PosY Rot Side 6 | ## End 7 | -------------------------------------------------------------------------------- /tensigral_lamp_1/tensigral_lamp_hardware_rev-/tensigral_lamp_hardware-top.pos: -------------------------------------------------------------------------------- 1 | ### Module positions - created on 12/24/2019 6:48:54 PM ### 2 | ### Printed by Pcbnew version kicad (5.1.4)-1 3 | ## Unit = mm, Angle = deg. 4 | ## Side : top 5 | # Ref Val Package PosX PosY Rot Side 6 | C1 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 19.3000 -93.6000 180.0000 top 7 | C2 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 93.2752 -52.7248 45.0000 top 8 | C3 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 68.5000 -47.0500 90.0000 top 9 | C4 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 52.8000 -99.1000 315.0000 top 10 | C5 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 41.4252 -22.8248 70.0000 top 11 | C6 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 92.9748 -77.7248 315.0000 top 12 | C7 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 80.8000 -83.4500 270.0000 top 13 | C8 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 21.0000 -48.4500 200.0000 top 14 | C9 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 55.2500 -60.5000 90.0000 top 15 | C10 22uF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 81.2500 -47.7500 90.0000 top 16 | C11 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 43.1300 -83.2500 0.0000 top 17 | C12 22uF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 55.2450 -74.2500 0.0000 top 18 | C13 22uF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 42.7500 -77.0000 180.0000 top 19 | C14 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 46.7500 -87.7500 270.0000 top 20 | C15 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 57.9125 -71.2123 240.0000 top 21 | C16 22uF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 87.7000 -39.7500 180.0000 top 22 | C17 22nF C_0805_2012Metric_Pad1.15x1.40mm_HandSolder 107.8500 -43.6500 315.0000 top 23 | D1 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 74.5500 -47.1500 180.0000 top 24 | D2 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 87.4500 -49.7500 155.0000 top 25 | D3 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 97.2500 -57.8500 120.0000 top 26 | D4 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 97.2500 -72.8500 60.0000 top 27 | D5 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 87.4500 -81.3000 25.0000 top 28 | D6 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 74.3500 -83.4000 0.0000 top 29 | D7 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 62.2000 -83.8000 30.0000 top 30 | D8 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 55.8000 -93.6500 60.0000 top 31 | D9 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 47.6500 -103.4000 40.0000 top 32 | D10 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 35.7500 -109.0500 5.0000 top 33 | D11 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 21.8000 -100.6500 300.0000 top 34 | D12 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 20.0900 -86.7800 258.0000 top 35 | D13 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 24.9500 -74.5000 240.0000 top 36 | D14 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 24.8000 -56.0000 300.0000 top 37 | D15 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 19.1500 -40.8000 280.0000 top 38 | D16 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 21.8500 -28.1000 230.0000 top 39 | D17 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 34.6500 -21.5500 175.0000 top 40 | D18 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 47.4000 -26.2000 140.0000 top 41 | D19 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 55.5000 -36.4500 120.0000 top 42 | D20 SK6812-RGBWW LED_WS2812B_PLCC4_5.0x5.0mm_P3.2mm 62.0000 -46.0500 150.0000 top 43 | L1 10uH L_2816_7142Metric 49.5000 -79.0000 0.0000 top 44 | R1 33k-1% R_0805_2012Metric_Pad1.15x1.40mm_HandSolder 39.2500 -91.2500 0.0000 top 45 | R2 6.8k-1% R_0805_2012Metric_Pad1.15x1.40mm_HandSolder 38.2500 -87.2500 270.0000 top 46 | R3 6.8k-1% R_0805_2012Metric_Pad1.15x1.40mm_HandSolder 38.9000 -54.1500 180.0000 top 47 | R4 6.8k-1% R_0805_2012Metric_Pad1.15x1.40mm_HandSolder 103.1748 -48.1748 315.0000 top 48 | R5 6.8k-1% R_0805_2012Metric_Pad1.15x1.40mm_HandSolder 104.1000 -41.9000 180.0000 top 49 | R6 6.8k-1% R_0805_2012Metric_Pad1.15x1.40mm_HandSolder 29.8450 -36.1950 270.0000 top 50 | U1 STM32F042F4Px TSSOP-20_4.4x6.5mm_P0.65mm 60.9255 -61.0521 190.0000 top 51 | U2 MT2492 SOT-23-6_Handsoldering 43.0200 -86.3100 0.0000 top 52 | U3 ATtiny45-20SU SOIJ-8_5.3x5.3mm_P1.27mm 96.6500 -41.1500 150.0000 top 53 | ## End 54 | -------------------------------------------------------------------------------- /tensigral_lamp_2/MT2492.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | #End Doc Library 4 | -------------------------------------------------------------------------------- /tensigral_lamp_2/MT2492.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.4 2 | #encoding utf-8 3 | # 4 | # MT2492 5 | # 6 | DEF MT2492 U 0 40 Y Y 1 F N 7 | F0 "U" 0 200 50 H V C CNN 8 | F1 "MT2492" 0 -200 50 H V C CNN 9 | F2 "" 0 0 50 H I C CNN 10 | F3 "" 0 0 50 H I C CNN 11 | DRAW 12 | S -150 150 150 -150 0 1 0 f 13 | X BS 1 -250 100 100 R 50 50 1 1 I 14 | X GND 2 -250 0 100 R 50 50 1 1 I 15 | X FB 3 -250 -100 100 R 50 50 1 1 I 16 | X EN 4 250 -100 100 L 50 50 1 1 I 17 | X IN 5 250 0 100 L 50 50 1 1 I 18 | X SW 6 250 100 100 L 50 50 1 1 I 19 | ENDDRAW 20 | ENDDEF 21 | # 22 | #End Library 23 | -------------------------------------------------------------------------------- /tensigral_lamp_2/ZTS6011E-MICROPHONE.pretty/ZTS6011E.kicad_mod: -------------------------------------------------------------------------------- 1 | (module ZTS6011E (layer F.Cu) (tedit 5ECA24BE) 2 | (fp_text reference REF** (at 0 3) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value ZTS6011E (at 0 -2) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -2 1.5) (end -2 -1.5) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 2 -1.5) (end 2 1.5) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start -2 -1.5) (end -2.5 -1.5) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start -2.5 -1.5) (end -2.5 -1) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -2.5 -1) (end -2 -1) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -2.5 -1.5) (end -2 -1) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -2 -1) (end -2 -1.5) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start -2 -1.5) (end -2.5 -1) (layer F.SilkS) (width 0.12)) 16 | (pad 1 smd circle (at -1.2 -0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 17 | (pad 2 smd circle (at 1.2 -0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 18 | (pad 3 smd circle (at 1.2 0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 19 | (pad 4 smd circle (at -1.2 0.85) (size 0.8 0.8) (layers F.Cu F.Paste F.Mask)) 20 | ) 21 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=main 2 | all: burn 3 | 4 | PREFIX=arm-none-eabi 5 | 6 | CC=$(PREFIX)-gcc 7 | LD=$(PREFIX)-gcc 8 | AS=$(PREFIX)-as 9 | CP=$(PREFIX)-objcopy 10 | OD=$(PREFIX)-objdump 11 | 12 | 13 | OBJCOPYFLAGS = -O binary 14 | 15 | BIN=$(CP) -O ihex 16 | 17 | DEFS = -DSTM32F042 18 | #DEFS := $(DEFS) -DDEBUG 19 | 20 | MCU = cortex-m0 21 | MCFLAGS = -mcpu=$(MCU) 22 | 23 | # -mthumb -mlittle-endian -mthumb-interwork 24 | 25 | STM32_INCLUDES = -Ilib -I. -ISTM32F0xx_StdPeriph_Driver/inc 26 | 27 | OPTIMIZE = -O2 -Wall # -flto -ffunction-sections -fdata-sections -Wl,--relax 28 | 29 | CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) \ 30 | -I. \ 31 | $(STM32_INCLUDES) \ 32 | -I../embeddedcommon \ 33 | -Wl,-T,lib/flash.ld 34 | 35 | CFLAGS+=-I. 36 | 37 | AFLAGS = $(MCFLAGS) 38 | 39 | SRC = main.c \ 40 | systems.c \ 41 | lib/system_stm32f0xx.c \ 42 | usb.c \ 43 | touch.c \ 44 | adc.c \ 45 | ws2812.c \ 46 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_rcc.c \ 47 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_adc.c \ 48 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_gpio.c \ 49 | STM32F0xx_StdPeriph_Driver/src/stm32f0xx_misc.c \ 50 | lib/startup_stm32f042.s 51 | 52 | 53 | burn : $(TARGET).bin 54 | openocd -f flash.cfg #-d3 55 | 56 | terminal : 57 | openocd -f terminal.cfg 58 | 59 | $(TARGET).bin : $(TARGET).out 60 | $(PREFIX)-size $^ 61 | $(CP) $(OBJCOPYFLAGS) $< $@ 62 | 63 | $(TARGET).hex: $(EXECUTABLE) 64 | $(CP) -O ihex $^ $@ 65 | 66 | $(TARGET).out : $(SRC) 67 | $(CC) $(CFLAGS) $^ -lm -lc -lnosys -o $@ 68 | 69 | clean: 70 | rm -f $(TARGET).lst $(TARGET).out $(TARGET).hex $(TARGET).bin $(TARGET).map $(EXECUTABLE) 71 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/README.md: -------------------------------------------------------------------------------- 1 | # Tensigral lamp firmware demo 2 | 3 | For operation on an STM32F042 with the tensigral lamp firmware, using SK6812-RGBW LEDs. 4 | 5 | # Prerequisites 6 | 7 | sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi openocd 8 | 9 | # Copyright Notice 10 | 11 | The code in this repository (except for ARM-only code) is Copyright 2017-2020 <>< Charles Lohr. 12 | 13 | I hope to update this license later, but I think it's going to be all 100% MIT/x11 14 | 15 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/MCD-ST Liberty SW License Agreement V2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/MCD-ST Liberty SW License Agreement V2.pdf -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/Release_Notes.html -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_CRC_H 31 | #define __STM32F0XX_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /*!< Includes ----------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup CRC_ReverseInputData 52 | * @{ 53 | */ 54 | #define CRC_ReverseInputData_No ((uint32_t)0x00000000) /*!< No reverse operation of Input Data */ 55 | #define CRC_ReverseInputData_8bits CRC_CR_REV_IN_0 /*!< Reverse operation of Input Data on 8 bits */ 56 | #define CRC_ReverseInputData_16bits CRC_CR_REV_IN_1 /*!< Reverse operation of Input Data on 16 bits */ 57 | #define CRC_ReverseInputData_32bits CRC_CR_REV_IN /*!< Reverse operation of Input Data on 32 bits */ 58 | 59 | #define IS_CRC_REVERSE_INPUT_DATA(DATA) (((DATA) == CRC_ReverseInputData_No) || \ 60 | ((DATA) == CRC_ReverseInputData_8bits) || \ 61 | ((DATA) == CRC_ReverseInputData_16bits) || \ 62 | ((DATA) == CRC_ReverseInputData_32bits)) 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup CRC_PolynomialSize 69 | * @brief Only applicable for STM32F042 and STM32F072 devices 70 | * @{ 71 | */ 72 | #define CRC_PolSize_7 CRC_CR_POLSIZE /*!< 7-bit polynomial for CRC calculation */ 73 | #define CRC_PolSize_8 CRC_CR_POLSIZE_1 /*!< 8-bit polynomial for CRC calculation */ 74 | #define CRC_PolSize_16 CRC_CR_POLSIZE_0 /*!< 16-bit polynomial for CRC calculation */ 75 | #define CRC_PolSize_32 ((uint32_t)0x00000000)/*!< 32-bit polynomial for CRC calculation */ 76 | 77 | #define IS_CRC_POL_SIZE(SIZE) (((SIZE) == CRC_PolSize_7) || \ 78 | ((SIZE) == CRC_PolSize_8) || \ 79 | ((SIZE) == CRC_PolSize_16) || \ 80 | ((SIZE) == CRC_PolSize_32)) 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /* Exported macro ------------------------------------------------------------*/ 87 | /* Exported functions ------------------------------------------------------- */ 88 | /* Configuration of the CRC computation unit **********************************/ 89 | void CRC_DeInit(void); 90 | void CRC_ResetDR(void); 91 | void CRC_PolynomialSizeSelect(uint32_t CRC_PolSize); /*!< Only applicable for STM32F042 and STM32F072 devices */ 92 | void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData); 93 | void CRC_ReverseOutputDataCmd(FunctionalState NewState); 94 | void CRC_SetInitRegister(uint32_t CRC_InitValue); 95 | void CRC_SetPolynomial(uint32_t CRC_Pol); /*!< Only applicable for STM32F042 and STM32F072 devices */ 96 | 97 | /* CRC computation ************************************************************/ 98 | uint32_t CRC_CalcCRC(uint32_t CRC_Data); 99 | uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data); /*!< Only applicable for STM32F042 and STM32F072 devices */ 100 | uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data); /*!< Only applicable for STM32F042 and STM32F072 devices */ 101 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 102 | uint32_t CRC_GetCRC(void); 103 | 104 | /* Independent register (IDR) access (write/read) *****************************/ 105 | void CRC_SetIDRegister(uint8_t CRC_IDValue); 106 | uint8_t CRC_GetIDRegister(void); 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* __STM32F0XX_CRC_H */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_DBGMCU_H 31 | #define __STM32F0XX_DBGMCU_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup DBGMCU 45 | * @{ 46 | */ 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | 51 | /** @defgroup DBGMCU_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | #define DBGMCU_STOP DBGMCU_CR_DBG_STOP 56 | #define DBGMCU_STANDBY DBGMCU_CR_DBG_STANDBY 57 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF9) == 0x00) && ((PERIPH) != 0x00)) 58 | 59 | #define DBGMCU_TIM2_STOP DBGMCU_APB1_FZ_DBG_TIM2_STOP /*!< Not applicable for STM32F030 devices */ 60 | #define DBGMCU_TIM3_STOP DBGMCU_APB1_FZ_DBG_TIM3_STOP 61 | #define DBGMCU_TIM6_STOP DBGMCU_APB1_FZ_DBG_TIM6_STOP 62 | #define DBGMCU_TIM7_STOP DBGMCU_APB1_FZ_DBG_TIM7_STOP /*!< Only applicable for STM32F072 devices */ 63 | #define DBGMCU_TIM14_STOP DBGMCU_APB1_FZ_DBG_TIM14_STOP 64 | #define DBGMCU_RTC_STOP DBGMCU_APB1_FZ_DBG_RTC_STOP 65 | #define DBGMCU_WWDG_STOP DBGMCU_APB1_FZ_DBG_WWDG_STOP 66 | #define DBGMCU_IWDG_STOP DBGMCU_APB1_FZ_DBG_IWDG_STOP 67 | #define DBGMCU_I2C1_SMBUS_TIMEOUT DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT 68 | #define DBGMCU_CAN1_STOP DBGMCU_APB1_FZ_DBG_CAN1_STOP /*!< Only applicable for STM32F042 and STM32F072 devices */ 69 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xFDDFE2CC) == 0x00) && ((PERIPH) != 0x00)) 70 | 71 | #define DBGMCU_TIM1_STOP DBGMCU_APB2_FZ_DBG_TIM1_STOP 72 | #define DBGMCU_TIM15_STOP DBGMCU_APB2_FZ_DBG_TIM15_STOP 73 | #define DBGMCU_TIM16_STOP DBGMCU_APB2_FZ_DBG_TIM16_STOP 74 | #define DBGMCU_TIM17_STOP DBGMCU_APB2_FZ_DBG_TIM17_STOP 75 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8F7FF) == 0x00) && ((PERIPH) != 0x00)) 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /* Exported macro ------------------------------------------------------------*/ 82 | /* Exported functions ------------------------------------------------------- */ 83 | 84 | /* Device and Revision ID management functions ********************************/ 85 | uint32_t DBGMCU_GetREVID(void); 86 | uint32_t DBGMCU_GetDEVID(void); 87 | 88 | /* Peripherals Configuration functions ****************************************/ 89 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 90 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 91 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* __STM32F0XX_DBGMCU_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 108 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_iwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_IWDG_H 31 | #define __STM32F0XX_IWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup IWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup IWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup IWDG_WriteAccess 56 | * @{ 57 | */ 58 | 59 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 60 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 61 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 62 | ((ACCESS) == IWDG_WriteAccess_Disable)) 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup IWDG_prescaler 68 | * @{ 69 | */ 70 | 71 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 72 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 73 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 74 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 75 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 76 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 77 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 78 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 79 | ((PRESCALER) == IWDG_Prescaler_8) || \ 80 | ((PRESCALER) == IWDG_Prescaler_16) || \ 81 | ((PRESCALER) == IWDG_Prescaler_32) || \ 82 | ((PRESCALER) == IWDG_Prescaler_64) || \ 83 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 84 | ((PRESCALER) == IWDG_Prescaler_256)) 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup IWDG_Flag 90 | * @{ 91 | */ 92 | 93 | #define IWDG_FLAG_PVU IWDG_SR_PVU 94 | #define IWDG_FLAG_RVU IWDG_SR_RVU 95 | #define IWDG_FLAG_WVU IWDG_SR_WVU 96 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU) || \ 97 | ((FLAG) == IWDG_FLAG_WVU)) 98 | 99 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 100 | 101 | #define IS_IWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0xFFF) 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /* Exported macro ------------------------------------------------------------*/ 111 | /* Exported functions ------------------------------------------------------- */ 112 | 113 | /* Prescaler and Counter configuration functions ******************************/ 114 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 115 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 116 | void IWDG_SetReload(uint16_t Reload); 117 | void IWDG_ReloadCounter(void); 118 | void IWDG_SetWindowValue(uint16_t WindowValue); 119 | 120 | /* IWDG activation function ***************************************************/ 121 | void IWDG_Enable(void); 122 | 123 | /* Flag management function ***************************************************/ 124 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* __STM32F0XX_IWDG_H */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 141 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_misc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_MISC_H 31 | #define __STM32F0XX_MISC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup MISC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | /** 51 | * @brief NVIC Init Structure definition 52 | */ 53 | 54 | typedef struct 55 | { 56 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 57 | This parameter can be a value of @ref IRQn_Type 58 | (For the complete STM32 Devices IRQ Channels list, 59 | please refer to stm32f0xx.h file) */ 60 | 61 | uint8_t NVIC_IRQChannelPriority; /*!< Specifies the priority level for the IRQ channel specified 62 | in NVIC_IRQChannel. This parameter can be a value 63 | between 0 and 3. */ 64 | 65 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 66 | will be enabled or disabled. 67 | This parameter can be set either to ENABLE or DISABLE */ 68 | } NVIC_InitTypeDef; 69 | 70 | /** 71 | * 72 | @verbatim 73 | 74 | @endverbatim 75 | */ 76 | 77 | /* Exported constants --------------------------------------------------------*/ 78 | 79 | /** @defgroup MISC_Exported_Constants 80 | * @{ 81 | */ 82 | 83 | /** @defgroup MISC_System_Low_Power 84 | * @{ 85 | */ 86 | 87 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 88 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 89 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 90 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 91 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 92 | ((LP) == NVIC_LP_SLEEPONEXIT)) 93 | /** 94 | * @} 95 | */ 96 | 97 | /** @defgroup MISC_Preemption_Priority_Group 98 | * @{ 99 | */ 100 | #define IS_NVIC_PRIORITY(PRIORITY) ((PRIORITY) < 0x04) 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | /** @defgroup MISC_SysTick_clock_source 107 | * @{ 108 | */ 109 | 110 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 111 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 112 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 113 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Exported macro ------------------------------------------------------------*/ 123 | /* Exported functions ------------------------------------------------------- */ 124 | 125 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 126 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 127 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif /* __STM32F0XX_MISC_H */ 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 144 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_wwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file contains all the functions prototypes for the WWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F0XX_WWDG_H 31 | #define __STM32F0XX_WWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f0xx.h" 39 | 40 | /** @addtogroup STM32F0xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup WWDG 45 | * @{ 46 | */ 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /* Exported macro ------------------------------------------------------------*/ 78 | /* Exported functions ------------------------------------------------------- */ 79 | /* Function used to set the WWDG configuration to the default reset state ****/ 80 | void WWDG_DeInit(void); 81 | 82 | /* Prescaler, Refresh window and Counter configuration functions **************/ 83 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 84 | void WWDG_SetWindowValue(uint8_t WindowValue); 85 | void WWDG_EnableIT(void); 86 | void WWDG_SetCounter(uint8_t Counter); 87 | 88 | /* WWDG activation functions **************************************************/ 89 | void WWDG_Enable(uint8_t Counter); 90 | 91 | /* Interrupts and flags management functions **********************************/ 92 | FlagStatus WWDG_GetFlagStatus(void); 93 | void WWDG_ClearFlag(void); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* __STM32F0XX_WWDG_H */ 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 110 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_misc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_misc.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 16-January-2014 7 | * @brief This file provides all the miscellaneous firmware functions (add-on 8 | * to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2014 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f0xx_misc.h" 31 | 32 | /** @addtogroup STM32F0xx_StdPeriph_Driver 33 | * @{ 34 | */ 35 | 36 | /** @defgroup MISC 37 | * @brief MISC driver modules 38 | * @{ 39 | */ 40 | 41 | /* Private typedef -----------------------------------------------------------*/ 42 | /* Private define ------------------------------------------------------------*/ 43 | /* Private macro -------------------------------------------------------------*/ 44 | /* Private variables ---------------------------------------------------------*/ 45 | /* Private function prototypes -----------------------------------------------*/ 46 | /* Private functions ---------------------------------------------------------*/ 47 | 48 | /** @defgroup MISC_Private_Functions 49 | * @{ 50 | */ 51 | /** 52 | * 53 | @verbatim 54 | ******************************************************************************* 55 | ##### Interrupts configuration functions ##### 56 | ******************************************************************************* 57 | [..] This section provide functions allowing to configure the NVIC interrupts 58 | (IRQ). The Cortex-M0 exceptions are managed by CMSIS functions. 59 | (#) Enable and Configure the priority of the selected IRQ Channels. 60 | The priority can be 0..3. 61 | 62 | -@- Lower priority values gives higher priority. 63 | -@- Priority Order: 64 | (#@) Lowest priority. 65 | (#@) Lowest hardware priority (IRQn position). 66 | 67 | @endverbatim 68 | */ 69 | 70 | /** 71 | * @brief Initializes the NVIC peripheral according to the specified 72 | * parameters in the NVIC_InitStruct. 73 | * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains 74 | * the configuration information for the specified NVIC peripheral. 75 | * @retval None 76 | */ 77 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct) 78 | { 79 | uint32_t tmppriority = 0x00; 80 | 81 | /* Check the parameters */ 82 | assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd)); 83 | assert_param(IS_NVIC_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPriority)); 84 | 85 | if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE) 86 | { 87 | /* Compute the Corresponding IRQ Priority --------------------------------*/ 88 | tmppriority = NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02]; 89 | tmppriority &= (uint32_t)(~(((uint32_t)0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8))); 90 | tmppriority |= (uint32_t)((((uint32_t)NVIC_InitStruct->NVIC_IRQChannelPriority << 6) & 0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8)); 91 | 92 | NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02] = tmppriority; 93 | 94 | /* Enable the Selected IRQ Channels --------------------------------------*/ 95 | NVIC->ISER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 96 | } 97 | else 98 | { 99 | /* Disable the Selected IRQ Channels -------------------------------------*/ 100 | NVIC->ICER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 101 | } 102 | } 103 | 104 | /** 105 | * @brief Selects the condition for the system to enter low power mode. 106 | * @param LowPowerMode: Specifies the new mode for the system to enter low power mode. 107 | * This parameter can be one of the following values: 108 | * @arg NVIC_LP_SEVONPEND: Low Power SEV on Pend. 109 | * @arg NVIC_LP_SLEEPDEEP: Low Power DEEPSLEEP request. 110 | * @arg NVIC_LP_SLEEPONEXIT: Low Power Sleep on Exit. 111 | * @param NewState: new state of LP condition. 112 | * This parameter can be: ENABLE or DISABLE. 113 | * @retval None 114 | */ 115 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState) 116 | { 117 | /* Check the parameters */ 118 | assert_param(IS_NVIC_LP(LowPowerMode)); 119 | 120 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 121 | 122 | if (NewState != DISABLE) 123 | { 124 | SCB->SCR |= LowPowerMode; 125 | } 126 | else 127 | { 128 | SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode); 129 | } 130 | } 131 | 132 | /** 133 | * @brief Configures the SysTick clock source. 134 | * @param SysTick_CLKSource: specifies the SysTick clock source. 135 | * This parameter can be one of the following values: 136 | * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. 137 | * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source. 138 | * @retval None 139 | */ 140 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) 141 | { 142 | /* Check the parameters */ 143 | assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource)); 144 | 145 | if (SysTick_CLKSource == SysTick_CLKSource_HCLK) 146 | { 147 | SysTick->CTRL |= SysTick_CLKSource_HCLK; 148 | } 149 | else 150 | { 151 | SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8; 152 | } 153 | } 154 | 155 | /** 156 | * @} 157 | */ 158 | 159 | /** 160 | * @} 161 | */ 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 168 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/adc.c: -------------------------------------------------------------------------------- 1 | #include "adc.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | /* 11 | #define ADC_IT_ADRDY ADC_IER_ADRDYIE // Doesn't trigger? 12 | #define ADC_IT_EOSMP ADC_IER_EOSMPIE //Triggers/ 13 | #define ADC_IT_EOC ADC_IER_EOCIE //Triggers. 14 | #define ADC_IT_EOSEQ ADC_IER_EOSEQIE //BINGO 15 | #define ADC_IT_OVR ADC_IER_OVRIE 16 | #define ADC_IT_AWD ADC_IER_AWDIE 17 | */ 18 | //#define ADCINT ADC_IT_EOSEQ || ADC_IT_EOSMP 19 | 20 | volatile uint16_t adcreads = 0; 21 | volatile static int adcstate = 0; 22 | volatile uint8_t adc_done = 0; 23 | volatile uint16_t ADCs[4]; 24 | 25 | 26 | #define ADCCHANS 3 //Base, 3.6v and Temp. 27 | 28 | void setup_adcs() 29 | { 30 | //int i; 31 | 32 | //From http://hung2492.blogspot.com/2015/02/lesson-5-adcdac-stm32f0.html 33 | 34 | GPIO_InitTypeDef GPIO_InitStructure; 35 | ADC_InitTypeDef ADC_InitStructure; 36 | 37 | //(#) Enable the ADC interface clock using 38 | // RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); 39 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); 40 | 41 | //(#) ADC pins configuration 42 | // (++) Enable the clock for the ADC GPIOs using the following function: 43 | // RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOx, ENABLE); 44 | // (++) Configure these ADC pins in analog mode using GPIO_Init(); 45 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); 46 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); 47 | 48 | GPIO_InitStructure.GPIO_Pin = 1<<2; //PA2 49 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; 50 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; 51 | GPIO_Init(GPIOA, &GPIO_InitStructure); 52 | 53 | GPIO_InitStructure.GPIO_Pin = 1; //PB0 (5V rail) 54 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; 55 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; 56 | GPIO_Init(GPIOB, &GPIO_InitStructure); 57 | 58 | //(#) Configure the ADC conversion resolution, data alignment, external 59 | // trigger and edge, scan direction and Enable/Disable the continuous mode 60 | // using the ADC_Init() function. 61 | ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; 62 | ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; 63 | ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; 64 | ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_TRGO; 65 | ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; 66 | ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Upward; 67 | ADC_Init(ADC1, &ADC_InitStructure); 68 | 69 | ADC_TempSensorCmd( ENABLE ); 70 | ADC_ChannelConfig(ADC1, 2, ADC_SampleTime_13_5Cycles); 71 | 72 | // Calibrate ADC before enabling 73 | ADC_GetCalibrationFactor(ADC1); 74 | //(#) Activate the ADC peripheral using ADC_Cmd() function. 75 | ADC_Cmd(ADC1, ENABLE); 76 | 77 | // Wait until ADC enabled 78 | while(ADC_GetFlagStatus(ADC1, ADC_FLAG_ADEN) == RESET); 79 | 80 | NVIC_InitTypeDef NVIC_InitStructure; 81 | NVIC_InitStructure.NVIC_IRQChannel = ADC1_IRQn; 82 | NVIC_InitStructure.NVIC_IRQChannelPriority = 3; 83 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 84 | NVIC_Init(&NVIC_InitStructure); 85 | 86 | // Enable Watchdog interrupt 87 | ADC_ITConfig(ADC1, ADC_IT_EOSEQ | ADC_IT_EOSMP, ENABLE); //Enable for end-of-conversion. 88 | 89 | adc_done = 1; 90 | 91 | send_text( "ADC Setup\n" ); 92 | } 93 | 94 | int initialize_adc_start() 95 | { 96 | if( !adc_done ) 97 | { 98 | return -1; 99 | } 100 | 101 | adc_done = 0; 102 | 103 | adcstate = 0; 104 | ADC1->CHSELR = 2; 105 | ADC_StartOfConversion(ADC1); 106 | 107 | adcstate = 1; 108 | return 0; 109 | } 110 | 111 | void __attribute__ ((interrupt("IRQ"))) ADC1_IRQHandler(void) 112 | { 113 | if(ADC1->ISR & ADC_IT_EOSMP) 114 | { 115 | //End of sample? Could switch to another mux. 116 | ADC_ClearFlag( ADC1, ADC_IT_EOSMP ); 117 | } 118 | if( ADC1->ISR & ADC_IT_EOSEQ ) 119 | { 120 | 121 | //Careful: Take as much time as possible between changing the mux values and the below part. 122 | //This gives time for the mux to switch over. 123 | 124 | ADC_ClearFlag( ADC1, ADC_IT_EOSEQ ); 125 | adcreads++; 126 | 127 | //uint8_t gotval = adcstate-1; 128 | uint16_t val = ADC1->DR; //ADC_GetConversionValue(ADC1); 129 | //uint8_t triple = (gotval>>1) * 3; 130 | 131 | //XXX Tricky: Get temperature state 132 | if( adcstate == ADCCHANS ) 133 | { 134 | #define TEMP110_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7C2)) 135 | #define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7B8)) 136 | #define VDD_CALIB ((uint16_t) (330)) 137 | #define VDD_APPLI ((uint16_t) (360)) 138 | int32_t temperature; /* will contain the temperature in degrees Celsius */ 139 | temperature = (((int32_t) val * VDD_APPLI / VDD_CALIB) - (int32_t) *TEMP30_CAL_ADDR ); 140 | temperature = temperature * (int32_t)(110 - 30) * 10; 141 | temperature = temperature / (int32_t)(*TEMP110_CAL_ADDR - *TEMP30_CAL_ADDR); 142 | val = temperature + 300; 143 | } 144 | 145 | //XXX Your value is in "val" 146 | ADCs[adcstate] = val; 147 | 148 | if( adcstate >= ADCCHANS ) 149 | { 150 | adc_done = 1; 151 | return; 152 | } 153 | 154 | adc_done = 1; 155 | ADC1->CHSELR = 2; 156 | ADC_StartOfConversion(ADC1); 157 | 158 | adcstate++; 159 | } 160 | } 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/adc.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADC_H 2 | #define _ADC_H 3 | 4 | #include 5 | 6 | void setup_adcs(); 7 | 8 | int initialize_adc_start(); 9 | 10 | extern volatile uint16_t adcreads; 11 | extern volatile uint8_t adc_done; 12 | extern volatile uint16_t ADCs[4]; 13 | 14 | #endif 15 | 16 | 17 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/flash.cfg: -------------------------------------------------------------------------------- 1 | source [find interface/stlink-v2.cfg] 2 | source [find target/stm32f0x.cfg] 3 | 4 | #reset_config none separate 5 | #reset_config srst_push_pull 6 | #separate trst_push_pull 7 | #reset_config srst_nogate 8 | 9 | init 10 | reset halt 11 | halt 20 12 | reset 13 | sleep 10 14 | reset halt 15 | flash write_image erase main.bin 0x08000000 16 | sleep 10 17 | reset 18 | sleep 10 19 | arm semihosting enable 20 | reset run 21 | sleep 10 22 | 23 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/lib/flash.ld: -------------------------------------------------------------------------------- 1 | /* Entry Point */ 2 | ENTRY(Reset_Handler) 3 | 4 | /* Tweaked for the STM32F042, 32kB of Flash + 6kB of ram! */ 5 | 6 | /* Highest address of the user mode stack */ 7 | _estack = 0x200017FF; /* end of RAM */ 8 | 9 | /* Generate a link error if heap and stack don't fit into RAM */ 10 | _Min_Heap_Size = 0x000; /* required amount of heap */ 11 | _Min_Stack_Size = 0x100; /* required amount of stack */ 12 | 13 | /* Specify the memory areas */ 14 | MEMORY 15 | { 16 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K 17 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 6K 18 | } 19 | 20 | /* Define output sections */ 21 | SECTIONS 22 | { 23 | /* The startup code goes first into FLASH */ 24 | .isr_vector : 25 | { 26 | . = ALIGN(4); 27 | KEEP(*(.isr_vector)) /* Startup code */ 28 | . = ALIGN(4); 29 | } >FLASH 30 | 31 | /* The program code and other data goes into FLASH */ 32 | .text : 33 | { 34 | . = ALIGN(4); 35 | *(.text) /* .text sections (code) */ 36 | *(.text*) /* .text* sections (code) */ 37 | *(.glue_7) /* glue arm to thumb code */ 38 | *(.glue_7t) /* glue thumb to arm code */ 39 | *(.eh_frame) 40 | 41 | KEEP (*(.init)) 42 | KEEP (*(.fini)) 43 | 44 | . = ALIGN(4); 45 | _etext = .; /* define a global symbols at end of code */ 46 | } >FLASH 47 | 48 | /* Constant data goes into FLASH */ 49 | .rodata : 50 | { 51 | . = ALIGN(4); 52 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 53 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 54 | . = ALIGN(4); 55 | } >FLASH 56 | 57 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 58 | .ARM : { 59 | __exidx_start = .; 60 | *(.ARM.exidx*) 61 | __exidx_end = .; 62 | } >FLASH 63 | 64 | .preinit_array : 65 | { 66 | PROVIDE_HIDDEN (__preinit_array_start = .); 67 | KEEP (*(.preinit_array*)) 68 | PROVIDE_HIDDEN (__preinit_array_end = .); 69 | } >FLASH 70 | .init_array : 71 | { 72 | PROVIDE_HIDDEN (__init_array_start = .); 73 | KEEP (*(SORT(.init_array.*))) 74 | KEEP (*(.init_array*)) 75 | PROVIDE_HIDDEN (__init_array_end = .); 76 | } >FLASH 77 | .fini_array : 78 | { 79 | PROVIDE_HIDDEN (__fini_array_start = .); 80 | KEEP (*(.fini_array*)) 81 | KEEP (*(SORT(.fini_array.*))) 82 | PROVIDE_HIDDEN (__fini_array_end = .); 83 | } >FLASH 84 | 85 | /* used by the startup to initialize data */ 86 | _sidata = LOADADDR(.data); 87 | 88 | /* Initialized data sections goes into RAM, load LMA copy after code */ 89 | .data : 90 | { 91 | . = ALIGN(4); 92 | _sdata = .; /* create a global symbol at data start */ 93 | *(.data) /* .data sections */ 94 | *(.data*) /* .data* sections */ 95 | 96 | . = ALIGN(4); 97 | _edata = .; /* define a global symbol at data end */ 98 | } >RAM AT> FLASH 99 | 100 | /* Uninitialized data section */ 101 | . = ALIGN(4); 102 | .bss : 103 | { 104 | /* This is used by the startup in order to initialize the .bss secion */ 105 | _sbss = .; /* define a global symbol at bss start */ 106 | __bss_start__ = _sbss; 107 | *(.bss) 108 | *(.bss*) 109 | *(COMMON) 110 | 111 | . = ALIGN(4); 112 | _ebss = .; /* define a global symbol at bss end */ 113 | __bss_end__ = _ebss; 114 | } >RAM 115 | 116 | /* User_heap_stack section, used to check that there is enough RAM left */ 117 | ._user_heap_stack : 118 | { 119 | . = ALIGN(4); 120 | PROVIDE ( end = . ); 121 | PROVIDE ( _end = . ); 122 | . = . + _Min_Heap_Size; 123 | . = . + _Min_Stack_Size; 124 | . = ALIGN(4); 125 | } >RAM 126 | 127 | 128 | /* Remove information from the standard libraries */ 129 | /DISCARD/ : 130 | { 131 | libc.a ( * ) 132 | libm.a ( * ) 133 | libgcc.a ( * ) 134 | } 135 | 136 | .ARM.attributes 0 : { *(.ARM.attributes) } 137 | } 138 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/lib/system_stm32f0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f0xx.h 4 | * @author MCD Application Team 5 | * @version V1.3.2 6 | * @date 27-March-2014 7 | * @brief CMSIS Cortex-M0 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32f0xx_system 33 | * @{ 34 | */ 35 | 36 | /** 37 | * @brief Define to prevent recursive inclusion 38 | */ 39 | #ifndef __SYSTEM_STM32F0XX_H 40 | #define __SYSTEM_STM32F0XX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @addtogroup STM32F0xx_System_Includes 47 | * @{ 48 | */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @addtogroup STM32F0xx_System_Exported_types 56 | * @{ 57 | */ 58 | 59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @addtogroup STM32F0xx_System_Exported_Constants 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @addtogroup STM32F0xx_System_Exported_Macros 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @addtogroup STM32F0xx_System_Exported_Functions 82 | * @{ 83 | */ 84 | 85 | extern void SystemInit(void); 86 | extern void SystemCoreClockUpdate(void); 87 | /** 88 | * @} 89 | */ 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /*__SYSTEM_STM32F0XX_H */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/main.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/main.bin -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/main.c: -------------------------------------------------------------------------------- 1 | // Copyright 2017, 2020 <>< Charles Lohr. See README.md for copyright details. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "touch.h" 9 | #include 10 | #include 11 | 12 | RCC_ClocksTypeDef RCC_Clocks; 13 | 14 | volatile int r; 15 | 16 | void SysTick_Handler(void) 17 | { 18 | r++; 19 | } 20 | 21 | void SystemBootFault( uint32_t HSEStatus, uint32_t Timeout ) 22 | { 23 | send_text( "No external oscillator.\n" ); 24 | while(1); 25 | // send_text_value( "HSEStatus:", HSEStatus ); 26 | // send_text_value( "Timeout:", Timeout ); 27 | // send_text_value( "RCC->CFGR:", RCC->CFGR ); 28 | // send_text_value( "RCC->CR:", RCC->CR ); 29 | 30 | // while(1); 31 | } 32 | 33 | void assert_param( int x ) 34 | { 35 | if( !x ) 36 | { 37 | send_text( "ASSERT\n" ); 38 | while(1); 39 | } 40 | } 41 | 42 | //All data is assumed 64-byte chunks. 43 | 44 | void CBHIDSetup( uint16_t length, uint8_t code ) 45 | { 46 | //Don't care about initial packet showing start of control transfer. 47 | 48 | //send_text_value( "L: ", length ); 49 | //send_text_value( "C: ", code ); 50 | } 51 | 52 | volatile int do_trigger_leds = 0; 53 | 54 | void CBHIDData( uint8_t paklen, uint8_t * data ) 55 | { 56 | #if 0 57 | //Byte 1 = MSB = Launch when done. --- LSBs = length of this packet in LEDs 58 | //Byte 2 = Offset, LEDs 59 | 60 | UpdateLEDs( data[1], &data[2], data[0] & 0x7f ); 61 | // send_text_value( "TV:", data[1] ); 62 | if( data[0] & 0x80 ) 63 | { 64 | TriggerDMA(); 65 | } 66 | #endif 67 | //Seems unreliable. 68 | } 69 | 70 | void CBHIDInterruptIn( uint8_t paklen, uint8_t * data ) 71 | { 72 | //Byte 1 = MSB = Launch when done. --- LSBs = length of this packet in LEDs 73 | //Byte 2 = Offset, LEDs 74 | 75 | // send_text_value( "SVD: ", data[0] ); 76 | 77 | UpdateLEDs( data[1], &data[2], data[0] & 0x7f ); 78 | // send_text_value( "TV:", data[1] ); 79 | if( data[0] & 0x80 ) 80 | { 81 | TriggerDMA(); 82 | } 83 | } 84 | 85 | 86 | uint8_t senddata[64]; 87 | 88 | int main() 89 | { 90 | int i; 91 | SystemCoreClockUpdate(); 92 | RCC_GetClocksFreq( &RCC_Clocks ); 93 | SysTick_Config( RCC_Clocks.SYSCLK_Frequency/100 ); //100 Hz. 94 | #if 0 95 | send_text_value( "SYSCLK_Frequency: ", RCC_Clocks.SYSCLK_Frequency ); 96 | send_text_value( "HCLK_Frequency: ", RCC_Clocks.HCLK_Frequency ); 97 | send_text_value( "PCLK_Frequency: ", RCC_Clocks.PCLK_Frequency ); 98 | send_text_value( "ADCCLK_Frequency: ", RCC_Clocks.ADCCLK_Frequency ); 99 | send_text_value( "CECCLK_Frequency: ", RCC_Clocks.CECCLK_Frequency ); 100 | send_text_value( "I2C1CLK_Frequency: ", RCC_Clocks.I2C1CLK_Frequency ); 101 | send_text_value( "USART1CLK_Frequency: ", RCC_Clocks.USART1CLK_Frequency ); 102 | send_text_value( "USART2CLK_Frequency: ", RCC_Clocks.USART2CLK_Frequency ); 103 | send_text_value( "USBCLK_Frequency: ", RCC_Clocks.USBCLK_Frequency ); 104 | send_text_value( "SYSCLK_Frequency: ", RCC_Clocks.SYSCLK_Frequency ); 105 | send_text_value( "RCC->CFGR:", RCC->CFGR ); 106 | send_text_value( "RCC->CR:", RCC->CR ); 107 | send_text_value( "SWS:",RCC->CFGR & RCC_CFGR_SWS); 108 | #endif 109 | 110 | ConfigureGPIO( 0x05, INOUT_OUT ); //Also do this first to enable port A. 111 | init_touch(); 112 | 113 | setup_adcs(); 114 | 115 | initialize_adc_start(); 116 | InitWSDMA(); 117 | 118 | init_usb(); 119 | 120 | for( i = 0; i < 20; i++ ) 121 | { 122 | UpdateLEDs( i, (uint8_t*)"\x60\x00\x80\xff", 1 ); 123 | } 124 | 125 | TriggerDMA(); 126 | 127 | uint8_t counts[3]; 128 | 129 | while(1) 130 | { 131 | // GPIOLatch( 0x00 ) &= ~(1<<6); 132 | //GPIOOn( 0x06 ); 133 | 134 | //GPIOOff( 0x06 ); 135 | 136 | if( usbDataOkToRead ) 137 | { 138 | CBHIDInterruptIn( 64, usb_get_out_ep_buffer() ); 139 | usb_release_out_ep_buffer(); 140 | usbDataOkToRead = 0; 141 | } 142 | if( usbDataOkToSend && adc_done ) 143 | { 144 | for( i = 0; i < 3; i++ ) 145 | { 146 | senddata[4+i*2+0] = ADCs[i] & 0xff; 147 | senddata[4+i*2+1] = (ADCs[i] >> 8) & 0xff; 148 | } 149 | 150 | senddata[0] = adcreads>>8; 151 | senddata[1] = adcreads; 152 | senddata[2]++; 153 | senddata[20] = counts[0]; 154 | senddata[21] = counts[1]; 155 | senddata[22] = counts[2]; 156 | usb_data( senddata, ENDPOINT1_SIZE ); 157 | initialize_adc_start(); 158 | 159 | run_touch( counts ); 160 | } 161 | //GPIOOn( 0x05 ); 162 | //GPIOOff( 0x05 ); 163 | //GPIOOn( 0x05 ); 164 | //GPIOOff( 0x05 ); 165 | } 166 | } 167 | 168 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/main.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/main.out -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/systems.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 <>< Charles Lohr. This file may be licensed under the MIT/x11 license or the NewBSD license. 2 | 3 | //Partially from colorchord. 4 | 5 | #ifndef _SYSTEMS_H 6 | #define _SYSTEMS_H 7 | 8 | 9 | #ifdef STM32F30X 10 | #include 11 | #elif defined( STM32F40_41xxx ) 12 | #include 13 | #elif defined( STM32F042 ) 14 | #include 15 | #endif 16 | 17 | 18 | void send_openocd_command(int command, void *message); 19 | 20 | #ifdef DEBUG 21 | void send_text( const char * text ); 22 | void send_text_value( const char * text, uint32_t val ); 23 | #else 24 | //No debug = no printfing. 25 | #define send_text( x ) 26 | #define send_text_value( x, y ) 27 | #endif 28 | 29 | void _delay_us( uint32_t us); 30 | char hexfrom1( uint8_t val ); 31 | 32 | 33 | typedef uint8_t gpio; 34 | 35 | gpio GetGPIOFromString( const char * str ); //i.e. "A4" or "PA5" or "B.7" 36 | #define GPIO_FROM_NUMS( port, pin ) (((port)<<4 ) | (pin)) 37 | 38 | #define DEFAULT_VALUE_FLAG 0x00000001 39 | #define DEFAULT_ON 0x00000001 40 | #define DEFAULT_OFF 0x00000000 41 | 42 | #define INOUT_FLAG 0x00000002 43 | #define INOUT_OUT 0x00000002 44 | #define INOUT_IN 0x00000000 45 | 46 | #define PUPD_FLAG 0x0000000C 47 | #define PUPD_NONE 0x00000000 48 | #define PUPD_UP 0x00000004 49 | #define PUPD_DOWN 0x00000008 50 | 51 | #define GPALTFUNCTION_FLAGS 0x0000ff00 52 | 53 | void ConfigureGPIO( gpio gpio, int parameters ); 54 | 55 | 56 | 57 | #ifdef STM32F30X 58 | #define GPIOOf(x) ((GPIO_TypeDef *) ((((x)>>4)<=6)?(AHB2PERIPH_BASE+0x400*((x)>>4)):0x60000000) ) 59 | #elif defined( STM32F40_41xxx ) 60 | #define GPIOOf(x) ((GPIO_TypeDef *) ((((x)>>4)<=6)?(AHB1PERIPH_BASE+0x400*((x)>>4)):0x60000000) ) 61 | #elif defined( STM32F042 ) 62 | #define GPIOOf(x) ((GPIO_TypeDef *) ((AHB2PERIPH_BASE + 0x00000400 * ((x)>>4) )) ) 63 | #endif 64 | 65 | #define GPIOPin(x) ((1<<((x)&0x0f))) 66 | #define GPIOLatch(x) GPIOOf(x)->ODR 67 | 68 | #ifdef STM32F30X 69 | #define GPIOOn(x) GPIOOf(x)->BSRR = (1<<((x)&0x0f)); 70 | #define GPIOOff(x) GPIOOf(x)->BRR = (1<<((x)&0x0f)); 71 | #elif defined( STM32F40_41xxx ) 72 | #define GPIOOn(x) GPIOOf(x)->BSRRH = (1<<((x)&0x0f)); 73 | #define GPIOOff(x) GPIOOf(x)->BSRRL = (1<<((x)&0x0f)); 74 | #elif defined( STM32F042 ) 75 | #define GPIOOn(x) GPIOOf(x)->BSRR = (1<<((x)&0x0f)); 76 | #define GPIOOff(x) GPIOOf(x)->BRR = (1<<((x)&0x0f)); 77 | #else 78 | #error Undefined architecture 79 | #endif 80 | 81 | #ifndef STM32F042 82 | 83 | #ifdef STM32F30X 84 | #define LEDPIN 0x18 85 | #elif defined( STM32F40_41xxx ) 86 | #define LEDPIN 0x3f 87 | #endif 88 | 89 | void ConfigureLED(); 90 | #define LED_TOGGLE {GPIOOf(LEDPIN)->ODR^=(1<<((LEDPIN)&0x0f));} 91 | #define LED_ON GPIOOn(LEDPIN) 92 | #define LED_OFF GPIOOff(LEDPIN) 93 | 94 | #endif 95 | 96 | #ifndef _BV 97 | #define _BV(x) (1<<(x)) 98 | #endif 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/terminal.cfg: -------------------------------------------------------------------------------- 1 | source [find interface/stlink-v2.cfg] 2 | source [find target/stm32f0x.cfg] 3 | 4 | #reset_config none separate 5 | #reset_config srst_push_pull 6 | #separate trst_push_pull 7 | 8 | reset_config srst_nogate 9 | init 10 | 11 | #to manually recover, unplug, connect reset hard to ground. 12 | # replug. 13 | # 'reset halt'. 14 | # unplug reset, plug into programmer's reset. 15 | 16 | # flash erase_sector 0 0 100 17 | # flash write_image erase main.bin 0x08000000 18 | 19 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/CNFGFunctions.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2011, 2017 <>< Charles Lohr - Under the MIT/x11 or NewBSD License you choose. 2 | 3 | #ifndef _DRAWFUCNTIONS_H 4 | #define _DRAWFUCNTIONS_H 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #include 11 | 12 | typedef struct { 13 | short x, y; 14 | } RDPoint; 15 | 16 | extern int CNFGPenX, CNFGPenY; 17 | extern uint32_t CNFGBGColor; 18 | extern uint32_t CNFGLastColor; 19 | extern uint32_t CNFGDialogColor; //background for boxes 20 | 21 | void CNFGDrawText( const char * text, int scale ); 22 | void CNFGDrawBox( int x1, int y1, int x2, int y2 ); 23 | void CNFGGetTextExtents( const char * text, int * w, int * h, int textsize ); 24 | void CNFGDrawTextbox( int x, int y, const char * text, int textsize ); //ignores pen. 25 | 26 | //To be provided by driver. 27 | uint32_t CNFGColor( uint32_t RGB ); 28 | void CNFGUpdateScreenWithBitmap( unsigned long * data, int w, int h ); 29 | void CNFGTackPixel( short x1, short y1 ); 30 | void CNFGTackSegment( short x1, short y1, short x2, short y2 ); 31 | void CNFGTackRectangle( short x1, short y1, short x2, short y2 ); 32 | void CNFGTackPoly( RDPoint * points, int verts ); 33 | void CNFGClearFrame(); 34 | void CNFGSwapBuffers(); 35 | 36 | void CNFGGetDimensions( short * x, short * y ); 37 | void CNFGSetup( const char * WindowName, int w, int h ); 38 | void CNFGSetupFullscreen( const char * WindowName, int screen_number ); 39 | void CNFGHandleInput(); 40 | 41 | 42 | //You must provide: 43 | void HandleKey( int keycode, int bDown ); 44 | void HandleButton( int x, int y, int button, int bDown ); 45 | void HandleMotion( int x, int y, int mask ); 46 | void HandleDestroy(); 47 | 48 | 49 | //Internal function for resizing rasterizer for rasterizer-mode. 50 | void CNFGInternalResize( short x, short y ); //don't call this. 51 | 52 | //Not available on all systems. Use The OGL portion with care. 53 | #ifdef CNFGOGL 54 | void CNFGSetVSync( int vson ); 55 | void * CNFGGetExtension( const char * extname ); 56 | #endif 57 | 58 | #ifdef __cplusplus 59 | }; 60 | #endif 61 | 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/CNFGFunctions.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/tester/CNFGFunctions.o -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/CNFGXDriver.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/tester/CNFGXDriver.o -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/Makefile: -------------------------------------------------------------------------------- 1 | all : hidtest hidtest.exe 2 | 3 | hidtest.exe : hidtest.c hidapi.c os_generic.c CNFGFunctions.c CNFGWinDriver.c 4 | i686-w64-mingw32-gcc -o $@ $^ $(CFLAGS) -lsetupapi -lgdi32 5 | 6 | hidtest : hidtest.o hidapi.o os_generic.o CNFGFunctions.o CNFGXDriver.o 7 | g++ -o $@ $^ -lusb-1.0 -ludev -lpthread -lX11 8 | 9 | clean : 10 | rm -rf *.o *~ hidtest 11 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/compile.bat: -------------------------------------------------------------------------------- 1 | c:\tcc\tcc.exe -o hidtest.exe hidtest.c hidapi.c CNFGFunctions.c CNFGWinDriver.c os_generic.c -DWINDOWS -DTCC -lgdi32 -lsetupapi -luser32 2 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/hidapi.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/tester/hidapi.o -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/hidtest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/tester/hidtest -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/hidtest.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/tester/hidtest.exe -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/hidtest.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/tester/hidtest.o -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/os_generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _OS_GENERIC_H 2 | #define _OS_GENERIC_H 3 | 4 | #if defined( WIN32 ) || defined (WINDOWS) || defined( _WIN32) 5 | #define USE_WINDOWS 6 | #endif 7 | 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | //Things that shouldn't be macro'd 14 | double OGGetAbsoluteTime(); 15 | void OGSleep( int is ); 16 | void OGUSleep( int ius ); 17 | double OGGetFileTime( const char * file ); 18 | 19 | //Threads and Mutices 20 | typedef void* og_thread_t; 21 | typedef void* og_mutex_t; 22 | typedef void* og_sema_t; 23 | 24 | og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ); 25 | void * OGJoinThread( og_thread_t ot ); 26 | void OGCancelThread( og_thread_t ot ); 27 | 28 | //Always a recursive mutex. 29 | og_mutex_t OGCreateMutex(); 30 | void OGLockMutex( og_mutex_t om ); 31 | void OGUnlockMutex( og_mutex_t om ); 32 | void OGDeleteMutex( og_mutex_t om ); 33 | 34 | //Always a semaphore 35 | og_sema_t OGCreateSema(); //Create a semaphore, comes locked initially. NOTE: Max count is 32767 36 | void OGLockSema( og_sema_t os ); 37 | int OGGetSema( og_sema_t os ); //if <0 there was a failure. 38 | void OGUnlockSema( og_sema_t os ); 39 | void OGDeleteSema( og_sema_t os ); 40 | 41 | #ifdef __cplusplus 42 | }; 43 | #endif 44 | 45 | 46 | 47 | #endif 48 | 49 | 50 | //Date Stamp: 2012-02-15 51 | 52 | /* 53 | NOTE: Portions (namely the top section) are part of headers from other 54 | sources. 55 | 56 | Copyright (c) 2011-2012 <>< Charles Lohr 57 | 58 | Permission is hereby granted, free of charge, to any person obtaining a 59 | copy of this software and associated documentation files (the "Software"), 60 | to deal in the Software without restriction, including without limitation 61 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 62 | and/or sell copies of the Software, and to permit persons to whom the 63 | Software is furnished to do so, subject to the following conditions: 64 | 65 | The above copyright notice and this permission notice shall be included in 66 | all copies or substantial portions of this file. 67 | 68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 70 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 71 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 72 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 73 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 74 | IN THE SOFTWARE. 75 | */ 76 | 77 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/tester/os_generic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/tensigral_lamp/333e5be833fd055385a4a9e8fe8b05cf69d794ed/tensigral_lamp_2/firmware/tester/os_generic.o -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/touch.c: -------------------------------------------------------------------------------- 1 | #include "touch.h" 2 | #include "systems.h" 3 | 4 | uint8_t touch_calib[3]; 5 | uint8_t done_startup; 6 | 7 | //DO_PD means we use the internal pull-down resistors to measure the capacitance 8 | //if we define this to be 0, then it will use the internal pull-up resistors. 9 | //I am still experimenting with both options to see which is better overall and 10 | //in a lot of situations. 11 | 12 | #define DO_PD 1 13 | 14 | 15 | //The methodology is we are trying to measure the capacitance of a pad. This is 16 | //done by driving the pad high, then, releasing the pad. If the capacitance is 17 | //low, then, the pad's voltage will very quickly drop. If the capacitance is high 18 | //then the pad's voltage will drop much more slowly. If your finger is not present 19 | //then the voltage will cross the 0 threshhold very quicky. If your finger is present 20 | //it will take much longer, sometimes as long as a microsecond! 21 | // 22 | // v Stop driving pin high 23 | // V ------ 24 | // O | 25 | // L \ 26 | // T \ 27 | // A \ 28 | // G \ 29 | // E ------------------------------- Threshhold for measuring zero 30 | // \ 31 | // \ 32 | // ^ ------- ^ The time we're measuring 33 | 34 | void init_touch() 35 | { 36 | //This demo shows the use of 3 touch buttons, but really, an unlimited number 37 | //of touch buttons can be used using this method as long as they're all on the 38 | //same IO section. I.e. This demo uses Port A. 39 | 40 | //I use "systems.c" of which an example can be found in the ColorChord Embedded 41 | //codebase. The rest of this specific project will be made public soon. But 42 | //you can use the HAL if you absolutely need to. This is just to turn on the 43 | //port's AHB, and enable the IO as an IO push-pull port will pull-down or pull 44 | //up resistors. 45 | #if DO_PD 46 | ConfigureGPIO( 0x00, INOUT_IN | PUPD_DOWN | DEFAULT_ON ); //T0 47 | ConfigureGPIO( 0x01, INOUT_IN | PUPD_DOWN | DEFAULT_ON ); //T1 48 | ConfigureGPIO( 0x03, INOUT_IN | PUPD_DOWN | DEFAULT_ON ); //T2 49 | #else 50 | ConfigureGPIO( 0x00, INOUT_IN | PUPD_UP | DEFAULT_OFF ); //T0 51 | ConfigureGPIO( 0x01, INOUT_IN | PUPD_UP | DEFAULT_OFF ); //T1 52 | ConfigureGPIO( 0x03, INOUT_IN | PUPD_UP | DEFAULT_OFF ); //T2 53 | #endif 54 | 55 | //We run the algorithm twice. The very first time, something is always 56 | //askew with the pads, not sure why, but the second run is 100% 57 | run_touch( touch_calib ); 58 | run_touch( touch_calib ); 59 | done_startup = 1; 60 | } 61 | 62 | 63 | void run_touch( uint8_t * counts ) 64 | { 65 | counts[0] = counts[1] = counts[2] = 0; 66 | 67 | //For this tiny period of time, we disable interrupts because timing matters. 68 | __disable_irq(); 69 | 70 | //We stop driving the pin here, and let it float down. 71 | GPIOOf(0)->MODER = (GPIOOf(0)->MODER & ~(0x000cf)); 72 | uint32_t idrcheck[32]; 73 | uint32_t *idrcheckmark = idrcheck; 74 | int i; 75 | 76 | //We read the value of IDR for the port. This will make it so 77 | //we can read every IO on the port at exactly the same time. This 78 | //makes it very convenient to synchronously read many touch sensors. 79 | 80 | //You can think of this a little bit like running a logic analyzer 81 | //for a very short period of time over every pin on a given port. 82 | *(idrcheckmark++) = GPIOOf(0)->IDR; 83 | *(idrcheckmark++) = GPIOOf(0)->IDR; 84 | *(idrcheckmark++) = GPIOOf(0)->IDR; 85 | *(idrcheckmark++) = GPIOOf(0)->IDR; 86 | *(idrcheckmark++) = GPIOOf(0)->IDR; 87 | *(idrcheckmark++) = GPIOOf(0)->IDR; 88 | *(idrcheckmark++) = GPIOOf(0)->IDR; 89 | *(idrcheckmark++) = GPIOOf(0)->IDR; 90 | *(idrcheckmark++) = GPIOOf(0)->IDR; 91 | *(idrcheckmark++) = GPIOOf(0)->IDR; 92 | *(idrcheckmark++) = GPIOOf(0)->IDR; 93 | *(idrcheckmark++) = GPIOOf(0)->IDR; 94 | *(idrcheckmark++) = GPIOOf(0)->IDR; 95 | *(idrcheckmark++) = GPIOOf(0)->IDR; 96 | *(idrcheckmark++) = GPIOOf(0)->IDR; 97 | *(idrcheckmark++) = GPIOOf(0)->IDR; 98 | *(idrcheckmark++) = GPIOOf(0)->IDR; 99 | *(idrcheckmark++) = GPIOOf(0)->IDR; 100 | *(idrcheckmark++) = GPIOOf(0)->IDR; 101 | *(idrcheckmark++) = GPIOOf(0)->IDR; 102 | *(idrcheckmark++) = GPIOOf(0)->IDR; 103 | *(idrcheckmark++) = GPIOOf(0)->IDR; 104 | *(idrcheckmark++) = GPIOOf(0)->IDR; 105 | *(idrcheckmark++) = GPIOOf(0)->IDR; 106 | *(idrcheckmark++) = GPIOOf(0)->IDR; 107 | *(idrcheckmark++) = GPIOOf(0)->IDR; 108 | *(idrcheckmark++) = GPIOOf(0)->IDR; 109 | *(idrcheckmark++) = GPIOOf(0)->IDR; 110 | *(idrcheckmark++) = GPIOOf(0)->IDR; 111 | *(idrcheckmark++) = GPIOOf(0)->IDR; 112 | *(idrcheckmark++) = GPIOOf(0)->IDR; 113 | *(idrcheckmark++) = GPIOOf(0)->IDR; 114 | 115 | //Once we've spent about 2 microseconds or so reading the ports, we 116 | //then go back to driving the ports high. 117 | GPIOOf(0)->MODER = (GPIOOf(0)->MODER | (0x00045)); 118 | 119 | //Because we're messing with MODER here, we probably don't want to let 120 | //an interrupt fire before we set it back, otherwise we might corrupt 121 | //it's value. 122 | __enable_irq(); 123 | 124 | 125 | //Now, that we have our data of what the 126 | counts[0] = counts[1] = counts[2] = 0; 127 | for( i = 0; i < 32; i++ ) 128 | { 129 | #if DO_PD 130 | //The &1 selects PinA.0, &2 selects PinA.1 and &8 selects PinA.3 131 | if( ( idrcheck[i] & 1 ) ) counts[0]++; 132 | if( ( idrcheck[i] & 2 ) ) counts[1]++; 133 | if( ( idrcheck[i] & 8 ) ) counts[2]++; 134 | #else 135 | if( !( idrcheck[i] & 1 ) ) counts[0]++; 136 | if( !( idrcheck[i] & 2 ) ) counts[1]++; 137 | if( !( idrcheck[i] & 8 ) ) counts[2]++; 138 | #endif 139 | } 140 | 141 | //Potentially write calibration data, and/or subtract out 142 | //our calibration data as being our reference "zero" pressure. 143 | 144 | //If the read value every drops very percipitiously, then, it 145 | //may be because the user had pressed the button at boot. This 146 | //will allow it to reset back down. 147 | 148 | //XXX TODO: Don't allow the calibration to reset down super fast 149 | //because there is theoretically (thouh I could not make it happen) 150 | //a possibility that ESD could make there be some sort of transient. 151 | for( i = 0; i < 3; i++ ) 152 | { 153 | if( done_startup ) 154 | { 155 | if( counts[i] < touch_calib[i] ) 156 | touch_calib[i] = counts[i]; 157 | counts[i] = counts[i] - touch_calib[i]; 158 | } 159 | else 160 | { 161 | touch_calib[i] = counts[i]; 162 | } 163 | } 164 | } 165 | 166 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/touch.h: -------------------------------------------------------------------------------- 1 | #ifndef _TOUCH_H 2 | #define _TOUCH_H 3 | #include 4 | 5 | void init_touch(); 6 | void run_touch( uint8_t * out ); 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/usb.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_H 2 | #define _USB_H 3 | 4 | #include 5 | 6 | extern volatile int usbDataOkToSend; 7 | extern volatile int usbDataOkToRead; 8 | 9 | void init_usb(); 10 | void usb_data( uint8_t * data, int len ); 11 | 12 | uint8_t * usb_get_out_ep_buffer(); 13 | void usb_release_out_ep_buffer(); 14 | 15 | //'length' is the size of the payload. 16 | //'code' is the HID wValue. This is usually the first byte in the HIDAPI stuff. 17 | //It is STRONGLY recommended you use 0 as the first byte. Experimentally, other values are NOT platform-safe. 18 | void CBHIDSetup( uint16_t length, uint8_t code ); 19 | void CBHIDData( uint8_t paksize, uint8_t * data ); 20 | void CBHIDInterruptIn( uint8_t paklen, uint8_t * data ); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/usbconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_CONFIG_H 2 | #define _USB_CONFIG_H 3 | 4 | #include 5 | //#include 6 | 7 | // You can change these to give your code its own name. 8 | #define STR_MANUFACTURER { 'm', 0, 'f', 0, 'g', 0 } 9 | #define STR_PRODUCT { 'p', 0, 'r', 0, 'd', 0 } 10 | #define STR_PRODUCT_LEN (6+1) 11 | #define STR_MANUFACTURER_LEN (6+1) 12 | 13 | #define VENDOR_ID 0xabcd 14 | #define PRODUCT_ID 0xf410 15 | 16 | #define HARDWARE_INTERFACE 0 17 | 18 | #define ENDPOINT0_SIZE CONTROL_MAX_PACKET_SIZE 19 | #define ENDPOINT1_SIZE 64 20 | #define ENDPOINT2_SIZE 64 21 | 22 | 23 | #define LSB(x) ((x)&0xff) 24 | #define MSB(x) ((x)>>8) 25 | 26 | 27 | const static uint8_t hid_report_desc[] = { 28 | 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined) 29 | 0x09, 0x04, // Usage 0x04 30 | 0xA1, 0x5C, // Collection 0x5C 31 | 0x75, 0x08, // report size = 8 bits (global) 32 | 0x15, 0x00, // logical minimum = 0 (global) 33 | 0x26, 0xFF, 0x00, // logical maximum = 255 (global) 34 | 0x95, 64, // report count (global) 64 bytes. 35 | 0x09, 0x75, // usage (local) 36 | 0x81, 0x02, // Input 37 | 0x95, 64, // report count (global) INPUT REPORT SIZE 38 | 0x09, 0x76, // usage (local) 39 | 0x91, 0x02, // Output 40 | 0x95, 64, // report count (global) OUTPUT REPORT SIZE [64] (0x96, 0x00, 0x02,=512) 41 | 0x09, 0x76, // usage (local) 42 | 0xB1, 0x02, // Feature 43 | 0xC0 // end collection 44 | 45 | }; 46 | 47 | 48 | const static uint8_t device_descriptor[] = { 49 | 18, // bLength 50 | 1, // bDescriptorType 51 | 0x10, 0x01, // bcdUSB 52 | 0, // bDeviceClass 53 | 0, // bDeviceSubClass 54 | 0, // bDeviceProtocol 55 | ENDPOINT0_SIZE, // bMaxPacketSize0 56 | LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor 57 | LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct 58 | 0x01, 0x01, // bcdDevice 59 | 1, // iManufacturer 60 | 2, // iProduct 61 | 3, // iSerialNumber 62 | 1 // bNumConfigurations 63 | }; 64 | 65 | #define CONFIG_DESCRIPTOR_SIZE (9+9+9+7+7) 66 | #define HID_DESC_OFFSET (9+9) 67 | 68 | const static uint8_t config_descriptor[CONFIG_DESCRIPTOR_SIZE] = { 69 | // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10 70 | 9, // bLength; 71 | 2, // bDescriptorType; 72 | LSB(CONFIG_DESCRIPTOR_SIZE), // wTotalLength 73 | MSB(CONFIG_DESCRIPTOR_SIZE), 74 | 1, // bNumInterfaces 75 | 1, // bConfigurationValue 76 | 0, // iConfiguration 77 | 0x80, // bmAttributes (0xC0 is self-powered) 78 | 20, // bMaxPower 79 | 80 | 9, // bLength 81 | 4, // bDescriptorType 82 | HARDWARE_INTERFACE, // bInterfaceNumber (unused, would normally be used for HID) 83 | 0, // bAlternateSetting 84 | 2, // bNumEndpoints 85 | 3, // bInterfaceClass 86 | 0xff, // bInterfaceSubClass (Was 0xff) 1 = Boot device subclass. 87 | 0xff, // bInterfaceProtocol (Was 0xff) 1 = keyboard, 2 = mouse. 88 | 0, // iInterface 89 | 90 | 91 | 9, // bLength 92 | 0x21, // bDescriptorType [33] 93 | 0x01, 0x01, // bcdHID 94 | 0, // bCountryCode 95 | 1, // bNumDescriptors 96 | 0x22, // bDescriptorType (Normally 0x22) 97 | LSB(sizeof(hid_report_desc)), // wDescriptorLength 98 | MSB(sizeof(hid_report_desc)), 99 | 100 | 101 | 7, // bLength 102 | 5, // bDescriptorType 103 | IN_ENDPOINT_ADDRESS, // bEndpointAddress (IN, 1) 104 | 0x03, // bmAttributes 105 | LSB(ENDPOINT1_SIZE), MSB(ENDPOINT1_SIZE), // wMaxPacketSize 106 | 1, // bInterval */ 107 | 108 | 109 | 7, // bLength 110 | 5, // bDescriptorType 111 | OUT_ENDPOINT_ADDRESS, // bEndpointAddress (OUT, 2) 112 | 0x03, // bmAttributes (Interrupt) 113 | LSB(ENDPOINT2_SIZE), MSB(ENDPOINT2_SIZE), // wMaxPacketSize 114 | 1, // bInterval 115 | }; 116 | 117 | 118 | 119 | // If you're desperate for a little extra code memory, these strings 120 | // can be completely removed if iManufacturer, iProduct, iSerialNumber 121 | // in the device desciptor are changed to zeros. 122 | struct usb_string_descriptor_struct { 123 | uint8_t bLength; 124 | uint8_t bDescriptorType; 125 | uint8_t wString[]; 126 | }; 127 | 128 | 129 | static const struct usb_string_descriptor_struct string0 = { 130 | 4, 131 | 3, 132 | //L"\x0409" 133 | { 0x09, 0x04, 0x00, 0x00 } 134 | }; 135 | static const struct usb_string_descriptor_struct string1 = { 136 | STR_MANUFACTURER_LEN, 137 | 3, 138 | STR_MANUFACTURER 139 | }; 140 | 141 | static const struct usb_string_descriptor_struct string2 = { 142 | STR_PRODUCT_LEN, 143 | 3, 144 | STR_PRODUCT 145 | }; 146 | static struct usb_string_descriptor_struct string3 = { 147 | 16, 148 | 3, 149 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00 } //This will be filled in with the UID on boot. 150 | }; 151 | 152 | 153 | // This table defines which descriptor data is sent for each specific 154 | // request from the host (in wValue and wIndex). 155 | const static struct descriptor_list_struct { 156 | uint16_t wValue; 157 | uint16_t wIndex; 158 | const uint8_t *addr; 159 | uint8_t length; 160 | } descriptor_list[] = { 161 | {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)}, 162 | {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)}, 163 | {0x2200, HARDWARE_INTERFACE, hid_report_desc, sizeof(hid_report_desc)}, 164 | {0x2100, HARDWARE_INTERFACE, config_descriptor+HID_DESC_OFFSET, 9}, 165 | {0x0300, 0x0000, (const uint8_t *)&string0, 4}, 166 | {0x0301, 0x0409, (const uint8_t *)&string1, STR_MANUFACTURER_LEN}, 167 | {0x0302, 0x0409, (const uint8_t *)&string2, STR_PRODUCT_LEN}, 168 | {0x0303, 0x0409, (const uint8_t *)&string3, 16} 169 | }; 170 | #define NUM_DESC_LIST (sizeof(descriptor_list)/sizeof(struct descriptor_list_struct)) 171 | 172 | 173 | #endif 174 | 175 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/ws2812.c: -------------------------------------------------------------------------------- 1 | #include "ws2812.h" 2 | #include 3 | #include 4 | 5 | //based off of https://github.com/fduignan/NucleoF042_DMAandSPItoWS2812Bs/blob/master/spi.c 6 | 7 | uint32_t rawwsdata[WSLEDS*4+12]; //12 buffer for resetting LEDs 8 | 9 | void InitWSDMA() 10 | { 11 | int i; 12 | 13 | //PB5 = SPI1_MOSI -> LED2 14 | //PB4 = SPI1_MISO 15 | //PB3 = SPI1_SCK 16 | 17 | // Turn on the clock for the SPI interface 18 | RCC->APB2ENR |= _BV(12); 19 | 20 | // Turn on PORT B 21 | // RCC->AHBENR |= _BV(18); 22 | 23 | ConfigureGPIO( GPIO_FROM_NUMS( 0, 7 ), 0b11 ); //Just for the sake of testing/setting the port up. 24 | 25 | for( i = 0; i < WSLEDS*4+12; i++ ) 26 | { 27 | rawwsdata[i] = 0; 28 | } 29 | 30 | // Configure the pins 31 | // GPIOB->MODER |= _BV(11); //GPIO B5 AF 32 | // GPIOB->MODER &= ~_BV(10); 33 | // GPIOB->AFR[0] &= ~(_BV(20) | _BV(21) | _BV(22) | _BV(23)); //Set AFMode 0. 34 | 35 | GPIOA->MODER |= _BV(15); //GPIO A7 AF 36 | GPIOA->MODER &= ~_BV(14); 37 | GPIOA->AFR[0] &= ~(_BV(28) | _BV(29) | _BV(30) | _BV(31)); //Set AFMode 0. 38 | 39 | SPI1->CR1 = SPI1->CR2 = 0; 40 | 41 | SPI1->CR1 |= SPI_CR1_CPHA; // set CPHA to ensure MOSI is low when idle 42 | SPI1->CR1 |= SPI_CR1_MSTR; // select master mode 43 | SPI1->CR1 |= (3 << 3); // select divider of 16. 48MHz/16 = 3MHz. 3 bits per WS2812 bit so: 1 Million WSbits/second : Within range of 1.53MHz to 540kHz 44 | SPI1->CR1 |= SPI_CR1_SSI | SPI_CR1_SSM; // select software slave management and drive SSI high (not relevant in TI mode and not output to pins) 45 | 46 | SPI1->CR2 |= (7 << 8); // select 8 bit data transfer size 47 | SPI1->CR2 |= SPI_CR2_TXDMAEN; // enable transmit DMA 48 | 49 | SPI1->CR1 |= SPI_CR1_SPE; // enable SPI1 50 | 51 | 52 | RCC->AHBENR |= RCC_AHBENR_DMAEN; // enable clocks for DMA controller 53 | 54 | DMA1_Channel3->CPAR = (uint32_t)(&(SPI1->DR)); 55 | // Select high priority, 8 bits, Memory increment mode (only), Read from memory, enable 56 | DMA1_Channel3->CCR = 57 | _BV(13) | _BV(12) | //Very high priority 58 | //MSIZE = PSIZE = 0 = 8 bit operations. TODO Consider trying to do it with 16-bit-wide registers. WARNING: This did not work. Don't know why. 59 | _BV(7) | //Memory increment mode 60 | //No circular mode. 61 | _BV(4) | 62 | 0; 63 | } 64 | 65 | 66 | void TriggerDMA() 67 | { 68 | // if( DMA1_Channel3->CCR != 12433 ) 69 | // send_text_value( "CDMA", DMA1_Channel3->CCR ); 70 | //send_text_value( "DMA: ", DMA1_Channel3->CCR ); 71 | DMA1_Channel3->CCR &= ~_BV(0); // disable DMA 72 | DMA1->IFCR = 0x0f00; // clear any pending interrupts XXX Fix this later. 73 | DMA1_Channel3->CPAR = (uint32_t)(&(SPI1->DR)); 74 | DMA1_Channel3->CMAR = (uint32_t)&rawwsdata; // Don't know what to send yet 75 | DMA1_Channel3->CNDTR = sizeof(rawwsdata)+1; // No bytes yet 76 | DMA1_Channel3->CCR |= _BV(0); // re-enable DMA 77 | } 78 | 79 | void UpdateLEDs( int ledstart, uint8_t * leddata, int lengthleds ) 80 | { 81 | 82 | static const uint16_t CodeData[4*4] = { 83 | 0x8888, 0x8e88, 0xe888, 0xee88, 84 | 0x888e, 0x8e8e, 0xe88e, 0xee8e, 85 | 0x88e8, 0x8ee8, 0xe8e8, 0xeee8, 86 | 0x88ee, 0x8eee, 0xe8ee, 0xeeee 87 | }; 88 | 89 | if( ledstart + lengthleds > WSLEDS ) 90 | { 91 | lengthleds = WSLEDS - ledstart; 92 | } 93 | 94 | int inmark = ledstart * 4; //Prefix zero data 95 | int bytes = lengthleds * 4; 96 | int i; 97 | for( i = 0; i < bytes; i++ ) 98 | { 99 | int8_t color = leddata[i]; 100 | //Word-on-wire order: (Determined experiomentally) 101 | //LSByte first. MSBit first. 102 | if( i + inmark >= WSLEDS*4 ) break; 103 | rawwsdata[i+inmark+12] = CodeData[(color>>4)&0xf] | (CodeData[(color)&0xf]<<16); 104 | } 105 | } 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /tensigral_lamp_2/firmware/ws2812.h: -------------------------------------------------------------------------------- 1 | #ifndef _WS2812_H 2 | #define _WS2812_H 3 | 4 | #define WSLEDS 20 5 | 6 | #include 7 | 8 | //Initialize DMA, etc. 9 | void InitWSDMA( ); 10 | void TriggerDMA( ); 11 | void UpdateLEDs( int ledstart, uint8_t * leddata, int lengthleds ); 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /tensigral_lamp_2/fp-lib-table: -------------------------------------------------------------------------------- 1 | (fp_lib_table 2 | (lib (name ZTS6011E-MICROPHONE)(type KiCad)(uri ${KIPRJMOD}/ZTS6011E-MICROPHONE.pretty)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /tensigral_lamp_2/sym-lib-table: -------------------------------------------------------------------------------- 1 | (sym_lib_table 2 | (lib (name tensigral_lamp_hardware-rescue)(type Legacy)(uri ${KIPRJMOD}/tensigral_lamp_hardware-rescue.lib)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /tensigral_lamp_2/tensigral_lamp_hardware-rescue.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | #End Doc Library 4 | -------------------------------------------------------------------------------- /tensigral_lamp_2/tensigral_lamp_hardware.pro: -------------------------------------------------------------------------------- 1 | update=12/24/2019 4:36:54 PM 2 | version=1 3 | last_client=kicad 4 | [general] 5 | version=1 6 | RootSch= 7 | BoardNm= 8 | [cvpcb] 9 | version=1 10 | NetIExt=net 11 | [eeschema] 12 | version=1 13 | LibDir= 14 | [eeschema/libraries] 15 | [schematic_editor] 16 | version=1 17 | PageLayoutDescrFile= 18 | PlotDirectoryName= 19 | SubpartIdSeparator=0 20 | SubpartFirstId=65 21 | NetFmtName=Pcbnew 22 | SpiceAjustPassiveValues=0 23 | LabSize=50 24 | ERC_TestSimilarLabels=1 25 | [pcbnew] 26 | version=1 27 | PageLayoutDescrFile= 28 | LastNetListRead=tensigral_lamp_hardware.net 29 | CopperLayerCount=2 30 | BoardThickness=1.6 31 | AllowMicroVias=0 32 | AllowBlindVias=0 33 | RequireCourtyardDefinitions=0 34 | ProhibitOverlappingCourtyards=1 35 | MinTrackWidth=0.3 36 | MinViaDiameter=0.4 37 | MinViaDrill=0.3 38 | MinMicroViaDiameter=0.2 39 | MinMicroViaDrill=0.09999999999999999 40 | MinHoleToHole=0.25 41 | TrackWidth1=0.3 42 | ViaDiameter1=0.8 43 | ViaDrill1=0.4 44 | dPairWidth1=0.3 45 | dPairGap1=0.25 46 | dPairViaGap1=0.25 47 | SilkLineWidth=0.12 48 | SilkTextSizeV=1 49 | SilkTextSizeH=1 50 | SilkTextSizeThickness=0.15 51 | SilkTextItalic=0 52 | SilkTextUpright=1 53 | CopperLineWidth=0.2 54 | CopperTextSizeV=1.5 55 | CopperTextSizeH=1.5 56 | CopperTextThickness=0.3 57 | CopperTextItalic=0 58 | CopperTextUpright=1 59 | EdgeCutLineWidth=0.05 60 | CourtyardLineWidth=0.05 61 | OthersLineWidth=0.15 62 | OthersTextSizeV=1 63 | OthersTextSizeH=1 64 | OthersTextSizeThickness=0.15 65 | OthersTextItalic=0 66 | OthersTextUpright=1 67 | SolderMaskClearance=0.051 68 | SolderMaskMinWidth=0.25 69 | SolderPasteClearance=0 70 | SolderPasteRatio=-0 71 | [pcbnew/Layer.F.Cu] 72 | Name=F.Cu 73 | Type=0 74 | Enabled=1 75 | [pcbnew/Layer.In1.Cu] 76 | Name=In1.Cu 77 | Type=0 78 | Enabled=0 79 | [pcbnew/Layer.In2.Cu] 80 | Name=In2.Cu 81 | Type=0 82 | Enabled=0 83 | [pcbnew/Layer.In3.Cu] 84 | Name=In3.Cu 85 | Type=0 86 | Enabled=0 87 | [pcbnew/Layer.In4.Cu] 88 | Name=In4.Cu 89 | Type=0 90 | Enabled=0 91 | [pcbnew/Layer.In5.Cu] 92 | Name=In5.Cu 93 | Type=0 94 | Enabled=0 95 | [pcbnew/Layer.In6.Cu] 96 | Name=In6.Cu 97 | Type=0 98 | Enabled=0 99 | [pcbnew/Layer.In7.Cu] 100 | Name=In7.Cu 101 | Type=0 102 | Enabled=0 103 | [pcbnew/Layer.In8.Cu] 104 | Name=In8.Cu 105 | Type=0 106 | Enabled=0 107 | [pcbnew/Layer.In9.Cu] 108 | Name=In9.Cu 109 | Type=0 110 | Enabled=0 111 | [pcbnew/Layer.In10.Cu] 112 | Name=In10.Cu 113 | Type=0 114 | Enabled=0 115 | [pcbnew/Layer.In11.Cu] 116 | Name=In11.Cu 117 | Type=0 118 | Enabled=0 119 | [pcbnew/Layer.In12.Cu] 120 | Name=In12.Cu 121 | Type=0 122 | Enabled=0 123 | [pcbnew/Layer.In13.Cu] 124 | Name=In13.Cu 125 | Type=0 126 | Enabled=0 127 | [pcbnew/Layer.In14.Cu] 128 | Name=In14.Cu 129 | Type=0 130 | Enabled=0 131 | [pcbnew/Layer.In15.Cu] 132 | Name=In15.Cu 133 | Type=0 134 | Enabled=0 135 | [pcbnew/Layer.In16.Cu] 136 | Name=In16.Cu 137 | Type=0 138 | Enabled=0 139 | [pcbnew/Layer.In17.Cu] 140 | Name=In17.Cu 141 | Type=0 142 | Enabled=0 143 | [pcbnew/Layer.In18.Cu] 144 | Name=In18.Cu 145 | Type=0 146 | Enabled=0 147 | [pcbnew/Layer.In19.Cu] 148 | Name=In19.Cu 149 | Type=0 150 | Enabled=0 151 | [pcbnew/Layer.In20.Cu] 152 | Name=In20.Cu 153 | Type=0 154 | Enabled=0 155 | [pcbnew/Layer.In21.Cu] 156 | Name=In21.Cu 157 | Type=0 158 | Enabled=0 159 | [pcbnew/Layer.In22.Cu] 160 | Name=In22.Cu 161 | Type=0 162 | Enabled=0 163 | [pcbnew/Layer.In23.Cu] 164 | Name=In23.Cu 165 | Type=0 166 | Enabled=0 167 | [pcbnew/Layer.In24.Cu] 168 | Name=In24.Cu 169 | Type=0 170 | Enabled=0 171 | [pcbnew/Layer.In25.Cu] 172 | Name=In25.Cu 173 | Type=0 174 | Enabled=0 175 | [pcbnew/Layer.In26.Cu] 176 | Name=In26.Cu 177 | Type=0 178 | Enabled=0 179 | [pcbnew/Layer.In27.Cu] 180 | Name=In27.Cu 181 | Type=0 182 | Enabled=0 183 | [pcbnew/Layer.In28.Cu] 184 | Name=In28.Cu 185 | Type=0 186 | Enabled=0 187 | [pcbnew/Layer.In29.Cu] 188 | Name=In29.Cu 189 | Type=0 190 | Enabled=0 191 | [pcbnew/Layer.In30.Cu] 192 | Name=In30.Cu 193 | Type=0 194 | Enabled=0 195 | [pcbnew/Layer.B.Cu] 196 | Name=B.Cu 197 | Type=0 198 | Enabled=1 199 | [pcbnew/Layer.B.Adhes] 200 | Enabled=1 201 | [pcbnew/Layer.F.Adhes] 202 | Enabled=1 203 | [pcbnew/Layer.B.Paste] 204 | Enabled=1 205 | [pcbnew/Layer.F.Paste] 206 | Enabled=1 207 | [pcbnew/Layer.B.SilkS] 208 | Enabled=1 209 | [pcbnew/Layer.F.SilkS] 210 | Enabled=1 211 | [pcbnew/Layer.B.Mask] 212 | Enabled=1 213 | [pcbnew/Layer.F.Mask] 214 | Enabled=1 215 | [pcbnew/Layer.Dwgs.User] 216 | Enabled=1 217 | [pcbnew/Layer.Cmts.User] 218 | Enabled=1 219 | [pcbnew/Layer.Eco1.User] 220 | Enabled=1 221 | [pcbnew/Layer.Eco2.User] 222 | Enabled=1 223 | [pcbnew/Layer.Edge.Cuts] 224 | Enabled=1 225 | [pcbnew/Layer.Margin] 226 | Enabled=1 227 | [pcbnew/Layer.B.CrtYd] 228 | Enabled=1 229 | [pcbnew/Layer.F.CrtYd] 230 | Enabled=1 231 | [pcbnew/Layer.B.Fab] 232 | Enabled=1 233 | [pcbnew/Layer.F.Fab] 234 | Enabled=1 235 | [pcbnew/Layer.Rescue] 236 | Enabled=0 237 | [pcbnew/Netclasses] 238 | [pcbnew/Netclasses/Default] 239 | Name=Default 240 | Clearance=0.199 241 | TrackWidth=0.3 242 | ViaDiameter=0.8 243 | ViaDrill=0.4 244 | uViaDiameter=0.3 245 | uViaDrill=0.1 246 | dPairWidth=0.3 247 | dPairGap=0.25 248 | dPairViaGap=0.25 249 | --------------------------------------------------------------------------------