Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jedeoric committed Mar 24, 2024
1 parent 54d15a2 commit b8f0155
Show file tree
Hide file tree
Showing 27 changed files with 332 additions and 81 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ $(OBJECTS8): $(SOURCES8)
@cp ch395-8.lib build/lib8/
@cp ch395-8.lib target/telestrat/lib/

test:
$(CC) -ttelestrat -I src/include test/ch395.c target/telestrat/lib/ch395-8.lib -o ch395

tool:
@mkdir -p target/telestrat/ch395cfg/
$(CC) -ttelestrat -I src/include tools/ch395cfg/src/main.c target/telestrat/lib/ch395-8.lib -o target/telestrat/ch395cfg/ch395cfg
Expand Down
39 changes: 31 additions & 8 deletions docs/api/2024.2/assembly/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ <h2 id="ch395_get_ic_ver">ch395_get_ic_ver</h2>
<hr>
<h2 id="ch395_get_int_status_sn">ch395_get_int_status_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>This command is used to get the interrupt status of Socket. It is necessary to input 1 byte of Socket index</p>
<p>This command is used to get the interrupt status of Socket. It is necessary to input 1 byte of Socket index value. After receiving this command, CH395 will output 1 byte of Socket interrupt code. The interrupt code bits are defined as follows:</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand Down Expand Up @@ -1504,7 +1504,7 @@ <h2 id="ch395_init">ch395_init</h2>
<hr>
<h2 id="ch395_open_socket_sn">ch395_open_socket_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Open socket from arg</p>
<p>This command is used to open Socket and use the necessary steps of Socket. It is necessary to input 1 byte of Socket index value. After sending this command, MCU shall send GET_CMD_STATUS to query the command execution status. After opening Socket in UDP, IPRAW or MACRAW mode and returning successfully, data transmission can be performed. Before this command is sent, necessary settings must be made for destination IP, protocol type, source port, destination port, etc. Please refer to 8.3 Application Reference Steps for detailed steps.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand Down Expand Up @@ -1543,7 +1543,7 @@ <h2 id="ch395_set_baudrate">ch395_set_baudrate</h2>
<hr>
<h2 id="ch395_set_des_port_sn">ch395_set_des_port_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Set dest port socket</p>
<p>This command is used to set the Socket destination port. It is necessary to input 1 byte of Socket index value and 2 bytes of destination port (the low bytes are in front). When Socket works in UDP or TCP Client mode, this value must be set.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socketid </li>
Expand Down Expand Up @@ -1591,11 +1591,14 @@ <h2 id="ch395_set_ip_addr">ch395_set_ip_addr</h2>
<hr>
<h2 id="ch395_set_ip_addr_sn">ch395_set_ip_addr_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Set Socket Ip address to connect with</p>
<p>This command is used to set the destination IP address of Socket. It is necessary to input 1 byte of Socket index value and 4 bytes of destination IP address. When Socket works in IPRAW, UDP, or TCP Client mode, 0the destination IP must be set before the command CMD_OPEN_SOCKET_SN is sent</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
<li>Y Register : low ptr ip</li>
<li>X Register : high ptr ip</li>
</ul>
<p><strong><em>Modify</em></strong></p>
<hr>
<h2 id="ch395_set_ipraw_pro_sn">ch395_set_ipraw_pro_sn</h2>
<p><strong><em>Description</em></strong></p>
Expand Down Expand Up @@ -1645,6 +1648,15 @@ <h2 id="ch395_set_phy">ch395_set_phy</h2>
</div>
<hr>
<h2 id="ch395_set_proto_type_sn">ch395_set_proto_type_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>This command is used to set the working mode of Socket. It is necessary to input 1 byte of Socket index value and 1 byte of working mode. The working mode is defined as follows:</p>
<p>Code Name Description</p>
<p>03H PROTO_TYPE_TCP TCP mode</p>
<p>02H PROTO_TYPE_UDP UDP mode</p>
<p>01H PROTO_TYPE_MAC_RAW MAC original message mode</p>
<p>00H PROTO_TYPE_IP_RAW IP original message mode</p>
<p>This command must be executed before CMD_OPEN_SOCKET_SN. Refer to 8.3 Application Reference</p>
<p>Steps for detailed steps.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand All @@ -1657,6 +1669,10 @@ <h2 id="ch395_set_retran_count">ch395_set_retran_count</h2>
<ul>
<li>Accumulator : Retran period</li>
</ul>
<p><strong><em>Modify</em></strong></p>
<ul>
<li>X Register </li>
</ul>
<hr>
<h2 id="ch395_set_retran_period">ch395_set_retran_period</h2>
<p><strong><em>Description</em></strong></p>
Expand All @@ -1679,7 +1695,7 @@ <h2 id="ch395_set_retran_period">ch395_set_retran_period</h2>
<hr>
<h2 id="ch395_set_sour_port_sn">ch395_set_sour_port_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Set source port</p>
<p>This command is used to set the source port of Socket. It is necessary to input 1 byte of Socket index value and 2 bytes of source port (low bytes in front). If two or more Sockets are in the same mode, the source port numbers must not be the same. For example, Socket 0 is in UDP mode, the source port number is 600, and Socket 1 is also in UDP mode. The source port number 600 cannot be used again, otherwise it may cause the0 opening failure.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand All @@ -1699,6 +1715,10 @@ <h2 id="ch395_set_ttl">ch395_set_ttl</h2>
<li>Accumulator : Socket ID</li>
<li>X Register : TTL value</li>
</ul>
<p><strong><em>Modify</em></strong></p>
<ul>
<li>Y Register </li>
</ul>
<hr>
<h2 id="ch395_tcp_connect_sn">ch395_tcp_connect_sn</h2>
<p><strong><em>Input</em></strong></p>
Expand All @@ -1714,11 +1734,11 @@ <h2 id="ch395_tcp_disconnect_sn">ch395_tcp_disconnect_sn</h2>
<hr>
<h2 id="ch395_tcp_listen_sn">ch395_tcp_listen_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>TCP listen socket</p>
<p>This command is only valid in TCP mode, enabling the Socket to be in the monitoring mode, namely, TCP Server mode. It is necessary to input a 1 byte of Socket index value. This command must be executed after OPEN_SOCKET_SN. After sending this command, MCU shall send GET_CMD_STATUS to query the 0command execution status. In TCP Server mode, the Socket will always detect connection events, and the interrupt SINT_STAT_CONNECT will be generated until the connection is successful. Only one connection can be 0established for each Socket. If an eligible connection event is received again, Socket will send TCP RESET to the remote end tried to be connected.</p>
<hr>
<h2 id="ch395_write_send_buf_sn">ch395_write_send_buf_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Send data to socketid</p>
<p>This command is used to write data to Socket transmit buffer. It is necessary to input 1 byte of Socket index value, 2 bytes of length (low bytes in front) and several bytes of data stream. The length of input data must not be larger than the size of transmit buffer. However, in MACRAW mode, the maximum length of input data can only be 1514, and any redundant data will be discarded. After the external MCU writes the data, CH395 will encapsulate the data packet according to the working mode of Socket, and then send it. Before MCU receives SINT_STAT_SENBUF_FREE, it is not allowed to write data into Socket transmit buffer again</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket ID</li>
Expand All @@ -1729,7 +1749,10 @@ <h2 id="ch395_write_send_buf_sn">ch395_write_send_buf_sn</h2>
<p><strong><em>Modify</em></strong></p>
<ul>
<li>RESTmp</li>
</ul></div>
</ul>
<p><strong><em>Example</em></strong></p>
<div class="highlight"><pre><span></span><code>
</code></pre></div></div>

