Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49decdf

Browse files
committed
Added avr comp functions/headers
1 parent904305b commit49decdf

File tree

4 files changed

+212
-0
lines changed

4 files changed

+212
-0
lines changed

‎api/avr/dtostrf.c.impl‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
dtostrf - Emulation for dtostrf function from avr-libc
3+
Copyright (c) 2016 Arduino LLC. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
// This is a default implementation for dtostrf function.
21+
// This file should be used if the standard lib doesn't provide an
22+
// implementation of dtostrf.
23+
24+
// Just create a file called "dtostrf.c" with the following include:
25+
// #include "api/avr/dtostrf.c.impl"
26+
27+
#include <stdio.h>
28+
29+
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
30+
asm(".global _printf_float");
31+
32+
char fmt[20];
33+
sprintf(fmt, "%%%d.%df", width, prec);
34+
sprintf(sout, fmt, val);
35+
return sout;
36+
}
37+

‎api/avr/dtostrf.h‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
dtostrf - Emulation for dtostrf function from avr-libc
3+
Copyright (c) 2015 Arduino LLC. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#pragma once
21+
22+
#ifdef__cplusplus
23+
extern"C" {
24+
#endif
25+
26+
char*dtostrf(doubleval,signedcharwidth,unsignedcharprec,char*sout);
27+
28+
#ifdef__cplusplus
29+
}
30+
#endif

‎api/avr/interrupt.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright (c) 2015 Arduino LCC. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
/*
20+
Empty file.
21+
This file is here to allow compatibility with sketches (made for AVR)
22+
that includes <AVR/interrupt.h>
23+
*/

