fix: spi dma

Squashed commit of the following:

commit f0df85e2d18ff36b04443ddb23e645cbbd5bfa58
Author: kuwoyuki <kuwoyuki@cock.li>
Date:   Wed Oct 16 01:36:26 2024 +0600

    fix: SPI DMA

    wait for SPI TXE and BSY flags, also fix korean lib

commit a16b9f769807a78803ba1d7cd10a4a4843827bb2
Author: kuwoyuki <kuwoyuki@cock.li>
Date:   Tue Oct 15 21:09:59 2024 +0600

    moar log

commit 0c457e17ffb956cb5fbbc40865e62f8acf8f2eea
Author: kuwoyuki <kuwoyuki@cock.li>
Date:   Tue Oct 15 14:09:31 2024 +0600

    _

commit a0b6820bc1312e429d04bf0bb39bc2a8b234cfc5
Author: kuwoyuki <kuwoyuki@cock.li>
Date:   Tue Oct 15 13:55:24 2024 +0600

    rewrite w/o interrupts

commit 83c2ab75b326be098bc15698d77ab650b14613e0
Author: kuwoyuki <kuwoyuki@cock.li>
Date:   Tue Oct 15 13:01:41 2024 +0600

    dma config

commit d871fef77d7c1838ac84f02a499f5555f78bc9ce
Author: kuwoyuki <kuwoyuki@cock.li>
Date:   Tue Oct 15 04:47:23 2024 +0600

    more dma
This commit is contained in:
2024-10-16 01:37:31 +06:00
parent 74bc0d25b7
commit 40f1cab745
11 changed files with 145 additions and 150 deletions

View File

@@ -54,6 +54,7 @@
//
//*****************************************************************************
#include "socket.h"
#include <stdio.h>
//M20150401 : Typing Error
//#define SOCK_ANY_PORT_NUM 0xC000;
@@ -507,6 +508,7 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t
return SOCKERR_SOCKMODE;
}
CHECK_SOCKDATA();
//M20140501 : For avoiding fatal error on memory align mismatched
//if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
//{
@@ -518,24 +520,37 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t
//}
//
//if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID;
if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO;
if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) {
return SOCKERR_IPINVALID;
}
if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) {
return SOCKERR_PORTZERO;
}
tmp = getSn_SR(sn);
//#if ( _WIZCHIP_ < 5200 )
if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS;
if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) {
return SOCKERR_SOCKSTATUS;
}
//#else
// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS;
//#endif
setSn_DIPR(sn,addr);
setSn_DPORT(sn,port);
freesize = getSn_TxMAX(sn);
if (len > freesize) len = freesize; // check size not to exceed MAX size.
if (len > freesize) {
len = freesize; // check size not to exceed MAX size.
}
while(1)
{
freesize = getSn_TX_FSR(sn);
if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED;
if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
if(getSn_SR(sn) == SOCK_CLOSED) {
return SOCKERR_SOCKCLOSED;
}
if( (sock_io_mode & (1<<sn)) && (len > freesize) ) {
return SOCK_BUSY;
}
if(len <= freesize) break;
};
wiz_send_data(sn, buf, len);
@@ -558,6 +573,7 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t
setSn_CR(sn,Sn_CR_SEND);
/* wait to process the command... */
while(getSn_CR(sn));
while(1)
{
tmp = getSn_IR(sn);
@@ -586,6 +602,7 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t
#endif
//M20150409 : Explicit Type Casting
//return len;
return (int32_t)len;
}