Add setup and teardown function. Use _TEST define for main.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 26 May 2008 13:25:21 +0000 (13:25 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 26 May 2008 13:25:21 +0000 (13:25 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1371 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/arm/drv/pwm_test.c

index 447b3d59b12079e0f41c45dcf2e846a860f8cb09..a96e694152c56a7c7e60b6be0abb3d69c279bb11 100644 (file)
                        pwm_enable(PWM_TEST_CH##index, true); \
        } while (0)
 
+
+/**
+ * Setup all needed to test PWM on AT91
+ *
+ */
+int pwm_setup(void)
+{
+       IRQ_ENABLE;
+       kdbg_init();
+       sysirq_init();
+       timer_init();
+
+       pwm_init();
+
+       return 0;
+}
+
+
 /**
  * Test suit for genation of pwm waveform.
  *
  */
-void pwm_test(void)
+int pwm_test(void)
 {
 
        kputs("PWM test\n\n");
 
        kputs("Init pwm..");
-
-       pwm_init();
+       pwm_setup();
        kputs("done.\n");
 
        PWM_TEST_CH_SET(0);
@@ -107,15 +124,23 @@ void pwm_test(void)
        kprintf("PWM test set ch[%d] =>freq[%ld], duty[%d]\n", PWM_TEST_CH2, PWM_TEST_CH2_FREQ, PWM_TEST_CH2_DUTY);
        PWM_TEST_CH_SET(3);
        kprintf("PWM test set ch[%d] =>freq[%ld], duty[%d]\n", PWM_TEST_CH3, PWM_TEST_CH3_FREQ, PWM_TEST_CH3_DUTY);
+
+       return 0;
+}
+
+/**
+ *
+ */
+int pwm_tearDown(void)
+{
+       /*    */
+       return 0;
 }
 
+#ifdef _TEST
 
 int main(void)
 {
-       IRQ_ENABLE;
-       kdbg_init();
-       sysirq_init();
-       timer_init();
        pwm_test();
 
 
@@ -154,6 +179,6 @@ int main(void)
        }
 
 }
-
+#endif