📄 makeframe_moroso.asm
字号:
;/*****************************************************************************/
;/* PROJECT : RF key demonstrator (ASK or FSK) */
;/* Functions: */
;/* Make_frame
;/* Read_ID
;/* Make_daytona_data
;/* Calculate_checksum
;/* Make_frame
;/*****************************************************************************/
;/*****************************************************************************/
;/* Make_preamble */
;/* Description : it reads the preamble & stores it in Tx_byte */
;/* In : Preamble in flash */
;/* Out : Tx_byte, Tx_byte+1 */
;/* local variables : */
;/*****************************************************************************/
Make_preamble:
ldhx #Preamble ; Constant
sthx Tx_byte
rts
;/*****************************************************************************/
;/* Make_device_ID */
;/* Description : it reads the device ID & stores it in Tx_byte */
;/* In : Device_ID in flash */
;/* Out : Tx_byte+2,3,4,5 */
;/* local variables : */
;/*****************************************************************************/
Make_device_ID:
lda Device_ID
sta Tx_byte+2
lda Device_ID+1
sta Tx_byte+3
lda Device_ID+2
sta Tx_byte+4
lda Device_ID+3
sta Tx_byte+5
rts
;/*****************************************************************************/
;/* Make_daytona_data */
;/* Description : it stores Daytona data in Tx_byte */
;/* In : daytona_output */
;/* Out : Tx_byte+6,7 */
;/* local variables : */
;/*****************************************************************************/
Make_daytona_data:
lda PRESSURE
sta Tx_byte+6
lda TEMPERATURE
sta Tx_byte+7
rts
;/*****************************************************************************/
;/* Make_status_byte */
;/* Description : Places the status byte in the right place in the frame. */
;/* In : parity */
;/* Out : Tx_byte+8 */
;/* local variables : */
;/*****************************************************************************/
Make_status_byte:
lda STATUS
sta Tx_byte+8
rts
;/*****************************************************************************/
;/* calculate_checksum */
;/* Description : stores checksum data in Tx_byte. Checksum is calculated */
;/* by two's complementing the sum of the following data: */
;/* ID1, ID2, ID3, PRESSURE, TEMPERATURE */
;/* such that the sum of these and the checksum is zero. */
;/* In : frame in Tx_byte */
;/* Out : Tx_byte+9 */
;/* local variables : */
;/*****************************************************************************/
Calculate_Checksum:
ldhx #Tx_byte+2 ; Preamble ($FFF6) is not included
lda #nb_tx_byte-4 ; Nor are the checksum or junk bytes
sta Chk_count
clra
Calculate_chk_next:
add ,x
incx
dbnz Chk_count,Calculate_chk_next
; repeat for each byte of the frame
nega
sta Tx_byte+!9 ; store calculated checksum
rts
;/*****************************************************************************/
;/* Make_frame */
;/* Description : it makes the frame to be transmitted */
;/* Preamble (2 bytes) */
;/* Device ID (4 bytes) */
;/* Daytona data (2 bytes) */
;/* Checksum (1 byte) */
;/* Junk (1 byte) */
;/* In : Daytona output, Status info, Preamble + ID in flash */
;/* Out : Tx_byte data frame */
;/* local variables : */
;/*****************************************************************************/
Make_frame:
jsr Make_preamble
jsr Make_device_ID
jsr Make_daytona_data
jsr Make_status_byte
jsr Calculate_Checksum
; This is a useless byte, which is there only because it
sta Tx_byte+!10 ; will be corrupted by the 33592 romeo receiver instead of
; the real data.
rts
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -