⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgmspacehlp.h

📁 butterflylogger_src_20060822 for atmel avr
💻 H
字号:
/*
	Local helper functions for the
	missing __flash workaround 
	
	- not part of the org. ATMEL code -
	done by Martin Thomas, KL, .de
*/

#ifndef _pgmspacehlp_h_
#define _pgmspacehlp_h_

#include <avr/pgmspace.h>

/* Read a float (4 Bytes) from PROGMEM
    the idea using a union is from Joerg Wunsch, found
    on the avr-gcc mailing-list, marked as "public domain"
    modifications by mt: (a) use pgm_read_word, (b) pass 
	pointer to float as param. and cast
*/
static inline float pgm_read_float_hlp(const float *addr)
{	
	union
	{
		int i[2];	// uint16_t 
		float f;
	} u;
	
	u.i[0]=pgm_read_word((PGM_P)addr);
	u.i[1]=pgm_read_word((PGM_P)addr+2);
	
	return u.f;
} 
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -