📄 accelerator.asm
字号:
; generated by Norcroft eCOG C Compiler V1.10 $BuildRevision$
; special options: -g
;
MODULE accelerator___accelerator
.CODE
.LARGE
; TARGET_MAX_STACK_OVERRUN = 8
;/******************************************************************************
;MODE: AML--#GPS+accelerator+compass
;MCU: Cyan eCOG1k
;COMPILER: CyanIDE v1.41
;FILE NAME: accelerator C source code files
;******************************************************************************/
;
;#define accelerator_code
;
;/******************************************************************************
;Project level include files.
;******************************************************************************/
;#include "accelerator.h"
;
;/******************************************************************************
;Declaration of static functions.
;******************************************************************************/
;extern void delay_ms(unsigned int ms_reg);
;int acc_read_16bit(unsigned int address);
;unsigned char acc_write_1byte_reg(unsigned int address,unsigned char write_data);
;void accelerator_initialization(void);
;unsigned char acc_read_1byte_reg(unsigned int address);
;void accelerator_3axis_reading(void);
;
;/******************************************************************************
;NOTE: The command byte of SPI bus is :
;(MSB) A A A A A A A RW 0 (LSB)
; | | | *- always zero
; | | *--- Read / Write Bit
; \-----------*------ Register address, 0x05 at this example
;
;Because of the real byte sent to SPI bus must be calculated:
;BYTE = (Address * 4) + RW*2;
;For Read operation RW = 0 and for Write operation RW = 1
;'Address *4' shifts the bit pattern to left by 2 and 'RW*2' by 1.
;BYTE = 0x05*4 + 0;
;BYTE = 0x14;
;
;FUNCTION
; reads SCA3000 X,Y,Z acceleration registers MSB and LSB.
;******************************************************************************/
;int acc_read_16bit(unsigned int address)
;
$acc_read_16bit:
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?42.1:
st AL,@(-1,Y)
st XH,@(-3,Y)
st X,@(-2,Y)
st AL,@(-6,Y) ; %r16 (address)
Lstab?0c:
;{
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?43.1:
Lstab?1c:
; int result;
;
; result = 0;
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?46.1:
ld AL,#0
; result = acc_read_1byte_reg(address);
st AL,@(-4,Y) ; %r17 (result)
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?47.1:
ld AL,@(-6,Y) ; %r16 (address)
add Y,#-7
Lstab?2a:
bsr $acc_read_1byte_reg
; result = result << 8;
st AL,@(3,Y) ; %r17 (result)
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?48.1:
ld AL,@(3,Y) ; %r17 (result)
asl #8
; result |= acc_read_1byte_reg(address - 1);
st AL,@(3,Y) ; %r17 (result)
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?49.1:
ld AL,@(1,Y) ; %r16 (address)
sub AL,#1
bsr $acc_read_1byte_reg
or AL,@(3,Y) ; %r17 (result)
;
; return (result);
st AL,@(3,Y) ; %r17 (result)
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?51.1:
ld AL,@(3,Y) ; %r17 (result)
?L6F1:
add Y,#7
ld XH,@(-3,Y)
bra @(-2,Y)
Lstab?3c:
;
;
;}
;
;
;/******************************************************************************
;FUNCTION
; Read/Write 1 byte from/to register of accelerator(SCA3000).
;
;RETURNS
; result.
;******************************************************************************/
;unsigned char acc_write_1byte_reg(unsigned int address,unsigned char write_data)
;
$acc_write_1byte_reg:
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?63.1:
add Y,#-12
Lstab?4a:
st AL,@(10,Y)
st AH,@(11,Y)
st XH,@(8,Y)
st X,@(9,Y)
st AL,@(1,Y) ; %r16 (address)
st AH,@(3,Y) ; %r17 (write_data)
Lstab?5c:
Lstab?6c:
ld AL,@(3,Y) ; %r17 (write_data)
and AL,#255
;{
st AL,@(7,Y) ; %r19 (write_data)
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?64.1:
Lstab?7c:
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?65.1:
ld AL,#0
; unsigned char result = 0;
;
; address = (address << 2) + 2;
st AL,@(5,Y) ; %r18 (result)
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?67.1:
ld AL,@(1,Y) ; %r16 (address)
asl #2
add AL,#2
;
; cyan_spi_transfer_byte( address );
st AL,@(1,Y) ; %r16 (address)
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?69.1:
ld AL,@(1,Y) ; %r16 (address)
bsr $cyan_spi_transfer_byte
; cyan_spi_transfer_byte( write_data );
^accelerator___accelerator.'D:\GPS\software\GPS_A_C\accelerator.c'.?70.1:
ld AL,@(7,Y) ; %r19 (write_data)
bsr $cyan_spi_transfer_byte
;
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -