9 #include "libpropeller/board/board_unit_tester.h" 
   26     static int MicrosecondsToClockCycles(
const int microseconds) {
 
   27         return (CLKFREQ * microseconds) / 1000000;
 
   30     static int ClockCyclesToMicroseconds(
const int clockCycles) {
 
   31         return clockCycles / (CLKFREQ / 1000000);
 
   34     static void setUp(
void) {
 
   41         waitcnt(CLKFREQ / 10 + CNT);
 
   45     static void tearDown(
void) {
 
   56     static void helper_CheckWidths(
const int highMicroseconds, 
const int lowMicroseconds) {
 
   61                 ClockCyclesToMicroseconds(pwr->
getLowTime(0)));
 
   64     static void helper_TestDuty(
const int percent, 
const int period) {
 
   66         waitcnt(CLKFREQ / 10 + CNT);
 
   70         helper_CheckWidths((period * percent) / 100, (period * (100 - percent)) / 100);
 
   73     static void helper_TestServo(
const int pulsewidth) {
 
   75         waitcnt(CLKFREQ / 10 + CNT);
 
   79         helper_CheckWidths(pulsewidth, 20000 - pulsewidth);
 
   82     static void helper_TestPWM(
const int high, 
const int low) {
 
   84         waitcnt(CLKFREQ / 10 + CNT);
 
   88         helper_CheckWidths(high, low);
 
   91     static void test_50PercentDuty(
void) {
 
   92         helper_TestDuty(50, 1000);
 
   95     static void test_20PercentDuty(
void) {
 
   96         helper_TestDuty(20, 1000);
 
   99     static void test_80PercentDuty(
void) {
 
  100         helper_TestDuty(80, 1000);
 
  103     static void test_ServoMiddle(
void) {
 
  104         helper_TestServo(1500);
 
  107     static void test_ServoLow(
void) {
 
  108         helper_TestServo(1000);
 
  111     static void test_ServoHigh(
void) {
 
  112         helper_TestServo(2000);
 
  115     static void test_ServoVeryLow(
void) {
 
  116         helper_TestServo(500);
 
  119     static void test_ServoVeryHigh(
void) {
 
  120         helper_TestServo(2500);
 
  123     static void test_pwmEven(
void) {
 
  124         helper_TestPWM(1000, 1000);
 
  127     static void test_pwmLongHigh(
void) {
 
  128         helper_TestPWM(2000, 100);
 
  131     static void test_pwmLongLow(
void) {
 
  132         helper_TestPWM(300, 1800);
 
  135     static void test_pwmPrimeTimes(
void) {
 
  136         helper_TestPWM(773, 907);