ASURO Library
2.80
|
Definitionen und Funktionen der ASURO Bibliothek. More...
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <avr/pgmspace.h>
#include <stdlib.h>
Go to the source code of this file.
Macros | |
#define | FALSE 0 |
#define | TRUE 1 |
#define | OFF 0 |
#define | ON 1 |
#define | GREEN 1 |
#define | RED 2 |
#define | YELLOW 3 |
#define | LEFT 0 |
#define | RIGHT 1 |
#define | CENTER 2 |
#define | K1 (1<<5) |
#define | K2 (1<<4) |
#define | K3 (1<<3) |
#define | K4 (1<<2) |
#define | K5 (1<<1) |
#define | K6 (1<<0) |
#define | ADC_CTRL_WHEEL_LEFT 0 |
#define | ADC_CTRL_WHEEL_RIGHT 1 |
#define | ADC_CTRL_SWITCHES 2 |
#define | ADC_CTRL_IR_LEFT 3 |
#define | ADC_CTRL_IR_RIGHT 4 |
#define | ADC_CTRL_BATTERIE 5 |
#define | ADC_CTRL_SWITCHED 6 |
#define | Go(distance, speed) GoTurn(distance,0,speed) |
#define | Turn(degree, speed) GoTurn(0,degree,speed) |
#define | Batterie Battery |
#define | OdometrieData OdometryData |
#define | SerPrint_P(_str) SerPrint_p(PSTR(_str)) |
#define | GREEN_LED_ON PORTB |= GREEN_LED |
#define | GREEN_LED_OFF PORTB &= ~GREEN_LED |
#define | RED_LED_ON PORTD |= RED_LED |
#define | RED_LED_OFF PORTD &= ~RED_LED |
#define | FWD _BV(PB5) |
#define | RWD _BV(PB4) |
#define | BREAK 0x00 |
#define | FREE _BV(PB4) | _BV(PB5) |
#define | IRTX _BV(PB3) |
#define | GREEN_LED _BV(PB0) |
#define | RED_LED _BV(PD2) |
#define | PWM _BV(PB1) | _BV(PB2) |
#define | RIGHT_DIR _BV(PB4) | _BV(PB5) |
#define | LEFT_DIR _BV(PD4) | _BV(PD5) |
#define | SWITCHES _BV(PD3) |
#define | SWITCH_ON PORTD |= SWITCHES |
#define | SWITCH_OFF PORTD &= ~SWITCHES |
#define | BATTERIE _BV(MUX0) | _BV(MUX2) |
#define | SWITCH _BV(MUX2) |
#define | IR_LEFT _BV(MUX0) | _BV(MUX1) |
#define | IR_RIGHT _BV(MUX1) |
#define | FRONT_LED _BV(PD6) |
#define | ODOMETRIE_LED _BV(PD7) |
#define | ODOMETRIE_LED_ON PORTD |= ODOMETRIE_LED |
#define | ODOMETRIE_LED_OFF PORTD &= ~ODOMETRIE_LED |
#define | WHEEL_LEFT _BV(MUX0) |
#define | WHEEL_RIGHT 0 |
Typedefs | |
typedef void(* | voidFuncPtr )(void) |
Functions | |
void | Init (void) |
unsigned long | Gettime (void) |
return time since system start in ms | |
void | Msleep (unsigned int ms) |
sleep function (ms) | |
void | Sleep (unsigned char time36kHz) |
sleep function (36Khz) | |
void | EncoderInit (void) |
initialise and starts odometry mesurement uses interrupt(ADC_vect) | |
void | EncoderSet (int setl, int setr) |
set odometry tick counter | |
void | EncoderStop (void) |
stop counting odometry sensor ticks | |
void | EncoderStart (void) |
stop counting odometry sensor ticks | |
void | GoTurn (int distance, int degree, int speed) |
moves the robot forward/backward OR turns the robot using the odometry sensors. You can use the old function-names Go() and Turn() | |
int | Battery (void) |
returns the battery voltage | |
void | LineData (unsigned int *data) |
reads out the phototransistors | |
void | OdometryData (unsigned int *data) |
reads out the odometry phototransistors | |
unsigned int | ReadADC (unsigned int mux, unsigned int sleep) |
void | StatusLED (unsigned char color) |
controls the StatusLED | |
void | FrontLED (unsigned char status) |
controls the FrontLED | |
void | BackLED (unsigned char left, unsigned char right) |
values: ON, OFF | |
void | MotorDir (unsigned char left_dir, unsigned char right_dir) |
Motor configuration. values: FWD, RWD, BREAK, FREE. | |
void | MotorSpeed (unsigned char left_speed, unsigned char right_speed) |
sets motor speed. range: 0..255 | |
void | MyMotorSpeed (unsigned char left_speed, unsigned char right_speed) |
sets motor speed. range: 0..255 | |
void | SetMotorPower (int8_t leftpwm, int8_t rightpwm) |
sets motor speed and direcction. range: -128..+128 | |
void | SerWrite (unsigned char *data, unsigned char length) |
Send Data to UART. | |
void | SerRead (unsigned char *data, unsigned char length, unsigned int timeout) |
Receive Data from UART. | |
void | UartPutc (unsigned char zeichen) |
Send a single character to UART. | |
void | SerPrint (char *data) |
Send a 0-terminated string to UART. | |
void | PrintInt (int wert) |
Send a Integer value converted to a string to UART. | |
void | PrintLong (long wert) |
Send a Long value converted to a string to UART. | |
void | SerPrint_p (const char *data) |
Send a 0-terminated string from program space to UART. | |
void | PrintFloat (float wert, char vorkomma, char nachkomma) |
Send a Float value converted to a string to UART. | |
unsigned char | PollSwitch (void) |
function to read out switches | |
void | StartSwitch (void) |
binds switch press to external Interrupt 1 catch it with ISR(INT1_vect) see avr-libc documentation for details | |
void | StopSwitch (void) |
stop sending switch interrupt clears INT1_vect | |
void | Sound (uint16_t freq, uint16_t duration_msec, uint8_t amplitude) |
Genrates a sound via the motors. | |
Variables | |
volatile unsigned int | adcValue [] |
const char | version [5] |
volatile int | switched |
any switch pressed? | |
volatile int | encoder [2] |
odometry sensors tick count access: encoder[LEFT], encoder[RIGHT] range: 0..255 | |
volatile unsigned char | count36kHz |
volatile unsigned long | timebase |
volatile int | autoencode |
volatile voidFuncPtr | Ovr2IntFunc |
volatile voidFuncPtr | AdcIntFunc |
Definitionen und Funktionen der ASURO Bibliothek.
Definition in file asuro.h.
#define BATTERIE _BV(MUX0) | _BV(MUX2) |
#define GREEN_LED_OFF PORTB &= ~GREEN_LED |
#define GREEN_LED_ON PORTB |= GREEN_LED |
#define IR_LEFT _BV(MUX0) | _BV(MUX1) |
#define IR_RIGHT _BV(MUX1) |
#define IRTX _BV(PB3) |
#define LEFT_DIR _BV(PD4) | _BV(PD5) |
#define ODOMETRIE_LED_OFF PORTD &= ~ODOMETRIE_LED |
#define ODOMETRIE_LED_ON PORTD |= ODOMETRIE_LED |
#define OdometrieData OdometryData |
#define PWM _BV(PB1) | _BV(PB2) |
#define RIGHT_DIR _BV(PB4) | _BV(PB5) |
#define SerPrint_P | ( | _str | ) | SerPrint_p(PSTR(_str)) |
#define SWITCH _BV(MUX2) |
#define WHEEL_LEFT _BV(MUX0) |
#define WHEEL_RIGHT 0 |
void BackLED | ( | unsigned char | left, |
unsigned char | right | ||
) |
values: ON, OFF
left | leftLED status |
right | rightLED status |
int Battery | ( | void | ) |
returns the battery voltage
void EncoderInit | ( | void | ) |
initialise and starts odometry mesurement uses interrupt(ADC_vect)
void EncoderSet | ( | int | setl, |
int | setr | ||
) |
set odometry tick counter
setl | left tick counter |
setr | left tick counter |
void EncoderStart | ( | void | ) |
stop counting odometry sensor ticks
void EncoderStop | ( | void | ) |
stop counting odometry sensor ticks
void FrontLED | ( | unsigned char | status | ) |
controls the FrontLED
status | values: ON, OFF |
unsigned long Gettime | ( | void | ) |
return time since system start in ms
void GoTurn | ( | int | distance, |
int | degree, | ||
int | speed | ||
) |
moves the robot forward/backward OR turns the robot using the odometry sensors. You can use the old function-names Go() and Turn()
distance | travalling distance in cm. positive = forward, negative = backward if distanse is zero, then the function will work as Turn. |
degree | degrees to turn. positive = turn right, negative = turn left. range: -360..360 |
speed | motor speed. range: 0..255 |
void Init | ( | void | ) |
initialises the hardware (ports, ADC, PWM) this function has to be called by every program first
void LineData | ( | unsigned int * | data | ) |
reads out the phototransistors
data | pointer to the data destination. access: data[LEFT], data[RIGHT] |
void MotorDir | ( | unsigned char | left_dir, |
unsigned char | right_dir | ||
) |
Motor configuration. values: FWD, RWD, BREAK, FREE.
left_dir | left motor direction |
right_dir | right motor direction |
void MotorSpeed | ( | unsigned char | left_speed, |
unsigned char | right_speed | ||
) |
sets motor speed. range: 0..255
left_speed | left motor |
right_speed | right motor |
void Msleep | ( | unsigned int | ms | ) |
sleep function (ms)
ms | time in ms |
void MyMotorSpeed | ( | unsigned char | left_speed, |
unsigned char | right_speed | ||
) |
sets motor speed. range: 0..255
left_speed | left motor speed |
right_speed | right motor speed |
void OdometryData | ( | unsigned int * | data | ) |
reads out the odometry phototransistors
data | pointer to the data destination. access: data[LEFT], data[RIGHT] |
unsigned char PollSwitch | ( | void | ) |
function to read out switches
void PrintFloat | ( | float | wert, |
char | vorkomma, | ||
char | nachkomma | ||
) |
Send a Float value converted to a string to UART.
wert | float value |
vorkomma | number of chars before the commata |
nachkomma | number of chars behind the commata |
void PrintInt | ( | int | wert | ) |
Send a Integer value converted to a string to UART.
wert | Integer value |
void PrintLong | ( | long | wert | ) |
Send a Long value converted to a string to UART.
wert | long value |
unsigned int ReadADC | ( | unsigned int | mux, |
unsigned int | sleep | ||
) |
void SerPrint | ( | char * | data | ) |
Send a 0-terminated string to UART.
data | Pointer to string |
void SerPrint_p | ( | const char * | data | ) |
Send a 0-terminated string from program space to UART.
data | Pointer to string |
void SerRead | ( | unsigned char * | data, |
unsigned char | length, | ||
unsigned int | timeout | ||
) |
Receive Data from UART.
data | pointer to data |
length | data count |
timeout | count, 0 meens blocking mode |
void SerWrite | ( | unsigned char * | data, |
unsigned char | length | ||
) |
Send Data to UART.
data | pointer to data |
length | data count |
void SetMotorPower | ( | int8_t | leftpwm, |
int8_t | rightpwm | ||
) |
sets motor speed and direcction. range: -128..+128
leftpwm | left motor speed (negative sign meens backward) |
rightpwm | right motor speed (negative sign meens backward) |
void Sleep | ( | unsigned char | time36kHz | ) |
sleep function (36Khz)
time36kHz | time in 1/36k (sec) |
void Sound | ( | uint16_t | freq, |
uint16_t | duration_msec, | ||
uint8_t | amplitude | ||
) |
Genrates a sound via the motors.
freq | frequence |
duration_msec | duration in milli seconds |
amplitude | amplitude |
void StartSwitch | ( | void | ) |
binds switch press to external Interrupt 1 catch it with ISR(INT1_vect) see avr-libc documentation for details
void StatusLED | ( | unsigned char | color | ) |
controls the StatusLED
color | values: OFF, GREEN, RED, YELLOW |
void StopSwitch | ( | void | ) |
stop sending switch interrupt clears INT1_vect
void UartPutc | ( | unsigned char | zeichen | ) |
Send a single character to UART.
zeichen | data to send |
volatile voidFuncPtr AdcIntFunc |
volatile unsigned int adcValue[] |
volatile int autoencode |
volatile unsigned char count36kHz |
volatile int encoder[2] |
odometry sensors tick count access: encoder[LEFT], encoder[RIGHT]
range: 0..255
volatile voidFuncPtr Ovr2IntFunc |
volatile int switched |
any switch pressed?
is being set to TRUE by interrupt if a switch is pressed
remember to set it to false again, since it is not reset automatically
volatile unsigned long timebase |
const char version[5] |
Asuro Lib Versions String