Defines | |||
![]() | ![]() | #define | DS_ALL_ACTIVE |
![]() | ![]() | all sensors active mode. | |
![]() | ![]() | #define | DS_ALL_PASSIVE |
![]() | ![]() | all sensors passive mode. | |
Functions | |||
![]() | ![]() | void | ds_rotation_set (volatile unsigned *sensor,int pos) |
![]() | ![]() | set rotation to an absolute value. More... | |
![]() | ![]() | void | ds_rotation_handler () |
![]() | ![]() | process rotation sensor on current A/D channel. More... | |
![]() | ![]() | void | ds_handler (void) |
![]() | ![]() | sensor A/D conversion IRQ handler. | |
![]() | ![]() | __asm__ (" .text .align 1 _ds_handler: ; r6 saved by ROM mov.b @_ds_channel,r6l ; r6l = current channel mov.b @_ds_activation,r6h ; r6h = activation bitmask btst r6l,r6h ; activate output? beq ds_noset bset r6l,@0xbb:8 ; activate output ds_noset: " " mov.b @_ds_rotation,r6h ; r6h = rotation bitmask btst r6l,r6h ; process rotation sensor? beq ds_norot push r0 ; save r0..r3 push r1 push r2 push r3 ; r4..r6 saved by gcc if necessary jsr _ds_rotation_handler ; process rotation sensor pop r3 pop r2 pop r1 pop r0 ds_norot: " " inc r6l ; next channel and #0x03,r6l ; limit to 0-3 mov.b r6l,@_ds_channel bclr r6l,@0xbb:8 ; output inactive mov.b @0xe8:8,r6h ; r6h = A/D CSR and.b #0x7c,r6h ; scan next channel or.b r6l,r6h mov.b r6h,@0xe8:8 bset #0x5,@0xe8:8 ; go! rts ") | |
![]() | ![]() | void | ds_init (void) |
![]() | ![]() | initialize sensor a/d conversion. More... | |
![]() | ![]() | void | ds_shutdown (void) |
![]() | ![]() | shutdown sensor a/d conversion. More... | |
Variables | |||
![]() | ![]() | volatile unsigned char | ds_channel |
![]() | ![]() | current A/D channel. | |
![]() | ![]() | unsigned char | ds_activation |
![]() | ![]() | channel bitmask. 1-> active. | |
![]() | ![]() | unsigned char | ds_rotation |
![]() | ![]() | channel bitmask. 1-> rotation. | |
![]() | ![]() | volatile int | ds_rotations [3] |
![]() | ![]() | sensor revolutions * 16. | |
![]() | ![]() | signed char | rotation_state [3] |
![]() | ![]() | rotation state. | |
![]() | ![]() | const signed char | ad2state [16] |
![]() | ![]() | convert a/d values to rotation states. More... | |
![]() | ![]() | const signed char | diff2change [7] |
![]() | ![]() | convert state difference to revolution count change. More... |
#define DS_ALL_ACTIVE () |
all sensors active mode.
#define DS_ALL_PASSIVE () |
all sensors passive mode.
void ds_rotation_set (volatile unsigned * sensor, int pos) |
set rotation to an absolute value.
sensor | the sensor address, can be &SENSOR_1, &SENSOR_2 or &SENSOR_3 |
pos |
desired absolute position
|
void ds_rotation_handler () |
process rotation sensor on current A/D channel.
void ds_handler (void) |
sensor A/D conversion IRQ handler.
__asm__ (".text.align 1_ds_handler:;r6 saved by ROM mov.b@ _ds_channel, r6l; r6l = current channel mov.b @_ds_activation, r6h; r6h = activation bitmask btst r6l, r6h;activate output? beq ds_noset bset r6l, @0xbb:8;activate output ds_noset:""mov.b@ _ds_rotation, r6h; r6h = rotation bitmask btst r6l, r6h;process rotation sensor?beq ds_norot push r0;save r0..r3 push r1 push r2 push r3;r4..r6 saved by gcc if necessary jsr _ds_rotation_handler;process rotation sensor pop r3 pop r2 pop r1 pop r0 ds_norot:""inc r6l;next channel and# 0x03, r6l;limit to 0-3 mov. b r6l, @ _ds_channel bclr r6l, @0xbb:8;output inactive mov.b@0xe8:8, r6h; r6h = A/D CSR and.b #0x7c, r6h;scan next channel or. b r6l, r6h mov. b r6h, @0xe8:8 bset# 0x5, @0xe8:8;go!rts") |
void ds_init (void) |
initialize sensor a/d conversion.
all sensors set to passive mode rotation tracking disabled
void ds_shutdown (void) |
shutdown sensor a/d conversion.
all sensors set to passive mode
volatile unsigned char ds_channel |
current A/D channel.
unsigned char ds_activation |
channel bitmask. 1-> active.
unsigned char ds_rotation |
channel bitmask. 1-> rotation.
volatile int ds_rotations[3] |
sensor revolutions * 16.
signed char rotation_state[3] [static]
|
rotation state.
const signed char ad2state[16] [static]
|
convert a/d values to rotation states.
Indexed with (value>>12). Invalid values yield negative states.
const signed char diff2change[7] [static]
|
convert state difference to revolution count change.
Indexed with (newstate-state)+3. Invalid differences yield zero change. Differences of magnitude two could have been acheived in either rotational sense, so their expected value is zero.