Without freeing the DAC, the pin will continue to be configured as DAC. Which make it impossible to change it from Analogout to anything else.
Check this code that allow you to change the AnalogOut to DigitalOut
<<code>>
#include "mbed.h"
class myAnalog : public AnalogOut{
public:
myAnalog(PinName myname);
~myAnalog();
PinName _myname;
};
myAnalog::myAnalog(PinName myname):AnalogOut(myname),
_myname(myname){
;
}
myAnalog::~myAnalog(){
analogout_free(&this->_dac);
}
myAnalog *x=0;
DigitalOut *xx=0;
void do_something_analog() {
x=new myAnalog(PA_4);
double g=0.0;
while(g<0.5){
x->write(g);
g=g+0.1;
wait_ms(50);
}
if (x!=0){
delete x;
x=0;
}
}
void do_something_digital() {
xx=new DigitalOut(PA_4);
for(int i=0;i<10;i++){
*xx = 1;
wait_ms(50);
*xx = 0;
wait_ms(50);
}
if (xx!=0){
delete xx;
xx=0;
}
}
int main()
{
printf("\nAnalog loop example\n");
while(1) {
do_something_digital();
do_something_analog();
}
}
<</code>>
Static keyword causes problems when trying to use force-inlined
functions from normal inlined functions. This is not legal:
static inline void forced() { }
inline void normal() { forced(); }
You cannot reference internal-linkage things from external-linkage
inline functions.
Removal of the static implies that in C there would need to be a
non-inline definition in case anyone calls it non-inlined, but if the
force attribute is doing its job, that should not happen.
Only significant in-tree user of the MBED_FORCEINLINE macro is
the atomic operations - making this change permits atomic operations
from non-static inline functions.
If "lwip.tcp-enabled" is set to false, ARMC6 compilation fails to error
Error: L6218E: Undefined symbol netconn_recv_tcp_pbuf
LWIP::socket_recv() is TCP socket specific method so implementation can be
enabled only when LWIP_TCP flag is set.
ARMC5 failed to compile the code with debug-profile (!!) as va_list
is getting into std:: namespace when one includes <cstdarg>. Other
compilers seem to be more relaxed, and so is ARMC5 if compiled
with other profiles.
Add the explicit std:: to references of va_list.
While here, remove one extra copy of "#include "PlatformMutex.h""
and a "#include <stdarg.h>" which is kind of duplicate of
"#include <cstdarg>".
Error being fixed:
--8<--8<--8<--
Compile [ 81.8%]: ATHandler.cpp
[Error] ATHandler.h@552,0: #20: identifier "va_list" is undefined
[Error] ATHandler.cpp@1226,0: #147: declaration is incompatible with "void mbed::ATHandler::handle_args(const char *, <error-type>)" (declared at line 552 of "./mbed-os/features/cellular/framework/AT/ATHandler.h")
[ERROR] "./mbed-os/features/cellular/framework/AT/ATHandler.h", line 552: Error: #20: identifier "va_list" is undefined
"./mbed-os/features/cellular/framework/AT/ATHandler.cpp", line 1226: Error: #147: declaration is incompatible with "void mbed::ATHandler::handle_args(const char *, <error-type>)" (declared at line 552 of "./mbed-os/features/cellular/framework/AT/ATHandler.h")
./mbed-os/features/cellular/framework/AT/ATHandler.cpp: 0 warnings, 2 errors
As the build tool in mbed-os 5.13 cannot appropriately deal with a segmented
bootloader when combining it with an application, this commit adjusts the
size reserved for interrupts (via the linker file) to avoid a bootloader
segmentation due to an unpopulated ROM area.
The microcontroller has a total of 60 vector interrupts + 16 exception
handlers. The allocated ROM flash for interrupts should be (60 + 16) x word
size in bytes = 76 x 4 = 304 = 0x130.
This commit changes the interrupt reserved space from 0x140 to 0x130.