ugh, still not working. im seeing activity using my dmm so idk what exactly is wrong
This commit is contained in:
parent
93cc1dd13c
commit
678709eb1f
|
@ -4,15 +4,31 @@
|
|||
#include "m_jscan/jscan.h"
|
||||
#include "m_jscan/jscan_hw.h"
|
||||
|
||||
void jscan_pin_disable(void) {
|
||||
inline static uint32_t get_mask(void) {
|
||||
uint32_t mask = (1 << JSCAN_PIN_MAX) - 1;
|
||||
if (JSCAN_PIN_MIN)
|
||||
mask ^= (1 << (JSCAN_PIN_MIN - 1)) - 1;
|
||||
|
||||
for (uint8_t i = JSCAN_PIN_MIN; i <= JSCAN_PIN_MAX; ++i)
|
||||
gpio_disable_pulls(i);
|
||||
return mask;
|
||||
}
|
||||
|
||||
gpio_set_dir_masked(mask, 0); // all inputs
|
||||
void jscan_pin_enable(void) {
|
||||
//gpio_init_mask(get_mask());
|
||||
for (uint8_t i = JSCAN_PIN_MIN; i <= JSCAN_PIN_MAX; ++i) {
|
||||
gpio_set_function(i, GPIO_FUNC_SIO);
|
||||
gpio_disable_pulls(i);
|
||||
gpio_set_dir(i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void jscan_pin_disable(void) {
|
||||
for (uint8_t i = JSCAN_PIN_MIN; i <= JSCAN_PIN_MAX; ++i) {
|
||||
gpio_disable_pulls(i);
|
||||
gpio_set_dir(i, 0);
|
||||
gpio_set_function(i, GPIO_FUNC_NULL);
|
||||
}
|
||||
|
||||
//gpio_set_dir_masked(get_mask(), 0); // all inputs
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -155,9 +155,9 @@ def jtag_scan(dev: DmjDevice, typ: str, start_pin: int, end_pin: int) -> int:
|
|||
dev.m3_jtagscan_start(typei[typ], start_pin, end_pin)
|
||||
|
||||
stat = typei[typ]
|
||||
while stat < SCAN_IDLE: # TODO: timeout?
|
||||
while stat < SCAN_IDLE: # TODO: timeout? # TODO: time guess? 50us*some factor*pins!/((pins-portnum)!)
|
||||
if stat != typei[typ]:
|
||||
print("Wut?!! device should be in state %d (%s) but is in %d (%s)" % (typei[typ].upper(), typ, stat, types.get(stat, '???').upper()))
|
||||
print("Wut?!! device should be in state %d (%s) but is in %d (%s)" % (typei[typ], typ.upper(), stat, types.get(stat, '???').upper()))
|
||||
|
||||
stat = dev.m3_jtagscan_get_status()
|
||||
time.sleep(0.1)
|
||||
|
@ -167,8 +167,8 @@ def jtag_scan(dev: DmjDevice, typ: str, start_pin: int, end_pin: int) -> int:
|
|||
|
||||
if (stat & SCAN_DONE_F) != 0:
|
||||
nmatches = stat & (SCAN_DONE_F - 1)
|
||||
print("JTAG scan finished (%d matches)%s" % \
|
||||
(nmatches, ':' if nmatches else ''))
|
||||
print("%s scan finished (%d matches)%s" % \
|
||||
(typ.upper(), nmatches, ':' if nmatches else ''))
|
||||
|
||||
matches = None
|
||||
if typ == 'jtag':
|
||||
|
|
|
@ -83,12 +83,14 @@ static void scan_swd(void);
|
|||
void jscan_task(void) {
|
||||
switch (status) { // should we start something?
|
||||
case jscan_type_jtag:
|
||||
jscan_pin_enable();
|
||||
scan_jtag();
|
||||
if (type != 0xff) // -1 means force-stopped
|
||||
status = jscan_mode_done_f | nmatches;
|
||||
jscan_pin_disable();
|
||||
break;
|
||||
case jscan_type_swd:
|
||||
jscan_pin_enable();
|
||||
scan_swd();
|
||||
if (type != 0xff) // -1 means force-stopped
|
||||
status = jscan_mode_done_f | nmatches;
|
||||
|
@ -339,6 +341,7 @@ static bool test_swd_lines(uint8_t swclk, uint8_t swdio, uint16_t* manuf, uint16
|
|||
read_id_code(swclk, swdio, &readbuf);
|
||||
bool result = get_ack(readbuf) == 1;
|
||||
init_pins(0xff, 0xff, 0xff, 0xff);
|
||||
printf("swclk=%hhu swdio=%hhu -> %08llx\n", swclk, swdio, readbuf);
|
||||
if (result) {
|
||||
*manuf = get_manuf(readbuf);
|
||||
*part = get_partno(readbuf);
|
||||
|
|
|
@ -44,6 +44,7 @@ void jscan_task(void);
|
|||
bool jscan_pin_get(uint8_t pin);
|
||||
void jscan_pin_set(uint8_t pin, bool v);*/
|
||||
// implement these inline in jscan_hw.h
|
||||
void jscan_pin_enable(void);
|
||||
void jscan_pin_disable(void);
|
||||
|
||||
// sleep for 25 microseconds (half a clock cycle of a 20 kHz clock)
|
||||
|
|
Loading…
Reference in New Issue