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.h"
|
||||||
#include "m_jscan/jscan_hw.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;
|
uint32_t mask = (1 << JSCAN_PIN_MAX) - 1;
|
||||||
if (JSCAN_PIN_MIN)
|
if (JSCAN_PIN_MIN)
|
||||||
mask ^= (1 << (JSCAN_PIN_MIN - 1)) - 1;
|
mask ^= (1 << (JSCAN_PIN_MIN - 1)) - 1;
|
||||||
|
|
||||||
for (uint8_t i = JSCAN_PIN_MIN; i <= JSCAN_PIN_MAX; ++i)
|
return mask;
|
||||||
gpio_disable_pulls(i);
|
}
|
||||||
|
|
||||||
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)
|
dev.m3_jtagscan_start(typei[typ], start_pin, end_pin)
|
||||||
|
|
||||||
stat = typei[typ]
|
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]:
|
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()
|
stat = dev.m3_jtagscan_get_status()
|
||||||
time.sleep(0.1)
|
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:
|
if (stat & SCAN_DONE_F) != 0:
|
||||||
nmatches = stat & (SCAN_DONE_F - 1)
|
nmatches = stat & (SCAN_DONE_F - 1)
|
||||||
print("JTAG scan finished (%d matches)%s" % \
|
print("%s scan finished (%d matches)%s" % \
|
||||||
(nmatches, ':' if nmatches else ''))
|
(typ.upper(), nmatches, ':' if nmatches else ''))
|
||||||
|
|
||||||
matches = None
|
matches = None
|
||||||
if typ == 'jtag':
|
if typ == 'jtag':
|
||||||
|
|
|
@ -83,12 +83,14 @@ static void scan_swd(void);
|
||||||
void jscan_task(void) {
|
void jscan_task(void) {
|
||||||
switch (status) { // should we start something?
|
switch (status) { // should we start something?
|
||||||
case jscan_type_jtag:
|
case jscan_type_jtag:
|
||||||
|
jscan_pin_enable();
|
||||||
scan_jtag();
|
scan_jtag();
|
||||||
if (type != 0xff) // -1 means force-stopped
|
if (type != 0xff) // -1 means force-stopped
|
||||||
status = jscan_mode_done_f | nmatches;
|
status = jscan_mode_done_f | nmatches;
|
||||||
jscan_pin_disable();
|
jscan_pin_disable();
|
||||||
break;
|
break;
|
||||||
case jscan_type_swd:
|
case jscan_type_swd:
|
||||||
|
jscan_pin_enable();
|
||||||
scan_swd();
|
scan_swd();
|
||||||
if (type != 0xff) // -1 means force-stopped
|
if (type != 0xff) // -1 means force-stopped
|
||||||
status = jscan_mode_done_f | nmatches;
|
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);
|
read_id_code(swclk, swdio, &readbuf);
|
||||||
bool result = get_ack(readbuf) == 1;
|
bool result = get_ack(readbuf) == 1;
|
||||||
init_pins(0xff, 0xff, 0xff, 0xff);
|
init_pins(0xff, 0xff, 0xff, 0xff);
|
||||||
|
printf("swclk=%hhu swdio=%hhu -> %08llx\n", swclk, swdio, readbuf);
|
||||||
if (result) {
|
if (result) {
|
||||||
*manuf = get_manuf(readbuf);
|
*manuf = get_manuf(readbuf);
|
||||||
*part = get_partno(readbuf);
|
*part = get_partno(readbuf);
|
||||||
|
|
|
@ -44,6 +44,7 @@ void jscan_task(void);
|
||||||
bool jscan_pin_get(uint8_t pin);
|
bool jscan_pin_get(uint8_t pin);
|
||||||
void jscan_pin_set(uint8_t pin, bool v);*/
|
void jscan_pin_set(uint8_t pin, bool v);*/
|
||||||
// implement these inline in jscan_hw.h
|
// implement these inline in jscan_hw.h
|
||||||
|
void jscan_pin_enable(void);
|
||||||
void jscan_pin_disable(void);
|
void jscan_pin_disable(void);
|
||||||
|
|
||||||
// sleep for 25 microseconds (half a clock cycle of a 20 kHz clock)
|
// sleep for 25 microseconds (half a clock cycle of a 20 kHz clock)
|
||||||
|
|
Loading…
Reference in New Issue