Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
ldrom_hid.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020, Cascoda Ltd.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the copyright holder nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef BAREMETAL_PLATFORM_CASCODA_NUVOTON_CHILI2_LDROM_HID_LDROM_HID_H_
30#define BAREMETAL_PLATFORM_CASCODA_NUVOTON_CHILI2_LDROM_HID_LDROM_HID_H_
31
32#include <stdint.h>
33
34#include "ca821x_error.h"
35#include "evbme_messages.h"
36
37/* Nuvoton BSP update from v3.00.003 to v3.00.007: */
38/* New macros switching between secure and non-secure peripheral pointers. */
39/* This causes ldrom_hid size to rise above limit of 4k. */
40/* All used macros re-named to USBD_NOTZ_* */
41#define USBD_NOTZ_GET_EP_BUF_ADDR(ep) ((uint32_t)*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].BUFSEG + (uint32_t)((ep) << 4))))
42#define USBD_NOTZ_SET_PAYLOAD_LEN(ep, size) (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].MXPLD + (uint32_t)((ep) << 4))) = (size))
43#define USBD_NOTZ_CONFIG_EP(ep, config) (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) = (config))
44#define USBD_NOTZ_SET_EP_BUF_ADDR(ep, offset) (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].BUFSEG + (uint32_t)((ep) << 4))) = (offset))
45#define USBD_NOTZ_GET_INT_FLAG() ((uint32_t)(USBD->INTSTS))
46#define USBD_NOTZ_CLR_INT_FLAG(flag) (USBD->INTSTS = (flag))
47
52{
53 uint8_t startAddr[4];
54 uint32_t data[61];
55};
56//Assert struct is packed even with uint32_t data
57#pragma GCC diagnostic push
58#pragma GCC diagnostic ignored "-Wunused-local-typedefs" //Suppresses warnings
60#pragma GCC diagnostic pop
61
73
78{
79 volatile uint8_t isReady;
80 uint8_t cmdid;
81 uint8_t len;
82 uint8_t dfu_cmdid;
84};
85
86//Assert SerialBuf struct is packed
87ca_static_assert(sizeof(struct SerialBuf) == sizeof(struct dfu_write_cmd_aligned) + 4);
88
89extern struct SerialBuf gRxBuffer;
90extern struct SerialBuf gTxBuffer;
91
92void HID_Init(void);
93void EP2_Handler(void);
94void EP3_Handler(void);
95
96//Functions to unblock IO:
97void RxHandled(void); //Call when a Rx message has been fully processed
98void TxReady(void); //Call when a Tx is ready to send
99
100#endif /* BAREMETAL_PLATFORM_CASCODA_NUVOTON_CHILI2_LDROM_HID_LDROM_HID_H_ */
Global error declarations for use across the Cascoda SDK.
Definitions relating to EVBME API messages.
#define ca_static_assert(x)
Static assert code.
Definition ca821x_error.h:88
struct SerialBuf gRxBuffer
Definition hid_transfer.c:61
struct SerialBuf gTxBuffer
Definition hid_transfer.c:62
void HID_Init(void)
USBD Endpoint Config.
Definition hid_transfer.c:271
void RxHandled(void)
Definition hid_transfer.c:212
void TxReady(void)
Definition hid_transfer.c:218
void EP3_Handler(void)
Definition hid_transfer.c:202
void EP2_Handler(void)
Definition hid_transfer.c:188
Cascoda serialbuffer structure.
Definition ldrom_hid.h:78
uint8_t dfu_cmdid
DFU cmdid.
Definition ldrom_hid.h:82
volatile uint8_t isReady
Is ready to: Tx-Write, Rx-Read.
Definition ldrom_hid.h:79
uint8_t len
Length of data.
Definition ldrom_hid.h:81
uint8_t cmdid
Cascoda command ID = EVBME_DFU_CMD (0xA3).
Definition ldrom_hid.h:80
union dfu_cmd_aligned dfu_cmd
dfu command
Definition ldrom_hid.h:83
Write command to write words of data - aligned for codespace and speed.
Definition ldrom_hid.h:52
uint32_t data[61]
Data to write, must be whole words.
Definition ldrom_hid.h:54
uint8_t startAddr[4]
Start address for writing - must be word aligned.
Definition ldrom_hid.h:53
Check command to validate flash against a checksum.
Definition evbme_messages.h:148
Erase command to erase whole pages.
Definition evbme_messages.h:130
Reboot command to boot into DFU or APROM.
Definition evbme_messages.h:122
Status command used as a reply from the Chili2 to host.
Definition evbme_messages.h:158
Union of all DFU commands - version with dfu_write_cmd_aligned.
Definition ldrom_hid.h:66
struct evbme_dfu_reboot_cmd reboot_cmd
Definition ldrom_hid.h:67
struct evbme_dfu_erase_cmd erase_cmd
Definition ldrom_hid.h:68
struct evbme_dfu_check_cmd check_cmd
Definition ldrom_hid.h:70
struct dfu_write_cmd_aligned write_cmd
Definition ldrom_hid.h:69
struct evbme_dfu_status_cmd status_cmd
Definition ldrom_hid.h:71