nathantsoi / stm32-serial-1wire-passthrough

a port of Achim's serial 1wire passthrough code
4 stars 2 forks source link

small bug found #2

Open 4712 opened 8 years ago

4712 commented 8 years ago

Hi Nathan, got it working here with a Flip32+ board. Found a bug that kept it working from other ESC than #1. Also the RX/TX led seem only work with #1 and #2.

void escSet(int8_t escIndex, BitAction val) { int i = 0; // Write all esc pins if (escIndex == -1) { for (i = 0; i < ESC_COUNT; i++) { GPIO_WriteBit(escHardware[i].gpio, escHardware[i].pin, val); } } // Write the specified pin else { //GPIO_WriteBit(escHardware[escIndex].gpio, escHardware[i].pin, val); //i was wrong GPIO_WriteBit(escHardware[escIndex].gpio, escHardware[escIndex].pin, val); } // low == data ledSetState(LED_ESC_TX, val == Bit_RESET); }

I would suggest to skip the "all" mode, because, it will not work reliable. At least it has timing issues (Pulse length 80µS instead of 52). img_043 There is also room left for tuning of timing in single ESC mode (I got 57.8µS H/46µS L here instead of 52µS/52µS)... EDIT: total byte timing seems to be ok

nathantsoi commented 8 years ago

Awesome, thanks Achim!

Any suggestion on the timing issues? I agree, "all" mode is unnecessary if we make it possible to switch back to the serial_cli without a reboot.

4712 commented 8 years ago

I played around with timing and got only 1µS here and there, but this isn't important, while the total time of one byte frame stays within the allowed borders. Yes, I stripped the all mode and found a way to switch the channels, but I miss the serial init function... I also need a platform independent delay structure uint32_t ct=3000; while(!RX_HI) { ct--; if (ct==0) { // Reset all GPIO GPIO_DeInit(escHardware[escIndex].gpio); enable_hardware_uart(); return; } }

BTW: BLHeliSuite will/can communicate cli and set the channels...

nathantsoi commented 8 years ago

Ahh, awesome! Should I implement this and remove the "all" code or are you working on it?

4712 commented 8 years ago

I'm working on it... give me some time...

nathantsoi commented 8 years ago

sounds great! take you're time.

4712 commented 8 years ago

OK, seems to run fine.The solution was not to DeInit the UART GPIO, only set the mode and disable irq.. With the counter in the loop, I can send a 0x00 with 110 baud to exit the 1wire pass-through.

There are still several things to implement into BLHeliSuite. Timing for the msp and cli commands must be checked and of course testing on the various platforms. I'll try to get my file into the repository...

nathantsoi commented 8 years ago

Awesome good find! Let me know when you get the file pushed and I can help test.

4712 commented 8 years ago

Well, Github is still a mystery for me... Anyway I have forked your cleanflight master, pulled the USBLinker branch and committed the altered files... I'm sure that was the wrong way to doe such things... Anyway: https://github.com/4712/cleanflight has now the files.

4712 commented 8 years ago

I'm still wondering, why the LED's do not work when selection ESC#3 and above???

nathantsoi commented 8 years ago

That's perfect! I'll load this up on my NAZE today, nice work!

4712 commented 8 years ago

Mhhh, I afraid, it will not work with a bluetooth adapter, because we cannot change the baud rate.

samguns commented 8 years ago

@4712 You don't need GPIO DeInit, just switch the mode when necessary

4712 commented 8 years ago

Thanks Sam, yes I realized this.