summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/HAL/drivers/include')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h89
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h175
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h111
5 files changed, 555 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h
new file mode 100644
index 00000000..c5631189
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h
@@ -0,0 +1,89 @@
+/**************************************************************************//**
+\file isdImageStorage.h
+
+\brief The public API of image storage driver.
+
+\author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+\internal
+ History:
+ 25.05.11 A. Khromykh - Created
+*******************************************************************************/
+
+#ifndef _ISDIMAGESTORAGE_H
+#define _ISDIMAGESTORAGE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <zclOTAUCluster.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Status which is returned by driver */
+typedef enum
+{
+ ISD_SUCCESS,
+ ISD_HARDWARE_FAULT,
+ ISD_COMMUNICATION_LOST
+} ISD_Status_t;
+
+typedef void (* IsdOpenCb_t)(ISD_Status_t);
+typedef void (* IsdQueryNextImageCb_t)(ZCL_OtauQueryNextImageResp_t *);
+typedef void (* IsdImageBlockCb_t)(ZCL_OtauImageBlockResp_t *);
+typedef void (* IsdUpgradeEndCb_t)(ZCL_OtauUpgradeEndResp_t *);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Open image storage driver
+
+\param[in] cb - callback about driver actions
+******************************************************************************/
+void ISD_Open(IsdOpenCb_t cb);
+
+/**************************************************************************//**
+\brief Close image storage driver
+******************************************************************************/
+void ISD_Close(void);
+
+/**************************************************************************//**
+\brief Send query next image request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_QueryNextImageReq(ZCL_Addressing_t *addressing, ZCL_OtauQueryNextImageReq_t *data, IsdQueryNextImageCb_t cb);
+
+/**************************************************************************//**
+\brief Send image block request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_ImageBlockReq(ZCL_Addressing_t *addressing, ZCL_OtauImageBlockReq_t *data, IsdImageBlockCb_t cb);
+
+/**************************************************************************//**
+\brief Send upgrade end request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_UpgradeEndReq(ZCL_Addressing_t *addressing, ZCL_OtauUpgradeEndReq_t *data, IsdUpgradeEndCb_t cb);
+
+#endif /* _ISDIMAGESTORAGE_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h
new file mode 100644
index 00000000..f8957a90
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h
@@ -0,0 +1,71 @@
+/****************************************************************************//**
+ \file massStorageDevice.h
+
+ \brief The header file describes the interface of the mass storage device
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _MASSSTORAGEDEVICE_H
+#define _MASSSTORAGEDEVICE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define MSD_TRANSMIT_PIPE 5
+#define MSD_RECEIVE_PIPE 6
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Status messages for upper layer about msd status */
+typedef enum
+{
+ MSD_STATUS_SUCCESS = 0,
+ MSD_INTERFACE_BUSY,
+ MSD_MEMORY_INIT_ERROR,
+ MSD_READ_CAPACITY_ERROR,
+ MSD_READ_ERROR,
+ MSD_WRITE_ERROR
+} MSD_Status_t;
+
+typedef void (* MSD_Callback_t)(MSD_Status_t);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens mass storage device.
+\param[in]
+ callback - pointer to function to notify about MSD errors and transactions;
+ responseBuffer - pointer to hsmci command response buffer; it should have
+ a size of four;
+ buffer - pointer to buffer for hsmci data transfer; it should be
+ a multiplier of 512;
+ length - length of buffer for data transfer.
+\return
+ nothing
+******************************************************************************/
+void MSD_Open(MSD_Callback_t callback, uint32_t *responseBuffer, uint8_t *buffer, uint32_t length);
+
+/**************************************************************************//**
+\brief Closes mass storage device.
+\return
+ nothing
+******************************************************************************/
+void MSD_Close(void);
+
+#endif /* _MASSSTORAGEDEVICE_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h
new file mode 100644
index 00000000..e15ed8fd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h
@@ -0,0 +1,175 @@
+/**************************************************************************//**
+\file ofdExtMemory.h
+
+\brief The public API of external flash driver.
+
+\author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+\internal
+ History:
+ 31/07/09 A. Khromykh - Created
+*******************************************************************************/
+
+#ifndef _OFDEXTMEMORY_H
+#define _OFDEXTMEMORY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/** \brief Size of memory block for internal ofd algorithms */
+#define OFD_BLOCK_FOR_CHECK_CRC 64
+#define OFD_BLOCK_SIZE OFD_BLOCK_FOR_CHECK_CRC
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Status messages for upper component about ofd state */
+typedef enum
+{
+ OFD_STATUS_SUCCESS = 0,
+ OFD_STATUS_SERIAL_BUSY,
+ OFD_STATUS_UNKNOWN_EXTERNAL_FLASH_TYPE,
+ OFD_STATUS_INCORRECT_API_PARAMETER,
+ OFD_STATUS_INCORRECT_EEPROM_PARAMETER,
+ OFD_SERIAL_INTERFACE_BUSY
+} OFD_Status_t ;
+
+/** \brief Number of position for image in the external flash */
+typedef enum
+{
+ OFD_POSITION_1,
+ OFD_POSITION_2,
+ OFD_POSITION_MAX
+} OFD_Position_t;
+
+/** \brief Source type which was been initiator of image saving. */
+typedef enum
+{
+ OFD_IMAGE_WAS_SAVED_FROM_MCU,
+ OFD_IMAGE_WAS_WRITTEN_THROUGH_API,
+} OFD_ImageSource_t;
+
+/** \brief Parameters for access to external memory \n
+ offset - offset from start address \n
+ data - pointer to mcu ram area with\for data for\from external memory \n
+ length - size of mcu ram area with\for data. */
+typedef struct
+{
+ uint32_t offset;
+ uint8_t *data;
+ uint32_t length;
+} OFD_MemoryAccessParam_t;
+
+/** \brief image crc */
+typedef uint8_t OFD_Crc_t;
+
+/** \brief Image information. Crc and image type. */
+typedef struct
+{
+ OFD_ImageSource_t type;
+ OFD_Crc_t crc;
+} OFD_ImageInfo_t;
+
+/** \brief callback methods for OFD API. \n
+ ATTENTION!!!! Callback functions must not call public OFD API directly.
+ */
+typedef void (* OFD_Callback_t)(OFD_Status_t);
+typedef void (* OFD_InfoCallback_t)(OFD_Status_t, OFD_ImageInfo_t *);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens serial interface and checks memory type.
+
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Open(OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Closes serial interface.
+******************************************************************************/
+void OFD_Close(void);
+
+/**************************************************************************//**
+\brief Erases image in the external memory.
+
+\param[in]
+ pos - image position in the external memory
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_EraseImage(OFD_Position_t pos, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Writes data to the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ accessParam - pointer to the access structure
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Write(OFD_Position_t pos, OFD_MemoryAccessParam_t *accessParam, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Flushes data from internal buffer, checks image crc and saves it to
+the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ countBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_FlushAndCheckCrc(OFD_Position_t pos, uint8_t *countBuff, OFD_InfoCallback_t cb);
+
+/**************************************************************************//**
+\brief Saves current mcu flash and eeprom to the external memory, checks crc for its
+and set command for bootloader.
+
+\param[in]
+ whereToSave - image position for current mcu flash and eeprom
+\param[in]
+ from - new image position
+\param[in]
+ copyBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_SwitchToNewImage(OFD_Position_t whereToSave, OFD_Position_t from, uint8_t *copyBuff, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Sets command for bootloader.
+
+\param[in]
+ from - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ChangeImage(OFD_Position_t from, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Reads image informations.
+
+\param[in]
+ pos - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ReadImageInfo(OFD_Position_t pos, OFD_InfoCallback_t cb);
+
+#endif /* _OFDEXTMEMORY_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h
new file mode 100644
index 00000000..8725d322
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h
@@ -0,0 +1,109 @@
+/**************************************************************************//**
+\file usbFifoUsart.h
+
+\brief The public API of usb fifo vitual COM port driver based on FTDI FT245RL.
+
+\author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+\internal
+ History:
+ 12.07.11 A. Khromykh - Created
+*******************************************************************************/
+#ifndef _USBFIFOUSART_H
+#define _USBFIFOUSART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define USART_CHANNEL_USBFIFO ((UsartChannel_t)6)
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens driver and registers event handlers.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ Returns positive uart descriptor on success or -1 in cases: \n
+ - bad uart channel; \n
+ - there are not enough resources; \n
+ - receiving buffer is less bulk endpoint size;
+******************************************************************************/
+int USBFIFO_OpenUsart(HAL_UsartDescriptor_t *descriptor);
+
+/*************************************************************************//**
+\brief Releases the driver.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ -1 - bad descriptor; \n
+ 0 - success.
+*****************************************************************************/
+int USBFIFO_CloseUsart(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Writes a number of bytes to driver.
+txCallback function will be used to notify when the transmission is finished.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application data buffer;
+
+\param[in]
+ length - number of bytes to transfer;
+
+\return
+ -1 - bad descriptor; \n
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int USBFIFO_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/*************************************************************************//**
+\brief Reads a number of bytes from driver and places them to the buffer.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application buffer;
+
+\param[in]
+ length - number of bytes to be placed to the buffer;
+
+\return
+ -1 - bad descriptor, or bad number of bytes to read; \n
+ Number of bytes placed to the buffer - success.
+*****************************************************************************/
+int USBFIFO_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer (for polling mode).
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+\return
+ -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int USBFIFO_IsTxEmpty(HAL_UsartDescriptor_t *descriptor);
+
+#endif /* _USBFIFOUSART_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h
new file mode 100644
index 00000000..0c54d8d1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h
@@ -0,0 +1,111 @@
+/****************************************************************************//**
+ \file vcpVirtualUsart.h
+
+ \brief The header file describes the interface of the virtual uart based on USB
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 05/09/08 A. Khromykh - Created
+*******************************************************************************/
+#ifndef _VCPVIRTUALUART_H
+#define _VCPVIRTUALUART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define USART_CHANNEL_VCP ((UsartChannel_t)5)
+#define VCP_TRANSMIT_PIPE 2
+#define VCP_RECEIVE_PIPE 1
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers uart's event handlers.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ Returns positive uart descriptor on success or -1 in cases: \n
+ - bad uart channel; \n
+ - there are not enough resources; \n
+ - receiving buffer is less bulk endpoint size;
+******************************************************************************/
+int VCP_OpenUsart(HAL_UsartDescriptor_t *descriptor);
+
+/*************************************************************************//**
+\brief Releases the uart channel.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ -1 - bad descriptor; \n
+ 0 - success.
+*****************************************************************************/
+int VCP_CloseUsart(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Writes a number of bytes to uart channel.
+txCallback function will be used to notify when the transmission is finished.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application data buffer;
+
+\param[in]
+ length - number of bytes to transfer;
+
+\return
+ -1 - bad descriptor; \n
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int VCP_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/*************************************************************************//**
+\brief Reads a number of bytes from uart and places them to the buffer.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application buffer;
+
+\param[in]
+ length - number of bytes to be placed to the buffer;
+
+\return
+ -1 - bad descriptor, or bad number of bytes to read; \n
+ Number of bytes placed to the buffer - success.
+*****************************************************************************/
+int VCP_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer (for polling mode).
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+\return
+ -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int VCP_IsTxEmpty(HAL_UsartDescriptor_t *descriptor);
+
+#endif /* _VCPVIRTUALUART_H */