📄 ports.ls
字号:
1 ; C Compiler for ST7 (COSMIC Software)
2 ; Generator V4.4a - 17 Dec 2001
3 ; Optimizer V4.2g - 21 Dec 2001
1554 ; 59 void PORTS_Init(void) // Setting for 56 pins case of Starter kit
1554 ; 60 {
1555 switch .text
1556 0000 _PORTS_Init:
1559 ; 62 PADDR = 0x00; //PA7 to PA0 floating Input
1561 0000 4f clr a
1562 0001 b701 ld _PADDR,a
1563 ; 63 PAOR = 0x00;
1565 0003 b702 ld _PAOR,a
1566 ; 65 PBDDR = 0x80; //PB7 output push pull
1568 0005 a680 ld a,#128
1569 0007 b704 ld _PBDDR,a
1570 ; 66 PBOR = 0x80; //PB6 to PB0 floating Input
1572 0009 b705 ld _PBOR,a
1573 ; 68 PCDDR = 0x00; //PC7 to PC0 floating Input
1575 000b 4f clr a
1576 000c b707 ld _PCDDR,a
1577 ; 69 PCOR = 0x00;
1579 000e b708 ld _PCOR,a
1580 ; 71 PDDDR = 0x00; //PD7 to PD0 floating Input
1582 0010 b70a ld _PDDDR,a
1583 ; 72 PDOR = 0x00;
1585 0012 b70b ld _PDOR,a
1586 ; 74 PEDDR = 0x00; //PE7 to PE0 floating Input
1588 0014 b70d ld _PEDDR,a
1589 ; 75 PEOR = 0x00;
1591 0016 b70e ld _PEOR,a
1592 ; 77 PFDDR = 0x00; //PF7 to PF0 floating Input
1594 0018 b710 ld _PFDDR,a
1595 ; 78 PFOR = 0x00;
1597 001a b711 ld _PFOR,a
1598 ; 80 KeyState = 0;
1600 001c c70000 ld L7401_KeyState,a
1601 ; 81 }
1604 001f 81 ret
1629 ; 94 void PORTS_RedLedOn(void)
1629 ; 95 {
1630 switch .text
1631 0020 _PORTS_RedLedOn:
1634 ; 96 PBDDR |= LED; //PB7 push-pull Output
1636 0020 b604 ld a,_PBDDR
1637 0022 aa80 or a,#128
1638 0024 b704 ld _PBDDR,a
1639 ; 97 PBOR |= LED;
1641 0026 b605 ld a,_PBOR
1642 0028 aa80 or a,#128
1643 002a b705 ld _PBOR,a
1644 ; 98 PBDR |= LED;
1646 002c b603 ld a,_PBDR
1647 002e aa80 or a,#128
1648 0030 b703 ld _PBDR,a
1649 ; 99 }
1652 0032 81 ret
1676 ; 101 void PORTS_RedLedOff(void)
1676 ; 102 {
1677 switch .text
1678 0033 _PORTS_RedLedOff:
1681 ; 103 PBOR &= (u8)~LED; // touch PBOR first
1683 0033 b605 ld a,_PBOR
1684 0035 a47f and a,#127
1685 0037 b705 ld _PBOR,a
1686 ; 104 PBDDR &= (u8)~LED; // then PBDDR -> PB7 Floating Input
1688 0039 b604 ld a,_PBDDR
1689 003b a47f and a,#127
1690 003d b704 ld _PBDDR,a
1691 ; 105 }
1694 003f 81 ret
1719 ; 107 void PORTS_RedLedToggle(void)
1719 ; 108 {
1720 switch .text
1721 0040 _PORTS_RedLedToggle:
1724 ; 109 if (ValBit(PBDDR,PB7)) // push-pull config?
1726 0040 0f040d btjf _PBDDR,#7,L7111
1727 ; 111 PBOR &= (u8)~LED;
1729 0043 b605 ld a,_PBOR
1730 0045 a47f and a,#127
1731 0047 b705 ld _PBOR,a
1732 ; 112 PBDDR &= (u8)~LED; //Toggle PB7 direction (Floating Input or push-pull Output)
1734 0049 b604 ld a,_PBDDR
1735 004b a47f and a,#127
1736 004d b704 ld _PBDDR,a
1739 004f 81 ret
1740 0050 L7111:
1741 ; 116 PBDDR |= LED; //Toggle PB7 direction (Floating Input or push-pull Output)
1743 0050 b604 ld a,_PBDDR
1744 0052 aa80 or a,#128
1745 0054 b704 ld _PBDDR,a
1746 ; 117 PBOR |= LED;
1748 0056 b605 ld a,_PBOR
1749 0058 aa80 or a,#128
1750 005a b705 ld _PBOR,a
1751 ; 118 PBDR |= LED; // ((u8)0x80)
1753 005c b603 ld a,_PBDR
1754 005e aa80 or a,#128
1755 0060 b703 ld _PBDR,a
1756 ; 120 }
1759 0062 81 ret
1784 ; 122 void PORTS_GreenLedOn(void)
1784 ; 123 {
1785 switch .text
1786 0063 _PORTS_GreenLedOn:
1789 ; 124 PBDDR |= LED; //PB7 push-pull Output
1791 0063 b604 ld a,_PBDDR
1792 0065 aa80 or a,#128
1793 0067 b704 ld _PBDDR,a
1794 ; 125 PBOR |= LED;
1796 0069 b605 ld a,_PBOR
1797 006b aa80 or a,#128
1798 006d b705 ld _PBOR,a
1799 ; 126 PBDR &= (u8)~LED;
1801 006f b603 ld a,_PBDR
1802 0071 a47f and a,#127
1803 0073 b703 ld _PBDR,a
1804 ; 127 }
1807 0075 81 ret
1831 ; 129 void PORTS_GreenLedOff(void)
1831 ; 130 {
1832 switch .text
1833 0076 _PORTS_GreenLedOff:
1836 ; 131 PBOR &= (u8)~LED; // touch first PBOR
1838 0076 b605 ld a,_PBOR
1839 0078 a47f and a,#127
1840 007a b705 ld _PBOR,a
1841 ; 132 PBDDR &= (u8)~LED; // then PBDDR -> PB7 Floating Input
1843 007c b604 ld a,_PBDDR
1844 007e a47f and a,#127
1845 0080 b704 ld _PBDDR,a
1846 ; 133 }
1849 0082 81 ret
1875 ; 135 void PORTS_GreenLedToggle(void)
1875 ; 136 {
1876 switch .text
1877 0083 _PORTS_GreenLedToggle:
1880 ; 137 if (ValBit(PBDDR,PB7)) // output config?
1882 0083 0f040d btjf _PBDDR,#7,L3511
1883 ; 139 PBOR &= (u8)~LED;
1885 0086 b605 ld a,_PBOR
1886 0088 a47f and a,#127
1887 008a b705 ld _PBOR,a
1888 ; 140 PBDDR &= (u8)~LED; //Toggle PB7 direction (Floating Input or push-pull Output)
1890 008c b604 ld a,_PBDDR
1891 008e a47f and a,#127
1892 0090 b704 ld _PBDDR,a
1895 0092 81 ret
1896 0093 L3511:
1897 ; 144 PBDDR |= LED; //Toggle PB7 direction (Floating Input or push-pull Output)
1899 0093 b604 ld a,_PBDDR
1900 0095 aa80 or a,#128
1901 0097 b704 ld _PBDDR,a
1902 ; 145 PBOR |= LED;
1904 0099 b605 ld a,_PBOR
1905 009b aa80 or a,#128
1906 009d b705 ld _PBOR,a
1907 ; 146 PBDR &= (u8)~LED;
1909 009f b603 ld a,_PBDR
1910 00a1 a47f and a,#127
1911 00a3 b703 ld _PBDR,a
1912 ; 148 }
1915 00a5 81 ret
1941 ; 150 void PORTS_RedGreenLedToggle(void)
1941 ; 151 {
1942 switch .text
1943 00a6 _PORTS_RedGreenLedToggle:
1946 ; 152 if (!ValBit(PBDDR,PB7))
1948 00a6 0e040c btjt _PBDDR,#7,L7611
1949 ; 154 PBDDR |= LED; //Toggle PB7 direction (Floating Input or push-pull Output)
1951 00a9 b604 ld a,_PBDDR
1952 00ab aa80 or a,#128
1953 00ad b704 ld _PBDDR,a
1954 ; 155 PBOR |= LED;
1956 00af b605 ld a,_PBOR
1957 00b1 aa80 or a,#128
1958 00b3 b705 ld _PBOR,a
1959 00b5 L7611:
1960 ; 157 PBDR ^= LED;
1962 00b5 b603 ld a,_PBDR
1963 00b7 a880 xor a,#128
1964 00b9 b703 ld _PBDR,a
1965 ; 158 }
1968 00bb 81 ret
1992 ; 160 void PORTS_BothLedOff(void)
1992 ; 161 {
1993 switch .text
1994 00bc _PORTS_BothLedOff:
1997 ; 162 PBDDR &= (u8)~LED; //PB7 Floating Input
1999 00bc b604 ld a,_PBDDR
2000 00be a47f and a,#127
2001 00c0 b704 ld _PBDDR,a
2002 ; 163 PBOR &= (u8)~LED;
2004 00c2 b605 ld a,_PBOR
2005 00c4 a47f and a,#127
2006 00c6 b705 ld _PBOR,a
2007 ; 164 }
2010 00c8 81 ret
2035 ; 170 BOOL PORTS_KeyScan(void)
2035 ; 171 {
2036 switch .text
2037 00c9 _PORTS_KeyScan:
2040 ; 172 if (!ValBit(BUTTON_PORT,BUTTON)) // Button released (Pull-up resistor)
2042 00c9 000626 btjt _PCDR,#0,L7121
2043 ; 174 switch(KeyState)
2045 00cc c60000 ld a,L7401_KeyState
2048 00cf 2713 jreq L3021
2049 00d1 4a dec a
2050 00d2 271c jreq L5021
2051 00d4 4a dec a
2052 00d5 2619 jrne L5021
2053 ; 176 case KEY_PUSHED:
2053 ; 177 if (DebounceButton == 0)
2055 00d7 c60000 ld a,_DebounceButton
2056 00da 2606 jrne L5221
2057 ; 179 KeyState = KEY_IDLE_NEXT;
2059 00dc a601 ld a,#1
2060 00de c70000 ld L7401_KeyState,a
2061 ; 180 return (TRUE);
2065 00e1 81 ret
2066 00e2 L5221:
2067 ; 182 else return (FALSE);
2069 00e2 4f clr a
2072 00e3 81 ret
2073 00e4 L3021:
2074 ; 184 case KEY_IDLE:
2074 ; 185 DebounceButton = 10; // 100ms debounce time
2076 00e4 a60a ld a,#10
2077 00e6 c70000 ld _DebounceButton,a
2078 ; 186 KeyState = KEY_PUSHED;
2080 00e9 a602 ld a,#2
2081 00eb c70000 ld L7401_KeyState,a
2082 ; 187 return(FALSE);
2084 00ee 4f clr a
2087 00ef 81 ret
2088 00f0 L5021:
2089 ; 189 case KEY_IDLE_NEXT:
2089 ; 190 default:
2089 ; 191 return(FALSE);
2092 00f0 4f clr a
2095 00f1 81 ret
2096 ; 192 break;
2097 00f2 L7121:
2098 ; 195 else KeyState = KEY_IDLE;
2100 00f2 4f clr a
2101 00f3 c70000 ld L7401_KeyState,a
2102 ; 196 return(FALSE);
2106 00f6 81 ret
2128 ; 217 void PORTS_0_Interrupt(void)
2128 ; 218 {
2129 switch .text
2130 00f7 _PORTS_0_Interrupt:
2134 ; 220 }
2137 00f7 80 iret
2160 xdef _PORTS_0_Interrupt
2161 switch .bss
2162 0000 L7401_KeyState:
2163 0000 00 ds.b 1
2164 xref _DebounceButton
2165 xdef _PORTS_KeyScan
2166 xdef _PORTS_BothLedOff
2167 xdef _PORTS_RedGreenLedToggle
2168 xdef _PORTS_GreenLedToggle
2169 xdef _PORTS_GreenLedOff
2170 xdef _PORTS_GreenLedOn
2171 xdef _PORTS_RedLedToggle
2172 xdef _PORTS_RedLedOff
2173 xdef _PORTS_RedLedOn
2174 xdef _PORTS_Init
2194 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -