Defines | |
#define | PC5 19 |
#define | PC4 18 |
#define | PD3 3 |
#define | PD4 4 |
#define | PD6 6 |
#define | PD5 5 |
#define | PC3 17 |
#define | ACCEL_X 1 |
#define | ACCEL_Y 2 |
#define | ACCEL_Z 3 |
#define | HIGH true |
#define | LOW false |
Functions | |
uint16 | analog_read (uint8 pin) |
void | analog_read_fast (bool start, uint8 pin) |
void | analog_write (uint8 pin, uint8 val) |
void | atmega_reset (bool wait) |
uint8 | atmega_read_8 (uint8 reg) |
void | atmega_write_8 (uint8 reg, uint8 val) |
bool | digital_read (uint8 pin) |
void | digital_write (uint8 pin, bool val) |
uint8 | i2c_receive (uint8 addr, uint8 *dest, uint8 size) |
uint8 | i2c_send (uint8 addr, const uint8 *src, uint8 size) |
void | servo_detach (uint8 pin) |
bool | servo_set (uint8 pin, uint8 pos) |
bool | em4102_send (uint8 pin, const uint8 *data, uint8 tries) |
#define ACCEL_X 1 |
#define ACCEL_Y 2 |
#define ACCEL_Z 3 |
#define HIGH true |
#define LOW false |
#define PC3 17 |
#define PC4 18 |
#define PC5 19 |
#define PD3 3 |
#define PD4 4 |
#define PD5 5 |
#define PD6 6 |
uint16 analog_read | ( | uint8 | pin | ) |
read the value of an analog pin.
works with PC5, PC4; PC3 (ds brut uart only) you can use this function to read from a build-in adxl330 accelerometer, using ACCEL_{X,Y,Z} as pin.
pin | pin to use (see pin definitions above) |
void analog_read_fast | ( | bool | start, | |
uint8 | pin | |||
) |
start a fast adc conversion of an analog pin.
this function continuously returns the value of the analog pin as an uint8 (8 bit) in the normal input queue (so read with uart_read(), etc). until this function is called again with start set to false, all other data send to the device will be ignored.
start | true to start, false to stop | |
pin | pin to use (see pin definitions above) |
void analog_write | ( | uint8 | pin, | |
uint8 | val | |||
) |
write a pwm value to a pin.
works with PD3, PD6, PD5
pin | pin to use (see pin definitions above) | |
val | value |
uint8 atmega_read_8 | ( | uint8 | reg | ) |
read registers on the device.
see atmega168 datasheet, p. 343f.
reg | register address |
void atmega_reset | ( | bool | wait | ) |
reset the device.
this function triggers a watchdog reset on the atmega micro- controller. a modified bootloader is necessary for this to work, otherwise no reset will be performed.
wait | wait for the card to become available again |
void atmega_write_8 | ( | uint8 | reg, | |
uint8 | val | |||
) |
write to registers on the device.
see atmega168 datasheet, p. 343f.
reg | register address | |
val | value to set |
bool digital_read | ( | uint8 | pin | ) |
read the value of a pin.
pin | pin to use (see pin definitions above) |
void digital_write | ( | uint8 | pin, | |
bool | val | |||
) |
set a pin either high or low.
pin | pin to use (see pin definitions above) | |
val | HIGH or LOW |
bool em4102_send | ( | uint8 | pin, | |
const uint8 * | data, | |||
uint8 | tries | |||
) |
send an EM4102 sequence
data is expected to be five bytes. first byte holds the manufacturer id while the other ones hold the unique (card) id. needs firmware version 0x13 or higher.
pin | pin to use (see pin definitions above) | |
data | data buffer (expected to be five bytes) | |
tries | number of consecutive times to send the sequence |
uint8 i2c_receive | ( | uint8 | addr, | |
uint8 * | dest, | |||
uint8 | size | |||
) |
receive data over the i2c bus.
use PC4 as SDA and PC5 as SCL line. the device joins the i2c bus as master. addr has the destination address in the lower 7 bits. internally, they are being left-shifted and the read/write bit appended (like on arduino).
addr | source address (slave) | |
dest | destination buffer | |
size | size of destination buffer in bytes |
uint8 i2c_send | ( | uint8 | addr, | |
const uint8 * | src, | |||
uint8 | size | |||
) |
send data over the i2c bus.
use PC4 as SDA and PC5 as SCL line. the device joins the i2c bus as master. addr has the destination address in the lower 7 bits. internally, they are being left-shifted and the read/write bit appended (like on arduino).
addr | destination address (slave) | |
src | data to send | |
size | number of bytes to send |
0 | success | |
1 | size to big for (atmega) buffer | |
2 | address send, nack received | |
3 | data send, nack received | |
4 | other i2c error (lost bus arbitration, bus error) | |
255 | out of memory |
void servo_detach | ( | uint8 | pin | ) |
detach a servo from a pin
pin | pin to use (see pin definitions above) |
bool servo_set | ( | uint8 | pin, | |
uint8 | pos | |||
) |
set a servo to a given position
DS brut only supports a finite number of servo objects. When exceeding this number this function will return false for commands to new pins. (Use servo_detach() to make room for new ones.)
pin | pin to use (see pin definitions above) | |
pos | position (normally 0 to 180) |