Skip to content

Commit

Permalink
More experiments,
Browse files Browse the repository at this point in the history
add LICENSE
  • Loading branch information
MarkR42 committed Mar 6, 2019
1 parent 5f65d84 commit 966991c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
26 changes: 26 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2019, Mark Robson
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Malenki-ESC project.
4 changes: 4 additions & 0 deletions firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ pyupdi can be used with a simple serial cable + 1 resistor.

See https://github.com/mraardvark/pyupdi/

Useful examples:

https://github.com/chromia/attiny1614example

47 changes: 47 additions & 0 deletions firmware/demo1/PIN_ASSIGNMENTS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Pin assignments / usage

PA0 - RESET / UPDI - default - not used by code. Used for programming
firmware, wired to a pogo pin on underside.
PA1 - UART0 TxD - used for diagnostic serial output.
connected to pin 3 of the pogo pins J6 on underside of board.

PA2 - UART0 RxD - connected to the RXIN connection.
This is used to receive either PPM signals, or serial
from the radio.

PA3 - Motor1F (Weapon)
PA4 - Motor3R (Right)
PA5 - Motor3F (Right)

PA6 - BLINKY - high for blue LED, low for red LED.
PA7 - VSENSE - senses battery voltage.
This is connected to two resistors pulled down by 10k, pulled up by 33k.
So it will give the voltage of approximately VBAT * (10 / 43)
Or approx 1/4 of the bat voltage.

PB0 - Motor1R (Weapon)
PB1 - Motor2R (Left)
PB2 - Motor2F (Left)

PB3 - Unused

Peripheral usage

USART0 - transmitter - for debug messages
receiver - to receive digial data from rx

TCA0 - timer generates 6x PWM pulses on motors
use in "split mode"

TCB0 - Count the pulse width on PA2 for pulse input
could generate irq when pulse ends
TCB1 - Generate periodic interrupts
- so that we can increment a time counter
to run periodic tasks every so often

TCD0 - unused

EVENTSYSTEM - need to route event from pin PA2 to
the TCB0 to sense pulses.

ADC - need just one channel to read bat. voltage
17 changes: 15 additions & 2 deletions firmware/demo1/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
char unused1;
unsigned char somestorage[10];

void init_ports_out()
void init_hardware()
{
// Set all the ports which need to be outputs, to be outputs.
// should all be low initially.
Expand All @@ -23,6 +23,19 @@ void init_ports_out()
PORTB.DIRSET = 1 << 0;
PORTB.DIRSET = 1 << 1;
PORTB.DIRSET = 1 << 2;

// Timer A = generate PWM on thos pins

// UART0- need to use "alternate" pins
// This puts TxD and RxD on PA1 and PA2
PORTMUX.CTRLB = 1; // Bit 0 = alt. usart pins

// TxD pin is used for debug, should be an output
PORTA.DIRSET = 1 << 1;

//
// Timer A should be in split mode
//
}

void init_timer_interrupts()
Expand All @@ -46,7 +59,7 @@ ISR(TCB0_INT_vect)
int main(void)
{
memset(somestorage, 0, sizeof(somestorage));
init_ports_out();
init_hardware();
init_timer_interrupts();
sei(); // enable interrupts
_delay_ms(100);
Expand Down

0 comments on commit 966991c

Please sign in to comment.