├── .gitignore ├── LICENSE ├── README.md ├── bike-light ├── bike-light.C ├── bike-light.PDK ├── bike-light.PRE ├── bike-light.PRJ └── extern.h ├── biquad-test ├── biquad-test.C ├── biquad-test.PDK ├── biquad-test.PRE ├── biquad-test.PRJ └── extern.h └── ws2812-spi ├── FPPA_1.C ├── extern.h ├── test.py ├── ws2812-spi.C ├── ws2812-spi.PDK ├── ws2812-spi.PRE └── ws2812-spi.PRJ /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | .idea/ 55 | obj/ 56 | *.tmp 57 | 58 | .vscode/ 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jay Carlson 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 | # Padauk Experiments 2 | 3 | These are some experiments I've built with the Padauk microcontrollers. 4 | -------------------------------------------------------------------------------- /bike-light/bike-light.C: -------------------------------------------------------------------------------- 1 | 2 | #include "extern.h" 3 | 4 | 5 | 6 | void FPPA0 (void) 7 | { 8 | .ADJUST_IC SYSCLK=ILRC // SYSCLK=IHRC/2 9 | 10 | // Insert Initial Code 11 | PAC = 0xDF; // make everything an output except PA5 12 | PAPH = 0x20; // make PA5 pull-up 13 | 14 | while (1) 15 | { 16 | PA = 0xFF; 17 | STOPSYS; 18 | .wait0 PA.5; 19 | .wait1 PA.5; 20 | 21 | while(PA.5) { 22 | PA = 0x00; 23 | .delay 3000; 24 | PA = 0xFF; 25 | .delay 3000; 26 | } 27 | .wait1 PA.5; 28 | .delay 1000; 29 | 30 | // ... 31 | // wdreset; 32 | 33 | } 34 | } 35 | 36 | 37 | void Interrupt (void) 38 | { 39 | pushaf; 40 | 41 | if (Intrq.T16) 42 | { // T16 Trig 43 | // User can add code 44 | Intrq.T16 = 0; 45 | //... 46 | } 47 | 48 | popaf; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /bike-light/bike-light.PDK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaydcarlson/padauk-experiments/7dd9a55c46e432e8f8bfd2940b4753441094f143/bike-light/bike-light.PDK -------------------------------------------------------------------------------- /bike-light/bike-light.PRE: -------------------------------------------------------------------------------- 1 | 2 | .CHIP PMS150C 3 | //{{PADAUK_CODE_OPTION 4 | .Code_Option Bootup_Time Slow 5 | .Code_Option LVR 2.0V 6 | .Code_Option Security Disable // Security Disable 7 | .Code_Option Drive Normal 8 | //}}PADAUK_CODE_OPTION 9 | 10 | // ----------- IMPORTANT ------------- 11 | // Please don't change the follow code 12 | // It only be used for internal Mini-C 13 | // ----------------------------------- 14 | 15 | .JMP FPPA0 , 0 16 | .ROMADR 0x10 17 | .PUT Interrupt , 8 18 | 19 | -------------------------------------------------------------------------------- /bike-light/bike-light.PRJ: -------------------------------------------------------------------------------- 1 | [INI] 2 | PROJECT=PRE_FILE 3 | [LINKS] 4 | ~bike-light.C 5 | [HEAD] 6 | ~extern.h 7 | [DEPEND] 8 | ~$:INC_PDK\PMS150C.INC 9 | ~bike-light.PRE 10 | [Ram_Break] 11 | Break1=No 0000 12 | Break2=No 0000 13 | Break3=No 0000 14 | Break4=No 0000 15 | [Stack_Break] 16 | Break1=Au 0000 00FF 17 | Break2=Au 0000 00FF 18 | Break3=Au 0000 00FF 19 | Break4=Au 0000 00FF 20 | Break5=Au 0000 00FF 21 | Break6=Au 0000 00FF 22 | Break7=Au 0000 00FF 23 | Break8=Au 0000 00FF 24 | [Ctrl_Break] 25 | Mark=51 1 26 | ICE=0 6 2 1388 27 | [PRE] 28 | ~bike-light.PRJ 29 | ~bike-light.PRE 30 | -------------------------------------------------------------------------------- /bike-light/extern.h: -------------------------------------------------------------------------------- 1 | 2 | System_Clock EQU 8000000 // Used at UART, PS2, ... 3 | 4 | /* // A example for use ADCRH & ADCR 5 | #if defined(ADCC) 6 | #if defined(ADCR) 7 | ADCRH EQU ADCR 8 | ADCRL EQU 0 9 | #else 10 | ADCR EQU ADCRH 11 | #endif 12 | #endif 13 | */ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /biquad-test/biquad-test.C: -------------------------------------------------------------------------------- 1 | 2 | #include "extern.h" 3 | 4 | WORD in[55]; 5 | WORD out[55]; 6 | 7 | WORD z1, z2; 8 | 9 | WORD pOut, pIn; // these are pointers, but aren't typed as such 10 | 11 | int i; 12 | 13 | WORD x; 14 | WORD y; 15 | WORD mulOut; 16 | 17 | #ifdef MULOP 18 | void mul16(void) { 19 | // L x L 20 | MULOP = x$0; 21 | A = y$0; 22 | mul 23 | mulOut = A + (MULRH << 8); 24 | 25 | // L x H 26 | MULOP = x$0; 27 | A = y$1; 28 | mul 29 | mulOut += (A << 8); 30 | 31 | // H x L 32 | MULOP = x$1; 33 | A = y$0; 34 | mul 35 | mulOut += (A << 8); 36 | 37 | // H x H 38 | MULOP = x$1; 39 | A = y$1; 40 | mul 41 | mulOut += (A << 8); 42 | } 43 | #endif 44 | 45 | void FPPA0 (void) 46 | { 47 | .ADJUST_IC SYSCLK=ILRC // SYSCLK=IHRC/2 48 | 49 | PAC.6 = 1; // make PA6 an output 50 | while(1) { 51 | pOut = out; 52 | pIn = in; 53 | i = 0; 54 | do { 55 | // out = in * 16384 + z1; 56 | *pOut = (*pIn << 14) + z1; 57 | 58 | // z1 = inTemp * -32768 + z2 59 | z1 = -(*pIn << 15) + z2; 60 | 61 | // z1 += 25576 * out; 62 | #ifdef MULOP 63 | x = *pOut; 64 | y = 25576; 65 | mul16(); 66 | z1 += mulOut; 67 | #else 68 | z1 += (*pOut << 14) 69 | + (*pOut << 13) 70 | + (*pOut << 9) 71 | + (*pOut << 8) 72 | + (*pOut << 7) 73 | + (*pOut << 6) 74 | + (*pOut << 5) 75 | + (*pOut << 3); 76 | #endif 77 | // z2 = in * 16384 78 | z2 = (*pIn << 14); 79 | 80 | // z2 -= 10508 * out; 81 | #ifdef MULOP 82 | x = *pOut; 83 | y = 10508; 84 | mul16(); 85 | z2 -= mulOut; 86 | #else 87 | z2 -= (*pOut << 13) 88 | - (*pOut << 11) 89 | - (*pOut << 8) 90 | - (*pOut << 3) 91 | - (*pOut << 2); 92 | #endif 93 | 94 | i++; 95 | pOut++; 96 | pIn++; 97 | } while(i < 55); 98 | 99 | PA.6 = 0; 100 | } 101 | } 102 | 103 | 104 | void Interrupt (void) 105 | { 106 | pushaf; 107 | 108 | if (Intrq.T16) 109 | { // T16 Trig 110 | // User can add code 111 | Intrq.T16 = 0; 112 | //... 113 | } 114 | 115 | popaf; 116 | } 117 | 118 | -------------------------------------------------------------------------------- /biquad-test/biquad-test.PDK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaydcarlson/padauk-experiments/7dd9a55c46e432e8f8bfd2940b4753441094f143/biquad-test/biquad-test.PDK -------------------------------------------------------------------------------- /biquad-test/biquad-test.PRE: -------------------------------------------------------------------------------- 1 | 2 | .CHIP PMS134 3 | //{{PADAUK_CODE_OPTION 4 | .Code_Option Bootup_Time Slow 5 | .Code_Option Security Disable // Security Disable 6 | .Code_Option LCD2 Disable 7 | .Code_Option Comparator_Edge All_Edge 8 | .Code_Option GPC_PWM Disable 9 | .Code_Option PWM_Source 16MHz 10 | .Code_Option TMx_Bit 6BIT 11 | .Code_Option TMx_Source 16MHz 12 | .Code_Option Interrupt_Src1 PB.0 13 | .Code_Option Interrupt_Src0 PA.0 14 | .Code_Option PB4_PB7_Drive Strong 15 | .Code_Option LVR 3.5V 16 | //}}PADAUK_CODE_OPTION 17 | 18 | // ----------- IMPORTANT ------------- 19 | // Please don't change the follow code 20 | // It only be used for internal Mini-C 21 | // ----------------------------------- 22 | 23 | .JMP FPPA0 , 0 24 | .ROMADR 0x10 25 | .PUT Interrupt , 8 26 | 27 | -------------------------------------------------------------------------------- /biquad-test/biquad-test.PRJ: -------------------------------------------------------------------------------- 1 | [INI] 2 | PROJECT=PRE_FILE 3 | [LINKS] 4 | ~biquad-test.C 5 | [HEAD] 6 | ~extern.h 7 | [DEPEND] 8 | ~$:INC_PDK\PMS134.INC 9 | ~biquad-test.PRE 10 | [Ram_Break] 11 | Break1=No 0000 12 | Break2=No 0000 13 | Break3=No 0000 14 | Break4=No 0000 15 | [Stack_Break] 16 | Break1=Au 0000 00FF 17 | Break2=Au 0000 00FF 18 | Break3=Au 0000 00FF 19 | Break4=Au 0000 00FF 20 | Break5=Au 0000 00FF 21 | Break6=Au 0000 00FF 22 | Break7=Au 0000 00FF 23 | Break8=Au 0000 00FF 24 | [Ctrl_Break] 25 | Mark=51 1 26 | ICE=0 6 2 1388 27 | [PRE] 28 | ~biquad-test.PRJ 29 | ~biquad-test.PRE 30 | -------------------------------------------------------------------------------- /biquad-test/extern.h: -------------------------------------------------------------------------------- 1 | 2 | System_Clock EQU 8000000 // Used at UART, PS2, ... 3 | 4 | /* // A example for use ADCRH & ADCR 5 | #if defined(ADCC) 6 | #if defined(ADCR) 7 | ADCRH EQU ADCR 8 | ADCRL EQU 0 9 | #else 10 | ADCR EQU ADCRH 11 | #endif 12 | #endif 13 | */ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ws2812-spi/FPPA_1.C: -------------------------------------------------------------------------------- 1 | 2 | extern bit dataReady : pa.0; 3 | BYTE SPI_Data_In; 4 | BYTE cnt; 5 | 6 | BIT SPI_In : PA.6; 7 | BIT SPI_InMode : PAC.6; 8 | BIT SPI_Clk : PA.7; 9 | BIT SPI_ClkMode : PAC.7; 10 | 11 | 12 | // This FPPA is responsible for receiving SPI bytes and alerting FFPPA0 whenever a new byte is received. 13 | void FPPA1 (void) 14 | { 15 | set0 SPI_ClkMode; 16 | set0 SPI_InMode; 17 | 18 | while (1) 19 | { 20 | cnt = 8; 21 | 22 | do 23 | { 24 | .wait0 SPI_Clk; 25 | .wait1 SPI_Clk; 26 | swapc SPI_In; // swap the data pin with carry 27 | slc SPI_Data_In; // left-shift the carry 28 | } while (--cnt); 29 | dataReady = 1; 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /ws2812-spi/extern.h: -------------------------------------------------------------------------------- 1 | 2 | System_Clock EQU 8000000 // Used at UART, PS2, ... 3 | Program_Mode EQU 0 // 4 | 5 | /* // A example for use ADCRH & ADCR 6 | #if defined(ADCC) 7 | #if defined(ADCR) 8 | ADCRH EQU ADCR 9 | ADCRL EQU 0 10 | #else 11 | ADCR EQU ADCRH 12 | #endif 13 | #endif 14 | */ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ws2812-spi/test.py: -------------------------------------------------------------------------------- 1 | import treehopper.api 2 | import colorsys 3 | import time 4 | 5 | board = treehopper.api.find_boards()[0] 6 | board.connect() 7 | board.spi.enabled = True 8 | 9 | numLeds = 50 10 | 11 | frameBuffer = [0] * numLeds * 3 12 | 13 | time = 1000 14 | 15 | def setRGB(idx, r, g, b): 16 | frameBuffer[idx * 3 + 0] = int(g) 17 | frameBuffer[idx * 3 + 1] = int(r) 18 | frameBuffer[idx * 3 + 2] = int(b) 19 | 20 | 21 | def flush(): 22 | board.spi.send_receive(frameBuffer, None, 0, 0.49, 0, 0) 23 | 24 | 25 | for j in range(0, 500): 26 | for i in range(0, numLeds): 27 | rgb = colorsys.hls_to_rgb((i/numLeds) + j/100, 0.01, 1.0) 28 | setRGB(i, 255.0*rgb[0], 255.0*rgb[1], 255.0*rgb[2]) 29 | flush() 30 | time.sleep(0.01) 31 | -------------------------------------------------------------------------------- /ws2812-spi/ws2812-spi.C: -------------------------------------------------------------------------------- 1 | #include "extern.h" 2 | 3 | // attach the WS2812B LED(s) to this pin 4 | bit LED : pa.3; 5 | bit LEDC : pac.3; 6 | 7 | // this pin is used for debugging; it asserts whenever a byte is received 8 | bit dataReady : pa.0; 9 | bit dataReadyC : pac.0; 10 | 11 | extern BYTE SPI_Data_In; 12 | BYTE spiTemp; 13 | 14 | // Main CPU context is responsible for initalizing the pins and 15 | // managing the WS2812B LEDs 16 | void FPPA0 (void) 17 | { 18 | // we're running the CPU a bit hot --- 18 MHz --- but otherwise the timing doesn't work out. 19 | .ADJUST_IC SYSCLK=IHRC/2, IHRC=18MHz, VDD=5V; 20 | fppen = 0xFF; // enable the other FPPAs (only two total in our case) 21 | DISGINT; // disable global interrupt 22 | LEDC = 1; // set pin to output 23 | dataReadyC = 1; // debug pin as an output 24 | 25 | while (1) 26 | { 27 | // TODO: we need some sort of watchdog that we feed whenever we get a byte 28 | // otherwise, the SPI state machine might get out of sync 29 | .wait1 dataReady; 30 | spiTemp = SPI_Data_In; 31 | dataReady = 0; 32 | 33 | .FOR bit, <7,6,5,4,3,2,1,0> 34 | if (spiTemp.bit == 0) { 35 | SET1 LED; 36 | SET0 LED; 37 | .DELAY 2; 38 | } else { 39 | SET1 LED; 40 | .DELAY 2; 41 | SET0 LED; 42 | } 43 | .ENDM 44 | } 45 | } 46 | 47 | 48 | void Interrupt (void) 49 | { 50 | pushaf; 51 | 52 | if (Intrq.T16) { 53 | Intrq.T16 = 0; 54 | } 55 | popaf; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /ws2812-spi/ws2812-spi.PDK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaydcarlson/padauk-experiments/7dd9a55c46e432e8f8bfd2940b4753441094f143/ws2812-spi/ws2812-spi.PDK -------------------------------------------------------------------------------- /ws2812-spi/ws2812-spi.PRE: -------------------------------------------------------------------------------- 1 | 2 | .CHIP PMC251 3 | //{{PADAUK_CODE_OPTION 4 | .Code_Option Under_20mS_VDD_Ok No 5 | .Code_Option FPPA 2-FPPA 6 | .Code_Option LVR 3.1V 7 | .Code_Option Security Disable // Security Disable 8 | //}}PADAUK_CODE_OPTION 9 | 10 | // ----------- IMPORTANT ------------- 11 | // Please don't change the follow code 12 | // It only be used for internal Mini-C 13 | // ----------------------------------- 14 | 15 | .JMP FPPA0 , 0 16 | .JMP FPPA1 , 1 17 | .ROMADR 0x10 18 | .PUT Interrupt , 8 19 | 20 | -------------------------------------------------------------------------------- /ws2812-spi/ws2812-spi.PRJ: -------------------------------------------------------------------------------- 1 | [INI] 2 | PROJECT=PRE_FILE 3 | [LINKS] 4 | ~FPPA_1.C 5 | ~ws2812-spi.C 6 | [HEAD] 7 | ~extern.h 8 | [DEPEND] 9 | ~$:INC_PDK\PMC251.INC 10 | ~ws2812-spi.PRE 11 | [Ram_Break] 12 | Break1=No 0000 13 | Break2=No 0000 14 | Break3=No 0000 15 | Break4=No 0000 16 | [Stack_Break] 17 | Break1=Au 0000 00FF 18 | Break2=Au 0000 00FF 19 | Break3=Au 0000 00FF 20 | Break4=Au 0000 00FF 21 | Break5=Au 0000 00FF 22 | Break6=Au 0000 00FF 23 | Break7=Au 0000 00FF 24 | Break8=Au 0000 00FF 25 | [Ctrl_Break] 26 | Mark=51 1 27 | ICE=0 6 2 1388 28 | [PRE] 29 | ~ws2812-spi.PRJ 30 | ~ws2812-spi.PRE 31 | --------------------------------------------------------------------------------