我在LPC1754,59和68 + FreeRTOS + CMSIS 上运行固件.
我希望能够将微控制器置于最低功耗模式,但是:
据我在" LPC17xx用户手册 "(第58,59页)中所读到的,我应该可以从EINT3唤醒到"断电"模式.
我错过了什么?是否在低功率时产生中断?怎么说?我应该做任何特定的东西才能生成它吗?
编辑:
如何使用M4从输入文件中删除空行(多余的empy行)?
我知道我可以dnl在脚本的每一行末尾追加以禁止换行输出,但是我的意思是空白行不在脚本中,而是在包含的数据文件中(不应放置在其中dnl's)。
我尝试过这样的事情:
define(`
',`')
Run Code Online (Sandbox Code Playgroud)
(不要换新行)但是它没有用。
谢谢。
对于没有足够的时间进行深入调查并依赖您的帮助,我深表歉意。
\n考虑简单的代码:
\n#include <iostream>\n\nenum class PrintColour\n{\n COLOUR_1 = 0,\n COLOUR_2 = 1,\n};\n \nvoid colour( auto c = PrintColour::COLOUR_1 )\n{\n switch ( c )\n {\n case PrintColour::COLOUR_1:\n std::cout << "Colour 1" << std::endl;\n break;\n case PrintColour::COLOUR_2:\n std::cout << "Colour 2" << std::endl;\n }\n}\n\nint main( )\n{\n// colour( ); couldn\'t deduce template parameter \xe2\x80\x98auto:1\xe2\x80\x99\n colour( PrintColour::COLOUR_1 ); // Fine!\n}\nRun Code Online (Sandbox Code Playgroud)\n这段代码完全按照原样编译和运行,没有问题。但是,如果我取消注释colour( );, g++ 会引发错误:
auto_param.cpp: In function \xe2\x80\x98int main()\xe2\x80\x99:\nauto_param.cpp:27:10: error: no matching function for call to \xe2\x80\x98colour()\xe2\x80\x99\n colour( …Run Code Online (Sandbox Code Playgroud) 考虑这段代码:
\n\n#include <iostream>\n\nclass test\n{\npublic:\n test( char *arg )\n : _arg( arg )\n {} \n char *_arg;\n};\n\nint main( )\n{\n char *txt1 = "Text one"; // Ignore this warning.\n const char *txt2 = "Text two";\n\n test t1( txt1 ); // Normal case, nothing new.\n const test t2( txt2 ); // Since object is const, I\'d like to be able to pass a const argument in.\n}\nRun Code Online (Sandbox Code Playgroud)\n\n它因错误而爆炸:
\n\nerror: invalid conversion from \xe2\x80\x98const char*\xe2\x80\x99 to \xe2\x80\x98char*\xe2\x80\x99 [-fpermissive]\n const test t2( txt2 …Run Code Online (Sandbox Code Playgroud) 从这个问题开始:
并考虑这个简化的代码:
#include <string>
#include <iostream>
class Abstract
{
public:
virtual void method(int a)
{
std::cout << __PRETTY_FUNCTION__ << "a: " << a << std::endl;
}
};
class Concrete : public Abstract
{
public:
void method(char c, std::string s)
{
std::cout << __PRETTY_FUNCTION__ << "c: " << c << "; s: " << s << std::endl;
}
};
int main()
{
Concrete c;
c.method(42); // error: no matching function for call to 'Concrete::method(int)'
c.method('a', std::string("S1_1"));
Abstract *ptr = &c; …Run Code Online (Sandbox Code Playgroud) 今天有人请我帮忙做一个用 G++ 编译的 VC++ 项目,我偶然发现了这一行:
static char data[constexpr(sizeof(T))];
Run Code Online (Sandbox Code Playgroud)
(当然,它位于带有名为 的模板参数的模板函数内T)。
我没有 C++ 标准,但根据cppreference:
句法
sizeof( 类型 ) (1)
表达式的大小 (2)
两个版本都是 std::size_t 类型的常量表达式。
sizeof()那么告诉 VC++预期的结果有什么意义呢constexpr?
尝试一下: https: //rextester.com/VIWP36674。
正如预期的那样,在 VC 上有效,但在 G++ 上失败。
另一种尝试选择: https: //godbolt.org/z/DnioLS
适用于 VC 直至 19.10。似乎是在 19.14 修复的,所以我认为这确实是一个怪癖,但即使如此,也一定有人有理由编写这样的代码......
简单来说,有一种ANSI-C方式使函数成为一个常量表达式吗?
constexpr并且不会在运行时解决.背景:
我需要在没有浮点的嵌入式处理器中实现大量的数学运算,所以我在我的应用程序中使用了固定点.
不过,我不喜欢在我的头文件中看到神秘的常量.我的硬件需要几个浮点常量(例如130.7 microseconds,0.2503 mJ),我真的希望能够读取(其他城市)我的常量数据表值列的部分.
在给定的时刻,我的硬件需要使用这个常量,例如,填写一个计时器重载值,并且,由于值是常量,我想有类似的东西:
// Header file.
static const int values_table[] =
{
_Time( 123.45 ), // 123.45 microseconds.
// ...
};
Run Code Online (Sandbox Code Playgroud)
然后:
// Application source file.
int conv_to_timer( x ) { /* my calculations - all const. */ }
// ...
void my_code( void )
{
// ...
timer_reload = conv_to_timer( values_table[ index ] );
Run Code Online (Sandbox Code Playgroud)
一种方法是让我的_Time( x )宏进行计时器值所需的所有计算,但它不灵活(即不能与某些外部相比),既不是便携式(不同的硬件也需要不同的计算).
有什么优雅方法的建议吗?
请将此视为我要做的最简单的工作示例,以揭示我的疑问:
#include <iostream>
#include <stdint.h>
#include <typeinfo>
using DefaultType = uint32_t;
class point
{
public:
DefaultType x( ) const { return DefaultType( 0 ); }
DefaultType y( ) const { return DefaultType( 0 ); }
};
int main( )
{
long cast_me = 0xaaaaaaaa;
auto casted = static_cast< std::result_of< decltype( &point::x )( point ) >::type >( cast_me );
std::cout << "cast_me (" << typeid( cast_me ).name( )
<< ") has been casted (" << typeid( casted ).name( ) << ")" …Run Code Online (Sandbox Code Playgroud) c++ ×6
c++14 ×2
ansi-c ×1
arguments ×1
arm ×1
auto ×1
c ×1
c++11 ×1
casting ×1
const ×1
constants ×1
constexpr ×1
constructor ×1
cortex-m3 ×1
embedded ×1
g++ ×1
lpc ×1
m4 ×1
name-hiding ×1
name-lookup ×1
preprocessor ×1
sizeof ×1
visual-c++ ×1