SAMV71 Xplained Ultra Software Package 1.3

main.c File Reference

#include "board.h"
#include "libstoragemedia.h"
#include <USBD_Config.h>
#include <USBD_LEDs.h>
#include <HIDMSDDriver.h>
#include <HIDDKeyboard.h>
#include <MSDFunction.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Defines

#define NO_PUSHBUTTON
#define MCK   BOARD_MCK
#define NUM_KEYS   2
#define NUM_NORMAL_KEYS   1
#define NUM_MODIFIER_KEYS   (NUM_KEYS - NUM_NORMAL_KEYS)
#define LED_NUMLOCK   USBD_LEDOTHER
#define MAX_LUNS   1
#define DRV_RAMDISK   0
#define DRV_SDMMC   1
#define DRV_NAND   2
#define BLOCK_SIZE   512
#define MSD_BUFFER_SIZE   (12*BLOCK_SIZE)
#define RAMDISK_SIZE   128*1024
#define RAMDISK_BASE_ADDR   ((uint32_t)ramdisk_reserved)
#define MSD_REFRESH_LOOP   0

Functions

 COMPILER_SECTION ("ramdisk_region")
void USBDDriverCallbacks_ConfigurationChanged (uint8_t cfgnum)
void USBDCallbacks_RequestReceived (const USBGenericRequest *request)
void HIDDKeyboardCallbacks_LedsChanged (uint8_t numLockStatus, uint8_t capsLockStatus, uint8_t scrollLockStatus)
int main (void)

Variables

sMedia medias [MAX_LUNS]
MSDLun luns [MAX_LUNS]
uint8_t msdBuffer [MSD_BUFFER_SIZE]
uint32_t msdWriteTotal = 0
uint32_t msdRefreshDelay = MSD_REFRESH_LOOP

Detailed Description

This file contains all the specific code for the usb_hid_msd

Contents

The code can be roughly broken down as follows:

Definition in file main.c.


Define Documentation

#define BLOCK_SIZE   512

Size of one block in bytes.

Definition at line 172 of file main.c.

#define DRV_NAND   2

Nand flash

Definition at line 169 of file main.c.

#define DRV_RAMDISK   0

Media index for different disks RAM disk

Definition at line 167 of file main.c.

#define DRV_SDMMC   1

SD card

Definition at line 168 of file main.c.

#define LED_NUMLOCK   USBD_LEDOTHER

Num lock LED index.

Definition at line 161 of file main.c.

#define MAX_LUNS   1

Maximum number of LUNs which can be defined.

Definition at line 165 of file main.c.

#define MCK   BOARD_MCK

Master clock frequency in Hz

Definition at line 149 of file main.c.

#define MSD_BUFFER_SIZE   (12*BLOCK_SIZE)

Size of the MSD IO buffer in bytes (6K, more the better).

Definition at line 175 of file main.c.

#define NUM_KEYS   2

Number of keys used in the example.

Definition at line 152 of file main.c.

#define NUM_MODIFIER_KEYS   (NUM_KEYS - NUM_NORMAL_KEYS)

Number of modifier keys.

Definition at line 158 of file main.c.

#define NUM_NORMAL_KEYS   1

Number of non-modifiers keys.

Definition at line 155 of file main.c.

#define RAMDISK_SIZE   128*1024

Ramdisk size: 20K (WinXP can not format the disk if lower than 20K)

Definition at line 178 of file main.c.


Function Documentation

COMPILER_SECTION ( "ramdisk_region"   ) 

List of pinsPushButtons to configure for the application.

Definition at line 180 of file main.c.

void HIDDKeyboardCallbacks_LedsChanged ( uint8_t  numLockStatus,
uint8_t  capsLockStatus,
uint8_t  scrollLockStatus 
)

Invoked when the status of the keyboard LEDs changes. Turns the num. lock LED on or off.

Parameters:
numLockStatus Indicates the current status of the num. lock key.
capsLockStatus Indicates the current status of the caps lock key.
scrollLockStatus Indicates the current status of the scroll lock key

Definition at line 307 of file main.c.

Here is the call graph for this function:

int main ( void   ) 

Initializes drivers and start the USB composite device.

Definition at line 444 of file main.c.

Here is the call graph for this function:

void USBDCallbacks_RequestReceived ( const USBGenericRequest request  ) 

Invoked when a new SETUP request is received from the host. Forwards the request to the Mass Storage device driver handler function.

Parameters:
request Pointer to a USBGenericRequest instance.

Definition at line 247 of file main.c.

Here is the call graph for this function:

void USBDDriverCallbacks_ConfigurationChanged ( uint8_t  cfgnum  ) 

Invoked when the configuration of the device changes. Parse used endpoints.

Parameters:
cfgnum New configuration number.

Definition at line 237 of file main.c.

Here is the call graph for this function:


Variable Documentation

MSDLun luns[MAX_LUNS]

Device LUNs.

Definition at line 220 of file main.c.

sMedia medias[MAX_LUNS]

Available media.

Definition at line 217 of file main.c.

uint8_t msdBuffer[MSD_BUFFER_SIZE]

LUN read/write buffer.

Definition at line 223 of file main.c.

uint32_t msdRefreshDelay = MSD_REFRESH_LOOP

Delay for data write refresh

Definition at line 228 of file main.c.

uint32_t msdWriteTotal = 0

Total data write to disk

Definition at line 226 of file main.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines