addfile ./calypso-debug-logger/README hunk ./calypso-debug-logger/README 1 +at90usbkey + http://www.atmel.com/dyn/resources/prod_documents/doc7627.pdf + +at90usb1287 chip + http://www.atmel.com/dyn/resources/prod_documents/doc7593.pdf + PD5 usart1 external clock input/output + PD3 usart1 transmit + PD2 usart1 receive + GND + +2.5mm 3-pole plug + plug_tip calypso RX + plug_middle calypso TX + plug_bottom ground + +=> we need to connect the following: + plug_tip <=> PD3 + plug_middle <=> PD2 + plug_bottom <=> GND + +0..3V 115200 8N1 + +MyUSB_1.5.1/Demos/USBtoSerial LGPLv3 + +!DL_GSM: gpio J6=0 + + < DocScrutinizer> lindi-: you also should disable the amp output to + headset by setting amp-mute and amp_spk so the gsm-dl path isn't + seeing load from amp (they messed this in fab. that's the reason they + refused to use decent Cs XD ) + +amixer -q -d sset "Amp Spk" mute + +8 MHz is needed for USB but it makes a poor oscillator for USART (3% +error at 115200). Maybe we should bit-bang instead? + http://www.mil.ufl.edu/~chrisarnold/components/microcontrollerBoard/AVR/avrlib/ + +#if USE_2X +/usr/lib/avr/include/util/setbaud.h:#define UBRR_VALUE (((F_CPU) + 8UL * (BAUD)) / (16UL * (BAUD)) -1UL) + + +The device is shipped with Low Power Crystal Oscillator (8.0MHz-max) +enabled and with the fuse CKDIV8 programmed, resulting in 1.0MHz +system clock (with a 8 MHz cristal). The default fuse configuration is +CKSEL = "1111", SUT = "10", CKDIV8 = "0". This default setting ensures +that all users can make their desired clock source setting using any +available programming interface. + +PD2 is also INT2 + + +$ python decode-serial < bitbang3.out | grep char|cut -d' ' -f2|tr -d '\n';echo +\x02\x12ADC:169470\n\r\x02\x02\x12gauging16947\n\r\x02\x02\x11\x00\n\x00\x10\x10\x05IQEXT:ADCEnd\x02 + +void bitbang_input(void) { + uint16_t i; + while (PIND & _BV(PD2)) { + ; + } + for (i = 0; i < BUFLEN; i++) { + buffer[i] = PIND; + } +} + +00000000 : + 0: 4a 99 sbic 0x09, 2 ; 9 + 2: 00 c0 rjmp .+0 ; 0x4 + 4: e0 e0 ldi r30, 0x00 ; 0 + 6: f0 e0 ldi r31, 0x00 ; 0 + 8: 89 b1 in r24, 0x09 ; 9 + a: 81 93 st Z+, r24 + c: 80 e0 ldi r24, 0x00 ; 0 + e: e0 30 cpi r30, 0x00 ; 0 + 10: f8 07 cpc r31, r24 + 12: 01 f4 brne .+0 ; 0x14 + 14: 08 95 ret addfile ./CycleCounter/notes hunk ./CycleCounter/notes 1 +#include +prog_void (*bootloader)(void) = 0xf000; +// f000 = crash (should be right address according to objdump) +// f000*2 = crash +// f800 = reboot +// f800*2 = crash +// f000*2 + cli = crash +// f800*2 + cli = crash +// f000 + cli = crash +// f800 + cli = reboot + + + case 'b': + cli(); + RAMPZ = 1; + asm("jmp 0xe000"); + bootloader(); + break; + + + + hunk ./remote-keyboard/CDC_task.c 82 - if (cmd == '0' || cmd == '1') { - data >>= 1; - if (cmd == '1') { - data |= _BV(10); - } - debug[2] = data >> 8; - debug[3] = data & 0xff; - return; - } hunk ./remote-keyboard/CDC_task.c 84 - if (cmd >= '2' && cmd <= '9') { - print_bits(debug[cmd - '2']); - } - if (cmd == 's') { + switch (cmd) { + case 'b': + reboot(); + break; + case 'd': + cmd = get_byte(); + if (cmd >= '0' && cmd <= '9') { + print_bits(debug[cmd - '0']); + } + break; + case 's': + { hunk ./remote-keyboard/CDC_task.c 97 - - cli(); + + /* assert(clocks == 0); */ + data = _BV(11) /*extra*/; + for (i = 0; i < 11; i++) { + if (get_byte() == '1') { + data |= _BV(i); + } + } hunk ./remote-keyboard/CDC_task.c 106 - data |= _BV(11) /*extra*/; hunk ./remote-keyboard/CDC_task.c 107 - sei(); hunk ./remote-keyboard/CDC_task.c 110 + break; hunk ./remote-keyboard/CDC_task.c 112 - switch (cmd) { - case 'b': - reboot(); + case 't': + { + uint8_t i; + + data = _BV(11) /*extra*/; + for (i = 0; i < 11; i++) { + if (get_byte() == '1') { + data |= _BV(i); + } + } + print_bits(data >> 8); + print_bits(data & 0xff); + break; + } + default: + put_byte('?'); hunk ./remote-keyboard/CDC_task.c 137 - if (Endpoint_ReadWriteAllowed()) { - if (Endpoint_BytesInEndpoint()) { - uint8_t b; - - b = Endpoint_Read_Byte(); - Endpoint_ClearCurrentBank(); - handle_cmd(b); - } + while (byte_readable()) { + handle_cmd(get_byte()); + Endpoint_SelectEndpoint(CDC_RX_EPNUM); hunk ./remote-keyboard/helpers.h 13 +static uint8_t dev_rx_cnt; + +static uint8_t byte_readable(void) { + return dev_rx_cnt || (Endpoint_ReadWriteAllowed() && Endpoint_BytesInEndpoint()); +} + +static uint8_t get_byte(void) { + uint8_t ret; + + Endpoint_SelectEndpoint(CDC_RX_EPNUM); + if (dev_rx_cnt == 0) { + while (!byte_readable()) { + } + dev_rx_cnt = Endpoint_BytesInEndpoint(); + } + ret = Endpoint_Read_Byte(); + dev_rx_cnt--; + if (dev_rx_cnt == 0) { + Endpoint_ClearCurrentBank(); + } + return ret; +} + hunk ./remote-keyboard/CDC_task.c 63 - if ((PIND & _BV(PD3)) == 0) { + if ((PIND & _BV(PD3)) == 0 && clocks > 1) { hunk ./remote-keyboard/CDC_task.c 96 + // (echo s00011100001; sleep 0.1; echo s00000111111s00011100001) > /dev/ttyS1 hunk ./remote-keyboard/CDC_task.c 170 - -// 01001010001s -// 00000111111s01001010001s - -// hunk ./remote-keyboard/CDC_task.c 82 - put_byte(cmd); - put_byte('='); - switch (cmd) { - case 'b': - reboot(); - break; - case 'd': - cmd = get_byte(); - if (cmd >= '0' && cmd <= '9') { - print_bits(debug[cmd - '0']); - } - break; - case 's': - { - // (echo s00011100001; sleep 0.1; echo s00000111111s00011100001) > /dev/ttyS1 + // (echo s00011100001; sleep 0.1; echo s00000111111s00011100001) > /dev/ttyS1 + if (cmd == 's') { hunk ./remote-keyboard/CDC_task.c 85 - + hunk ./remote-keyboard/CDC_task.c 98 - break; + return; hunk ./remote-keyboard/CDC_task.c 100 + if (cmd == '\n' || cmd == '\r') { + return; + } + put_byte(cmd); + put_byte('='); + switch (cmd) { + case 'b': + reboot(); + break; + case 'd': + cmd = get_byte(); + if (cmd >= '0' && cmd <= '9') { + print_bits(debug[cmd - '0']); + } + break; hunk ./remote-keyboard/CDC_task.c 118 - + addfile ./CycleCounter/program.sh hunk ./CycleCounter/program.sh 1 +#!/bin/bash +exec sudo sh -c 'dfu-programmer at90usb1287 erase; dfu-programmer at90usb1287 flash CDC.hex; dfu-programmer at90usb1287 start'