diff --git a/README.md b/README.md index 7b611f6..993f917 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,18 @@ # ch395-lib +## Documentation + +https://orix-software.github.io/ch395lib/api/ + +## Repository + +## Dependencies + ca65 syntax If you set a mac address maybe will refuse to attribute a mac address -https://orix-software.github.io/ds1501lib/api/ - -#" Informations complétemtaires sur le chip +## Informations complémentaires sur le chip * Même quand le cable est déconnecté, il est possible de lire le buffer quand on a déjà récupéré de la data. * Quand le cable est débranché, l'ip est persistante dans la stack. En revanche, les serveurs DNS fournis par le dhcp smeblent être eux resettés quand le cable est débranché. diff --git a/VERSION b/VERSION index 2cf03e5..a2a8260 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2024.1 \ No newline at end of file +2024.2 \ No newline at end of file diff --git a/src/6502/_ch395_check_exist.s b/src/6502/_ch395_check_exist.s index ab1009f..65845b0 100644 --- a/src/6502/_ch395_check_exist.s +++ b/src/6502/_ch395_check_exist.s @@ -9,7 +9,7 @@ ;;@proto unsigned char ch395_check_exist(); ;;@brief Checks if ch395 exists ;;@```c - ;;@` val = ch395_get_glob_int_status(); + ;;@` val = ch395_check_exist(); ;;@` if (val == CH395_DETECTED) printf("Ch395 is here"); ;;@``` .endproc @@ -17,7 +17,7 @@ .proc ch395_check_exist ;;@brief Checks if ch395 exists ;;@```ca65 - ;;@` jsr ch395_get_glob_int_status + ;;@` jsr ch395_check_exist ;;@` cmp #CH395_DETECTED ;;@` beq ch395_connected ;;@` rts diff --git a/src/6502/_ch395_clear_recv_buf_sn.s b/src/6502/_ch395_clear_recv_buf_sn.s index 779712b..fcd11ce 100644 --- a/src/6502/_ch395_clear_recv_buf_sn.s +++ b/src/6502/_ch395_clear_recv_buf_sn.s @@ -7,7 +7,7 @@ .proc _ch395_clear_recv_buf_sn ;;@proto void ch395_clear_recv_buf_sn(unsigned char ID_SOCKET) - ;;@brief Clear receive buffer + ;;@brief This command is used to clear the Socket receive buffer. It is necessary to input 1 byte of Socket index value. Upon receiving this command, CH395 will reset the receiving length of this Socket, and the receiving pointer will point to the buffer head. ;;@```c ;;@` ch395_clear_recv_buf_sn(CH395_SOCKET1); ;;@``` @@ -15,7 +15,7 @@ .proc ch395_clear_recv_buf_sn - ;;@brief Clear receive buffer + ;;@brief This command is used to clear the Socket receive buffer. It is necessary to input 1 byte of Socket index value. Upon receiving this command, CH395 will reset the receiving length of this Socket, and the receiving pointer will point to the buffer head. ;;@inputA Socket id ;;@modifyA ;;@modifyY diff --git a/src/6502/_ch395_close_socket_sn.s b/src/6502/_ch395_close_socket_sn.s index 2033b79..06c3171 100644 --- a/src/6502/_ch395_close_socket_sn.s +++ b/src/6502/_ch395_close_socket_sn.s @@ -6,8 +6,8 @@ .export ch395_close_socket_sn .proc _ch395_close_socket_sn - ;;@proto oid ch395_close_socket_sn(unsigned char socketid) - ;;@brief Close socket + ;;@proto void ch395_close_socket_sn(unsigned char socketid) + ;;@brief This command is used to close Socket. It is necessary to input a 1 byte of Socket index value. After Socket is closed, the receive buffer and transmit buffer of Socket are emptied, but the configuration information is still reserved, and you just need to open the Socket again when using the Socket the next time. In TCP mode, CH395 will automatically disconnect TCP before turning off Socket. ;;@inputPARAM_socketid The socketid ;;@```c ;;@` ch395_close_socket_sn(CH395_SOCKET1); @@ -16,7 +16,7 @@ .proc ch395_close_socket_sn - ;;@brief Close socket + ;;@brief This command is used to close Socket. It is necessary to input a 1 byte of Socket index value. After Socket is closed, the receive buffer and transmit buffer of Socket are emptied, but the configuration information is still reserved, and you just need to open the Socket again when using the Socket the next time. In TCP mode, CH395 will automatically disconnect TCP before turning off Socket. ;;@inputA The id of the socket to close ;;@modifyY ;;@```ca65 diff --git a/src/6502/_ch395_dhcp_enable.s b/src/6502/_ch395_dhcp_enable.s index f53a684..f810013 100644 --- a/src/6502/_ch395_dhcp_enable.s +++ b/src/6502/_ch395_dhcp_enable.s @@ -1,15 +1,16 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" + .export _ch395_dhcp_enable .export ch395_dhcp_enable .proc _ch395_dhcp_enable + ;;@proto void ch395_dhcp_enable() + ;;@brief This command is used to start or stop DHCP. It is necessary to input a 1-byte flag. If the flag is 1, it will indicate that DHCP is on; if the flag is 0, it will indicate that DHCP is off. CH395 must be initialized before DHCP is started. After DHCP is started, CH395 will broadcast DHCPDISCOVER message to the network to discover DHCP Server, request the address and other configuration parameters after finding DHCP Server, and then generate GINT_STAT_DHCP interrupt. MCU can send GET_DHCP_STATUS command to get DHCP status. If the status code is 0, it will indicate success, and MCU can send the command GET_IP_INF to get IP, MASK and other information. If the status code is 1, it will indicate error, which is generally caused by timeout, for example, no DHCP Server is found. DHCP is always in a working state after startup unless it receives a DHCP shutdown command from MCU. During this process, if DHCP Server reassigns a configuration to CH395 and the configuration is different from the original configuration, CH395 will still generate an interrupt. After timeout interrupt is generated, if DHCP Server is not found, CH395 will continue to send DHCPDISCOVER message at an interval of about 16 seconds. It takes about 20MS to execute this command. MCU can send GET_CMD_STATUS to query whether the execution has finished and the execution status .endproc .proc ch395_dhcp_enable - ;;@brief Enable or not dhcp + ;;@brief This command is used to start or stop DHCP. It is necessary to input a 1-byte flag. If the flag is 1, it will indicate that DHCP is on; if the flag is 0, it will indicate that DHCP is off. CH395 must be initialized before DHCP is started. After DHCP is started, CH395 will broadcast DHCPDISCOVER message to the network to discover DHCP Server, request the address and other configuration parameters after finding DHCP Server, and then generate GINT_STAT_DHCP interrupt. MCU can send GET_DHCP_STATUS command to get DHCP status. If the status code is 0, it will indicate success, and MCU can send the command GET_IP_INF to get IP, MASK and other information. If the status code is 1, it will indicate error, which is generally caused by timeout, for example, no DHCP Server is found. DHCP is always in a working state after startup unless it receives a DHCP shutdown command from MCU. During this process, if DHCP Server reassigns a configuration to CH395 and the configuration is different from the original configuration, CH395 will still generate an interrupt. After timeout interrupt is generated, if DHCP Server is not found, CH395 will continue to send DHCPDISCOVER message at an interval of about 16 seconds. It takes about 20MS to execute this command. MCU can send GET_CMD_STATUS to query whether the execution has finished and the execution status ;;@inputA The mode to activate DHCP mode ;;@modifyX ldx #CH395_DHCP_ENABLE diff --git a/src/6502/_ch395_get_cmd_status.s b/src/6502/_ch395_get_cmd_status.s index b5292bd..1d85c4e 100644 --- a/src/6502/_ch395_get_cmd_status.s +++ b/src/6502/_ch395_get_cmd_status.s @@ -1,7 +1,4 @@ - -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "../include/ch395.inc" .export _ch395_get_cmd_status .export ch395_get_cmd_status diff --git a/src/6502/_ch395_get_dhcp_status.s b/src/6502/_ch395_get_dhcp_status.s index 3fd94a7..4995c53 100644 --- a/src/6502/_ch395_get_dhcp_status.s +++ b/src/6502/_ch395_get_dhcp_status.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_get_dhcp_status .export ch395_get_dhcp_status diff --git a/src/6502/_ch395_get_glob_int_status.s b/src/6502/_ch395_get_glob_int_status.s index 6c5d792..94faa09 100644 --- a/src/6502/_ch395_get_glob_int_status.s +++ b/src/6502/_ch395_get_glob_int_status.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_get_glob_int_status .export ch395_get_glob_int_status diff --git a/src/6502/_ch395_get_ic_ver.s b/src/6502/_ch395_get_ic_ver.s index de6a164..b53d49f 100644 --- a/src/6502/_ch395_get_ic_ver.s +++ b/src/6502/_ch395_get_ic_ver.s @@ -1,7 +1,4 @@ - -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "../include/ch395.inc" .export _ch395_get_ic_ver .export ch395_get_ic_ver diff --git a/src/6502/_ch395_get_int_status_sn.s b/src/6502/_ch395_get_int_status_sn.s index bc0ce51..9111c15 100644 --- a/src/6502/_ch395_get_int_status_sn.s +++ b/src/6502/_ch395_get_int_status_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "../include/ch395.inc" .export _ch395_get_int_status_sn .export ch395_get_int_status_sn diff --git a/src/6502/_ch395_get_ip_inf.s b/src/6502/_ch395_get_ip_inf.s index 4edd39d..71136c9 100644 --- a/src/6502/_ch395_get_ip_inf.s +++ b/src/6502/_ch395_get_ip_inf.s @@ -1,8 +1,6 @@ -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "ch395.inc" - .include "telestrat.inc" +.include "telestrat.inc" .export _ch395_get_ip_inf .export ch395_get_ip_inf diff --git a/src/6502/_ch395_get_mac_adress.s b/src/6502/_ch395_get_mac_adress.s index 5f5aedd..210eb54 100644 --- a/src/6502/_ch395_get_mac_adress.s +++ b/src/6502/_ch395_get_mac_adress.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .ifndef ptr1 .importzp ptr1 diff --git a/src/6502/_ch395_get_phy_status.s b/src/6502/_ch395_get_phy_status.s index 818f621..dabcb8f 100644 --- a/src/6502/_ch395_get_phy_status.s +++ b/src/6502/_ch395_get_phy_status.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "ch395.inc" .export _ch395_get_phy_status .export ch395_get_phy_status diff --git a/src/6502/_ch395_get_recv_len_sn.s b/src/6502/_ch395_get_recv_len_sn.s index 6e66ed0..9409bb8 100644 --- a/src/6502/_ch395_get_recv_len_sn.s +++ b/src/6502/_ch395_get_recv_len_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_get_recv_len_sn .export ch395_get_recv_len_sn diff --git a/src/6502/_ch395_get_remot_ipp_sn.s b/src/6502/_ch395_get_remot_ipp_sn.s index 4638cdb..b03f467 100644 --- a/src/6502/_ch395_get_remot_ipp_sn.s +++ b/src/6502/_ch395_get_remot_ipp_sn.s @@ -1,16 +1,11 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif - - - .importzp ptr1 - .import popax +.include "ch395.inc" +.importzp ptr1 +.import popax .export _ch395_get_remot_ipp_sn .export ch395_get_remot_ipp_sn - .proc ch395_get_remot_ipp_sn ;;@brief Get remote ip connected to the socket ;;@inputA The Socket for the ip to get @@ -19,6 +14,15 @@ ;;@modifyA ;;@modifyX ;;@modifyY + ;;@```ca65 + ;;@` lda #$01 ; Socket 1 + ;;@` ldx #ip_dest + ;;@` jsr ch395_get_remot_ipp_sn + ;;@` rts + ;;@`ipdest: + ;;@` .byte 192,168,0,1 + ;;@``` sty ptr1 stx ptr1+1 diff --git a/src/6502/_ch395_get_socket_status_sn.s b/src/6502/_ch395_get_socket_status_sn.s index 7f3c214..f2c1d8d 100644 --- a/src/6502/_ch395_get_socket_status_sn.s +++ b/src/6502/_ch395_get_socket_status_sn.s @@ -1,7 +1,4 @@ - -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "ch395.inc" .export _ch395_get_socket_status_sn .export ch395_get_socket_status_sn @@ -23,6 +20,8 @@ ;;@` lda #$01 ; Socket 1 ;;@` jsr ch395_get_socket_status_sn ;;@` ; check A and X for the state + ;;@` cmp #CH395_SOCKET_CLOSED + ;;@` beq @soclet is closed ;;@``` ldx #CH395_GET_SOCKET_STATUS_SN stx CH395_COMMAND_PORT diff --git a/src/6502/_ch395_init.s b/src/6502/_ch395_init.s index 2340767..d7ad991 100644 --- a/src/6502/_ch395_init.s +++ b/src/6502/_ch395_init.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "ch395.inc" .export _ch395_init .export ch395_init diff --git a/src/6502/_ch395_open_socket_sn.s b/src/6502/_ch395_open_socket_sn.s index a453e02..f433b34 100644 --- a/src/6502/_ch395_open_socket_sn.s +++ b/src/6502/_ch395_open_socket_sn.s @@ -1,6 +1,5 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" + .export _ch395_open_socket_sn .export ch395_open_socket_sn diff --git a/src/6502/_ch395_read_recv_buf_sn.s b/src/6502/_ch395_read_recv_buf_sn.s index b115257..eef226a 100644 --- a/src/6502/_ch395_read_recv_buf_sn.s +++ b/src/6502/_ch395_read_recv_buf_sn.s @@ -1,6 +1,5 @@ -.ifndef CH395_COMMAND_PORT + .include "ch395.inc" -.endif .import popax .importzp ptr1, ptr2 diff --git a/src/6502/_ch395_reset_all.s b/src/6502/_ch395_reset_all.s index 64f058e..cd58f9b 100644 --- a/src/6502/_ch395_reset_all.s +++ b/src/6502/_ch395_reset_all.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_reset_all .export ch395_reset_all diff --git a/src/6502/_ch395_retran_period.s b/src/6502/_ch395_retran_period.s index 58a9d3b..d6fb47c 100644 --- a/src/6502/_ch395_retran_period.s +++ b/src/6502/_ch395_retran_period.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_retran_period .export ch395_retran_period diff --git a/src/6502/_ch395_set_des_port_sn.s b/src/6502/_ch395_set_des_port_sn.s index 3d21eac..7d057e2 100644 --- a/src/6502/_ch395_set_des_port_sn.s +++ b/src/6502/_ch395_set_des_port_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .importzp ptr1 .import popax diff --git a/src/6502/_ch395_set_fun_para.s b/src/6502/_ch395_set_fun_para.s index e5f36bc..ef877b9 100644 --- a/src/6502/_ch395_set_fun_para.s +++ b/src/6502/_ch395_set_fun_para.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_set_fun_para .export ch395_set_fun_para diff --git a/src/6502/_ch395_set_gwip_addr.s b/src/6502/_ch395_set_gwip_addr.s index 09653c7..caa794a 100644 --- a/src/6502/_ch395_set_gwip_addr.s +++ b/src/6502/_ch395_set_gwip_addr.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_set_gwip_addr .export ch395_set_gwip_addr diff --git a/src/6502/_ch395_set_ip_addr.s b/src/6502/_ch395_set_ip_addr.s index bb43260..d3a64aa 100644 --- a/src/6502/_ch395_set_ip_addr.s +++ b/src/6502/_ch395_set_ip_addr.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "ch395.inc" .export _ch395_set_ip_addr .export ch395_set_ip_addr diff --git a/src/6502/_ch395_set_ip_addr_sn.s b/src/6502/_ch395_set_ip_addr_sn.s index 43ebcf6..e6f86d1 100644 --- a/src/6502/_ch395_set_ip_addr_sn.s +++ b/src/6502/_ch395_set_ip_addr_sn.s @@ -1,6 +1,5 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" + .ifndef ptr1 .importzp ptr1 diff --git a/src/6502/_ch395_set_ipraw_pro_sn.s b/src/6502/_ch395_set_ipraw_pro_sn.s index c004937..c53e014 100644 --- a/src/6502/_ch395_set_ipraw_pro_sn.s +++ b/src/6502/_ch395_set_ipraw_pro_sn.s @@ -1,6 +1,5 @@ -.ifndef CH395_COMMAND_PORT - .include "../include/ch395.inc" -.endif +.include "ch395.inc" + .export _ch395_set_ipraw_pro_sn .export ch395_set_ipraw_pro_sn @@ -14,9 +13,8 @@ .proc ch395_set_ipraw_pro_sn ;;@brief Set ipraw protocol on socket ;;@inputA Socket id - ; A the socket - ; X the mode proto - + ;;@inputX the mode proto + ;;@modifyY ldy #CH395_SET_IPRAW_PRO_SN sty CH395_COMMAND_PORT sta CH395_DATA_PORT ; Set socket port diff --git a/src/6502/_ch395_set_mac_adress.s b/src/6502/_ch395_set_mac_adress.s index af88f7d..21437e8 100644 --- a/src/6502/_ch395_set_mac_adress.s +++ b/src/6502/_ch395_set_mac_adress.s @@ -1,7 +1,4 @@ - -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_set_mac_adress .export ch395_set_mac_adress diff --git a/src/6502/_ch395_set_proto_type_sn.s b/src/6502/_ch395_set_proto_type_sn.s index a558c30..c97e20f 100644 --- a/src/6502/_ch395_set_proto_type_sn.s +++ b/src/6502/_ch395_set_proto_type_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .import popa diff --git a/src/6502/_ch395_set_retran_count.s b/src/6502/_ch395_set_retran_count.s index 581d74c..65359bc 100644 --- a/src/6502/_ch395_set_retran_count.s +++ b/src/6502/_ch395_set_retran_count.s @@ -1,6 +1,5 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" + .export _ch395_set_retran_count .export ch395_set_retran_count diff --git a/src/6502/_ch395_set_sour_port_sn.s b/src/6502/_ch395_set_sour_port_sn.s index fa478d9..7d8a8b3 100644 --- a/src/6502/_ch395_set_sour_port_sn.s +++ b/src/6502/_ch395_set_sour_port_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .import popax .importzp ptr1 diff --git a/src/6502/_ch395_set_ttl.s b/src/6502/_ch395_set_ttl.s new file mode 100644 index 0000000..79c27c4 --- /dev/null +++ b/src/6502/_ch395_set_ttl.s @@ -0,0 +1,20 @@ +.include "ch395.inc" + +.export _ch395_set_ttl +.export ch395_set_ttl + +.proc _ch395_set_ttl + ;;@brief This command is used to set Socket TTL. It is necessary to input 1 byte of Socket index value and 1 byte of TTL value. It shall be set after the Socket is opened, and the maximum value is 128 + ;;@proto ch395_set_ttl(unsigned char ID_SOCKET, unsigned char ttl_value); +.endproc + +.proc ch395_set_ttl + ;;@brief This command is used to set Socket TTL. It is necessary to input 1 byte of Socket index value and 1 byte of TTL value. It shall be set after the Socket is opened, and the maximum value is 128 + ;;@inputA Socket ID + ;;@inputX TTL value + ldy #CH395_SET_TTL + sty CH395_COMMAND_PORT + sta CH395_DATA_PORT ; Send socket id + stx CH395_DATA_PORT ; Send TTL value + rts +.endproc diff --git a/src/6502/_ch395_tcp_connect_sn.s b/src/6502/_ch395_tcp_connect_sn.s index 0f76673..0b14ac8 100644 --- a/src/6502/_ch395_tcp_connect_sn.s +++ b/src/6502/_ch395_tcp_connect_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_tcp_connect_sn .export ch395_tcp_connect_sn diff --git a/src/6502/_ch395_tcp_disconnect_sn.s b/src/6502/_ch395_tcp_disconnect_sn.s index c1853a1..6dd28a8 100644 --- a/src/6502/_ch395_tcp_disconnect_sn.s +++ b/src/6502/_ch395_tcp_disconnect_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_tcp_disconnect_sn .export ch395_tcp_disconnect_sn diff --git a/src/6502/_ch395_tcp_listen_sn.s b/src/6502/_ch395_tcp_listen_sn.s index 670d465..62f21fd 100644 --- a/src/6502/_ch395_tcp_listen_sn.s +++ b/src/6502/_ch395_tcp_listen_sn.s @@ -1,6 +1,4 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .export _ch395_tcp_listen_sn .export ch395_tcp_listen_sn @@ -12,6 +10,7 @@ .proc ch395_tcp_listen_sn ;;@brief TCP listen socket ;;inputA SocketID + ;;modifyY ldy #CH395_TCP_LISTEN_SN sty CH395_COMMAND_PORT sta CH395_DATA_PORT ; Send socket id diff --git a/src/6502/_ch395_write_send_buf_sn.s b/src/6502/_ch395_write_send_buf_sn.s index 3459c07..eb184b6 100644 --- a/src/6502/_ch395_write_send_buf_sn.s +++ b/src/6502/_ch395_write_send_buf_sn.s @@ -1,16 +1,11 @@ -.ifndef CH395_COMMAND_PORT - .include "ch395.inc" -.endif +.include "ch395.inc" .import popax .importzp ptr1, ptr2 - .export _ch395_write_send_buf_sn .export ch395_write_send_buf_sn - - .proc ch395_write_send_buf_sn ;;@brief Send data to socketid ;;@inputA Socket ID diff --git a/src/include/ch395.h b/src/include/ch395.h index 60e73df..5561b21 100644 --- a/src/include/ch395.h +++ b/src/include/ch395.h @@ -41,6 +41,8 @@ unsigned char ch395_get_glob_int_status(); void ch395_clear_recv_buf_sn(unsigned char socket); void ch395_set_fun_para(unsigned char flag); void ch395_tcp_disconnect_sn(unsigned char ID_SOCKET); +void ch395_set_ttl(unsigned char ID_SOCKET, unsigned char ttl_value); + #define CH395_DETECTED 0xaa @@ -90,29 +92,29 @@ void ch395_tcp_disconnect_sn(unsigned char ID_SOCKET); #define CH395_SINT_STAT_SEND_OK 0x02 #define CH395_SINT_STAT_SENBUF_FREE 0x01 -#define CH395_PHY_DISCONN 0x01 -#define CH395_PHY_10M_FLL 0x02 -#define CH395_PHY_10M_HALF 0x04 -#define CH395_PHY_100M_FLL 0x08 -#define CH395_PHY_100M_HALF 0x10 - -#define CH395_SOCKET_CLOSED 0x00 -#define CH395_SOCKET_OPEN 0x05 - - -#define CH395_TCP_CLOSED 0x00 // Shutdown -#define CH395_TCP_LISTEN 0x01 -#define CH395_TCP_SYN_SENT 0x02 -#define CH395_TCP_SYN_REVD 0x03 -#define CH395_TCP_ESTABLISHED 0x04 -#define CH395_TCP_FIN_WAIT_1 0x05 -#define CH395_TCP_FIN_WAIT_2 0x06 -#define CH395_TCP_CLOSE_WAIT 0x07 -#define CH395_TCP_CLOSING 0x08 -#define CH395_TCP_LAST_ACK 0x09 -#define CH395_TCP_TIME_WAIT 0x0A - -#define CH395_FUN_PARA_FLAG_TCP_SERVER 0x02 -#define CH395_FUN_PARA_FLAG_LOW_PWR 0x04 -#define CH395_FUN_PARA_FLAG_SOCKET_CLOSE 0x08 -#define CH395_FUN_PARA_FLAG_DISABLE_SEND_OK 0x10 +#define CH395_PHY_DISCONN 0x01 +#define CH395_PHY_10M_FLL 0x02 +#define CH395_PHY_10M_HALF 0x04 +#define CH395_PHY_100M_FLL 0x08 +#define CH395_PHY_100M_HALF 0x10 + +#define CH395_SOCKET_CLOSED 0x00 +#define CH395_SOCKET_OPEN 0x05 + + +#define CH395_TCP_CLOSED 0x00 // Shutdown +#define CH395_TCP_LISTEN 0x01 +#define CH395_TCP_SYN_SENT 0x02 +#define CH395_TCP_SYN_REVD 0x03 +#define CH395_TCP_ESTABLISHED 0x04 +#define CH395_TCP_FIN_WAIT_1 0x05 +#define CH395_TCP_FIN_WAIT_2 0x06 +#define CH395_TCP_CLOSE_WAIT 0x07 +#define CH395_TCP_CLOSING 0x08 +#define CH395_TCP_LAST_ACK 0x09 +#define CH395_TCP_TIME_WAIT 0x0A + +#define CH395_FUN_PARA_FLAG_TCP_SERVER 0x02 +#define CH395_FUN_PARA_FLAG_LOW_PWR 0x04 +#define CH395_FUN_PARA_FLAG_SOCKET_CLOSE 0x08 +#define CH395_FUN_PARA_FLAG_DISABLE_SEND_OK 0x10 diff --git a/src/include/ch395.inc b/src/include/ch395.inc index b8cd4a8..2678eb5 100644 --- a/src/include/ch395.inc +++ b/src/include/ch395.inc @@ -97,59 +97,57 @@ CH395_DHCP_STATUS_DISABLED = $01 CH395_NUMBER_MAX_SOCKET = $08 -CH395_SOCKET0 = 0 -CH395_SOCKET1 = 1 -CH395_SOCKET2 = 2 -CH395_SOCKET3 = 3 -CH395_SOCKET4 = 4 -CH395_SOCKET5 = 5 -CH395_SOCKET6 = 6 -CH395_SOCKET7 = 7 - -CH395_PROTO_TYPE_TCP = $03 -CH395_PROTO_TYPE_UDP = $02 -CH395_PROTO_TYPE_MAC_RAW = $01 -CH395_PROTO_TYPE_IP_RAW = $00 - -CH395_SINT_STAT_TIM_OUT = $40 -CH395_SINT_STAT_DISCONNECT = $10 -CH395_SINT_STAT_CONNECT = $08 -CH395_SINT_STAT_RECV = $04 -CH395_SINT_STAT_SEND_OK = $02 -CH395_SINT_STAT_SENBUF_FREE = $01 - -CH395_PHY_DISCONN = $01 -CH395_PHY_10M_FLL = $02 -CH395_PHY_10M_HALF = $04 -CH395_PHY_100M_FLL = $08 -CH395_PHY_100M_HALF = $10 - -CH395_SOCKET_CLOSED = $00 -CH395_SOCKET_OPEN = $05 - -CH395_TCP_CLOSED = $00 -CH395_TCP_LISTEN = $01 -CH395_TCP_SYN_SENT = $02 -CH395_TCP_SYN_REVD = $03 -CH395_TCP_ESTABLISHED = $04 -CH395_TCP_FIN_WAIT_1 = $05 -CH395_TCP_FIN_WAIT_2 = $06 -CH395_TCP_CLOSE_WAIT = $07 -CH395_TCP_CLOSING = $08 -CH395_TCP_LAST_ACK = $09 -CH395_TCP_TIME_WAIT = $0A - -GINT_STAT_DHCP = $08 ; Duplicate and should be removed -CH395_GINT_STAT_DHCP = $08 - - -CH395_FUN_PARA_FLAG_TCP_SERVER = $02 -CH395_FUN_PARA_FLAG_LOW_PWR = $04 -CH395_FUN_PARA_FLAG_SOCKET_CLOSE = $08 -CH395_FUN_PARA_FLAG_DISABLE_SEND_OK = $10 - - -CH395_GINT_STAT_SOCK0 = 16 -CH395_GINT_STAT_SOCK1 = 32 -CH395_GINT_STAT_SOCK2 = 64 -CH395_GINT_STAT_SOCK3 = 128 +CH395_SOCKET0 = 0 +CH395_SOCKET1 = 1 +CH395_SOCKET2 = 2 +CH395_SOCKET3 = 3 +CH395_SOCKET4 = 4 +CH395_SOCKET5 = 5 +CH395_SOCKET6 = 6 +CH395_SOCKET7 = 7 + +CH395_PROTO_TYPE_TCP = $03 +CH395_PROTO_TYPE_UDP = $02 +CH395_PROTO_TYPE_MAC_RAW = $01 +CH395_PROTO_TYPE_IP_RAW = $00 + +CH395_SINT_STAT_TIM_OUT = $40 +CH395_SINT_STAT_DISCONNECT = $10 +CH395_SINT_STAT_CONNECT = $08 +CH395_SINT_STAT_RECV = $04 +CH395_SINT_STAT_SEND_OK = $02 +CH395_SINT_STAT_SENBUF_FREE = $01 + +CH395_PHY_DISCONN = $01 +CH395_PHY_10M_FLL = $02 +CH395_PHY_10M_HALF = $04 +CH395_PHY_100M_FLL = $08 +CH395_PHY_100M_HALF = $10 + +CH395_SOCKET_CLOSED = $00 +CH395_SOCKET_OPEN = $05 + +CH395_TCP_CLOSED = $00 +CH395_TCP_LISTEN = $01 +CH395_TCP_SYN_SENT = $02 +CH395_TCP_SYN_REVD = $03 +CH395_TCP_ESTABLISHED = $04 +CH395_TCP_FIN_WAIT_1 = $05 +CH395_TCP_FIN_WAIT_2 = $06 +CH395_TCP_CLOSE_WAIT = $07 +CH395_TCP_CLOSING = $08 +CH395_TCP_LAST_ACK = $09 +CH395_TCP_TIME_WAIT = $0A + +GINT_STAT_DHCP = $08 ; Duplicate and should be removed +CH395_GINT_STAT_DHCP = $08 + +CH395_FUN_PARA_FLAG_TCP_SERVER = $02 +CH395_FUN_PARA_FLAG_LOW_PWR = $04 +CH395_FUN_PARA_FLAG_SOCKET_CLOSE = $08 +CH395_FUN_PARA_FLAG_DISABLE_SEND_OK = $10 + +CH395_GINT_STAT_SOCK0 = 16 +CH395_GINT_STAT_SOCK1 = 32 +CH395_GINT_STAT_SOCK2 = 64 +CH395_GINT_STAT_SOCK3 = 128