embedded

Source code in embedded C for unsigned integer to string

北城以北 提交于 2019-11-28 02:16:07
问题 Without resorting to standard library utoa, I'm looking for source code of utoa so I may customise it for specific project. I have unsigned integer (32 bits) with output such as 0xFFFF_FFFF I also looking for source code for unsigned integer and half word to string in binary format. 回答1: Try this: char *dec(unsigned x, char *s) { *--s = 0; if (!x) *--s = '0'; for (; x; x/=10) *--s = '0'+x%10; return s; } You call it with a pointer to the end of a caller-provided buffer, and the function

how to convert double between host and network byte order?

泄露秘密 提交于 2019-11-28 00:27:20
Could somebody tell me how to convert double precision into network byte ordering. I tried uint32_t htonl(uint32_t hostlong); uint16_t htons(uint16_t hostshort); uint32_t ntohl(uint32_t netlong); uint16_t ntohs(uint16_t netshort); functions and they worked well but none of them does double (float) conversion because these types are different on every architecture. And through the XDR i found double-float precision format representations ( http://en.wikipedia.org/wiki/Double_precision ) but no byte ordering there. So, I would much appreciate if somebody helps me out on this (C code would be

STM32 SPI Slow Compute

你说的曾经没有我的故事 提交于 2019-11-28 00:20:11
I'm using a STM32F4 and its SPI to talk to a 74HC595 like in this tutorial. Difference is for starters I'm using the non-DMA version for simplicity. I used STMCubeMX to configure SPI and GPIO Issue is: I'm not getting the latch PIN, that I set to PA8 to toggle during transmission fast enough. The code I'm using: spiTxBuf[0] = 0b00000010; HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET); HAL_SPI_Transmit(&hspi1, spiTxBuf, 1, HAL_MAX_DELAY); // while(HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET); HAL_Delay(1); Things I tried: Set the

Converting 'float' to 'byte[4]' and back to 'float' in .NET Micro Framework

匆匆过客 提交于 2019-11-28 00:11:59
What's the best way to convert a float to a byte[4] and then back to a 'float'? I am doing this in C# .NET Micro Framework , so there is no BitConverter available for my use. I've modified the BitConverter class from a Netduino implementation to allow endianness specification (it's not the "best way", but it works). If the byte array is sent over the network, I would use BigEndian . Just a reminder that unsafe is not officially supported in NETMF. using System; using System.Diagnostics; namespace netduino { public static class BitConverter { public static byte[] GetBytes(uint value) { return

undefined reference to “only some math.h” functions

青春壹個敷衍的年華 提交于 2019-11-27 23:49:56
I am having a strange problem. The math libraries has been added to my makefile. # include standard C library LDFLAGS += -lc # include standard math library LDFLAGS += -lm and in the output file (.map) I can see that everything has been linked properly: LOAD c:/gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/bin/../lib/gcc/powerpc-eabi/4.3.3/nof\libgcc.a LOAD c:/gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/bin/../lib/gcc/powerpc-eabi/4.3.3/../../../../powerpc-eabi/lib/nof\libc.a LOAD c:/gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/bin/../lib/gcc/powerpc-eabi/4.3.3/../../../../powerpc-eabi/lib/nof\libm.a

Low level qemu based debugging

狂风中的少年 提交于 2019-11-27 23:33:40
问题 I've to test some low level code on an ARM architecture. Typically experimentation is quite complicated on the real board, so I was thinking about QEMU. What I'd like to get is some kind of debugging information like printfs or gdb. I know that this is simple with linux since it implements both the device driver for the QEMU Integrator and the gdb feature, but I'm not working with Linux. Also I suspect that extracting this kind of functionality from the Linux kernel source code would be

How to improve fixed point square-root for small values

笑着哭i 提交于 2019-11-27 22:59:49
I am using Anthony Williams' fixed point library described in the Dr Dobb's article " Optimizing Math-Intensive Applications with Fixed-Point Arithmetic " to calculate the distance between two geographical points using the Rhumb Line method . This works well enough when the distance between the points is significant (greater than a few kilometers), but is very poor at smaller distances. The worst case being when the two points are equal or near equal, the result is a distance of 194 meters, while I need precision of at least 1 metre at distances >= 1 metre. By comparison with a double

Hardware acceleration without X

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 22:34:15
问题 I was wondering if it would be possible to get graphical hardware acceleration without Xorg and its DDX driver, only with kernel module and the rest of userspace driver. I'm asking this because I'm starting to develop on an embedded platform (something like beagleboard or more roughly a Texas instruments ARM chip with integrated GPU), and I would get hardware acceleration without the overhead of a graphical server (that is not needed). If yes, how? I was thinking about OpenGL or OpengGLES

@ sign in C variable declaration

不问归期 提交于 2019-11-27 21:55:09
I found this header file for PIC microcontrollers by the name of pic1250.h and I'm unable to get the hang of some syntax used in it. The source for the file is: /* * Header file for the Microchip * PIC 12c508 chip * PIC 12c509 chip * Baseline Microcontrollers */ static volatile unsigned char RTCC @ 0x01; static volatile unsigned char TMR0 @ 0x01; static volatile unsigned char PCL @ 0x02; static volatile unsigned char STATUS @ 0x03; static unsigned char FSR @ 0x04; static volatile unsigned char OSCCAL @ 0x05; static volatile unsigned char GPIO @ 0x06; static unsigned char control OPTION @ 0x00;

Graphics library for embedded systems without Linux? [closed]

痞子三分冷 提交于 2019-11-27 21:50:21
问题 It seems that any kind of graphic library like DirectFB or MiniGui requires some sort of underlying operation system like Linux or uClinux. I am challenged with writing a software for a micro controller with just 512kb flash, an LCD display and a touchscreen to display and handle some pictures and GUI parts. Do you know any library which just need a pointer to the video memory that also can handle lines, images and fonts? 回答1: By the time you incorporate some third party solution you could