summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/display/ssd1306.py21
-rw-r--r--drivers/wiznet5k/ethernet/socket.c13
-rw-r--r--drivers/wiznet5k/ethernet/w5500/w5500.c10
-rw-r--r--drivers/wiznet5k/ethernet/w5500/w5500.h1
-rw-r--r--drivers/wiznet5k/ethernet/wizchip_conf.h2
5 files changed, 28 insertions, 19 deletions
diff --git a/drivers/display/ssd1306.py b/drivers/display/ssd1306.py
index d65f2d350..cd358d00e 100644
--- a/drivers/display/ssd1306.py
+++ b/drivers/display/ssd1306.py
@@ -1,7 +1,6 @@
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
from micropython import const
-import time
import framebuf
@@ -47,7 +46,6 @@ class SSD1306:
self.text = fb.text
self.scroll = fb.scroll
self.blit = fb.blit
- self.poweron()
self.init_display()
def init_display(self):
@@ -80,6 +78,9 @@ class SSD1306:
def poweroff(self):
self.write_cmd(SET_DISP | 0x00)
+ def poweron(self):
+ self.write_cmd(SET_DISP | 0x01)
+
def contrast(self, contrast):
self.write_cmd(SET_CONTRAST)
self.write_cmd(contrast)
@@ -123,9 +124,6 @@ class SSD1306_I2C(SSD1306):
self.i2c.write(buf)
self.i2c.stop()
- def poweron(self):
- pass
-
class SSD1306_SPI(SSD1306):
def __init__(self, width, height, spi, dc, res, cs, external_vcc=False):
@@ -137,6 +135,12 @@ class SSD1306_SPI(SSD1306):
self.dc = dc
self.res = res
self.cs = cs
+ import time
+ self.res(1)
+ time.sleep_ms(1)
+ self.res(0)
+ time.sleep_ms(10)
+ self.res(1)
super().__init__(width, height, external_vcc)
def write_cmd(self, cmd):
@@ -154,10 +158,3 @@ class SSD1306_SPI(SSD1306):
self.cs(0)
self.spi.write(buf)
self.cs(1)
-
- def poweron(self):
- self.res(1)
- time.sleep_ms(1)
- self.res(0)
- time.sleep_ms(10)
- self.res(1)
diff --git a/drivers/wiznet5k/ethernet/socket.c b/drivers/wiznet5k/ethernet/socket.c
index 129473ad4..ec25fcc79 100644
--- a/drivers/wiznet5k/ethernet/socket.c
+++ b/drivers/wiznet5k/ethernet/socket.c
@@ -52,10 +52,9 @@
#include <string.h>
+#include "py/mpthread.h"
#include "socket.h"
-extern void HAL_Delay(uint32_t);
-
#define SOCK_ANY_PORT_NUM 0xC000;
static uint16_t sock_any_port = SOCK_ANY_PORT_NUM;
@@ -242,7 +241,7 @@ int8_t WIZCHIP_EXPORT(connect)(uint8_t sn, uint8_t * addr, uint16_t port)
#endif
return SOCKERR_TIMEOUT;
}
- HAL_Delay(1);
+ MICROPY_THREAD_YIELD();
}
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
setSUBR((uint8_t*)"\x00\x00\x00\x00");
@@ -317,6 +316,7 @@ int32_t WIZCHIP_EXPORT(send)(uint8_t sn, uint8_t * buf, uint16_t len)
}
if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
if(len <= freesize) break;
+ MICROPY_THREAD_YIELD();
}
wiz_send_data(sn, buf, len);
#if _WIZCHIP_ == 5200
@@ -368,7 +368,7 @@ int32_t WIZCHIP_EXPORT(recv)(uint8_t sn, uint8_t * buf, uint16_t len)
}
if((sock_io_mode & (1<<sn)) && (recvsize == 0)) return SOCK_BUSY;
if(recvsize != 0) break;
- HAL_Delay(1);
+ MICROPY_THREAD_YIELD();
};
if(recvsize < len) len = recvsize;
wiz_recv_data(sn, buf, len);
@@ -416,7 +416,7 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED;
if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
if(len <= freesize) break;
- HAL_Delay(1);
+ MICROPY_THREAD_YIELD();
};
wiz_send_data(sn, buf, len);
@@ -446,7 +446,7 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
return SOCKERR_TIMEOUT;
}
////////////
- HAL_Delay(1);
+ MICROPY_THREAD_YIELD();
}
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
setSUBR((uint8_t*)"\x00\x00\x00\x00");
@@ -486,6 +486,7 @@ int32_t WIZCHIP_EXPORT(recvfrom)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_
if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED;
if( (sock_io_mode & (1<<sn)) && (pack_len == 0) ) return SOCK_BUSY;
if(pack_len != 0) break;
+ MICROPY_THREAD_YIELD();
};
}
sock_pack_info[sn] = PACK_COMPLETED;
diff --git a/drivers/wiznet5k/ethernet/w5500/w5500.c b/drivers/wiznet5k/ethernet/w5500/w5500.c
index 6b3111f99..3107b1b71 100644
--- a/drivers/wiznet5k/ethernet/w5500/w5500.c
+++ b/drivers/wiznet5k/ethernet/w5500/w5500.c
@@ -57,6 +57,16 @@
////////////////////////////////////////////////////
+#define LPC_SSP0 (0)
+
+static void Chip_SSP_ReadFrames_Blocking(int dummy, uint8_t *buf, uint32_t len) {
+ WIZCHIP.IF.SPI._read_bytes(buf, len);
+}
+
+static void Chip_SSP_WriteFrames_Blocking(int dummy, const uint8_t *buf, uint32_t len) {
+ WIZCHIP.IF.SPI._write_bytes(buf, len);
+}
+
uint8_t WIZCHIP_READ(uint32_t AddrSel)
{
uint8_t ret;
diff --git a/drivers/wiznet5k/ethernet/w5500/w5500.h b/drivers/wiznet5k/ethernet/w5500/w5500.h
index f0ffcb0c8..c2afb180e 100644
--- a/drivers/wiznet5k/ethernet/w5500/w5500.h
+++ b/drivers/wiznet5k/ethernet/w5500/w5500.h
@@ -44,7 +44,6 @@
#include <stdint.h>
#include "../wizchip_conf.h"
-#include "board.h"
#define _W5500_IO_BASE_ 0x00000000
diff --git a/drivers/wiznet5k/ethernet/wizchip_conf.h b/drivers/wiznet5k/ethernet/wizchip_conf.h
index 55c79ae0a..4a7a7bd69 100644
--- a/drivers/wiznet5k/ethernet/wizchip_conf.h
+++ b/drivers/wiznet5k/ethernet/wizchip_conf.h
@@ -56,7 +56,9 @@
* @todo You should select one, \b 5100, \b 5200 ,\b 5500 or etc. \n\n
* ex> <code> #define \_WIZCHIP_ 5500 </code>
*/
+#ifndef _WIZCHIP_
#define _WIZCHIP_ 5200 // 5100, 5200, 5500
+#endif
#define _WIZCHIP_IO_MODE_NONE_ 0x0000
#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */