Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
e90eefc8
Commit
e90eefc8
authored
Apr 02, 2014
by
Damien George
Browse files
stmhal: Fix servo object; add fpclassify to math functions.
parent
094d4500
Changes
2
Hide whitespace changes
Inline
Side-by-side
stmhal/math.c
View file @
e90eefc8
#include
<stdint.h>
#include
<math.h>
typedef
float
float_t
;
typedef
union
{
float
f
;
...
...
@@ -86,7 +88,6 @@ float erfcf(float x) { return 0.0; }
float
modff
(
float
x
,
float
*
y
)
{
return
0
.
0
;
}
float
frexpf
(
float
x
,
int
*
exp
)
{
return
0
.
0
;
}
float
ldexpf
(
float
x
,
int
exp
)
{
return
0
.
0
;
}
int
__fpclassifyf
(
float
x
)
{
return
0
;
}
/*****************************************************************************/
// from musl-0.9.15 libm.h
...
...
@@ -135,6 +136,18 @@ do { \
(d) = __u.f; \
} while (0)
/*****************************************************************************/
// __fpclassifyf from musl-0.9.15
int
__fpclassifyf
(
float
x
)
{
union
{
float
f
;
uint32_t
i
;}
u
=
{
x
};
int
e
=
u
.
i
>>
23
&
0xff
;
if
(
!
e
)
return
u
.
i
<<
1
?
FP_SUBNORMAL
:
FP_ZERO
;
if
(
e
==
0xff
)
return
u
.
i
<<
9
?
FP_NAN
:
FP_INFINITE
;
return
FP_NORMAL
;
}
/*****************************************************************************/
// scalbnf from musl-0.9.15
...
...
stmhal/servo.c
View file @
e90eefc8
...
...
@@ -27,8 +27,6 @@ typedef struct _pyb_servo_obj_t {
uint16_t
pulse_dest
;
}
pyb_servo_obj_t
;
STATIC
const
mp_obj_type_t
servo_obj_type
;
STATIC
pyb_servo_obj_t
pyb_servo_obj
[
PYB_SERVO_NUM
];
void
servo_init
(
void
)
{
...
...
@@ -36,7 +34,7 @@ void servo_init(void) {
// reset servo objects
for
(
int
i
=
0
;
i
<
PYB_SERVO_NUM
;
i
++
)
{
pyb_servo_obj
[
i
].
base
.
type
=
&
servo_
obj_
type
;
pyb_servo_obj
[
i
].
base
.
type
=
&
pyb_
servo_type
;
pyb_servo_obj
[
i
].
servo_id
=
i
+
1
;
pyb_servo_obj
[
i
].
time_left
=
0
;
pyb_servo_obj
[
i
].
pulse_cur
=
150
;
// units of 10us
...
...
@@ -149,7 +147,7 @@ STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
// check servo number
if
(
!
(
0
<=
servo_id
&&
servo_id
<
PYB_SERVO_NUM
))
{
nlr_jump
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"Servo %d does not exist"
,
servo_id
));
nlr_jump
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"Servo %d does not exist"
,
servo_id
+
1
));
}
// get and init servo object
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment