aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/fx3/b200/bootloader/main.c
blob: f46690813f3190487859d7429dae520d83e26c7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Copyright 2011-2012 Cypress Semiconductor Corporation
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//

#include "cyfx3usb.h"
#include "cyfx3device.h"

extern void usbBoot (void);
extern uint8_t glCheckForDisconnect;
extern uint8_t glInCompliance;

int main (void)
{
    CyFx3BootErrorCode_t status;
    CyFx3BootIoMatrixConfig_t ioCfg = {
        .isDQ32Bit       = CyFalse,
        .useUart         = CyFalse,
        .useI2C          = CyTrue,
        .useI2S          = CyFalse,
        .useSpi          = CyFalse,
        .gpioSimpleEn[0] = 0,
        .gpioSimpleEn[1] = 0
    };

    CyFx3BootDeviceInit(CyTrue);

    status = CyFx3BootDeviceConfigureIOMatrix(&ioCfg);

    if (status != CY_FX3_BOOT_SUCCESS)
    {
        return status;
    }

    usbBoot();

    while (1)
    {
        if (glCheckForDisconnect)
        {
            CyFx3BootUsbCheckUsb3Disconnect();
            glCheckForDisconnect = 0;
        }

        if (glInCompliance)
        {
            CyFx3BootUsbSendCompliancePatterns();
            glInCompliance = 0;
        }
    }
    return 0;
}