#include <stdlib.h>
#include <aversive.h>
#include <aversive/wait.h>
#include <encoders_microb.h>
#include <encoders_microb_config.h>
Go to the source code of this file.
Defines | |
#define | SEL_A() cbi(ENCODERS_MICROB_SEL_PORT,ENCODERS_MICROB_SEL_BIT) |
#define | SEL_B() sbi(ENCODERS_MICROB_SEL_PORT,ENCODERS_MICROB_SEL_BIT) |
#define | READ(n) |
#define | INIT(n) |
Functions | |
void | encoders_microb_init (void) |
void | encoders_microb_manage (void *dummy) |
int32_t | encoders_microb_get_value (void *number) |
void | encoders_microb_set_value (void *number, int32_t v) |
Variables | |
int32_t | g_encoders_microb_values [ENCODERS_MICROB_NUMBER] |
int8_t | g_encoders_microb_previous [ENCODERS_MICROB_NUMBER] |
The harware is quite simple here :
* ---------- * | | 8 * | PINx|<-/--- value * | | * | | 8 * | PINy|<-/--- value * | | * | | 8 * | PINz|<-/--- value * | | * | ....| * | | * | SEL |----> (1 bit) * | | * | | * | | * ---------- *
Definition in file encoders_microb.c.
#define INIT | ( | n | ) |
Value:
do { \ g_encoders_microb_values[n] = 0; \ } while(0)
Definition at line 91 of file encoders_microb.c.
Referenced by encoders_microb_init().
#define READ | ( | n | ) |
Value:
do { \ val = ENCODERS_MICROB##n##_PIN; \ nop(); \ if (val != ENCODERS_MICROB##n##_PIN) \ val = ENCODERS_MICROB##n##_PIN; \ \ res = (val - g_encoders_microb_previous[n]); \ g_encoders_microb_previous[n] = val; \ \ g_encoders_microb_values[n] += (int32_t)res ; \ } while(0)
Definition at line 76 of file encoders_microb.c.
Referenced by encoders_microb_manage().
#define SEL_A | ( | ) | cbi(ENCODERS_MICROB_SEL_PORT,ENCODERS_MICROB_SEL_BIT) |
Definition at line 71 of file encoders_microb.c.
Referenced by encoders_microb_init(), and encoders_microb_manage().
#define SEL_B | ( | ) | sbi(ENCODERS_MICROB_SEL_PORT,ENCODERS_MICROB_SEL_BIT) |
Definition at line 72 of file encoders_microb.c.
Referenced by encoders_microb_init(), and encoders_microb_manage().
int32_t encoders_microb_get_value | ( | void * | number | ) |
Extract encoder value.
number | : a (void *) that is casted in (int) containing the number of the encoder to be read. |
Definition at line 230 of file encoders_microb.c.
References g_encoders_microb_values, IRQ_LOCK, and IRQ_UNLOCK.
void encoders_microb_init | ( | void | ) |
Initialisation of encoders, variables
Definition at line 104 of file encoders_microb.c.
References DDR, encoders_microb_manage(), INIT, IRQ_LOCK, IRQ_UNLOCK, sbi, SEL_A, SEL_B, and wait_4cyc.
void encoders_microb_manage | ( | void * | dummy | ) |
Update encoders values, need to be done quite often (Fmax_encoders/64). First, encoders 0 2 4 6 are read, and at next call encoders 1 3 5 7.
dummy | : a (void *) pointer that is not used. It is here according to the encoders interface. |
Definition at line 166 of file encoders_microb.c.
References IRQ_LOCK, IRQ_UNLOCK, READ, SEL_A, and SEL_B.
Referenced by encoders_microb_init().
void encoders_microb_set_value | ( | void * | number, | |
int32_t | v | |||
) |
Set an encoder value
number | : a (void *) that is casted in (int) containing the number of the encoder to be read. | |
v | : the value |
Definition at line 248 of file encoders_microb.c.
References g_encoders_microb_values, IRQ_LOCK, and IRQ_UNLOCK.
int8_t g_encoders_microb_previous[ENCODERS_MICROB_NUMBER] |
Definition at line 67 of file encoders_microb.c.
int32_t g_encoders_microb_values[ENCODERS_MICROB_NUMBER] |
Definition at line 66 of file encoders_microb.c.
Referenced by encoders_microb_get_value(), and encoders_microb_set_value().