Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jedeoric committed Mar 18, 2024
1 parent a7fa1e8 commit 0cb2a66
Show file tree
Hide file tree
Showing 39 changed files with 175 additions and 202 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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é.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.1
2024.2
4 changes: 2 additions & 2 deletions src/6502/_ch395_check_exist.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
;;@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

.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
Expand Down
4 changes: 2 additions & 2 deletions src/6502/_ch395_clear_recv_buf_sn.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

.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);
;;@```
.endproc


.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
Expand Down
6 changes: 3 additions & 3 deletions src/6502/_ch395_close_socket_sn.s
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/6502/_ch395_dhcp_enable.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/6502/_ch395_get_cmd_status.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_get_dhcp_status.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_get_glob_int_status.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/6502/_ch395_get_ic_ver.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_get_int_status_sn.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/6502/_ch395_get_ip_inf.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_get_mac_adress.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ifndef CH395_COMMAND_PORT
.include "ch395.inc"
.endif
.include "ch395.inc"

.ifndef ptr1
.importzp ptr1
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_get_phy_status.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_get_recv_len_sn.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 12 additions & 8 deletions src/6502/_ch395_get_remot_ipp_sn.s
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,6 +14,15 @@
;;@modifyA
;;@modifyX
;;@modifyY
;;@```ca65
;;@` lda #$01 ; Socket 1
;;@` ldx #<ip_dest
;;@` ldy #>ip_dest
;;@` jsr ch395_get_remot_ipp_sn
;;@` rts
;;@`ipdest:
;;@` .byte 192,168,0,1
;;@```

sty ptr1
stx ptr1+1
Expand Down
7 changes: 3 additions & 4 deletions src/6502/_ch395_get_socket_status_sn.s
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_init.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ifndef CH395_COMMAND_PORT
.include "../include/ch395.inc"
.endif
.include "ch395.inc"

.export _ch395_init
.export ch395_init
Expand Down
5 changes: 2 additions & 3 deletions src/6502/_ch395_open_socket_sn.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/6502/_ch395_read_recv_buf_sn.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.ifndef CH395_COMMAND_PORT

.include "ch395.inc"
.endif

.import popax
.importzp ptr1, ptr2
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_reset_all.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ifndef CH395_COMMAND_PORT
.include "ch395.inc"
.endif
.include "ch395.inc"

.export _ch395_reset_all
.export ch395_reset_all
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_retran_period.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ifndef CH395_COMMAND_PORT
.include "ch395.inc"
.endif
.include "ch395.inc"

.export _ch395_retran_period
.export ch395_retran_period
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_set_des_port_sn.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ifndef CH395_COMMAND_PORT
.include "ch395.inc"
.endif
.include "ch395.inc"

.importzp ptr1
.import popax
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_set_fun_para.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_set_gwip_addr.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_set_ip_addr.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/6502/_ch395_set_ip_addr_sn.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.ifndef CH395_COMMAND_PORT
.include "ch395.inc"
.endif
.include "ch395.inc"


.ifndef ptr1
.importzp ptr1
Expand Down
10 changes: 4 additions & 6 deletions src/6502/_ch395_set_ipraw_pro_sn.s
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/6502/_ch395_set_mac_adress.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_set_proto_type_sn.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ifndef CH395_COMMAND_PORT
.include "ch395.inc"
.endif
.include "ch395.inc"

.import popa

Expand Down
5 changes: 2 additions & 3 deletions src/6502/_ch395_set_retran_count.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/6502/_ch395_set_sour_port_sn.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ifndef CH395_COMMAND_PORT
.include "ch395.inc"
.endif
.include "ch395.inc"

.import popax
.importzp ptr1
Expand Down
20 changes: 20 additions & 0 deletions src/6502/_ch395_set_ttl.s
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 0cb2a66

Please sign in to comment.