4 #include "libpropeller/board/board_unit_tester.h"
19 static int MicrosecondsToClockCycles(
const int microseconds) {
20 return (CLKFREQ * microseconds) / 1000000;
23 static int ClockCyclesToMicroseconds(
const int clockCycles) {
24 return clockCycles / (CLKFREQ / 1000000);
27 static void setUp(
void) {
36 waitcnt(CLKFREQ / 10 + CNT);
40 static void tearDown(
void) {
51 static void helper_CheckWidths(
const int highMicroseconds,
const int lowMicroseconds) {
52 TEST_ASSERT_INT_WITHIN(3, highMicroseconds,
55 TEST_ASSERT_INT_WITHIN(3, lowMicroseconds,
56 ClockCyclesToMicroseconds(pwr->
getLowTime(0)));
59 static void helper_TestDuty(
const int percent) {
65 waitcnt(CLKFREQ / 10 + CNT);
69 helper_CheckWidths((periodUs * percent) / 100, (periodUs * (100 - percent)) / 100);
72 static void test_80PercentDuty(
void) {
76 static void test_20PercentDuty(
void) {
81 static void test_50PercentDuty(
void) {