8000 stmhal, modwiznet5k: Add very minimal documentation. · mimoccc/circuitpython@bad2df3 · GitHub
[go: up one dir, main page]

Skip to content

Commit bad2df3

Browse files
committed
stmhal, modwiznet5k: Add very minimal documentation.
1 parent bcf041f commit bad2df3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

stmhal/modwiznet5k.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@
4646
#include "ethernet/socket.h"
4747
#include "internet/dns/dns.h"
4848

49+
/// \module wiznet5k - control WIZnet5x00 Ethernet adaptors
50+
///
51+
/// This module allows you to control WIZnet5x00 Ethernet adaptors based on
52+
/// the W5200 and W5500 chipsets (only W5200 tested).
53+
///
54+
/// Example usage:
55+
///
56+
/// import wiznet5k
57+
/// w = wiznet5k.WIZnet5k()
58+
/// print(w.ipaddr())
59+
/// w.gethostbyname('micropython.org')
60+
/// s = w.socket()
61+
/// s.connect(('192.168.0.2', 8080))
62+
/// s.send('hello')
63+
/// print(s.recv(10))
64+
4965
#define IPADDR_BUF_SIZE (4)
5066

5167
STATIC const mp_obj_type_t wiznet5k_type;
@@ -157,7 +173,7 @@ STATIC void wiznet5k_print(void (*print)(void *env, const char *fmt, ...), void
157173
}
158174

159175
/// \classmethod \constructor()
160-
/// Create and return a wiznet5k object.
176+
/// Create and return a WIZnet5k object.
161177
STATIC mp_obj_t wiznet5k_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
162178
// check arguments
163179
mp_arg_check_num(n_args, n_kw, 0, 0, false);
@@ -277,6 +293,8 @@ STATIC mp_obj_t wiznet5k_ipaddr(mp_uint_t n_args, const mp_obj_t *args) {
277293
}
278294
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(wiznet5k_ipaddr_obj, 1, 2, wiznet5k_ipaddr);
279295

296+
/// \method socket(family=AF_INET, type=SOCK_STREAM, fileno=-1)
297+
/// Create a socket.
280298
STATIC const mp_arg_t wiznet5k_socket_args[] = {
281299
{ MP_QSTR_family, MP_ARG_INT, {.u_int = 0} }, // ignored, only AF_INET supported
282300
{ MP_QSTR_type, MP_ARG_INT, {.u_int = Sn_MR_TCP} }, // SOCK_STREAM or SOCK_DGRAM
@@ -307,6 +325,8 @@ STATIC mp_obj_t wiznet5k_socket(mp_uint_t n_args, const mp_obj_t *args, mp_map_t
307325
}
308326
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wiznet5k_socket_obj, 1, wiznet5k_socket);
309327

328+
/// \method gethostbyname(name)
329+
/// Use DNS to lookup a host name. Returns an IP address.
310330
STATIC mp_obj_t wiznet5k_gethostbyname(mp_obj_t self_in, mp_obj_t name_in) {
311331
uint8_t dns_ip[IPADDR_BUF_SIZE] = {8, 8, 8, 8};
312332
const char *name = mp_obj_str_get_str(name_in);

0 commit comments

Comments
 (0)
0