Select Git revision
fsusermount.c
modwiznet5k.c 19.86 KiB
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include "stm32f4xx_hal.h"
#include "mpconfig.h"
#include "nlr.h"
#include "misc.h"
#include "qstr.h"
#include "obj.h"
#include "runtime.h"
#include "pin.h"
#include "genhdr/pins.h"
#include "spi.h"
#include MICROPY_HAL_H
#include "ethernet/wizchip_conf.h"
#include "ethernet/socket.h"
#include "internet/dns/dns.h"
/// \module wiznet5k - control WIZnet5x00 Ethernet adaptors
///
/// This module allows you to control WIZnet5x00 Ethernet adaptors based on
/// the W5200 and W5500 chipsets (only W5200 tested).
///
/// Example usage:
///
/// import wiznet5k
/// w = wiznet5k.WIZnet5k()
/// print(w.ipaddr())
/// w.gethostbyname('micropython.org')
/// s = w.socket()
/// s.connect(('192.168.0.2', 8080))
/// s.send('hello')
/// print(s.recv(10))
#define IPADDR_BUF_SIZE (4)
STATIC const mp_obj_type_t wiznet5k_type;
STATIC const mp_obj_type_t wiznet5k_socket_type;
STATIC mp_obj_t wiznet5k_socket_new(uint8_t sn, mp_uint_t type);