Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1455 → Rev 1456

/branches/V0.76g-acid/servoboard/readme.txt
0,0 → 1,21
 
atmega8 8mhz
 
beschaltung
 
GND
VCC
RESET
 
LED an PD7
 
Servo 1 an PB0
Servo 2 an PB1
Servo 3 an PB2
Servo 4 an PB3
Servo 5 an PB4
Servo 6 an PB5
 
 
LED an = betriebsbereit
LED blinkt = I2C daten werden emfpangen
/branches/V0.76g-acid/servoboard/servoboard.c
93,8 → 93,6
pwm_limit[4] = 0;
pwm_limit[5] = 0;
 
set_pwm_neutral();
 
}
 
void eeprom_write() {
119,11 → 117,14
 
int main(void) {
 
#define PROGRAMMINGMODE 0
#if PROGRAMMINGMODE
uint8_t current_servo = 0;
uint8_t keyrate = 0;
#endif
 
DDRD = 0xff;
PORTD = 0xff;
DDRD = 0x80;
PORTD = 0x80;
 
DDRC &= ~0x0f;
PORTC |= 0x0f;
132,10 → 133,12
eeprom_init();
InitIC2_Slave(0x82);
pwm_init();
set_pwm_neutral();
sei();
 
#define PROGRAMMINGMODE 0
#if PROGRAMMINGMODE
DDRD = 0xff;
PORTD = 0xff;
if (!(PINC & 0x01)) {
pwm_neutral_programming_mode = 1;
PORTD = ~(1 << current_servo);
/branches/V0.76g-acid/servoboard/twislave.c
6,9 → 6,8
#include "servoboard.h"
#include "twislave.h"
 
unsigned char I2C_RXBuffer[32];
unsigned char Byte_Counter = 0;
unsigned char I2C_Timeout = 0;
uint8_t I2C_RXBuffer[32];
uint8_t Byte_Counter = 0;
 
void InitIC2_Slave(uint8_t adr)
{
27,21 → 26,17
 
ISR (TWI_vect) {
 
#if 1
static char cnt=0;
static char cnt = 0;
if (pwm_neutral_programming_mode == 0 && cnt++ == 0) {
if (PORTD&0x80) PORTD&=~0x80; else PORTD|=0x80;
if (PORTD & 0x80) PORTD &= ~0x80; else PORTD |= 0x80;
}
#endif
switch (TWSR & 0xF8)
{
switch (TWSR & 0xF8) {
case SR_SLA_ACK:
TWCR |= (1<<TWINT);
Byte_Counter = 0;
return;
case SR_PREV_ACK:
I2C_Timeout = 250;
if (Byte_Counter < 32) {
I2C_RXBuffer[Byte_Counter++] = TWDR;
}
56,8 → 51,9
TWCR |=(1<<TWSTO) | (1<<TWINT);
case TWI_BUS_ERR_1:
TWCR |=(1<<TWSTO) | (1<<TWINT);
}
TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE); // TWI Reset
}
TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
 
}