X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fpwm_test.c;h=39b18b365a4dc77a1ba92e1cdbcde6b6919ec135;hb=9c41a52cad9f3a8e7c7ec1c29f8722c722d4698d;hp=cea720e4b662d4aab054153a0331b0c35878add1;hpb=97c013481a2c85dd01b8231017545360c7cc33ac;p=bertos.git diff --git a/bertos/drv/pwm_test.c b/bertos/drv/pwm_test.c index cea720e4..39b18b36 100644 --- a/bertos/drv/pwm_test.c +++ b/bertos/drv/pwm_test.c @@ -52,7 +52,7 @@ * So you can see if the hardware manage correctly this situation. * * Note: To be simple and target independently we not use a timer module, - * and so the delay is do with a for cicle. + * and so the delay is do with a for cycle. * * \version $Id$ * @@ -60,10 +60,15 @@ */ #include "hw/pwm_map.h" // For PwmDev and channel avaible on thi target - +#include "cfg/cfg_pwm.h" #include #include +// Define logging setting (for cfg/log.h module). +#define LOG_LEVEL PWM_LOG_LEVEL +#define LOG_VERBOSITY PWM_LOG_VERBOSITY +#include // for logging system + #include #include @@ -114,11 +119,11 @@ static PwmTest pwm_test_cfg[PWM_CNT] = * Setup all needed to test PWM on AT91 * */ -int pwm_testSetup(void) +int pwm_testSetUp(void) { - kputs("Init pwm.."); + LOG_INFO("Init pwm.."); pwm_init(); - kputs("done.\n"); + LOG_INFO("done.\n"); return 0; } @@ -130,41 +135,40 @@ int pwm_testSetup(void) */ int pwm_testRun(void) { - int duty = 0; + pwm_duty_t duty = 0; int delay = 0; - pwm_testSetup(); + pwm_testSetUp(); - kputs("\n\n===== BeRTOS PWM test =====\n\n"); + LOG_INFO("\n\n===== BeRTOS PWM test =====\n\n"); for (int i = 0; i < PWM_CNT; i++) { - kprintf("PWM test ch[%d]\n", pwm_test_cfg[i].ch); - - kprintf("--> set pol[%d]", pwm_test_cfg[i].pol); - kputs(" (Note: if polarity is false the output waveform start at high level,\n see low level implentation for detail)"); + LOG_INFO("PWM test ch[%d]\n", pwm_test_cfg[i].ch); + LOG_INFO("--> set pol[%d]", pwm_test_cfg[i].pol); + LOG_INFO("\n(Note: if polarity is false the output waveform start at high level,\n see low level implentation for detail)i\n"); pwm_setPolarity(pwm_test_cfg[i].ch, pwm_test_cfg[i].pol); - kputs("..ok\n"); + LOG_INFO("..ok\n"); - kprintf("--> set freq[%ld]", pwm_test_cfg[i].freq); + LOG_INFO("--> set freq[%ld]", pwm_test_cfg[i].freq); pwm_setFrequency(pwm_test_cfg[i].ch, pwm_test_cfg[i].freq); - kputs("..ok\n"); + LOG_INFO("..ok\n"); - kprintf("--> set duty[%d]", pwm_test_cfg[i].duty); + LOG_INFO("--> set duty[%d]", pwm_test_cfg[i].duty); pwm_setDuty(pwm_test_cfg[i].ch, pwm_test_cfg[i].duty); - kputs("..ok\n"); + LOG_INFO("..ok\n"); - kputs("--> Enable pwm"); + LOG_INFO("--> Enable pwm"); pwm_enable(pwm_test_cfg[i].ch, true); - kputs("..ok\n"); + LOG_INFO("..ok\n"); } - kputs("\n-------------------------- Dinamic PWM test --------------------------\n"); - kputs("We test if driver change correctly the duty cycle durind it working.\n"); - kputs("On your oscilloscope you should see the pwm singal that increase until\n"); - kputs("the duty value is 100%. After this value we invert a polarity of pwm,\n"); - kputs("and repeat the test. But now you should see that pwm duty decreasing until\n"); - kputs("0% duty value.\nAfter that, we repeat the test from beginning.\n\n"); + LOG_INFO("\n-------------------------- Dinamic PWM test --------------------------\n"); + LOG_INFO("We test if driver change correctly the duty cycle durind it working.\n"); + LOG_INFO("On your oscilloscope you should see the pwm singal that increase until\n"); + LOG_INFO("the duty value is 100%%. After this value we invert a polarity of pwm,\n"); + LOG_INFO("and repeat the test. But now you should see that pwm duty decreasing until\n"); + LOG_INFO("0%% duty value.\nAfter that, we repeat the test from beginning.\n\n"); for (;;) { @@ -172,36 +176,36 @@ int pwm_testRun(void) { for (int i = 0; i < PWM_CNT; i++) { - kprintf("PWM test ch[%d]\n", pwm_test_cfg[i].ch); - kprintf("--> set duty[%d]", duty); + LOG_INFO("PWM test ch[%d]\n", pwm_test_cfg[i].ch); + LOG_INFO("--> set duty[%d]", duty); pwm_setDuty(pwm_test_cfg[i].ch, duty); - kputs("..ok\n"); + LOG_INFO("..ok\n"); } - kputs("\n++++++++++++++++++++\n"); + LOG_INFO("\n++++++++++++++++++++\n"); duty += PWM_DUTY_INC; delay = 0; } //Reset duty cycle overflow - if (duty >= 0xFFFF) + if (duty >= (pwm_duty_t)0xFFFF) { duty = 0; for (int i = 0; i < PWM_CNT; i++) { - kputs("Duty reset, swap polarity:\n"); - kprintf("--> pol from [%d] to [%d]", pwm_test_cfg[i].pol, !pwm_test_cfg[i].pol); + LOG_INFO("Duty reset, swap polarity:\n"); + LOG_INFO("--> pol from [%d] to [%d]", pwm_test_cfg[i].pol, !pwm_test_cfg[i].pol); pwm_test_cfg[i].pol = !pwm_test_cfg[i].pol; pwm_setPolarity(pwm_test_cfg[i].ch, pwm_test_cfg[i].pol); - kputs("..ok\n"); + LOG_INFO("..ok\n"); } - kputs("\n++++++++++++++++++++\n"); + LOG_INFO("\n++++++++++++++++++++\n"); } delay++; } - return 0; + return 0; } /** @@ -220,7 +224,7 @@ int pwm_testTearDown(void) * Look it as exmple or use it if * you want test a PWM driver stand alone. */ - #if 0 +#if 0 int main(void) { IRQ_ENABLE;