Elmagnifico's Blog

云深不知归处

APM中的Schedule Starved

嵌入式,驱动,Timeout

相关代码 void Copter::loop() { // wait for an INS sample while (ins_sample_time + 2500 > micros()) { if ((ins_sample_time + 2500) - micros() > 1500) delay(1); else if ((ins_sample_time...

嵌入式底层驱动中时序等待超时处理

嵌入式,驱动,Timeout

超时代码 //来源于STM32F4系列官方标准例程 uint8_t sFLASH_SendByte(uint8_t byte) { /*!< Loop while DR register in not emplty */ while (SPI_I2S_GetFlagStatus(sFLASH_SPI, SPI_I2S_FLAG_TXE) == RESET); /*...

C++中Enum与array的最后一个逗号

c/c++,enum,array,comma

编译环境 Visual Studio 2013 标准C++控制台程序 Keil 5 STM32F407 C++工程 编译没报错?? 在检查飞控工程的时候,在usb程序里的头文件,突然发现竟然有enum类型,最后多了一个逗号,竟然还通过了编译没报错,搞得我还以为是keil的bug typedef enum { HC_IDLE = 0, HC_XFRC, HC_HALT...

C++中坑人的fstream(二)

c/c++,fstream

编译环境 Visual Studio 2013 标准C++控制台程序 我的问题 紧接着上一篇,在这里发出我遇到的问题 #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std; int _tmain(int...

C++中坑人的fstream(一)

c/c++,fstream

编译环境 Visual Studio 2013 标准C++控制台程序 起因 我只是想写一个简单,可以往已有文本文件中添加一行内容而已. 比如: 往所有的markdown文件中添加”catalog: true”使老的文章中也能自动出现侧面目录栏 --- layout: post title: "C++中坑人的fstream" subtitle: "c/...

LeetCode Solution(Easy.97-100)

c/c++,python,for work

97.Construct the Rectangle For a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a recta...

LeetCode Solution(Easy.93-96)

c/c++,python,for work

93.Number Complement Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fi...

LeetCode Solution(Easy.89-92)

c/c++,python,for work

89.Power of Three Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 89.Power of Three-Analysis 不用循环和递归判断是...

LeetCode Solution(Easy.85-88)

c/c++,python,for work

85.Number of Boomerangs Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between ...

LeetCode Solution(Easy.81-84)

c/c++,python,for work

81.First Unique Character in a String Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. Examples: s = "leetcode" return 0. s = ...