<hr>
<div class="md-source-file">
Expand Down
25 changes: 22 additions & 3 deletions docs/api/2024.2/c/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@
<div><h1 id="c">C</h1>
<h2 id="unsigned-char-ch395_check_exist">unsigned char ch395_check_exist();</h2>
<p><strong><em>Description</em></strong></p>
<p>Checks if ch395 exists</p>
<p>This command is used to test the communication interface and working state to check whether CH395 is working properly. This command needs to input 1 byte of data, which can be any data. If CH395 is working properly, the output data of CH395 will be the bitwise reverse of the input data. For example, if the input data is 57H, the output data will be A8H.</p>
<h2 id="void-ch395_clear_recv_buf_snunsigned-char-id_socket">void ch395_clear_recv_buf_sn(unsigned char ID_SOCKET)</h2>
<p><strong><em>Description</em></strong></p>
<p>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.</p>
Expand All @@ -1047,7 +1047,26 @@ <h2 id="unsigned-int-ch395_get_glob_int_status">unsigned int ch395_get_glob_int_
<p>Get General interrupt Status</p>
<h2 id="unsigned-char-ch395_get_ic_ver">unsigned char ch395_get_ic_ver();</h2>
<p><strong><em>Description</em></strong></p>
<p>Get ch395 firmware version</p>
<p>;;@brief This command is used to get the chip and firmware versions. 1 byte of data returned is the version number, the bit 7 is 0, the bit 6 is 1, and the bits 5-0 are the version number. If the returned value is 41H, remove bits 7 and 6, and the version number will be 01H. It is called chip version in this text</p>
<p>;;@inputA Socket id
;;@modifyA
;;@modifyX
;;@returnsA Status of selected socket
;;@<code>ca65
;;@` lda #CH395_SOCKET1 ; Check socket 1
;;@` jsr ch395_get_int_status_sn
;;@` ; Check interrupt type
;;@` and #CH395_SINT_STAT_SEND_OK
;;@` cmp #CH395_SINT_STAT_SEND_OK
;;@` beq @send_ok
;;@` rts
;;@</code>
ldx #CH395_GET_INT_STATUS_SN
stx CH395_COMMAND_PORT
sta CH395_DATA_PORT
lda CH395_DATA_PORT
rts
endproc</p>
<h2 id="unsigned-char-ch395_get_int_status_snunsigned-char-id_socket">unsigned char ch395_get_int_status_sn(unsigned char ID_SOCKET);</h2>
<p><strong><em>Description</em></strong></p>
<p>Check interrupt socket status</p>
Expand Down Expand Up @@ -1093,7 +1112,7 @@ <h2 id="void-ch395_set_fun_paraunsigned-char-flag">void ch395_set_fun_para(unsig
<p><strong><em>Description</em></strong></p>
<p>Set gateway ip addr</p>
<p><strong><em>Description</em></strong></p>
<p>Set ip addr</p>
<p>This command is used to set the destination IP address of Socket. It is necessary to input 1 byte of Socket index value and 4 bytes of destination IP address. When Socket works in IPRAW, UDP, or TCP Client mode, 0the destination IP must be set before the command CMD_OPEN_SOCKET_SN is sent</p>
<h2 id="void-ch395_set_ip_addr_snunsigned-char-ip_addr-unsigned-char-id_socket">void ch395_set_ip_addr_sn(unsigned char ip_addr[], unsigned char ID_SOCKET)</h2>
<h2 id="void-ch395_set_ipraw_pro_snunsigned-char-id_socket">void ch395_set_ipraw_pro_sn(unsigned char ID_SOCKET);</h2>
<p><strong><em>Description</em></strong></p>
Expand Down
39 changes: 31 additions & 8 deletions docs/api/assembly/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ <h2 id="ch395_get_ic_ver">ch395_get_ic_ver</h2>
<hr>
<h2 id="ch395_get_int_status_sn">ch395_get_int_status_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>This command is used to get the interrupt status of Socket. It is necessary to input 1 byte of Socket index</p>
<p>This command is used to get the interrupt status of Socket. It is necessary to input 1 byte of Socket index value. After receiving this command, CH395 will output 1 byte of Socket interrupt code. The interrupt code bits are defined as follows:</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand Down Expand Up @@ -1158,7 +1158,7 @@ <h2 id="ch395_init">ch395_init</h2>
<hr>
<h2 id="ch395_open_socket_sn">ch395_open_socket_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Open socket from arg</p>
<p>This command is used to open Socket and use the necessary steps of Socket. It is necessary to input 1 byte of Socket index value. After sending this command, MCU shall send GET_CMD_STATUS to query the command execution status. After opening Socket in UDP, IPRAW or MACRAW mode and returning successfully, data transmission can be performed. Before this command is sent, necessary settings must be made for destination IP, protocol type, source port, destination port, etc. Please refer to 8.3 Application Reference Steps for detailed steps.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand Down Expand Up @@ -1197,7 +1197,7 @@ <h2 id="ch395_set_baudrate">ch395_set_baudrate</h2>
<hr>
<h2 id="ch395_set_des_port_sn">ch395_set_des_port_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Set dest port socket</p>
<p>This command is used to set the Socket destination port. It is necessary to input 1 byte of Socket index value and 2 bytes of destination port (the low bytes are in front). When Socket works in UDP or TCP Client mode, this value must be set.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socketid </li>
Expand Down Expand Up @@ -1245,11 +1245,14 @@ <h2 id="ch395_set_ip_addr">ch395_set_ip_addr</h2>
<hr>
<h2 id="ch395_set_ip_addr_sn">ch395_set_ip_addr_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Set Socket Ip address to connect with</p>
<p>This command is used to set the destination IP address of Socket. It is necessary to input 1 byte of Socket index value and 4 bytes of destination IP address. When Socket works in IPRAW, UDP, or TCP Client mode, 0the destination IP must be set before the command CMD_OPEN_SOCKET_SN is sent</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
<li>Y Register : low ptr ip</li>
<li>X Register : high ptr ip</li>
</ul>
<p><strong><em>Modify</em></strong></p>
<hr>
<h2 id="ch395_set_ipraw_pro_sn">ch395_set_ipraw_pro_sn</h2>
<p><strong><em>Description</em></strong></p>
Expand Down Expand Up @@ -1299,6 +1302,15 @@ <h2 id="ch395_set_phy">ch395_set_phy</h2>
</div>
<hr>
<h2 id="ch395_set_proto_type_sn">ch395_set_proto_type_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>This command is used to set the working mode of Socket. It is necessary to input 1 byte of Socket index value and 1 byte of working mode. The working mode is defined as follows:</p>
<p>Code Name Description</p>
<p>03H PROTO_TYPE_TCP TCP mode</p>
<p>02H PROTO_TYPE_UDP UDP mode</p>
<p>01H PROTO_TYPE_MAC_RAW MAC original message mode</p>
<p>00H PROTO_TYPE_IP_RAW IP original message mode</p>
<p>This command must be executed before CMD_OPEN_SOCKET_SN. Refer to 8.3 Application Reference</p>
<p>Steps for detailed steps.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand All @@ -1311,6 +1323,10 @@ <h2 id="ch395_set_retran_count">ch395_set_retran_count</h2>
<ul>
<li>Accumulator : Retran period</li>
</ul>
<p><strong><em>Modify</em></strong></p>
<ul>
<li>X Register </li>
</ul>
<hr>
<h2 id="ch395_set_retran_period">ch395_set_retran_period</h2>
<p><strong><em>Description</em></strong></p>
Expand All @@ -1333,7 +1349,7 @@ <h2 id="ch395_set_retran_period">ch395_set_retran_period</h2>
<hr>
<h2 id="ch395_set_sour_port_sn">ch395_set_sour_port_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Set source port</p>
<p>This command is used to set the source port of Socket. It is necessary to input 1 byte of Socket index value and 2 bytes of source port (low bytes in front). If two or more Sockets are in the same mode, the source port numbers must not be the same. For example, Socket 0 is in UDP mode, the source port number is 600, and Socket 1 is also in UDP mode. The source port number 600 cannot be used again, otherwise it may cause the0 opening failure.</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket id</li>
Expand All @@ -1353,6 +1369,10 @@ <h2 id="ch395_set_ttl">ch395_set_ttl</h2>
<li>Accumulator : Socket ID</li>
<li>X Register : TTL value</li>
</ul>
<p><strong><em>Modify</em></strong></p>
<ul>
<li>Y Register </li>
</ul>
<hr>
<h2 id="ch395_tcp_connect_sn">ch395_tcp_connect_sn</h2>
<p><strong><em>Input</em></strong></p>
Expand All @@ -1368,11 +1388,11 @@ <h2 id="ch395_tcp_disconnect_sn">ch395_tcp_disconnect_sn</h2>
<hr>
<h2 id="ch395_tcp_listen_sn">ch395_tcp_listen_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>TCP listen socket</p>
<p>This command is only valid in TCP mode, enabling the Socket to be in the monitoring mode, namely, TCP Server mode. It is necessary to input a 1 byte of Socket index value. This command must be executed after OPEN_SOCKET_SN. After sending this command, MCU shall send GET_CMD_STATUS to query the 0command execution status. In TCP Server mode, the Socket will always detect connection events, and the interrupt SINT_STAT_CONNECT will be generated until the connection is successful. Only one connection can be 0established for each Socket. If an eligible connection event is received again, Socket will send TCP RESET to the remote end tried to be connected.</p>
<hr>
<h2 id="ch395_write_send_buf_sn">ch395_write_send_buf_sn</h2>
<p><strong><em>Description</em></strong></p>
<p>Send data to socketid</p>
<p>This command is used to write data to Socket transmit buffer. It is necessary to input 1 byte of Socket index value, 2 bytes of length (low bytes in front) and several bytes of data stream. The length of input data must not be larger than the size of transmit buffer. However, in MACRAW mode, the maximum length of input data can only be 1514, and any redundant data will be discarded. After the external MCU writes the data, CH395 will encapsulate the data packet according to the working mode of Socket, and then send it. Before MCU receives SINT_STAT_SENBUF_FREE, it is not allowed to write data into Socket transmit buffer again</p>
<p><strong><em>Input</em></strong></p>
<ul>
<li>Accumulator : Socket ID</li>
Expand All @@ -1383,7 +1403,10 @@ <h2 id="ch395_write_send_buf_sn">ch395_write_send_buf_sn</h2>
<p><strong><em>Modify</em></strong></p>
<ul>
<li>RESTmp</li>
</ul></div>
</ul>
<p><strong><em>Example</em></strong></p>
<div class="highlight"><pre><span></span><code>
</code></pre></div></div>

<hr>
<div class="md-source-file">
Expand Down
Loading

0 comments on commit b8f0155

Please sign in to comment.