Port COM is not appear STM32F4 tinyUSB - stm32

I'm trying to add tinyUSB library but I get this define CFG_TUSB_RHPORT1_MODE as not defined.With this line I have problem. If i comment this line, my usb is not appear in device manager. I did this tutorial. Could you check what i'm doing wrong (link to repo below)?
At the end I want to make CDC communication without misc.

Okey I solved issue. Silly I did't think to change number from 1 to 0... so it looks now:
if (!(rhport == 1 && (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED))) usb_otg->GCCFG |= USB_OTG_GCCFG_PWRDWN;
and in tusb_config.h I added:
#define CFG_TUSB_MCU OPT_MCU_STM32F4
#define CFG_TUSB_OS OPT_OS_NONE
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
#define BOARD_DEVICE_RHPORT_NUM 0
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
Now its working :D Discussion can be closed

Had similar issue with RHPORT1 in my case - STM32F407:
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_NONE)

Related

How to set Pin touch mode to capacitive on micro:bit v2 in MicroPython

If I use the makecode editor to create the code, it generates:
pins.touch_set_mode(TouchTarget.P0, TouchTargetMode.CAPACITIVE)
However, if I try and run this, it can't find 'pins'.
Note: I then investigated further and found out how to do this before submitting my question...
Capacitive mode can be set for each pin, e.g.
from microbit import *
...
pin0.set_touch_mode(pin0.CAPACITIVE)
...
if pin0.is_touched():
...
The last line checks whether the pin is touched - usually in a loop.
Hope this saves other people some time...

LGT8F328P-SSOP20 arduino clone and SPI

LGT8F328P clone I Would like to use the SPI interface.
as indicated on the datasheet:
It has everything necessary but I don't know how to configure <SPI.h>.
and how to make it works for example with W5500?
I found out the problem, using LGT8F328P-SSOP20 there are two pins identical!
the MOSI on 11 and SS on 10.
in this way I cannot communicate with SPI protocol.
This may help you:
https://github.com/dbuezas/lgt8fx/issues/54
Somebody else got SPI working on the SSOP20 package by overriding the default pin IO direction of PB0
For W5500 chip, you can using ethernet2 library. Edit the ethernet2.h file for replacing w5500_cspin to 9.
EthernetClass() { _dhcp = NULL; w5500_cspin = 9; } //default 10
void init(uint8_t _cspin = 9) { w5500_cspin = _cspin; }
This is specially for LGT8F328P-SSOP20

Set DEBUG to false

I want to test the below lines of code :
#ifdef DEBUG
#define VAR 10
#else
#define VAR 20
#endif
In project->build settings->preprocessor macros I had DEBUG=1 and NSLogging the value of VAR logged 10. Then I set DEBUG=0 to check if it loggs 20. But it logged 10 only.How to set DEBUG value so that else condition in code is satisfied?
Just make it easy:
#define DEBUG 1
#ifdef DEBUG
#define debug(...) NSLog(__VA_ARGS__)
#else
#define debug(...)
#endif
When you summit to appstore, comment #define DEBUG 1 :D
This is the way I used.
I dont know how to define something like you but it's great if it's possible!
Could you show me how to do that?
You should NOT be setting DEBUG=0 to get the right result.
Just don't define DEBUG at all to get release behavior.
Remember, #ifdef DEBUG code checks if DEBUG is defined or not.
Alternatively, #if DEBUG code would get you the right result.
As Aditya said, other library used in application may have defined DEBUG macro and hence even I remove it from preprocessor macro the condition #ifdef DEBUG is always satisfied. The solution is simple though. Just use different macro name such as IS_DEBUG instead of DEBUG. This solved my problem. It was a matter of just a macro name.

Is there any way to clear NSLog Output?

I have been googling from last couple of hours for finding that is there any way to clear NSLog output using code or not?
Like we have clrscr() in c. So if we are trying to print something which we want to focus most and there is lots of log printin there we can put that code there and get keep our desire log on top for easy searching. This can be done by putting breakpoint on my NSLog line and than click on clear console. but question is is there a way to achive this programatically?
I found few question on stack overflow but I din't satisfied with answer like this is saying that I can disable log for release mode etc.
Or I can use DLog, ALog or ULog as requirement but my question is different..
Any one can help me in this?
Thanks in advance :)
You can use a conditional breakpoint to simulate it. Define a function like this in your code:
int clear_console()
{
NSLog(#"\n\n\n\n\n\n\n\n");
}
Then, when you want to clear the console just add a breakpoint before the NSLog with this condition:
Condition: 1 > 0
Action: Debugger Command expr (int) clear_console()
Options: Automatically continue after evaluating Check it to skip the pause.
Tested with Xcode 4.3.2 and lldb.
Previous answer:
AFAIK, no, there isn't.
Just in case you're not doing it yet, you can create custom macros to format the output to highlight what you want.
Define macros like this:
#define CLEAR(...) NSLog(#"\n\n\n\n\n\n") /* enough \n to "clear" the console */
#define WTF(...) CLEAR();NSLog(#"!!!!!!!!!!!!!!");NSLog(__VA_ARGS__)
#define TRACE(__message__) NSLog(#">>>>>>>>>>>>>>> %# <<<<<<<<<<<<<<<<<<<", __message__)
Then:
WTF(#"This should't be here object: %#", theObject);
...
TRACE(#"Start Encoding");
...
It's not what you want but it pretty much solves the problem. You'll end up with your own set of macros with custom prefixes easily scannable in the console output.

How to use code inside #ifdef SHOUTCAST_METADATA

I am using code of "Matt Gallagher" for streaming player
and there are some code inside
#ifdef SHOUTCAST_METADATA
//Code
#endif
The system is not able to go inside these blocks.
Now currently the code inside is not working.....the code just needed to get the name of the stream playing.
Please help
Add this at the top of the file w/that #ifdef:
#define SHOUTCAST_METADATA 1
Of course, you'll need to deal with any dependencies incurred; that code was compiled out for a reason.