; 78K0R C Compiler V2.10 Assembler Source Date:13 Jun 2010 Time:19:31:23 ; Command : -c9F0104 -yC:\Program Files\NEC Electronics Tools\DEV -_msgoff -i ; renge -iC:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\ ; V1.20\inc78k0r -ms -qvjl3wt -sainter_asm -zp -no i2c_mcu.c ; In-file : i2c_mcu.c ; Asm-file : inter_asm\i2c_mcu.asm ; Para-file : $PROCESSOR(9F0104) $DEBUG $NODEBUGA $KANJICODE SJIS $TOL_INF 03FH, 0210H, 02H, 00H, 00H, 00H, 00H $DGS FIL_NAM, .file, 0100H, 0FFFEH, 03FH, 067H, 01H, 00H $DGS AUX_FIL, i2c_mcu.c $DGS MOD_NAM, i2c_mcu, 00H, 0FFFEH, 00H, 077H, 00H, 00H $DGS SEC_NAM, @@BITS, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@CNST, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@R_INIT, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@INIT, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@DATA, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@R_INIS, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@INIS, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@DATS, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@CNSTL, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@RLINIT, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@INITL, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@DATAL, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@CALT, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, ROM_CODE, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@CODEL, U, U, 00H, 078H, 00H, 00H $DGS SEC_NAM, @@BASE, U, U, 00H, 078H, 00H, 00H $DGS LAB_SYM, bs_F0085, U, U, 00H, 06H, 00H, 00H $DGS LAB_SYM, es_F0085, U, U, 00H, 06H, 00H, 00H $DGS LAB_SYM, bs_S0086, U, U, 00H, 06H, 00H, 00H $DGS LAB_SYM, es_S0086, U, U, 00H, 06H, 00H, 00H $DGS LAB_SYM, bs_S0087, U, U, 00H, 06H, 00H, 00H $DGS LAB_SYM, es_S0087, U, U, 00H, 06H, 00H, 00H $DGS LAB_SYM, bs_F0084, U, U, 00H, 06H, 00H, 00H $DGS LAB_SYM, es_F0084, U, U, 00H, 06H, 00H, 00H $DGS STA_SYM, _lpf_coeff, U, U, 05002H, 03H, 01H, 03H $DGS AUX_STR, 00H, 00H, 02FH, 02FH, 00H, 00H, 00H, 00H $DGS GLV_SYM, _nop8, U, U, 01H, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 023H, 00H, 00H $DGS BEG_FUN, ??bf_nop8, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 04CH, 00H, 023H $DGS END_FUN, ??ef_nop8, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 02H $DGS GLV_SYM, _iic_mcu_read_a_byte, U, U, 0CH, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 03CH, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_read_a_byte, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 057H, 04H, 02AH $DGS FUN_ARG, _SLA, 02H, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _adrs, 0AH, 0FFFFH, 0CH, 09H, 00H, 00H $DGS AUT_VAR, _dat, 01H, 0FFFFH, 0CH, 01H, 00H, 00H $DGS BEG_BLK, ??bb00_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 05H, 00H, 02EH $DGS END_BLK, ??eb00_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 0DH $DGS BEG_BLK, ??bb01_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 010H, 00H, 032H $DGS END_BLK, ??eb01_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 012H $DGS BEG_BLK, ??bb02_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 019H, 00H, 036H $DGS END_BLK, ??eb02_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 01DH $DGS BEG_BLK, ??bb03_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 030H, 00H, 00H $DGS END_BLK, ??eb03_iic_mcu_read_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 032H $DGS END_FUN, ??ef_iic_mcu_read_a_byte, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 039H $DGS GLV_SYM, _iic_mcu_read, U, U, 0CH, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 05FH, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_read, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 09EH, 02H, 045H $DGS FUN_ARG, _slave, 00H, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _adrs, 08H, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _len, 0AH, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _dest, 0CH, 0FFFFH, 0CH, 09H, 01H, 01H $DGS AUX_STR, 00H, 00H, 02H, 00H, 00H, 00H, 00H, 01H $DGS BEG_BLK, ??bb00_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 06H, 00H, 049H $DGS END_BLK, ??eb00_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 0EH $DGS BEG_BLK, ??bb01_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 010H, 00H, 04DH $DGS END_BLK, ??eb01_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 012H $DGS BEG_BLK, ??bb02_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 020H, 00H, 051H $DGS END_BLK, ??eb02_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 023H $DGS BEG_BLK, ??bb03_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 033H, 00H, 053H $DGS BEG_BLK, ??bb04_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 035H, 00H, 057H $DGS END_BLK, ??eb04_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 037H $DGS BEG_BLK, ??bb05_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 03BH, 00H, 00H $DGS END_BLK, ??eb05_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 03DH $DGS END_BLK, ??eb03_iic_mcu_read, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 041H $DGS END_FUN, ??ef_iic_mcu_read, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 049H $DGS GLV_SYM, _iic_mcu_write_a_byte, U, U, 0CH, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 074H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_write_a_byte, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 0F2H, 02H, 066H $DGS FUN_ARG, _SLA, 00H, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _adrs, 08H, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _dat, 0AH, 0FFFFH, 0CH, 09H, 00H, 00H $DGS BEG_BLK, ??bb00_iic_mcu_write_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 04H, 00H, 06AH $DGS END_BLK, ??eb00_iic_mcu_write_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 0CH $DGS BEG_BLK, ??bb01_iic_mcu_write_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 0EH, 00H, 06EH $DGS END_BLK, ??eb01_iic_mcu_write_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 010H $DGS BEG_BLK, ??bb02_iic_mcu_write_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 01AH, 00H, 00H $DGS END_BLK, ??eb02_iic_mcu_write_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 01DH $DGS END_FUN, ??ef_iic_mcu_write_a_byte, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 024H $DGS GLV_SYM, _iic_mcu_write, U, U, 0CH, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 097H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_write, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 0129H, 02H, 07DH $DGS FUN_ARG, _slave, 00H, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _adrs, 08H, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _len, 0AH, 0FFFFH, 0CH, 09H, 00H, 00H $DGS FUN_ARG, _src, 0CH, 0FFFFH, 01H, 09H, 01H, 01H $DGS AUX_STR, 00H, 00H, 02H, 00H, 00H, 00H, 00H, 01H $DGS BEG_BLK, ??bb00_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 05H, 00H, 081H $DGS END_BLK, ??eb00_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 0DH $DGS BEG_BLK, ??bb01_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 0FH, 00H, 085H $DGS END_BLK, ??eb01_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 011H $DGS BEG_BLK, ??bb02_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 020H, 00H, 089H $DGS END_BLK, ??eb02_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 024H $DGS BEG_BLK, ??bb03_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 028H, 00H, 08BH $DGS BEG_BLK, ??bb04_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 02FH, 00H, 091H $DGS END_BLK, ??eb04_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 030H $DGS END_BLK, ??eb03_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 03EH $DGS BEG_BLK, ??bb05_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 040H, 00H, 00H $DGS END_BLK, ??eb05_iic_mcu_write, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 04AH $DGS END_FUN, ??ef_iic_mcu_write, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 04CH $DGS GLV_SYM, _int_dma1, U, U, 0E001H, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0AAH, 00H, 00H $DGS BEG_FUN, ??bf_int_dma1, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 0184H, 016H, 09CH $DGS REG_VAR, _i, 0103H, 0FFFFH, 010DH, 04H, 00H, 00H $DGS BEG_BLK, ??bb00_int_dma1, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 09H, 00H, 09EH $DGS BEG_BLK, ??bb01_int_dma1, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 0BH, 00H, 0A4H $DGS END_BLK, ??eb01_int_dma1, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 0DH $DGS END_BLK, ??eb00_int_dma1, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 0EH $DGS BEG_BLK, ??bb02_int_dma1, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 011H, 00H, 00H $DGS END_BLK, ??eb02_int_dma1, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 033H $DGS END_FUN, ??ef_int_dma1, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 036H $DGS GLV_SYM, _int_iic10, U, U, 0E001H, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0B8H, 00H, 00H $DGS BEG_FUN, ??bf_int_iic10, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 01C4H, 016H, 0AEH $DGS BEG_BLK, ??bb00_int_iic10, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 04H, 00H, 0B2H $DGS END_BLK, ??eb00_int_iic10, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 09H $DGS BEG_BLK, ??bb01_int_iic10, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 0EH, 00H, 00H $DGS END_BLK, ??eb01_int_iic10, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 030H $DGS END_FUN, ??ef_int_iic10, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 033H $DGS STA_SYM, _iic_mcu_call_slave, U, U, 0CH, 03H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0C3H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_call_slave, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 0201H, 02H, 0BDH $DGS REG_PAR, _slave, 06H, 0FFFFH, 010CH, 011H, 00H, 00H $DGS BEG_BLK, ??bb00_iic_mcu_call_slave, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 06H, 00H, 00H $DGS END_BLK, ??eb00_iic_mcu_call_slave, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 09H $DGS END_FUN, ??ef_iic_mcu_call_slave, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 0CH $DGS STA_SYM, _iic_mcu_send_a_byte, U, U, 0CH, 03H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0D2H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_send_a_byte, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 0215H, 02H, 0C8H $DGS REG_PAR, _dat, 06H, 0FFFFH, 010CH, 011H, 00H, 00H $DGS BEG_BLK, ??bb00_iic_mcu_send_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 06H, 00H, 0CCH $DGS END_BLK, ??eb00_iic_mcu_send_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 08H $DGS BEG_BLK, ??bb01_iic_mcu_send_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 0AH, 00H, 00H $DGS END_BLK, ??eb01_iic_mcu_send_a_byte, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 0DH $DGS END_FUN, ??ef_iic_mcu_send_a_byte, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 0FH $DGS STA_SYM, _iic_mcu_send_st, U, U, 01H, 03H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0D8H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_send_st, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 022CH, 00H, 0D8H $DGS END_FUN, ??ef_iic_mcu_send_st, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 016H $DGS STA_SYM, _iic_mcu_send_re_st, U, U, 01H, 03H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0DEH, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_send_re_st, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 0249H, 00H, 0DEH $DGS END_FUN, ??ef_iic_mcu_send_re_st, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 022H $DGS STA_SYM, _iic_mcu_send_sp, U, U, 01H, 03H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0E4H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_send_sp, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 0273H, 00H, 0E4H $DGS END_FUN, ??ef_iic_mcu_send_sp, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 023H $DGS GLV_SYM, _iic_mcu_start, U, U, 01H, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0F2H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_start, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 029EH, 00H, 0E8H $DGS BEG_BLK, ??bb00_iic_mcu_start, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 06H, 00H, 0ECH $DGS END_BLK, ??eb00_iic_mcu_start, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 06H $DGS BEG_BLK, ??bb01_iic_mcu_start, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 02AH, 00H, 00H $DGS END_BLK, ??eb01_iic_mcu_start, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 02AH $DGS END_FUN, ??ef_iic_mcu_start, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 030H $DGS GLV_SYM, _iic_mcu_stop, U, U, 01H, 026H, 01H, 02H $DGS AUX_FUN, 00H, U, U, 0100H, 00H, 00H $DGS BEG_FUN, ??bf_iic_mcu_stop, U, U, 00H, 065H, 01H, 00H $DGS AUX_BEG, 02D6H, 00H, 0F6H $DGS BEG_BLK, ??bb00_iic_mcu_stop, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 03H, 00H, 0FAH $DGS END_BLK, ??eb00_iic_mcu_stop, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 04H $DGS BEG_BLK, ??bb01_iic_mcu_stop, U, U, 00H, 064H, 01H, 00H $DGS AUX_BEG, 06H, 00H, 00H $DGS END_BLK, ??eb01_iic_mcu_stop, U, U, 00H, 064H, 01H, 00H $DGS AUX_END, 06H $DGS END_FUN, ??ef_iic_mcu_stop, U, U, 00H, 065H, 01H, 00H $DGS AUX_END, 09H $DGS GLV_SYM, _iic_mcu_wo_dma, U, U, 034CH, 027H, 00H, 00H $DGS GLV_SYM, _iic_mcu_busy, U, U, 0134CH, 027H, 00H, 00H $DGS GLV_SYM, _iic_mcu_initialized, U, U, 0134CH, 027H, 00H, 00H $DGS GLV_SYM, _iic_send_work, U, U, 0CH, 026H, 01H, 03H $DGS AUX_STR, 00H, 00H, 04H, 04H, 00H, 00H, 00H, 00H $DGS GLV_SYM, _p_iic_send_wo_dma_dat, U, U, 0CH, 026H, 01H, 01H $DGS AUX_STR, 00H, 00H, 02H, 00H, 00H, 00H, 00H, 01H $DGS GLV_SYM, _iic_send_wo_dma_len, U, U, 0CH, 026H, 00H, 00H $DGS GLV_SYM, _iic_mcu_bus_status, U, U, 0CH, 026H, 00H, 00H $DGS GLV_SYM, _@SEGAX, U, U, 00H, 02H, 00H, 00H $DGS GLV_SYM, _@SEGDE, U, U, 00H, 02H, 00H, 00H $DGS GLV_SYM, _@RTARG0, U, U, 00H, 02H, 00H, 00H EXTRN _@SEGAX EXTRN _@SEGDE EXTRN _@RTARG0 PUBLIC _iic_mcu_wo_dma PUBLIC _iic_mcu_busy PUBLIC _iic_mcu_initialized PUBLIC _iic_send_work PUBLIC _p_iic_send_wo_dma_dat PUBLIC _iic_send_wo_dma_len PUBLIC _iic_mcu_bus_status PUBLIC _nop8 PUBLIC _iic_mcu_read_a_byte PUBLIC _iic_mcu_read PUBLIC _iic_mcu_write_a_byte PUBLIC _iic_mcu_write PUBLIC _int_dma1 PUBLIC _int_iic10 PUBLIC _iic_mcu_start PUBLIC _iic_mcu_stop @@BITS BSEG _iic_mcu_wo_dma DBIT _iic_mcu_busy DBIT _iic_mcu_initialized DBIT @@CNST CSEG MIRRORP _lpf_coeff: DB 01H ; 1 DB 02H ; 2 DB 02H ; 2 DB 03H ; 3 DB 03H ; 3 DB 02H ; 2 DB 00H ; 0 DB 0FEH ; 254 DB 0FBH ; 251 DB 0F7H ; 247 DB 0F3H ; 243 DB 0F0H ; 240 DB 0F0H ; 240 DB 0F3H ; 243 DB 0FAH ; 250 DB 04H ; 4 DB 012H ; 18 DB 025H ; 37 DB 038H ; 56 DB 04DH ; 77 DB 05FH ; 95 DB 06EH ; 110 DB 077H ; 119 DB 07AH ; 122 DB 077H ; 119 DB 06EH ; 110 DB 05FH ; 95 DB 04DH ; 77 DB 038H ; 56 DB 025H ; 37 DB 012H ; 18 DB 04H ; 4 DB 0FAH ; 250 DB 0F3H ; 243 DB 0F0H ; 240 DB 0F0H ; 240 DB 0F3H ; 243 DB 0F7H ; 247 DB 0FBH ; 251 DB 0FEH ; 254 DB 00H ; 0 DB 02H ; 2 DB 03H ; 3 DB 03H ; 3 DB 02H ; 2 DB 02H ; 2 DB 01H ; 1 DB (1) @@R_INIT CSEG UNIT64KP @@INIT DSEG BASEP @@DATA DSEG BASEP _iic_send_work: DS (4) _p_iic_send_wo_dma_dat: DS (2) _iic_send_wo_dma_len: DS (1) _iic_mcu_bus_status: DS (1) @@R_INIS CSEG UNIT64KP @@INIS DSEG SADDRP @@DATS DSEG SADDRP @@CNSTL CSEG PAGE64KP @@RLINIT CSEG UNIT64KP @@INITL DSEG UNIT64KP @@DATAL DSEG UNIT64KP @@CALT CSEG CALLT0 ; Sub-Routines created by CC78K0R ROM_CODE CSEG BASE bs_F0085: shrw ax,8 ;[INF] 2, 1 br !_iic_mcu_send_a_byte ;[INF] 3, 3 es_F0085: ROM_CODE CSEG BASE bs_S0086: movw ax,#04H ; 4 ;[INF] 3, 1 movw !ST0,ax ;[INF] 3, 1 ret ;[INF] 1, 6 es_S0086: ROM_CODE CSEG BASE bs_S0087: movw ax,#04H ; 4 ;[INF] 3, 1 movw !SS0,ax ;[INF] 3, 1 ret ;[INF] 1, 6 es_S0087: ROM_CODE CSEG BASE bs_F0084: mov a,[hl] ;[INF] 1, 1 shrw ax,8 ;[INF] 2, 1 call !_iic_mcu_call_slave ;[INF] 3, 3 cmp0 c ;[INF] 1, 1 ret ;[INF] 1, 6 es_F0084: ; *** Sub-Routine Information *** ; ; $SUB bs_F0084 ; CODE SIZE= 8 bytes ; ; $SUB bs_F0085 ; CODE SIZE= 5 bytes ; ; $SUB bs_S0086 ; CODE SIZE= 7 bytes ; ; $SUB bs_S0087 ; CODE SIZE= 7 bytes ; End of Sub-Routines ; line 1 : /* ======================================================== ; line 2 : 簡易I2C(内蔵ペリフェラル使用)通信 ; line 3 : de JHL 藤田@開技 ; line 4 : '09 Feb - ; line 5 : ======================================================== */ ; line 6 : #pragma sfr ; line 7 : #pragma di ; line 8 : #pragma ei ; line 9 : #pragma nop ; line 10 : #pragma inline // memcpy()をインライン展開する ; line 11 : ; line 12 : #include "incs.h" ; line 13 : #include "i2c_mcu.h" ; line 14 : ; line 15 : ; line 16 : ; line 17 : // ======================================================== ; line 18 : // レジスタのビット名 ; line 19 : // プリフィックスbだが、一部のビット名がレジスタ名にかぶるため.. ; . ; line 20 : // SMR0n ; line 21 : #define bCKS0 ( 1 << 15 ) ; line 22 : #define bCCS0 ( 1 << 14 ) ; line 23 : #define bSTS0 ( 1 << 8 ) ; line 24 : #define bSIS0 ( 1 << 6 ) ; line 25 : #define bMD0n2 ( 1 << 2 ) ; line 26 : #define bMD0n1 ( 1 << 1 ) ; line 27 : #define bMD0n0 ( 1 << 0 ) ; line 28 : #define bSMR0n_FIXEDBIT ( 1 << 5 ) ; line 29 : ; line 30 : // SSR0n ; line 31 : #define bit_TSF0 6 ; line 32 : #define PEF0 ( 1 << 1 ) ; line 33 : ; line 34 : // SIR0n ; line 35 : #define PECT0 ( 1 << 1 ) ; line 36 : ; line 37 : // SCR0n ; line 38 : #define TXE0 ( 1 << 15 ) ; line 39 : #define RXE0 ( 1 << 14 ) ; line 40 : #define SLC02 4 ; line 41 : #define DLS02 0 ; line 42 : #define TSF0 ( 1 << 6 ) ; line 43 : ; line 44 : // SOn ; line 45 : #define TAUS_MASK 0b0000101100001011; ; line 46 : ; line 47 : // DMCn ; line 48 : #define DRS ( 1 << 6 ) ; line 49 : ; line 50 : ; line 51 : ; line 52 : ; line 53 : // ======================================================== ; line 54 : static void iic_mcu_send_st( ); ; line 55 : static void iic_mcu_send_re_st( ); ; line 56 : static void iic_mcu_send_sp( ); ; line 57 : static err iic_mcu_send_a_byte( u8 ); ; line 58 : static err iic_mcu_call_slave( u8 slave ); ; line 59 : ; line 60 : ; line 61 : ; line 62 : // ======================================================== ; line 63 : bit iic_mcu_wo_dma; ; line 64 : volatile bit iic_mcu_busy; ; line 65 : volatile bit iic_mcu_initialized; ; line 66 : ; line 67 : ; line 68 : u8 iic_send_work[4]; ; line 69 : u8 *p_iic_send_wo_dma_dat; ; line 70 : u8 iic_send_wo_dma_len; ; line 71 : ; line 72 : u8 iic_mcu_bus_status; // 一文字リードの時はデータを返す ; 。 ; line 73 : // ステータスが必要ならこっちを呼 ; んで ; line 74 : ; line 75 : void nop8() ; line 76 : { ROM_CODE CSEG BASE _nop8: $DGL 1,29 ??bf_nop8: ; line 77 : } $DGL 0,2 ??ef_nop8: ret ;[INF] 1, 6 ??ee_nop8: ; line 78 : ; line 79 : ; line 80 : ; line 81 : /* ======================================================== ; line 82 : スレーブからの 『1文字』 リード ; line 83 : 返値がデータそのものです。 ; line 84 : エラー判定ができません。 ; line 85 : ======================================================== */ ; line 86 : u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs ) ; line 87 : { _iic_mcu_read_a_byte: $DGL 1,35 push hl ;[INF] 1, 1 push ax ;[INF] 1, 1 push ax ;[INF] 1, 1 movw hl,sp ;[INF] 3, 1 ??bf_iic_mcu_read_a_byte: ; line 88 : u8 dat; ; line 89 : ; line 90 : if( iic_mcu_initialized == 0 ) $DGL 0,4 bt _iic_mcu_initialized,$?L0005 ;[INF] 4, 5 ; line 91 : { ??bb00_iic_mcu_read_a_byte: ; line 92 : #ifdef _debug_ ; line 93 : iic_mcu_start( ); $DGL 0,7 call !_iic_mcu_start ;[INF] 3, 3 ??eb00_iic_mcu_read_a_byte: ; line 94 : #else ; line 95 : while( 1 ) ; line 96 : { ; line 97 : } ; line 98 : #endif ; line 99 : } ?L0005: ; line 100 : ; line 101 : while( iic_mcu_busy ) $DGL 0,15 bf _iic_mcu_busy,$?L0008 ;[INF] 4, 5 ; line 102 : { ??bb01_iic_mcu_read_a_byte: ; line 103 : NOP( ); $DGL 0,17 nop ;[INF] 1, 1 ??eb01_iic_mcu_read_a_byte: ; line 104 : } $DGL 0,18 br $?L0005 ;[INF] 2, 3 ?L0008: ; line 105 : iic_mcu_busy = 1; $DGL 0,19 set1 _iic_mcu_busy ;[INF] 3, 2 ; line 106 : ; line 107 : iic_mcu_bus_status = ERR_OK; $DGL 0,21 clrb !_iic_mcu_bus_status ;[INF] 3, 1 ; line 108 : ; line 109 : // スタートコンディションとスレーブの呼び出し、レジスタアドレ ; スの送信 ; line 110 : if( iic_mcu_call_slave( SLA ) != 0 ) $DGL 0,24 mov a,[hl+2] ; SLA ;[INF] 2, 1 shrw ax,8 ;[INF] 2, 1 call !_iic_mcu_call_slave ;[INF] 3, 3 cmp0 c ;[INF] 1, 1 bz $?L0009 ;[INF] 2, 4 ; line 111 : { ??bb02_iic_mcu_read_a_byte: ; line 112 : iic_mcu_bus_status = ERR_NOSLAVE; $DGL 0,26 mov !_iic_mcu_bus_status,#02H ; 2 ;[INF] 4, 1 ; line 113 : iic_mcu_busy = 0; $DGL 0,27 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 114 : return ( 0 ); $DGL 0,28 clrw bc ;[INF] 1, 1 br $?L0004 ;[INF] 2, 3 ??eb02_iic_mcu_read_a_byte: ; line 115 : } ?L0009: ; line 116 : ; line 117 : // レジスタアドレスの送信 ; line 118 : iic_mcu_send_a_byte( adrs ); // 終わるまで帰ってこない $DGL 0,32 mov a,[hl+10] ; adrs ;[INF] 2, 1 call !bs_F0085 ;[INF] 3, 3 ; line 119 : // if( err != ERR_SUCCESS )〜 ; line 120 : ; line 121 : // データ受信 // ; line 122 : iic_mcu_send_re_st( ); // リスタートコンディション $DGL 0,36 call !_iic_mcu_send_re_st ;[INF] 3, 3 ; line 123 : iic_mcu_send_a_byte( SLA | 0x01 ); // 送信完了まで戻ってきま ; せん。 $DGL 0,37 mov a,[hl+2] ; SLA ;[INF] 2, 1 or a,#01H ; 1 ;[INF] 2, 1 call !bs_F0085 ;[INF] 3, 3 ; line 124 : ; line 125 : ST0 = 0x0004; // 受信モードに設定を変えるのでロ ; ジック停止 $DGL 0,39 call !bs_S0086 ;[INF] 3, 3 ; line 126 : SCR02 = RXE0 | 1 << SLC02 | 7 << DLS02; // 受信設定 $DGL 0,40 movw ax,#04017H ; 16407 ;[INF] 3, 1 movw !SCR02,ax ;[INF] 3, 1 ; line 127 : SS0 = 0x0004; // 通信待機 $DGL 0,41 call !bs_S0087 ;[INF] 3, 3 ; line 128 : ; line 129 : SOE0 = 0x0000; // 1バイト送信なので、最後のNAKを ; 送る $DGL 0,43 clrw ax ;[INF] 1, 1 movw !SOE0,ax ;[INF] 3, 1 ; line 130 : IICIF10 = 0; $DGL 0,44 clr1 IF1L.0 ;[INF] 3, 2 ; line 131 : SIO10 = 0xFF; // ダミーデータを書くと受信開始 $DGL 0,45 mov SIO10,#0FFH ; 255 ;[INF] 3, 1 ; line 132 : ; line 133 : while( IICIF10 == 0 ) $DGL 0,47 ?L0011: bt IF1L.0,$?L0012 ;[INF] 4, 5 ; line 134 : { // 受信完了待ち ??bb03_iic_mcu_read_a_byte: ; line 135 : ; ??eb03_iic_mcu_read_a_byte: ; line 136 : } $DGL 0,50 br $?L0011 ;[INF] 2, 3 ?L0012: ; line 137 : dat = SIO10; $DGL 0,51 mov a,SIO10 ;[INF] 2, 1 mov [hl+1],a ; dat ;[INF] 2, 1 ; line 138 : ; line 139 : iic_mcu_send_sp( ); $DGL 0,53 call !_iic_mcu_send_sp ;[INF] 3, 3 ; line 140 : IICIF10 = 0; // 後を濁さないこと $DGL 0,54 clr1 IF1L.0 ;[INF] 3, 2 ; line 141 : iic_mcu_busy = 0; $DGL 0,55 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 142 : return ( dat ); $DGL 0,56 mov a,[hl+1] ; dat ;[INF] 2, 1 shrw ax,8 ;[INF] 2, 1 movw bc,ax ;[INF] 1, 1 ; line 143 : } ?L0004: $DGL 0,57 ??ef_iic_mcu_read_a_byte: addw sp,#04H ;[INF] 2, 1 pop hl ;[INF] 1, 1 ret ;[INF] 1, 6 ??ee_iic_mcu_read_a_byte: ; line 144 : ; line 145 : ; line 146 : ; line 147 : /* ======================================================== ; line 148 : スレーブからのリード ; line 149 : 0 正常終了 ; line 150 : 1 スレーブが応答しない ; line 151 : 2 バスが誰かに占有されていてタイムアウト ; line 152 : 3 意味不明エラー ; line 153 : 【注】 ; line 154 : スレーブがウェイトコンディションを出すことは禁止です。 ; line 155 : その場合でもエラー検出などできません ; line 156 : ======================================================== */ ; line 157 : err iic_mcu_read( u8 slave, u8 adrs, u8 len, u8 * dest ) ; line 158 : { _iic_mcu_read: $DGL 1,60 push hl ;[INF] 1, 1 push ax ;[INF] 1, 1 movw hl,sp ;[INF] 3, 1 ??bf_iic_mcu_read: ; line 159 : ; line 160 : //* ; line 161 : // 使用中なら待つ ; line 162 : if( iic_mcu_initialized == 0 ) $DGL 0,5 bt _iic_mcu_initialized,$?L0015 ;[INF] 4, 5 ; line 163 : { ??bb00_iic_mcu_read: ; line 164 : #ifdef _debug_ ; line 165 : iic_mcu_start( ); $DGL 0,8 call !_iic_mcu_start ;[INF] 3, 3 ??eb00_iic_mcu_read: ; line 166 : #else ; line 167 : while( 1 ) ; line 168 : { ; line 169 : } ; line 170 : #endif ; line 171 : } ?L0015: ; line 172 : while( iic_mcu_busy ) $DGL 0,15 bf _iic_mcu_busy,$?L0018 ;[INF] 4, 5 ; line 173 : { ??bb01_iic_mcu_read: ; line 174 : NOP( ); $DGL 0,17 nop ;[INF] 1, 1 ??eb01_iic_mcu_read: ; line 175 : } $DGL 0,18 br $?L0015 ;[INF] 2, 3 ?L0018: ; line 176 : /*/ ; line 177 : // 使用中なら帰る ; line 178 : if( iic_mcu_initialized == 0 ){ ; line 179 : return(0x80); ; line 180 : } ; line 181 : if( iic_mcu_busy != 0 ){ ; line 182 : return( 3 ); ; line 183 : } ; line 184 : //*/ ; line 185 : ; line 186 : iic_mcu_busy = 1; $DGL 0,29 set1 _iic_mcu_busy ;[INF] 3, 2 ; line 187 : // スタートコンディションとスレーブの呼び出し、レジスタアドレ ; スの送信 ; line 188 : if( iic_mcu_call_slave( slave ) != 0 ) $DGL 0,31 call !bs_F0084 ;[INF] 3, 3 bz $?L0019 ;[INF] 2, 4 ; line 189 : { ??bb02_iic_mcu_read: ; line 190 : iic_mcu_busy = 0; $DGL 0,33 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 191 : return ( ERR_NOSLAVE ); $DGL 0,34 onew bc ;[INF] 1, 1 incw bc ;[INF] 1, 1 br $?L0014 ;[INF] 2, 3 ??eb02_iic_mcu_read: ; line 192 : } ?L0019: ; line 193 : ; line 194 : // レジスタアドレスの送信 ; line 195 : iic_mcu_send_a_byte( adrs ); // 終わるまで帰ってこない $DGL 0,38 mov a,[hl+8] ; adrs ;[INF] 2, 1 call !bs_F0085 ;[INF] 3, 3 ; line 196 : // if( err != ERR_SUCCESS )〜 ; line 197 : ; line 198 : // データ受信 // ; line 199 : iic_mcu_send_re_st( ); // リスタートコンディション $DGL 0,42 call !_iic_mcu_send_re_st ;[INF] 3, 3 ; line 200 : iic_mcu_send_a_byte( slave | 0x01 ); // 送信完了まで戻 ; ってきません。 $DGL 0,43 mov a,[hl] ; slave ;[INF] 1, 1 or a,#01H ; 1 ;[INF] 2, 1 call !bs_F0085 ;[INF] 3, 3 ; line 201 : ; line 202 : // データ受信 ; line 203 : ST0 = 0x0004; // 受信モードに設定を変えるのでロ ; ジック停止 $DGL 0,46 call !bs_S0086 ;[INF] 3, 3 ; line 204 : SCR02 = RXE0 | 1 << SLC02 | 7 << DLS02; // 受信設定 $DGL 0,47 movw ax,#04017H ; 16407 ;[INF] 3, 1 movw !SCR02,ax ;[INF] 3, 1 ; line 205 : SS0 = 0x0004; // 通信待機 $DGL 0,48 call !bs_S0087 ;[INF] 3, 3 ; line 206 : ; line 207 : do ?L0021: ; line 208 : { ??bb03_iic_mcu_read: ; line 209 : if( len == 1 ) $DGL 0,52 mov a,[hl+10] ; len ;[INF] 2, 1 dec a ;[INF] 1, 1 bnz $?L0024 ;[INF] 2, 4 ; line 210 : { ??bb04_iic_mcu_read: ; line 211 : SOE0 = 0x0000; // 最後のNAK $DGL 0,54 clrw ax ;[INF] 1, 1 movw !SOE0,ax ;[INF] 3, 1 ??eb04_iic_mcu_read: ; line 212 : } ?L0024: ; line 213 : IICIF10 = 0; $DGL 0,56 clr1 IF1L.0 ;[INF] 3, 2 ; line 214 : SIO10 = 0xFF; // ダミーデータを書くと受信開始 $DGL 0,57 mov SIO10,#0FFH ; 255 ;[INF] 3, 1 ; line 215 : while( IICIF10 == 0 ) $DGL 0,58 ?L0026: bt IF1L.0,$?L0027 ;[INF] 4, 5 ; line 216 : { // 受信完了待ち ??bb05_iic_mcu_read: ; line 217 : ; ??eb05_iic_mcu_read: ; line 218 : } $DGL 0,61 br $?L0026 ;[INF] 2, 3 ?L0027: ; line 219 : *dest = SIO10; $DGL 0,62 movw ax,[hl+12] ; dest ;[INF] 2, 1 movw de,ax ;[INF] 1, 1 mov a,SIO10 ;[INF] 2, 1 mov [de],a ;[INF] 1, 1 ; line 220 : dest++; $DGL 0,63 incw [hl+12] ; dest ;[INF] 3, 2 ; line 221 : len--; $DGL 0,64 dec [hl+10] ; len ;[INF] 3, 2 ??eb03_iic_mcu_read: ; line 222 : } ; line 223 : while( len != 0 ); $DGL 0,66 mov a,[hl+10] ; len ;[INF] 2, 1 cmp0 a ;[INF] 1, 1 bnz $?L0021 ;[INF] 2, 4 ; line 224 : ; line 225 : iic_mcu_send_sp( ); $DGL 0,68 call !_iic_mcu_send_sp ;[INF] 3, 3 ; line 226 : ; line 227 : IICIF10 = 0; $DGL 0,70 clr1 IF1L.0 ;[INF] 3, 2 ; line 228 : iic_mcu_busy = 0; $DGL 0,71 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 229 : return ( ERR_SUCCESS ); $DGL 0,72 clrw bc ;[INF] 1, 1 ; line 230 : } ?L0014: $DGL 0,73 ??ef_iic_mcu_read: pop ax ;[INF] 1, 1 pop hl ;[INF] 1, 1 ret ;[INF] 1, 6 ??ee_iic_mcu_read: ; line 231 : ; line 232 : ; line 233 : ; line 234 : ; line 235 : /* ======================================================== ; line 236 : スレーブへ 『1バイト』 ライト ; line 237 : 前の転送が終わるのを待って、ライトします。 ; line 238 : 返値 iic_mcu_write に同じ ; line 239 : ; line 240 : ======================================================== */ ; line 241 : err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat ) ; line 242 : { _iic_mcu_write_a_byte: $DGL 1,95 push hl ;[INF] 1, 1 push ax ;[INF] 1, 1 movw hl,sp ;[INF] 3, 1 ??bf_iic_mcu_write_a_byte: ; line 243 : ; line 244 : if( iic_mcu_initialized == 0 ) $DGL 0,3 bt _iic_mcu_initialized,$?L0030 ;[INF] 4, 5 ; line 245 : { ??bb00_iic_mcu_write_a_byte: ; line 246 : #ifdef _debug_ ; line 247 : iic_mcu_start( ); $DGL 0,6 call !_iic_mcu_start ;[INF] 3, 3 ??eb00_iic_mcu_write_a_byte: ; line 248 : #else ; line 249 : while( 1 ) ; line 250 : { ; line 251 : } ; line 252 : #endif ; line 253 : } ?L0030: ; line 254 : while( iic_mcu_busy ) $DGL 0,13 bf _iic_mcu_busy,$?L0033 ;[INF] 4, 5 ; line 255 : { ??bb01_iic_mcu_write_a_byte: ; line 256 : NOP( ); $DGL 0,15 nop ;[INF] 1, 1 ??eb01_iic_mcu_write_a_byte: ; line 257 : } $DGL 0,16 br $?L0030 ;[INF] 2, 3 ?L0033: ; line 258 : iic_mcu_busy = 1; $DGL 0,17 set1 _iic_mcu_busy ;[INF] 3, 2 ; line 259 : #if 0 ; line 260 : temp = dat; ; line 261 : return ( iic_mcu_write( SLA, adrs, 1, &temp ) ); ; line 262 : } ; line 263 : #else ; line 264 : // スタートコンディションとスレーブの呼び出し... ; line 265 : IICMK10 = 1; $DGL 0,24 set1 MK1L.0 ;[INF] 3, 2 ; line 266 : if( iic_mcu_call_slave( SLA ) != 0 ) $DGL 0,25 call !bs_F0084 ;[INF] 3, 3 bz $?L0034 ;[INF] 2, 4 ; line 267 : { ??bb02_iic_mcu_write_a_byte: ; line 268 : iic_mcu_busy = 0; $DGL 0,27 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 269 : return ( ERR_NAK ); $DGL 0,28 onew bc ;[INF] 1, 1 br $?L0029 ;[INF] 2, 3 ??eb02_iic_mcu_write_a_byte: ; line 270 : } ?L0034: ; line 271 : iic_mcu_send_a_byte( adrs ); $DGL 0,30 mov a,[hl+8] ; adrs ;[INF] 2, 1 call !bs_F0085 ;[INF] 3, 3 ; line 272 : iic_mcu_send_a_byte( dat ); $DGL 0,31 mov a,[hl+10] ; dat ;[INF] 2, 1 call !bs_F0085 ;[INF] 3, 3 ; line 273 : iic_mcu_send_sp( ); $DGL 0,32 call !_iic_mcu_send_sp ;[INF] 3, 3 ; line 274 : iic_mcu_busy = 0; $DGL 0,33 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 275 : return ( ERR_SUCCESS ); $DGL 0,34 clrw bc ;[INF] 1, 1 ; line 276 : #endif ; line 277 : } ?L0029: $DGL 0,36 ??ef_iic_mcu_write_a_byte: pop ax ;[INF] 1, 1 pop hl ;[INF] 1, 1 ret ;[INF] 1, 6 ??ee_iic_mcu_write_a_byte: ; line 278 : ; line 279 : ; line 280 : ; line 281 : /* ======================================================== ; line 282 : スレーブへライト ; line 283 : レジスタ adrs を先頭に、 ; line 284 : *strから ; line 285 : len文字書きます。 ; line 286 : ; line 287 : 0 正常終了 ; line 288 : 1 スレーブが応答しない ; line 289 : 2 バスが誰かに占有されていてタイムアウト ; line 290 : 3 前に指示された通信がまだ終わってない ; line 291 : 【注】 ; line 292 : スレーブがウェイトコンディションを出すことは禁止です。 ; line 293 : その場合でもエラー検出などできません ; line 294 : DMA1を使用します。 ; line 295 : *************************************************************** ; ***************/ ; line 296 : err iic_mcu_write( u8 slave, u8 adrs, u8 len, void * src ) ; line 297 : { _iic_mcu_write: $DGL 1,116 push hl ;[INF] 1, 1 push ax ;[INF] 1, 1 movw hl,sp ;[INF] 3, 1 ??bf_iic_mcu_write: ; line 298 : //* ; line 299 : // 使用中なら待つ ; line 300 : if( iic_mcu_initialized == 0 ) $DGL 0,4 bt _iic_mcu_initialized,$?L0038 ;[INF] 4, 5 ; line 301 : { ??bb00_iic_mcu_write: ; line 302 : #ifdef _debug_ ; line 303 : iic_mcu_start( ); $DGL 0,7 call !_iic_mcu_start ;[INF] 3, 3 ??eb00_iic_mcu_write: ; line 304 : #else ; line 305 : while( 1 ) ; line 306 : { ; line 307 : } ; line 308 : #endif ; line 309 : } ?L0038: ; line 310 : while( iic_mcu_busy ) $DGL 0,14 bf _iic_mcu_busy,$?L0041 ;[INF] 4, 5 ; line 311 : { ??bb01_iic_mcu_write: ; line 312 : NOP( ); $DGL 0,16 nop ;[INF] 1, 1 ??eb01_iic_mcu_write: ; line 313 : } $DGL 0,17 br $?L0038 ;[INF] 2, 3 ?L0041: ; line 314 : /*/ ; line 315 : // 使用中なら帰る ; line 316 : if( iic_mcu_initialized == 0 ){ ; line 317 : return(0x80); ; line 318 : } ; line 319 : if( iic_mcu_busy != 0 ){ ; line 320 : return( 3 ); ; line 321 : } ; line 322 : //*/ ; line 323 : iic_mcu_busy = 1; $DGL 0,27 set1 _iic_mcu_busy ;[INF] 3, 2 ; line 324 : // スタートコンディションとスレーブの呼び出し... ; line 325 : IICMK10 = 1; $DGL 0,29 set1 MK1L.0 ;[INF] 3, 2 ; line 326 : IICIF10 = 0; $DGL 0,30 clr1 IF1L.0 ;[INF] 3, 2 ; line 327 : if( iic_mcu_call_slave( slave ) != 0 ) $DGL 0,31 call !bs_F0084 ;[INF] 3, 3 bz $?L0042 ;[INF] 2, 4 ; line 328 : { ??bb02_iic_mcu_write: ; line 329 : iic_mcu_busy = 0; $DGL 0,33 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 330 : EI( ); $DGL 0,34 ei ;[INF] 3, 4 ; line 331 : return ( ERR_NAK ); $DGL 0,35 onew bc ;[INF] 1, 1 br $?L0037 ;[INF] 2, 3 ??eb02_iic_mcu_write: ; line 332 : } ?L0042: ; line 333 : ; line 334 : IICIF10 = 0; $DGL 0,38 clr1 IF1L.0 ;[INF] 3, 2 ; line 335 : if( !iic_mcu_wo_dma ) $DGL 0,39 bt _iic_mcu_wo_dma,$?L0044 ;[INF] 4, 5 ; line 336 : { ??bb03_iic_mcu_write: ; line 337 : // DMAを使用する(通常) ; line 338 : ; line 339 : // レジスタアドレスを送り、データの準備 ; line 340 : memcpy( iic_send_work, src, 4 ); //バッファとして ; 4バイトしか用意して無いため。 $DGL 0,44 push hl ;[INF] 1, 1 movw de,#loww (_iic_send_work) ;[INF] 3, 1 movw ax,[hl+12] ; src ;[INF] 2, 1 movw hl,ax ;[INF] 1, 1 mov c,#04H ; 4 ;[INF] 2, 1 ?L0046: mov a,[hl] ;[INF] 1, 1 mov [de],a ;[INF] 1, 1 incw de ;[INF] 1, 1 incw hl ;[INF] 1, 1 dec c ;[INF] 1, 1 bnz $?L0046 ;[INF] 2, 4 pop hl ;[INF] 1, 1 ; line 341 : // DMAセット ; line 342 : while( DST1 ) $DGL 0,46 ?L0048: bf DRC1.0,$?L0049 ;[INF] 4, 5 ; line 343 : {; ??bb04_iic_mcu_write: ??eb04_iic_mcu_write: ; line 344 : } $DGL 0,48 br $?L0048 ;[INF] 2, 3 ?L0049: ; line 345 : ; line 346 : DEN1 = 1; $DGL 0,50 set1 DRC1.7 ;[INF] 3, 2 ; line 347 : DSA1 = ( u8 ) ( &SIO10 ); $DGL 0,51 mov DSA1,#044H ; 68 ;[INF] 3, 1 ; line 348 : DRA1 = ( u16 ) iic_send_work; $DGL 0,52 movw DRA1,#loww (_iic_send_work) ;[INF] 4, 1 ; line 349 : DBC1 = len; $DGL 0,53 mov a,[hl+10] ; len ;[INF] 2, 1 shrw ax,8 ;[INF] 2, 1 movw DBC1,ax ;[INF] 2, 1 ; line 350 : DMC1 = DRS | 8; // RAM -> SFR, 8bit, IRQ, IIC10 $DGL 0,54 mov DMC1,#048H ; 72 ;[INF] 3, 1 ; line 351 : ; line 352 : DMAIF1 = 0; $DGL 0,56 clr1 IF0H.4 ;[INF] 3, 2 ; line 353 : DMAMK1 = 0; $DGL 0,57 clr1 MK0H.4 ;[INF] 3, 2 ; line 354 : DST1 = 1; $DGL 0,58 set1 DRC1.0 ;[INF] 3, 2 ; line 355 : ; line 356 : SIO10 = adrs; // 書きっぱなし! 割り込みが発生 ; してDMAスタート $DGL 0,60 mov a,[hl+8] ; adrs ;[INF] 2, 1 mov SIO10,a ;[INF] 2, 1 ??eb03_iic_mcu_write: ; line 357 : // 残りは割り込みルーチン内で ; line 358 : } $DGL 0,62 br $?L0045 ;[INF] 2, 3 ?L0044: ; line 359 : else ; line 360 : { ??bb05_iic_mcu_write: ; line 361 : // DMAを使用しない // ; line 362 : ; line 363 : // レジスタアドレスの送信 ; line 364 : SIO10 = adrs; $DGL 0,68 mov a,[hl+8] ; adrs ;[INF] 2, 1 mov SIO10,a ;[INF] 2, 1 ; line 365 : ; line 366 : IICMK10 = 0; $DGL 0,70 clr1 MK1L.0 ;[INF] 3, 2 ; line 367 : iic_send_wo_dma_len = len; $DGL 0,71 mov a,[hl+10] ; len ;[INF] 2, 1 mov !_iic_send_wo_dma_len,a ;[INF] 3, 1 ; line 368 : p_iic_send_wo_dma_dat = src; $DGL 0,72 movw ax,[hl+12] ; src ;[INF] 2, 1 movw !_p_iic_send_wo_dma_dat,ax ;[INF] 3, 1 ??eb05_iic_mcu_write: ; line 369 : // 残りは割り込みルーチン内で ; line 370 : } ?L0045: ; line 371 : return ( ERR_SUCCESS ); $DGL 0,75 clrw bc ;[INF] 1, 1 ; line 372 : } ?L0037: $DGL 0,76 ??ef_iic_mcu_write: pop ax ;[INF] 1, 1 pop hl ;[INF] 1, 1 ret ;[INF] 1, 6 ??ee_iic_mcu_write: ; line 373 : ; line 374 : ; line 375 : ; line 376 : ; line 377 : /* ======================================================== ; line 378 : DMA1転送終了割り込み ; line 379 : IIC_mcu の送信完了コールバック関数のようなもの ; line 380 : 注:DMA転送が終わっただけで、I2Cの転送は終わってません ; line 381 :   割り込み中などで、DMA1の処理が遅延した場合、 ; line 382 : IIC10の割り込みの準備ができずに、割り込みを発生させられなくなる ; line 383 : 恐れがあります。また、回避方法も特にありません。 ; line 384 :  そのため、DMA仕様の差異は、最後のバイトは送信完了を ; line 385 : フラグのポーリングで確認します。 ; line 386 : ======================================================== */ ; line 387 : __interrupt void int_dma1( ) ; line 388 : { @@BASE CSEG BASE _int_dma1: $DGL 1,151 push ax ;[INF] 1, 1 push bc ;[INF] 1, 1 push de ;[INF] 1, 1 push hl ;[INF] 1, 1 mov c,#0CH ;[INF] 2, 1 dec c ;[INF] 1, 1 dec c ;[INF] 1, 1 movw ax,_@SEGAX[c] ;[INF] 3, 1 push ax ;[INF] 1, 1 bnz $$-6 ;[INF] 2, 4 mov a,ES ;[INF] 2, 1 mov x,a ;[INF] 1, 1 mov a,CS ;[INF] 2, 1 push ax ;[INF] 1, 1 ??bf_int_dma1: ; line 389 : u16 i = 0; $DGL 0,2 clrw ax ;[INF] 1, 1 movw hl,ax ;[INF] 1, 1 ; line 390 : ; line 391 : EI(); $DGL 0,4 ei ;[INF] 3, 4 ; line 392 : ; line 393 : DMAMK1 = 1; $DGL 0,6 set1 MK0H.4 ;[INF] 3, 2 ; line 394 : DEN1 = 0; $DGL 0,7 clr1 DRC1.7 ;[INF] 3, 2 ; line 395 : while( ( SSR02L & TSF0 ) != 0 ) $DGL 0,8 ?L0052: mov a,#040H ; 64 ;[INF] 2, 1 and a,!SSR02L ;[INF] 3, 1 cmp0 a ;[INF] 1, 1 bz $?L0053 ;[INF] 2, 4 ; line 396 : { ??bb00_int_dma1: ; line 397 : if( ++i == 0 ) // タイムアウト? $DGL 0,10 incw hl ;[INF] 1, 1 clrw ax ;[INF] 1, 1 cmpw ax,hl ;[INF] 1, 1 bnz $?L0052 ;[INF] 2, 4 ; line 398 : { ??bb01_int_dma1: ; line 399 : break; ??eb01_int_dma1: ; line 400 : } ??eb00_int_dma1: ; line 401 : } ?L0053: ; line 402 : ; line 403 : // iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪いの ; で展開 ; line 404 : { ??bb02_int_dma1: ; line 405 : ST0 = 0x0004; $DGL 0,18 movw ax,#04H ; 4 ;[INF] 3, 1 movw !ST0,ax ;[INF] 3, 1 ; line 406 : SOE0 = 0; // 受信の時はもっと前に「も」設定 ; してる。(NACK出力) $DGL 0,19 clrw ax ;[INF] 1, 1 movw !SOE0,ax ;[INF] 3, 1 ; line 407 : SO0 = 0x0000 | TAUS_MASK; // SCL $DGL 0,20 movw ax,#0B0BH ; 2827 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 408 : nop8(); $DGL 0,21 call !_nop8 ;[INF] 3, 3 ; line 409 : /* ; line 410 : NOP( ); ; line 411 : NOP( ); ; line 412 : NOP( ); ; line 413 : NOP( ); ; line 414 : #ifdef _OVERCLOCK_ ; line 415 : NOP( ); ; line 416 : NOP( ); ; line 417 : NOP( ); ; line 418 : NOP( ); ; line 419 : NOP( ); ; line 420 : #endif ; line 421 : */ ; line 422 : SO0 = 0x0400 | TAUS_MASK; // SCL $DGL 0,35 movw ax,#0F0BH ; 3851 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 423 : nop8(); $DGL 0,36 call !_nop8 ;[INF] 3, 3 ; line 424 : /* ; line 425 : NOP( ); ; line 426 : NOP( ); ; line 427 : NOP( ); ; line 428 : NOP( ); ; line 429 : #ifdef _OVERCLOCK_ ; line 430 : NOP( ); ; line 431 : NOP( ); ; line 432 : NOP( ); ; line 433 : NOP( ); ; line 434 : NOP( ); ; line 435 : #endif ; line 436 : */ ; line 437 : SO0 = 0x0404 | TAUS_MASK; $DGL 0,50 movw ax,#0F0FH ; 3855 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ??eb02_int_dma1: ; line 438 : } ; line 439 : IICMK10 = 1; $DGL 0,52 set1 MK1L.0 ;[INF] 3, 2 ; line 440 : iic_mcu_busy = 0; $DGL 0,53 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 441 : } $DGL 0,54 ??ef_int_dma1: pop ax ;[INF] 1, 1 mov CS,a ;[INF] 2, 1 mov a,x ;[INF] 1, 1 mov ES,a ;[INF] 2, 1 movw de,#_@SEGAX ;[INF] 3, 1 mov c,#06H ;[INF] 2, 1 pop ax ;[INF] 1, 1 movw [de],ax ;[INF] 1, 1 incw de ;[INF] 1, 1 incw de ;[INF] 1, 1 dec c ;[INF] 1, 1 bnz $$-5 ;[INF] 2, 4 pop hl ;[INF] 1, 1 pop de ;[INF] 1, 1 pop bc ;[INF] 1, 1 pop ax ;[INF] 1, 1 reti ;[INF] 2, 6 ??ee_int_dma1: ; line 442 : ; line 443 : ; line 444 : ; line 445 : /* ======================================================== ; line 446 : IIC MCUのバイト送出完了割り込み ; line 447 : ※DMA使用時は使用されません。 ; line 448 :  他の割り込み処理中でDMAの割り込みにすぐ飛ばない場合、 ; line 449 :  IIC割り込みのセットが間に合わず困ることがあります。 ; line 450 : ======================================================== */ ; line 451 : __interrupt void int_iic10( ) ; line 452 : { _int_iic10: $DGL 1,170 push ax ;[INF] 1, 1 push bc ;[INF] 1, 1 push de ;[INF] 1, 1 push hl ;[INF] 1, 1 mov c,#0CH ;[INF] 2, 1 dec c ;[INF] 1, 1 dec c ;[INF] 1, 1 movw ax,_@SEGAX[c] ;[INF] 3, 1 push ax ;[INF] 1, 1 bnz $$-6 ;[INF] 2, 4 mov a,ES ;[INF] 2, 1 mov x,a ;[INF] 1, 1 mov a,CS ;[INF] 2, 1 push ax ;[INF] 1, 1 ??bf_int_iic10: ; line 453 : EI(); $DGL 0,2 ei ;[INF] 3, 4 ; line 454 : if( iic_send_wo_dma_len != 0 ) $DGL 0,3 cmp0 !_iic_send_wo_dma_len ;[INF] 3, 1 bz $?L0058 ;[INF] 2, 4 ; line 455 : { ??bb00_int_iic10: ; line 456 : SIO10 = *p_iic_send_wo_dma_dat; $DGL 0,5 movw de,!_p_iic_send_wo_dma_dat ;[INF] 3, 1 mov a,[de] ;[INF] 1, 1 mov SIO10,a ;[INF] 2, 1 ; line 457 : p_iic_send_wo_dma_dat++; $DGL 0,6 incw !_p_iic_send_wo_dma_dat ;[INF] 3, 2 ; line 458 : iic_send_wo_dma_len--; $DGL 0,7 dec !_iic_send_wo_dma_len ;[INF] 3, 2 ; line 459 : return; $DGL 0,8 br $?L0057 ;[INF] 2, 3 ??eb00_int_iic10: ; line 460 : } ?L0058: ; line 461 : ; line 462 : // 最後のバイト送信完了 ; line 463 : IICMK10 = 1; $DGL 0,12 set1 MK1L.0 ;[INF] 3, 2 ; line 464 : // iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪い ; ので展開 ; line 465 : { ??bb01_int_iic10: ; line 466 : ST0 = 0x0004; $DGL 0,15 movw ax,#04H ; 4 ;[INF] 3, 1 movw !ST0,ax ;[INF] 3, 1 ; line 467 : SOE0 = 0; // 受信の時はもっと前に「も」設定 ; してる。(NACK出力) $DGL 0,16 clrw ax ;[INF] 1, 1 movw !SOE0,ax ;[INF] 3, 1 ; line 468 : SO0 = 0x0000 | TAUS_MASK; // SCL $DGL 0,17 movw ax,#0B0BH ; 2827 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 469 : nop8(); $DGL 0,18 call !_nop8 ;[INF] 3, 3 ; line 470 : /* ; line 471 : NOP( ); ; line 472 : NOP( ); ; line 473 : NOP( ); ; line 474 : NOP( ); ; line 475 : #ifdef _OVERCLOCK_ ; line 476 : NOP( ); ; line 477 : NOP( ); ; line 478 : NOP( ); ; line 479 : NOP( ); ; line 480 : NOP( ); ; line 481 : #endif ; line 482 : */ ; line 483 : SO0 = 0x0400 | TAUS_MASK; // SCL $DGL 0,32 movw ax,#0F0BH ; 3851 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 484 : nop8(); $DGL 0,33 call !_nop8 ;[INF] 3, 3 ; line 485 : /* ; line 486 : NOP( ); ; line 487 : NOP( ); ; line 488 : NOP( ); ; line 489 : NOP( ); ; line 490 : #ifdef _OVERCLOCK_ ; line 491 : NOP( ); ; line 492 : NOP( ); ; line 493 : NOP( ); ; line 494 : NOP( ); ; line 495 : NOP( ); ; line 496 : #endif ; line 497 : */ ; line 498 : SO0 = 0x0404 | TAUS_MASK; $DGL 0,47 movw ax,#0F0FH ; 3855 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ??eb01_int_iic10: ; line 499 : } ; line 500 : iic_mcu_wo_dma = 0; $DGL 0,49 clr1 _iic_mcu_wo_dma ;[INF] 3, 2 ; line 501 : iic_mcu_busy = 0; $DGL 0,50 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 502 : } ?L0057: $DGL 0,51 ??ef_int_iic10: pop ax ;[INF] 1, 1 mov CS,a ;[INF] 2, 1 mov a,x ;[INF] 1, 1 mov ES,a ;[INF] 2, 1 movw de,#_@SEGAX ;[INF] 3, 1 mov c,#06H ;[INF] 2, 1 pop ax ;[INF] 1, 1 movw [de],ax ;[INF] 1, 1 incw de ;[INF] 1, 1 incw de ;[INF] 1, 1 dec c ;[INF] 1, 1 bnz $$-5 ;[INF] 2, 4 pop hl ;[INF] 1, 1 pop de ;[INF] 1, 1 pop bc ;[INF] 1, 1 pop ax ;[INF] 1, 1 reti ;[INF] 2, 6 ??ee_int_iic10: ; line 503 : ; line 504 : ; line 505 : ; line 506 : /* ======================================================== ; line 507 : スレーブの呼び出し ; line 508 :  スレーブアドレスを呼んで、ACKの確認。 ; line 509 : ACK →                 返:0 ; line 510 :  NACK → ストップコンディションを出す。 返:1 ; line 511 : ======================================================== */ ; line 512 : static err iic_mcu_call_slave( u8 slave ) ; line 513 : { ROM_CODE CSEG BASE _iic_mcu_call_slave: $DGL 1,184 push hl ;[INF] 1, 1 movw hl,ax ;[INF] 1, 1 ??bf_iic_mcu_call_slave: ; line 514 : iic_mcu_send_st( ); $DGL 0,2 call !_iic_mcu_send_st ;[INF] 3, 3 ; line 515 : ; line 516 : // SIR02 = SSR02; // NAKエラーのフラグクリア ; line 517 : if( iic_mcu_send_a_byte( slave ) != ERR_SUCCESS ) $DGL 0,5 movw ax,hl ;[INF] 1, 1 clrb a ;[INF] 1, 1 call !_iic_mcu_send_a_byte ;[INF] 3, 3 cmp0 c ;[INF] 1, 1 bz $?L0062 ;[INF] 2, 4 ; line 518 : { ??bb00_iic_mcu_call_slave: ; line 519 : iic_mcu_send_sp( ); $DGL 0,7 call !_iic_mcu_send_sp ;[INF] 3, 3 ; line 520 : return ( ERR_NAK ); // 指定のスレーブがいない / busy $DGL 0,8 onew bc ;[INF] 1, 1 br $?L0061 ;[INF] 2, 3 ??eb00_iic_mcu_call_slave: ; line 521 : } ?L0062: ; line 522 : ; line 523 : return ( ERR_SUCCESS ); $DGL 0,11 clrw bc ;[INF] 1, 1 ; line 524 : } ?L0061: $DGL 0,12 ??ef_iic_mcu_call_slave: pop hl ;[INF] 1, 1 ret ;[INF] 1, 6 ??ee_iic_mcu_call_slave: ; line 525 : ; line 526 : ; line 527 : ; line 528 : /* ======================================================== ; line 529 : ほんとに1バイト書くのみ ; line 530 : 書き終わるまで帰りません ; line 531 : ======================================================== */ ; line 532 : static err iic_mcu_send_a_byte( u8 dat ) ; line 533 : { _iic_mcu_send_a_byte: $DGL 1,195 push hl ;[INF] 1, 1 movw hl,ax ;[INF] 1, 1 ??bf_iic_mcu_send_a_byte: ; line 534 : IICMK10 = 1; $DGL 0,2 set1 MK1L.0 ;[INF] 3, 2 ; line 535 : IICIF10 = 0; $DGL 0,3 clr1 IF1L.0 ;[INF] 3, 2 ; line 536 : SIO10 = dat; $DGL 0,4 mov a,l ;[INF] 1, 1 mov SIO10,a ;[INF] 2, 1 ; line 537 : while( IICIF10 == 0 ) $DGL 0,5 ?L0066: bt IF1L.0,$?L0067 ;[INF] 4, 5 ; line 538 : { ??bb00_iic_mcu_send_a_byte: ; line 539 : NOP( ); $DGL 0,7 nop ;[INF] 1, 1 ??eb00_iic_mcu_send_a_byte: ; line 540 : } // 通信中 $DGL 0,8 br $?L0066 ;[INF] 2, 3 ?L0067: ; line 541 : if( SSR02 != 0 ) $DGL 0,9 clrw ax ;[INF] 1, 1 cmpw ax,!SSR02 ;[INF] 3, 1 bz $?L0068 ;[INF] 2, 4 ; line 542 : { ??bb01_iic_mcu_send_a_byte: ; line 543 : SIR02 = SSR02; $DGL 0,11 movw ax,!SSR02 ;[INF] 3, 1 movw !SIR02,ax ;[INF] 3, 1 ; line 544 : return ( ERR_NAK ); $DGL 0,12 onew bc ;[INF] 1, 1 br $?L0065 ;[INF] 2, 3 ??eb01_iic_mcu_send_a_byte: ; line 545 : } ?L0068: ; line 546 : return ( ERR_SUCCESS ); $DGL 0,14 clrw bc ;[INF] 1, 1 ; line 547 : } ?L0065: $DGL 0,15 ??ef_iic_mcu_send_a_byte: pop hl ;[INF] 1, 1 ret ;[INF] 1, 6 ??ee_iic_mcu_send_a_byte: ; line 548 : ; line 549 : ; line 550 : ; line 551 : /* ======================================================== ; line 552 : スタートコンディションを発行 ; line 553 : ソフトウェア制御 ; line 554 : ======================================================== */ ; line 555 : static void iic_mcu_send_st( ) ; line 556 : { _iic_mcu_send_st: $DGL 1,210 ??bf_iic_mcu_send_st: ; line 557 : SO0 &= ~0x0004; // SDA $DGL 0,2 movw ax,!SO0 ;[INF] 3, 1 xch a,x ;[INF] 1, 1 and a,#0FBH ; 251 ;[INF] 2, 1 xch a,x ;[INF] 1, 1 movw !SO0,ax ;[INF] 3, 1 ; line 558 : nop8(); $DGL 0,3 call !_nop8 ;[INF] 3, 3 ; line 559 : /* ; line 560 : NOP( ); ; line 561 : NOP( ); ; line 562 : NOP( ); ; line 563 : NOP( ); ; line 564 : #ifdef _OVERCLOCK_ ; line 565 : NOP( ); ; line 566 : NOP( ); ; line 567 : NOP( ); ; line 568 : NOP( ); ; line 569 : NOP( ); ; line 570 : #endif ; line 571 : */ ; line 572 : SO0 &= ~0x0400; // SCL $DGL 0,17 movw ax,!SO0 ;[INF] 3, 1 and a,#0FBH ; 251 ;[INF] 2, 1 movw !SO0,ax ;[INF] 3, 1 ; line 573 : SOE0 = 0x0004; // ハード制御へ $DGL 0,18 movw ax,#04H ; 4 ;[INF] 3, 1 movw !SOE0,ax ;[INF] 3, 1 ; line 574 : ; line 575 : SCR02 = TXE0 | 1 << SLC02 | 7 << DLS02; // 送信許可、デー ; タは8ビット単位 $DGL 0,20 movw ax,#08017H ; -32745 ;[INF] 3, 1 movw !SCR02,ax ;[INF] 3, 1 ; line 576 : SS0 = 0x0004; // 通信待機 $DGL 0,21 call !bs_S0087 ;[INF] 3, 3 ; line 577 : } $DGL 0,22 ??ef_iic_mcu_send_st: ret ;[INF] 1, 6 ??ee_iic_mcu_send_st: ; line 578 : ; line 579 : ; line 580 : ; line 581 : /* ======================================================== ; line 582 : リスタート発行 ; line 583 : ======================================================== */ ; line 584 : static void iic_mcu_send_re_st( ) ; line 585 : { _iic_mcu_send_re_st: $DGL 1,216 ??bf_iic_mcu_send_re_st: ; line 586 : ST0 |= 0x0004; $DGL 0,2 movw ax,!ST0 ;[INF] 3, 1 xch a,x ;[INF] 1, 1 or a,#04H ; 4 ;[INF] 2, 1 xch a,x ;[INF] 1, 1 movw !ST0,ax ;[INF] 3, 1 ; line 587 : SO0 |= 0x0400 | TAUS_MASK; // ( SDA = H ), SCL -> H $DGL 0,3 movw ax,!SO0 ;[INF] 3, 1 or a,#0FH ; 15 ;[INF] 2, 1 xch a,x ;[INF] 1, 1 or a,#0BH ; 11 ;[INF] 2, 1 xch a,x ;[INF] 1, 1 movw !SO0,ax ;[INF] 3, 1 ; line 588 : nop8(); $DGL 0,4 call !_nop8 ;[INF] 3, 3 ; line 589 : /* ; line 590 : NOP( ); ; line 591 : NOP( ); ; line 592 : NOP( ); ; line 593 : NOP( ); ; line 594 : #ifdef _OVERCLOCK_ ; line 595 : NOP( ); ; line 596 : NOP( ); ; line 597 : NOP( ); ; line 598 : NOP( ); ; line 599 : NOP( ); ; line 600 : #endif ; line 601 : */ ; line 602 : SOE0 &= ~0x0004; // ( SCL = H ), SDA -> L $DGL 0,18 movw ax,!SOE0 ;[INF] 3, 1 xch a,x ;[INF] 1, 1 and a,#0FBH ; 251 ;[INF] 2, 1 xch a,x ;[INF] 1, 1 movw !SOE0,ax ;[INF] 3, 1 ; line 603 : nop8(); $DGL 0,19 call !_nop8 ;[INF] 3, 3 ; line 604 : /* ; line 605 : NOP( ); ; line 606 : NOP( ); ; line 607 : NOP( ); ; line 608 : NOP( ); ; line 609 : #ifdef _OVERCLOCK_ ; line 610 : NOP( ); ; line 611 : NOP( ); ; line 612 : NOP( ); ; line 613 : NOP( ); ; line 614 : NOP( ); ; line 615 : #endif ; line 616 : */ ; line 617 : iic_mcu_send_st( ); $DGL 0,33 br !_iic_mcu_send_st ;[INF] 3, 3 ??ef_iic_mcu_send_re_st: ??ee_iic_mcu_send_re_st: ; line 618 : } ; line 619 : ; line 620 : ; line 621 : ; line 622 : /* ======================================================== ; line 623 : ストップコンディション発行 ; line 624 : この前に、「最後のバイトの送受信」の時に前準備が必要です。 ; line 625 : ======================================================== */ ; line 626 : static void iic_mcu_send_sp( ) ; line 627 : { _iic_mcu_send_sp: $DGL 1,222 ??bf_iic_mcu_send_sp: ; line 628 : ST0 = 0x0004; $DGL 0,2 call !bs_S0086 ;[INF] 3, 3 ; line 629 : SOE0 = 0; // 受信の時はもっと前に「も」設定 ; してる。(NACK出力) $DGL 0,3 clrw ax ;[INF] 1, 1 movw !SOE0,ax ;[INF] 3, 1 ; line 630 : SO0 = 0x0000 | TAUS_MASK; // SCL $DGL 0,4 movw ax,#0B0BH ; 2827 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 631 : nop8(); $DGL 0,5 call !_nop8 ;[INF] 3, 3 ; line 632 : /* ; line 633 : NOP( ); ; line 634 : NOP( ); ; line 635 : NOP( ); ; line 636 : NOP( ); ; line 637 : #ifdef _OVERCLOCK_ ; line 638 : NOP( ); ; line 639 : NOP( ); ; line 640 : NOP( ); ; line 641 : NOP( ); ; line 642 : NOP( ); ; line 643 : #endif ; line 644 : */ ; line 645 : SO0 = 0x0400 | TAUS_MASK; // SCL $DGL 0,19 movw ax,#0F0BH ; 3851 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 646 : nop8(); $DGL 0,20 call !_nop8 ;[INF] 3, 3 ; line 647 : /* ; line 648 : NOP( ); ; line 649 : NOP( ); ; line 650 : NOP( ); ; line 651 : NOP( ); ; line 652 : #ifdef _OVERCLOCK_ ; line 653 : NOP( ); ; line 654 : NOP( ); ; line 655 : NOP( ); ; line 656 : NOP( ); ; line 657 : NOP( ); ; line 658 : #endif ; line 659 : */ ; line 660 : SO0 = 0x0404 | TAUS_MASK; $DGL 0,34 movw ax,#0F0FH ; 3855 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 661 : } $DGL 0,35 ??ef_iic_mcu_send_sp: ret ;[INF] 1, 6 ??ee_iic_mcu_send_sp: ; line 662 : ; line 663 : ; line 664 : ; line 665 : ; line 666 : /* ======================================================== ; line 667 : ペリフェラルモジュールの初期化 ; line 668 : ======================================================== */ ; line 669 : void iic_mcu_start( ) ; line 670 : { _iic_mcu_start: $DGL 1,228 ??bf_iic_mcu_start: ; line 671 : DST1 = 0; $DGL 0,2 clr1 DRC1.0 ;[INF] 3, 2 ; line 672 : NOP( ); // 2clkもしくは、DSTn==0をポーリ ; ング $DGL 0,3 nop ;[INF] 1, 1 ; line 673 : NOP( ); $DGL 0,4 nop ;[INF] 1, 1 ; line 674 : DEN1 = 0; $DGL 0,5 clr1 DRC1.7 ;[INF] 3, 2 ; line 675 : I2C_PU_on(); $DGL 0,6 ??bb00_iic_mcu_start: set1 PM5.3 ;[INF] 3, 2 set1 PM3.3 ;[INF] 3, 2 or P14,#03H ; 3 ;[INF] 3, 2 set1 P5.3 ;[INF] 3, 2 clr1 PM5.3 ;[INF] 3, 2 set1 P3.3 ;[INF] 3, 2 clr1 PM3.3 ;[INF] 3, 2 ??eb00_iic_mcu_start: ; line 676 : SAU0EN = 1; $DGL 0,7 set1 !PER0.2 ;[INF] 4, 2 ; line 677 : nop8(); $DGL 0,8 call !_nop8 ;[INF] 3, 3 ; line 678 : /* ; line 679 : NOP( ); ; line 680 : NOP( ); ; line 681 : NOP( ); ; line 682 : NOP( ); ; line 683 : #ifdef _OVERCLOCK_ ; line 684 : NOP( ); ; line 685 : NOP( ); ; line 686 : NOP( ); ; line 687 : NOP( ); ; line 688 : NOP( ); ; line 689 : #endif ; line 690 : */ ; line 691 : SPS0 = 0x0000; // シリアルユニットのクロック0。 ; (8M/2)/1 $DGL 0,22 clrw ax ;[INF] 1, 1 movw !SPS0,ax ;[INF] 3, 1 ; line 692 : SMR02 = bSMR0n_FIXEDBIT | bMD0n2; // 簡易I2Cに設定 $DGL 0,23 mov x,#024H ; 36 ;[INF] 2, 1 movw !SMR02,ax ;[INF] 3, 1 ; line 693 : #ifdef _OVERCLOCK_ ; line 694 : SDR02 = 12 << 9; // ボーレート設定 (8M/2)/1/(x+1 ; )/2 $DGL 0,25 movw SDR02,#01800H ; 6144 ;[INF] 4, 1 ; line 695 : #else ; line 696 : SDR02 = 5 << 9; // ボーレート設定 (8M/2)/1/(x+1) ; /2 ; line 697 : #endif ; line 698 : ; line 699 : SO0 = 0x0404 | TAUS_MASK; // 最初はHH $DGL 0,30 movw ax,#0F0FH ; 3855 ;[INF] 3, 1 movw !SO0,ax ;[INF] 3, 1 ; line 700 : iic_mcu_busy = 0; $DGL 0,31 clr1 _iic_mcu_busy ;[INF] 3, 2 ; line 701 : iic_mcu_wo_dma = 0; $DGL 0,32 clr1 _iic_mcu_wo_dma ;[INF] 3, 2 ; line 702 : ; line 703 : ; line 704 : // バスのリセット ; line 705 : IICIF10 = 0; $DGL 0,36 clr1 IF1L.0 ;[INF] 3, 2 ; line 706 : IICMK10 = 1; $DGL 0,37 set1 MK1L.0 ;[INF] 3, 2 ; line 707 : ; line 708 : iic_mcu_send_st(); $DGL 0,39 call !_iic_mcu_send_st ;[INF] 3, 3 ; line 709 : ; line 710 : SIO10 = 0xFF; $DGL 0,41 mov SIO10,#0FFH ; 255 ;[INF] 3, 1 ; line 711 : while( IICIF10 == 0 ){} // 通信中 $DGL 0,42 ?L0078: bt IF1L.0,$?L0079 ;[INF] 4, 5 ??bb01_iic_mcu_start: ??eb01_iic_mcu_start: br $?L0078 ;[INF] 2, 3 ?L0079: ; line 712 : iic_mcu_send_sp(); $DGL 0,43 call !_iic_mcu_send_sp ;[INF] 3, 3 ; line 713 : ; line 714 : SIR02 = SSR02; $DGL 0,45 movw ax,!SSR02 ;[INF] 3, 1 movw !SIR02,ax ;[INF] 3, 1 ; line 715 : ; line 716 : iic_mcu_initialized = 1; $DGL 0,47 set1 _iic_mcu_initialized ;[INF] 3, 2 ; line 717 : } $DGL 0,48 ??ef_iic_mcu_start: ret ;[INF] 1, 6 ??ee_iic_mcu_start: ; line 718 : ; line 719 : ; line 720 : ; line 721 : /* ======================================================== ; line 722 : モジュールの停止 ; line 723 : 再度使うときは初期化が必要 ; line 724 : ======================================================== */ ; line 725 : void iic_mcu_stop( ) ; line 726 : { _iic_mcu_stop: $DGL 1,242 ??bf_iic_mcu_stop: ; line 727 : while( iic_mcu_busy ) $DGL 0,2 ?L0082: bf _iic_mcu_busy,$?L0083 ;[INF] 4, 5 ; line 728 : {; ??bb00_iic_mcu_stop: ??eb00_iic_mcu_stop: ; line 729 : } // DMA動作中はもう少し待つ $DGL 0,4 br $?L0082 ;[INF] 2, 3 ?L0083: ; line 730 : iic_mcu_send_re_st( ); // SCL,SDAをLLにする $DGL 0,5 call !_iic_mcu_send_re_st ;[INF] 3, 3 ; line 731 : I2C_PU_off(); $DGL 0,6 ??bb01_iic_mcu_stop: set1 PM5.3 ;[INF] 3, 2 set1 PM3.3 ;[INF] 3, 2 and P14,#0FCH ; 252 ;[INF] 3, 2 clr1 P5.3 ;[INF] 3, 2 clr1 PM5.3 ;[INF] 3, 2 clr1 P3.3 ;[INF] 3, 2 clr1 PM3.3 ;[INF] 3, 2 ??eb01_iic_mcu_stop: ; line 732 : SAU0EN = 0; $DGL 0,7 clr1 !PER0.2 ;[INF] 4, 2 ; line 733 : iic_mcu_initialized = 0; $DGL 0,8 clr1 _iic_mcu_initialized ;[INF] 3, 2 ; line 734 : } $DGL 0,9 ??ef_iic_mcu_stop: ret ;[INF] 1, 6 ??ee_iic_mcu_stop: @@CODEL CSEG END ; *** Code Information *** ; ; $FILE C:\78k_data\yav-mcu-basara\branches\0.10(fix)\i2c_mcu.c ; ; $FUNC nop8(76) ; void=(void) ; CODE SIZE= 1 bytes, CLOCK_SIZE= 6 clocks, STACK_SIZE= 0 bytes ; ; $FUNC iic_mcu_read_a_byte(87) ; bc=(unsigned char SLA:x, unsigned char adrs:[sp+4]) ; CODE SIZE= 111 bytes, CLOCK_SIZE= 118 clocks, STACK_SIZE= 10 bytes ; ; $CALL iic_mcu_start(93) ; void=(void) ; ; $CALL iic_mcu_call_slave(110) ; bc=(int:ax) ; ; $CALL iic_mcu_send_a_byte(118) ; bc=(int:ax) ; ; $CALL iic_mcu_send_re_st(122) ; void=(void) ; ; $CALL iic_mcu_send_a_byte(123) ; bc=(int:ax) ; ; $CALL iic_mcu_send_sp(139) ; void=(void) ; ; $FUNC iic_mcu_read(158) ; bc=(unsigned char slave:x, unsigned char adrs:[sp+4], ; unsigned char len:[sp+6], pointer dest:[sp+8]) ; CODE SIZE= 111 bytes, CLOCK_SIZE= 141 clocks, STACK_SIZE= 12 bytes ; ; $CALL iic_mcu_start(165) ; void=(void) ; ; $CALL iic_mcu_call_slave(188) ; bc=(int:ax) ; ; $CALL iic_mcu_send_a_byte(195) ; bc=(int:ax) ; ; $CALL iic_mcu_send_re_st(199) ; void=(void) ; ; $CALL iic_mcu_send_a_byte(200) ; bc=(int:ax) ; ; $CALL iic_mcu_send_sp(225) ; void=(void) ; ; $FUNC iic_mcu_write_a_byte(242) ; bc=(unsigned char SLA:x, unsigned char adrs:[sp+4], ; unsigned char dat:[sp+6]) ; CODE SIZE= 56 bytes, CLOCK_SIZE= 79 clocks, STACK_SIZE= 12 bytes ; ; $CALL iic_mcu_start(247) ; void=(void) ; ; $CALL iic_mcu_call_slave(266) ; bc=(int:ax) ; ; $CALL iic_mcu_send_a_byte(271) ; bc=(int:ax) ; ; $CALL iic_mcu_send_a_byte(272) ; bc=(int:ax) ; ; $CALL iic_mcu_send_sp(273) ; void=(void) ; ; $FUNC iic_mcu_write(297) ; bc=(unsigned char slave:x, unsigned char adrs:[sp+4], ; unsigned char len:[sp+6], pointer src:[sp+8]) ; CODE SIZE= 127 bytes, CLOCK_SIZE= 121 clocks, STACK_SIZE= 12 bytes ; ; $CALL iic_mcu_start(303) ; void=(void) ; ; $CALL iic_mcu_call_slave(327) ; bc=(int:ax) ; ; $FUNC int_dma1(388) ; void=(void) ; CODE SIZE= 108 bytes, CLOCK_SIZE= 86 clocks, STACK_SIZE= 26 bytes ; ; $CALL nop8(408) ; void=(void) ; ; $CALL nop8(423) ; void=(void) ; ; $FUNC int_iic10(452) ; void=(void) ; CODE SIZE= 109 bytes, CLOCK_SIZE= 83 clocks, STACK_SIZE= 26 bytes ; ; $CALL nop8(469) ; void=(void) ; ; $CALL nop8(484) ; void=(void) ; ; $FUNC iic_mcu_call_slave(513) ; bc=(unsigned char slave:x) ; CODE SIZE= 22 bytes, CLOCK_SIZE= 30 clocks, STACK_SIZE= 6 bytes ; ; $CALL iic_mcu_send_st(514) ; void=(void) ; ; $CALL iic_mcu_send_a_byte(517) ; bc=(int:ax) ; ; $CALL iic_mcu_send_sp(519) ; void=(void) ; ; $FUNC iic_mcu_send_a_byte(533) ; bc=(unsigned char dat:x) ; CODE SIZE= 36 bytes, CLOCK_SIZE= 37 clocks, STACK_SIZE= 2 bytes ; ; $FUNC iic_mcu_send_st(556) ; void=(void) ; CODE SIZE= 37 bytes, CLOCK_SIZE= 32 clocks, STACK_SIZE= 4 bytes ; ; $CALL nop8(558) ; void=(void) ; ; $FUNC iic_mcu_send_re_st(585) ; void=(void) ; CODE SIZE= 41 bytes, CLOCK_SIZE= 25 clocks, STACK_SIZE= 4 bytes ; ; $CALL nop8(588) ; void=(void) ; ; $CALL nop8(603) ; void=(void) ; ; $CALL iic_mcu_send_st(617) ; void=(void) ; ; $FUNC iic_mcu_send_sp(627) ; void=(void) ; CODE SIZE= 32 bytes, CLOCK_SIZE= 31 clocks, STACK_SIZE= 4 bytes ; ; $CALL nop8(631) ; void=(void) ; ; $CALL nop8(646) ; void=(void) ; ; $FUNC iic_mcu_start(670) ; void=(void) ; CODE SIZE= 92 bytes, CLOCK_SIZE= 65 clocks, STACK_SIZE= 4 bytes ; ; $CALL nop8(677) ; void=(void) ; ; $CALL iic_mcu_send_st(708) ; void=(void) ; ; $CALL iic_mcu_send_sp(712) ; void=(void) ; ; $FUNC iic_mcu_stop(726) ; void=(void) ; CODE SIZE= 38 bytes, CLOCK_SIZE= 35 clocks, STACK_SIZE= 4 bytes ; ; $CALL iic_mcu_send_re_st(730) ; void=(void) ; Target chip : uPD79F0104 ; Device file : E1.00b