dcdc_example.c

来自「Sharp LH7A400 BSP平台无关部分的代码,有很高的参考价值,尤其是系」· C语言 代码 · 共 64 行

C
64
字号
#include "abl_types.h"
#include "lh7a400_dcdc_driver.h"

/***********************************************************************
 *
 * Function: c_entry
 *
 * Purpose: DCDC modulators driver example
 *
 * Processing:
 *     See function. This example sets up DCDC modulator 1 for a
 *     constant frequency and duty cycle output. (If the DCDC modulator
 *     output is connected to the speaker, a buzzing sound will be
 *     heard.)
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: Always returns 1
 *
 * Notes: None
 *
 **********************************************************************/
int c_entry(void)
{
    INT_32 dcdcdev;

    /* Open DCDC modulator */
    if ((dcdcdev = dcdc_open(DCDC, 0)) == 0x00000000)
    {
        return 0;
    }

    /* Set DCDC modulator 2 for 5/8th duty cycle for NEXTPWR = low */
    dcdc_ioctl(dcdcdev, DCDC2_SET_DUTYL, FIVE_EIGTHS);

    /* Set DCDC modulator 2 for 5/8th duty cycle for NEXTPWR = high */
    dcdc_ioctl(dcdcdev, DCDC2_SET_DUTYH, FIVE_EIGTHS);

    /* Set DCDC modulator 2 frequency to 7.2KHz for NEXTPWR = low */
    dcdc_ioctl(dcdcdev, DCDC2_SET_PSCL, SEVEN_POINT_TWO_KHZ);

    /* Set DCDC modulator 2 frequency to 7.2KHz for NEXTPWR = high */
    dcdc_ioctl(dcdcdev, DCDC2_SET_PSCH, SEVEN_POINT_TWO_KHZ);

    /* Close RTC */
    dcdc_close(dcdcdev);

    return 1;
}

#ifndef __GNUC__
/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int main(void)
{
    return c_entry();
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?