‎api/avr/pgmspace.h‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
pgmspace.h - Definitions for compatibility with AVR pgmspace macros
3+
4+
Copyright (c) 2015 Arduino LLC
5+
6+
Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in
16+
all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
THE SOFTWARE
25+
*/
26+
27+
#ifndef__PGMSPACE_H_
28+
#define__PGMSPACE_H_ 1
29+
30+
#include<inttypes.h>
31+
32+
#definePROGMEM
33+
#definePGM_P const char *
34+
#definePSTR(str) (str)
35+
36+
#define_SFR_BYTE(n) (n)
37+
38+
typedefvoidprog_void;
39+
typedefcharprog_char;
40+
typedefunsignedcharprog_uchar;
41+
typedefint8_tprog_int8_t;
42+
typedefuint8_tprog_uint8_t;
43+
typedefint16_tprog_int16_t;
44+
typedefuint16_tprog_uint16_t;
45+
typedefint32_tprog_int32_t;
46+
typedefuint32_tprog_uint32_t;
47+
typedefint64_tprog_int64_t;
48+
typedefuint64_tprog_uint64_t;
49+
50+
typedefconstvoid*int_farptr_t;
51+
typedefconstvoid*uint_farptr_t;
52+
53+
#definememchr_P(s,c,n) memchr((s), (c), (n))
54+
#definememcmp_P(s1,s2,n) memcmp((s1), (s2), (n))
55+
#definememccpy_P(dest,src,c,n) memccpy((dest), (src), (c), (n))
56+
#definememcpy_P(dest,src,n) memcpy((dest), (src), (n))
57+
#definememmem_P(haystack,haystacklen,needle,needlelen) memmem((haystack), (haystacklen), (needle), (needlelen))
58+
#definememrchr_P(s,c,n) memrchr((s), (c), (n))
59+
#definestrcat_P(dest,src) strcat((dest), (src))
60+
#definestrchr_P(s,c) strchr((s), (c))
61+
#definestrchrnul_P(s,c) strchrnul((s), (c))
62+
#definestrcmp_P(a,b) strcmp((a), (b))
63+
#definestrcpy_P(dest,src) strcpy((dest), (src))
64+
#definestrcasecmp_P(s1,s2) strcasecmp((s1), (s2))
65+
#definestrcasestr_P(haystack,needle) strcasestr((haystack), (needle))
66+
#definestrcspn_P(s,accept) strcspn((s), (accept))
67+
#definestrlcat_P(s1,s2,n) strlcat((s1), (s2), (n))
68+
#definestrlcpy_P(s1,s2,n) strlcpy((s1), (s2), (n))
69+
#definestrlen_P(a) strlen((a))
70+
#definestrnlen_P(s,n) strnlen((s), (n))
71+
#definestrncmp_P(s1,s2,n) strncmp((s1), (s2), (n))
72+
#definestrncasecmp_P(s1,s2,n) strncasecmp((s1), (s2), (n))
73+
#definestrncat_P(s1,s2,n) strncat((s1), (s2), (n))
74+
#definestrncpy_P(s1,s2,n) strncpy((s1), (s2), (n))
75+
#definestrpbrk_P(s,accept) strpbrk((s), (accept))
76+
#definestrrchr_P(s,c) strrchr((s), (c))
77+
#definestrsep_P(sp,delim) strsep((sp), (delim))
78+
#definestrspn_P(s,accept) strspn((s), (accept))
79+
#definestrstr_P(a,b) strstr((a), (b))
80+
#definestrtok_P(s,delim) strtok((s), (delim))
81+
#definestrtok_rP(s,delim,last) strtok((s), (delim), (last))
82+
83+
#definestrlen_PF(a) strlen((a))
84+
#definestrnlen_PF(src,len) strnlen((src), (len))
85+
#definememcpy_PF(dest,src,len) memcpy((dest), (src), (len))
86+
#definestrcpy_PF(dest,src) strcpy((dest), (src))
87+
#definestrncpy_PF(dest,src,len) strncpy((dest), (src), (len))
88+
#definestrcat_PF(dest,src) strcat((dest), (src))
89+
#definestrlcat_PF(dest,src,len) strlcat((dest), (src), (len))
90+
#definestrncat_PF(dest,src,len) strncat((dest), (src), (len))
91+
#definestrcmp_PF(s1,s2) strcmp((s1), (s2))
92+
#definestrncmp_PF(s1,s2,n) strncmp((s1), (s2), (n))
93+
#definestrcasecmp_PF(s1,s2) strcasecmp((s1), (s2))
94+
#definestrncasecmp_PF(s1,s2,n) strncasecmp((s1), (s2), (n))
95+
#definestrstr_PF(s1,s2) strstr((s1), (s2))
96+
#definestrlcpy_PF(dest,src,n) strlcpy((dest), (src), (n))
97+
#definememcmp_PF(s1,s2,n) memcmp((s1), (s2), (n))
98+
99+
#definesprintf_P(s,f, ...) sprintf((s), (f), __VA_ARGS__)
100+
#definesnprintf_P(s,f, ...) snprintf((s), (f), __VA_ARGS__)
101+
102+
#definepgm_read_byte(addr) (*(const unsigned char *)(addr))
103+
#definepgm_read_word(addr) (*(const unsigned short *)(addr))
104+
#definepgm_read_dword(addr) (*(const unsigned long *)(addr))
105+
#definepgm_read_float(addr) (*(const float *)(addr))
106+
#definepgm_read_ptr(addr) (*(const void *)(addr))
107+
108+
#definepgm_read_byte_near(addr) pgm_read_byte(addr)
109+
#definepgm_read_word_near(addr) pgm_read_word(addr)
110+
#definepgm_read_dword_near(addr) pgm_read_dword(addr)
111+
#definepgm_read_float_near(addr) pgm_read_float(addr)
112+
#definepgm_read_ptr_near(addr) pgm_read_ptr(addr)
113+
114+
#definepgm_read_byte_far(addr) pgm_read_byte(addr)
115+
#definepgm_read_word_far(addr) pgm_read_word(addr)
116+
#definepgm_read_dword_far(addr) pgm_read_dword(addr)
117+
#definepgm_read_float_far(addr) pgm_read_float(addr)
118+
#definepgm_read_ptr_far(addr) pgm_read_ptr(addr)
119+
120+
#definepgm_get_far_address(addr) (&(addr))
121+
122+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp