Enhanced Ethernet drivers.
Made Ethernet drivers easier to consume by assembly programs. * Replaced function pointers with JMP instructions. * Provide return values additionally via Carry flag. Reset Ethernet chips on initialization. Both for the CS8900A and the W5100 the data sheets just say that the RESET bit is automatically cleared after the RESET. This may be interpreted in two ways: 1) There's no need to be afraid of reading the RESET bit as 1 and unintentionally trigger a RESET by writing it back after ORing in some other bit. 2) The RESET process isn't complete before the RESET bit hasn't become 0 again. It's impossible for me to empirically falsify the latter option as the drivers are supposed to work on faster machines than the ones I have access to. And if the RESET process includes things like oscillators then the time to complete the RESET could differ even between multiple exemplars of the same chip. Therefore I opted to presume the latter option. However that means a non-exsistent chip may cause an infinite loop while waiting for the RESET bit to be cleared so I finally added code to detect the presence of the Ethernet chips. There's a risk of a chip being locked up in a way that makes the detection fail - and therefore the RESET not being performed. This catch-22 needs to be solved by the user doing a hard RESET.
This commit is contained in:
parent
a0961fc3c4
commit
a5d7a06027
4 changed files with 177 additions and 109 deletions
|
@ -47,9 +47,13 @@ struct {
|
|||
struct uip_eth_addr ethernet_address;
|
||||
uint8_t *buffer;
|
||||
uint16_t buffer_size;
|
||||
void __fastcall__ (* init)(uint16_t reg);
|
||||
char jmp_init;
|
||||
char __fastcall__ (* init)(uint16_t reg);
|
||||
char jmp_poll;
|
||||
uint16_t (* poll)(void);
|
||||
char jmp_send;
|
||||
void __fastcall__ (* send)(uint16_t len);
|
||||
char jmp_exit;
|
||||
void (* exit)(void);
|
||||
} *module;
|
||||
|
||||
|
@ -97,7 +101,10 @@ ethernet_init(struct ethernet_config *config)
|
|||
|
||||
module->buffer = uip_buf;
|
||||
module->buffer_size = UIP_BUFSIZE;
|
||||
module->init(config->addr);
|
||||
if(module->init(config->addr)) {
|
||||
log_message(config->name, ": No hardware");
|
||||
error_exit();
|
||||
}
|
||||
|
||||
uip_setethaddr(module->ethernet_address);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue