convert from u_int*_t to uint*_t
Change-Id: I33f6383535c5860b833f7ccb9bea122d38f28e3f
This commit is contained in:
parent
5a40e2fed1
commit
373c172ab8
|
@ -6,12 +6,12 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
struct openpcd_hdr {
|
struct openpcd_hdr {
|
||||||
u_int8_t cmd; /* command. high nibble: class,
|
uint8_t cmd; /* command. high nibble: class,
|
||||||
* low nibble: cmd */
|
* low nibble: cmd */
|
||||||
u_int8_t flags;
|
uint8_t flags;
|
||||||
u_int8_t reg; /* register */
|
uint8_t reg; /* register */
|
||||||
u_int8_t val; /* value (in case of write *) */
|
uint8_t val; /* value (in case of write *) */
|
||||||
u_int8_t data[0];
|
uint8_t data[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define OPCD_REV_LEN 16
|
#define OPCD_REV_LEN 16
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
/* this is kept compatible with OpenPCD protocol */
|
/* this is kept compatible with OpenPCD protocol */
|
||||||
struct simtrace_hdr {
|
struct simtrace_hdr {
|
||||||
u_int8_t cmd;
|
uint8_t cmd;
|
||||||
u_int8_t flags;
|
uint8_t flags;
|
||||||
u_int8_t res[2];
|
uint8_t res[2];
|
||||||
u_int8_t data[0];
|
uint8_t data[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
enum simtrace_usb_msgt {
|
enum simtrace_usb_msgt {
|
||||||
|
@ -24,14 +24,14 @@ enum simtrace_usb_msgt {
|
||||||
#define SIMTRACE_FLAG_PPS_FIDI 0x08 /* Fi/Di values in res[2] */
|
#define SIMTRACE_FLAG_PPS_FIDI 0x08 /* Fi/Di values in res[2] */
|
||||||
|
|
||||||
struct simtrace_stats {
|
struct simtrace_stats {
|
||||||
u_int32_t no_rctx;
|
uint32_t no_rctx;
|
||||||
u_int32_t rctx_sent;
|
uint32_t rctx_sent;
|
||||||
u_int32_t rst;
|
uint32_t rst;
|
||||||
u_int32_t pps;
|
uint32_t pps;
|
||||||
u_int32_t bytes;
|
uint32_t bytes;
|
||||||
u_int32_t parity_err;
|
uint32_t parity_err;
|
||||||
u_int32_t frame_err;
|
uint32_t frame_err;
|
||||||
u_int32_t overrun;
|
uint32_t overrun;
|
||||||
} stats;
|
} stats;
|
||||||
|
|
||||||
#endif /* SIMTRACE_USB_H */
|
#endif /* SIMTRACE_USB_H */
|
||||||
|
|
|
@ -119,11 +119,11 @@
|
||||||
* such requests may be made at any time.
|
* such requests may be made at any time.
|
||||||
*/
|
*/
|
||||||
struct usb_ctrlrequest {
|
struct usb_ctrlrequest {
|
||||||
u_int8_t bRequestType;
|
uint8_t bRequestType;
|
||||||
u_int8_t bRequest;
|
uint8_t bRequest;
|
||||||
u_int16_t wValue;
|
uint16_t wValue;
|
||||||
u_int16_t wIndex;
|
uint16_t wIndex;
|
||||||
u_int16_t wLength;
|
uint16_t wLength;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -169,8 +169,8 @@ struct usb_ctrlrequest {
|
||||||
|
|
||||||
/* All standard descriptors have these 2 fields at the beginning */
|
/* All standard descriptors have these 2 fields at the beginning */
|
||||||
struct usb_descriptor_header {
|
struct usb_descriptor_header {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,21 +178,21 @@ struct usb_descriptor_header {
|
||||||
|
|
||||||
/* USB_DT_DEVICE: Device descriptor */
|
/* USB_DT_DEVICE: Device descriptor */
|
||||||
struct usb_device_descriptor {
|
struct usb_device_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int16_t bcdUSB;
|
uint16_t bcdUSB;
|
||||||
u_int8_t bDeviceClass;
|
uint8_t bDeviceClass;
|
||||||
u_int8_t bDeviceSubClass;
|
uint8_t bDeviceSubClass;
|
||||||
u_int8_t bDeviceProtocol;
|
uint8_t bDeviceProtocol;
|
||||||
u_int8_t bMaxPacketSize0;
|
uint8_t bMaxPacketSize0;
|
||||||
u_int16_t idVendor;
|
uint16_t idVendor;
|
||||||
u_int16_t idProduct;
|
uint16_t idProduct;
|
||||||
u_int16_t bcdDevice;
|
uint16_t bcdDevice;
|
||||||
u_int8_t iManufacturer;
|
uint8_t iManufacturer;
|
||||||
u_int8_t iProduct;
|
uint8_t iProduct;
|
||||||
u_int8_t iSerialNumber;
|
uint8_t iSerialNumber;
|
||||||
u_int8_t bNumConfigurations;
|
uint8_t bNumConfigurations;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define USB_DT_DEVICE_SIZE 18
|
#define USB_DT_DEVICE_SIZE 18
|
||||||
|
@ -231,15 +231,15 @@ struct usb_device_descriptor {
|
||||||
* descriptors.
|
* descriptors.
|
||||||
*/
|
*/
|
||||||
struct usb_config_descriptor {
|
struct usb_config_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int16_t wTotalLength;
|
uint16_t wTotalLength;
|
||||||
u_int8_t bNumInterfaces;
|
uint8_t bNumInterfaces;
|
||||||
u_int8_t bConfigurationValue;
|
uint8_t bConfigurationValue;
|
||||||
u_int8_t iConfiguration;
|
uint8_t iConfiguration;
|
||||||
u_int8_t bmAttributes;
|
uint8_t bmAttributes;
|
||||||
u_int8_t bMaxPower;
|
uint8_t bMaxPower;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define USB_DT_CONFIG_SIZE 9
|
#define USB_DT_CONFIG_SIZE 9
|
||||||
|
@ -254,10 +254,10 @@ struct usb_config_descriptor {
|
||||||
|
|
||||||
/* USB_DT_STRING: String descriptor */
|
/* USB_DT_STRING: String descriptor */
|
||||||
struct usb_string_descriptor {
|
struct usb_string_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int16_t wData[0]; /* UTF-16LE encoded */
|
uint16_t wData[0]; /* UTF-16LE encoded */
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* note that "string" zero is special, it holds language codes that
|
/* note that "string" zero is special, it holds language codes that
|
||||||
|
@ -268,16 +268,16 @@ struct usb_string_descriptor {
|
||||||
|
|
||||||
/* USB_DT_INTERFACE: Interface descriptor */
|
/* USB_DT_INTERFACE: Interface descriptor */
|
||||||
struct usb_interface_descriptor {
|
struct usb_interface_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int8_t bInterfaceNumber;
|
uint8_t bInterfaceNumber;
|
||||||
u_int8_t bAlternateSetting;
|
uint8_t bAlternateSetting;
|
||||||
u_int8_t bNumEndpoints;
|
uint8_t bNumEndpoints;
|
||||||
u_int8_t bInterfaceClass;
|
uint8_t bInterfaceClass;
|
||||||
u_int8_t bInterfaceSubClass;
|
uint8_t bInterfaceSubClass;
|
||||||
u_int8_t bInterfaceProtocol;
|
uint8_t bInterfaceProtocol;
|
||||||
u_int8_t iInterface;
|
uint8_t iInterface;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define USB_DT_INTERFACE_SIZE 9
|
#define USB_DT_INTERFACE_SIZE 9
|
||||||
|
@ -286,13 +286,13 @@ struct usb_interface_descriptor {
|
||||||
|
|
||||||
/* USB_DT_ENDPOINT: Endpoint descriptor */
|
/* USB_DT_ENDPOINT: Endpoint descriptor */
|
||||||
struct usb_endpoint_descriptor {
|
struct usb_endpoint_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int8_t bEndpointAddress;
|
uint8_t bEndpointAddress;
|
||||||
u_int8_t bmAttributes;
|
uint8_t bmAttributes;
|
||||||
u_int16_t wMaxPacketSize;
|
uint16_t wMaxPacketSize;
|
||||||
u_int8_t bInterval;
|
uint8_t bInterval;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define USB_DT_ENDPOINT_SIZE 7
|
#define USB_DT_ENDPOINT_SIZE 7
|
||||||
|
@ -317,16 +317,16 @@ struct usb_endpoint_descriptor {
|
||||||
|
|
||||||
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
|
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
|
||||||
struct usb_qualifier_descriptor {
|
struct usb_qualifier_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int16_t bcdUSB;
|
uint16_t bcdUSB;
|
||||||
u_int8_t bDeviceClass;
|
uint8_t bDeviceClass;
|
||||||
u_int8_t bDeviceSubClass;
|
uint8_t bDeviceSubClass;
|
||||||
u_int8_t bDeviceProtocol;
|
uint8_t bDeviceProtocol;
|
||||||
u_int8_t bMaxPacketSize0;
|
uint8_t bMaxPacketSize0;
|
||||||
u_int8_t bNumConfigurations;
|
uint8_t bNumConfigurations;
|
||||||
u_int8_t bRESERVED;
|
uint8_t bRESERVED;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,10 +334,10 @@ struct usb_qualifier_descriptor {
|
||||||
|
|
||||||
/* USB_DT_OTG (from OTG 1.0a supplement) */
|
/* USB_DT_OTG (from OTG 1.0a supplement) */
|
||||||
struct usb_otg_descriptor {
|
struct usb_otg_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int8_t bmAttributes; /* support for HNP, SRP, etc */
|
uint8_t bmAttributes; /* support for HNP, SRP, etc */
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* from usb_otg_descriptor.bmAttributes */
|
/* from usb_otg_descriptor.bmAttributes */
|
||||||
|
@ -348,27 +348,27 @@ struct usb_otg_descriptor {
|
||||||
|
|
||||||
/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
|
/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
|
||||||
struct usb_debug_descriptor {
|
struct usb_debug_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
/* bulk endpoints with 8 byte maxpacket */
|
/* bulk endpoints with 8 byte maxpacket */
|
||||||
u_int8_t bDebugInEndpoint;
|
uint8_t bDebugInEndpoint;
|
||||||
u_int8_t bDebugOutEndpoint;
|
uint8_t bDebugOutEndpoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
|
/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
|
||||||
struct usb_interface_assoc_descriptor {
|
struct usb_interface_assoc_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int8_t bFirstInterface;
|
uint8_t bFirstInterface;
|
||||||
u_int8_t bInterfaceCount;
|
uint8_t bInterfaceCount;
|
||||||
u_int8_t bFunctionClass;
|
uint8_t bFunctionClass;
|
||||||
u_int8_t bFunctionSubClass;
|
uint8_t bFunctionSubClass;
|
||||||
u_int8_t bFunctionProtocol;
|
uint8_t bFunctionProtocol;
|
||||||
u_int8_t iFunction;
|
uint8_t iFunction;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
@ -378,11 +378,11 @@ struct usb_interface_assoc_descriptor {
|
||||||
* encryption types available for setting up a CC/association.
|
* encryption types available for setting up a CC/association.
|
||||||
*/
|
*/
|
||||||
struct usb_security_descriptor {
|
struct usb_security_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int16_t wTotalLength;
|
uint16_t wTotalLength;
|
||||||
u_int8_t bNumEncryptionTypes;
|
uint8_t bNumEncryptionTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -391,28 +391,28 @@ struct usb_security_descriptor {
|
||||||
* may be retrieved.
|
* may be retrieved.
|
||||||
*/
|
*/
|
||||||
struct usb_key_descriptor {
|
struct usb_key_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int8_t tTKID[3];
|
uint8_t tTKID[3];
|
||||||
u_int8_t bReserved;
|
uint8_t bReserved;
|
||||||
u_int8_t bKeyData[0];
|
uint8_t bKeyData[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
|
/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
|
||||||
struct usb_encryption_descriptor {
|
struct usb_encryption_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int8_t bEncryptionType;
|
uint8_t bEncryptionType;
|
||||||
#define USB_ENC_TYPE_UNSECURE 0
|
#define USB_ENC_TYPE_UNSECURE 0
|
||||||
#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
|
#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
|
||||||
#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
|
#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
|
||||||
#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
|
#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
|
||||||
u_int8_t bEncryptionValue; /* use in SET_ENCRYPTION */
|
uint8_t bEncryptionValue; /* use in SET_ENCRYPTION */
|
||||||
u_int8_t bAuthKeyIndex;
|
uint8_t bAuthKeyIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -420,36 +420,36 @@ struct usb_encryption_descriptor {
|
||||||
|
|
||||||
/* USB_DT_BOS: group of wireless capabilities */
|
/* USB_DT_BOS: group of wireless capabilities */
|
||||||
struct usb_bos_descriptor {
|
struct usb_bos_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int16_t wTotalLength;
|
uint16_t wTotalLength;
|
||||||
u_int8_t bNumDeviceCaps;
|
uint8_t bNumDeviceCaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
|
/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
|
||||||
struct usb_dev_cap_header {
|
struct usb_dev_cap_header {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
u_int8_t bDevCapabilityType;
|
uint8_t bDevCapabilityType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define USB_CAP_TYPE_WIRELESS_USB 1
|
#define USB_CAP_TYPE_WIRELESS_USB 1
|
||||||
|
|
||||||
struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
|
struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
u_int8_t bDevCapabilityType;
|
uint8_t bDevCapabilityType;
|
||||||
|
|
||||||
u_int8_t bmAttributes;
|
uint8_t bmAttributes;
|
||||||
#define USB_WIRELESS_P2P_DRD (1 << 1)
|
#define USB_WIRELESS_P2P_DRD (1 << 1)
|
||||||
#define USB_WIRELESS_BEACON_MASK (3 << 2)
|
#define USB_WIRELESS_BEACON_MASK (3 << 2)
|
||||||
#define USB_WIRELESS_BEACON_SELF (1 << 2)
|
#define USB_WIRELESS_BEACON_SELF (1 << 2)
|
||||||
#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
|
#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
|
||||||
#define USB_WIRELESS_BEACON_NONE (3 << 2)
|
#define USB_WIRELESS_BEACON_NONE (3 << 2)
|
||||||
u_int16_t wPHYRates; /* bit rates, Mbps */
|
uint16_t wPHYRates; /* bit rates, Mbps */
|
||||||
#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
|
#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
|
||||||
#define USB_WIRELESS_PHY_80 (1 << 1)
|
#define USB_WIRELESS_PHY_80 (1 << 1)
|
||||||
#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
|
#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
|
||||||
|
@ -458,10 +458,10 @@ struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
|
||||||
#define USB_WIRELESS_PHY_320 (1 << 5)
|
#define USB_WIRELESS_PHY_320 (1 << 5)
|
||||||
#define USB_WIRELESS_PHY_400 (1 << 6)
|
#define USB_WIRELESS_PHY_400 (1 << 6)
|
||||||
#define USB_WIRELESS_PHY_480 (1 << 7)
|
#define USB_WIRELESS_PHY_480 (1 << 7)
|
||||||
u_int8_t bmTFITXPowerInfo; /* TFI power levels */
|
uint8_t bmTFITXPowerInfo; /* TFI power levels */
|
||||||
u_int8_t bmFFITXPowerInfo; /* FFI power levels */
|
uint8_t bmFFITXPowerInfo; /* FFI power levels */
|
||||||
u_int16_t bmBandGroup;
|
uint16_t bmBandGroup;
|
||||||
u_int8_t bReserved;
|
uint8_t bReserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -470,15 +470,15 @@ struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
|
||||||
* each endpoint descriptor for a wireless device
|
* each endpoint descriptor for a wireless device
|
||||||
*/
|
*/
|
||||||
struct usb_wireless_ep_comp_descriptor {
|
struct usb_wireless_ep_comp_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
u_int8_t bMaxBurst;
|
uint8_t bMaxBurst;
|
||||||
u_int8_t bMaxSequence;
|
uint8_t bMaxSequence;
|
||||||
u_int16_t wMaxStreamDelay;
|
uint16_t wMaxStreamDelay;
|
||||||
u_int16_t wOverTheAirPacketSize;
|
uint16_t wOverTheAirPacketSize;
|
||||||
u_int8_t bOverTheAirInterval;
|
uint8_t bOverTheAirInterval;
|
||||||
u_int8_t bmCompAttributes;
|
uint8_t bmCompAttributes;
|
||||||
#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
|
#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
|
||||||
#define USB_ENDPOINT_SWITCH_NO 0
|
#define USB_ENDPOINT_SWITCH_NO 0
|
||||||
#define USB_ENDPOINT_SWITCH_SWITCH 1
|
#define USB_ENDPOINT_SWITCH_SWITCH 1
|
||||||
|
@ -492,13 +492,13 @@ struct usb_wireless_ep_comp_descriptor {
|
||||||
* exchanging short lived session keys. The handshake depends on a CC.
|
* exchanging short lived session keys. The handshake depends on a CC.
|
||||||
*/
|
*/
|
||||||
struct usb_handshake {
|
struct usb_handshake {
|
||||||
u_int8_t bMessageNumber;
|
uint8_t bMessageNumber;
|
||||||
u_int8_t bStatus;
|
uint8_t bStatus;
|
||||||
u_int8_t tTKID[3];
|
uint8_t tTKID[3];
|
||||||
u_int8_t bReserved;
|
uint8_t bReserved;
|
||||||
u_int8_t CDID[16];
|
uint8_t CDID[16];
|
||||||
u_int8_t nonce[16];
|
uint8_t nonce[16];
|
||||||
u_int8_t MIC[8];
|
uint8_t MIC[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -508,9 +508,9 @@ struct usb_handshake {
|
||||||
* wired USB!), and some devices may support CCs with multiple hosts.
|
* wired USB!), and some devices may support CCs with multiple hosts.
|
||||||
*/
|
*/
|
||||||
struct usb_connection_context {
|
struct usb_connection_context {
|
||||||
u_int8_t CHID[16]; /* persistent host id */
|
uint8_t CHID[16]; /* persistent host id */
|
||||||
u_int8_t CDID[16]; /* device id (unique w/in host context) */
|
uint8_t CDID[16]; /* device id (unique w/in host context) */
|
||||||
u_int8_t CK[16]; /* connection key */
|
uint8_t CK[16]; /* connection key */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
#define USB_DT_DFU 0x21
|
#define USB_DT_DFU 0x21
|
||||||
|
|
||||||
struct usb_dfu_func_descriptor {
|
struct usb_dfu_func_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
u_int8_t bmAttributes;
|
uint8_t bmAttributes;
|
||||||
#define USB_DFU_CAN_DOWNLOAD (1 << 0)
|
#define USB_DFU_CAN_DOWNLOAD (1 << 0)
|
||||||
#define USB_DFU_CAN_UPLOAD (1 << 1)
|
#define USB_DFU_CAN_UPLOAD (1 << 1)
|
||||||
#define USB_DFU_MANIFEST_TOL (1 << 2)
|
#define USB_DFU_MANIFEST_TOL (1 << 2)
|
||||||
#define USB_DFU_WILL_DETACH (1 << 3)
|
#define USB_DFU_WILL_DETACH (1 << 3)
|
||||||
u_int16_t wDetachTimeOut;
|
uint16_t wDetachTimeOut;
|
||||||
u_int16_t wTransferSize;
|
uint16_t wTransferSize;
|
||||||
u_int16_t bcdDFUVersion;
|
uint16_t bcdDFUVersion;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define USB_DT_DFU_SIZE 9
|
#define USB_DT_DFU_SIZE 9
|
||||||
|
@ -41,10 +41,10 @@ struct usb_dfu_func_descriptor {
|
||||||
#define USB_REQ_DFU_ABORT 0x06
|
#define USB_REQ_DFU_ABORT 0x06
|
||||||
|
|
||||||
struct dfu_status {
|
struct dfu_status {
|
||||||
u_int8_t bStatus;
|
uint8_t bStatus;
|
||||||
u_int8_t bwPollTimeout[3];
|
uint8_t bwPollTimeout[3];
|
||||||
u_int8_t bState;
|
uint8_t bState;
|
||||||
u_int8_t iString;
|
uint8_t iString;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define DFU_STATUS_OK 0x00
|
#define DFU_STATUS_OK 0x00
|
||||||
|
|
|
@ -214,16 +214,16 @@
|
||||||
#define HID_FEATURE_REPORT 2
|
#define HID_FEATURE_REPORT 2
|
||||||
|
|
||||||
struct usb_hid_class_descriptor {
|
struct usb_hid_class_descriptor {
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
u_int16_t wDescriptorLength;
|
uint16_t wDescriptorLength;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct usb_hid_descriptor {
|
struct usb_hid_descriptor {
|
||||||
u_int8_t bLength;
|
uint8_t bLength;
|
||||||
u_int8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
u_int16_t bcdHID;
|
uint16_t bcdHID;
|
||||||
u_int8_t bCountryCode;
|
uint8_t bCountryCode;
|
||||||
u_int8_t bNumDescriptors;
|
uint8_t bNumDescriptors;
|
||||||
|
|
||||||
struct hid_class_descriptor desc[1];
|
struct hid_class_descriptor desc[1];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
|
@ -28,27 +28,28 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static int utf8_to_utf16le(const char *s, u_int16_t *cp, unsigned len)
|
static int utf8_to_utf16le(const char *s, uint16_t *cp, unsigned len)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
u_int8_t c;
|
uint8_t c;
|
||||||
u_int16_t uchar;
|
uint16_t uchar;
|
||||||
|
|
||||||
/* this insists on correct encodings, though not minimal ones.
|
/* this insists on correct encodings, though not minimal ones.
|
||||||
* BUT it currently rejects legit 4-byte UTF-8 code points,
|
* BUT it currently rejects legit 4-byte UTF-8 code points,
|
||||||
* which need surrogate pairs. (Unicode 3.1 can use them.)
|
* which need surrogate pairs. (Unicode 3.1 can use them.)
|
||||||
*/
|
*/
|
||||||
while (len != 0 && (c = (u_int8_t) *s++) != 0) {
|
while (len != 0 && (c = (uint8_t) *s++) != 0) {
|
||||||
if (c & 0x80) {
|
if (c & 0x80) {
|
||||||
// 2-byte sequence:
|
// 2-byte sequence:
|
||||||
// 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
|
// 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
|
||||||
if ((c & 0xe0) == 0xc0) {
|
if ((c & 0xe0) == 0xc0) {
|
||||||
uchar = (c & 0x1f) << 6;
|
uchar = (c & 0x1f) << 6;
|
||||||
|
|
||||||
c = (u_int8_t) *s++;
|
c = (uint8_t) *s++;
|
||||||
if ((c & 0xc0) != 0xc0)
|
if ((c & 0xc0) != 0xc0)
|
||||||
goto fail;
|
goto fail;
|
||||||
c &= 0x3f;
|
c &= 0x3f;
|
||||||
|
@ -59,13 +60,13 @@ static int utf8_to_utf16le(const char *s, u_int16_t *cp, unsigned len)
|
||||||
} else if ((c & 0xf0) == 0xe0) {
|
} else if ((c & 0xf0) == 0xe0) {
|
||||||
uchar = (c & 0x0f) << 12;
|
uchar = (c & 0x0f) << 12;
|
||||||
|
|
||||||
c = (u_int8_t) *s++;
|
c = (uint8_t) *s++;
|
||||||
if ((c & 0xc0) != 0xc0)
|
if ((c & 0xc0) != 0xc0)
|
||||||
goto fail;
|
goto fail;
|
||||||
c &= 0x3f;
|
c &= 0x3f;
|
||||||
uchar |= c << 6;
|
uchar |= c << 6;
|
||||||
|
|
||||||
c = (u_int8_t) *s++;
|
c = (uint8_t) *s++;
|
||||||
if ((c & 0xc0) != 0xc0)
|
if ((c & 0xc0) != 0xc0)
|
||||||
goto fail;
|
goto fail;
|
||||||
c &= 0x3f;
|
c &= 0x3f;
|
||||||
|
@ -96,7 +97,7 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COLUMNS 6
|
#define COLUMNS 6
|
||||||
static int print_array16(u_int16_t *buf, int len)
|
static int print_array16(uint16_t *buf, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
|
@ -130,10 +131,10 @@ static void print_structhdr(int i, int size)
|
||||||
{
|
{
|
||||||
printf( "static const struct {\n"
|
printf( "static const struct {\n"
|
||||||
"\tstruct usb_descriptor_header hdr;\n"
|
"\tstruct usb_descriptor_header hdr;\n"
|
||||||
"\tu_int16_t wData[];\n"
|
"\tuint16_t wData[];\n"
|
||||||
"} __attribute__((packed)) string%d = {\n"
|
"} __attribute__((packed)) string%d = {\n"
|
||||||
"\t.hdr = {\n"
|
"\t.hdr = {\n"
|
||||||
"\t\t.bLength = sizeof(struct usb_descriptor_header) + %u * sizeof(u_int16_t),\n"
|
"\t\t.bLength = sizeof(struct usb_descriptor_header) + %u * sizeof(uint16_t),\n"
|
||||||
"\t\t.bDescriptorType = USB_DT_STRING,\n"
|
"\t\t.bDescriptorType = USB_DT_STRING,\n"
|
||||||
"\t},\n"
|
"\t},\n"
|
||||||
"\t.wData = {", i, size);
|
"\t.wData = {", i, size);
|
||||||
|
@ -146,7 +147,7 @@ static void print_structftr(void)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char asciibuf[512+1];
|
char asciibuf[512+1];
|
||||||
u_int16_t utf16buf[1024+1];
|
uint16_t utf16buf[1024+1];
|
||||||
int len;
|
int len;
|
||||||
int j, i = 1;
|
int j, i = 1;
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ int main(int argc, char **argv)
|
||||||
print_structftr();
|
print_structftr();
|
||||||
#if 0
|
#if 0
|
||||||
printf("static const struct usb_string_descriptor string0 = {\n"
|
printf("static const struct usb_string_descriptor string0 = {\n"
|
||||||
"\t.bLength = sizeof(string0) + 1 * sizeof(u_int16_t),\n"
|
"\t.bLength = sizeof(string0) + 1 * sizeof(uint16_t),\n"
|
||||||
"\t.bDescriptorType = USB_DT_STRING,\n"
|
"\t.bDescriptorType = USB_DT_STRING,\n"
|
||||||
"\t.wData[0] = 0x0409, /* English */\n"
|
"\t.wData[0] = 0x0409, /* English */\n"
|
||||||
"};\n\n");
|
"};\n\n");
|
||||||
|
@ -176,7 +177,7 @@ int main(int argc, char **argv)
|
||||||
print_structhdr(i, len);
|
print_structhdr(i, len);
|
||||||
#if 0
|
#if 0
|
||||||
printf("static const struct usb_string_descriptor string%d = {\n"
|
printf("static const struct usb_string_descriptor string%d = {\n"
|
||||||
"\t.bLength = sizeof(string%d) + %d * sizeof(u_int16_t),\n"
|
"\t.bLength = sizeof(string%d) + %d * sizeof(uint16_t),\n"
|
||||||
"\t.bDescriptorType = USB_DT_STRING,\n"
|
"\t.bDescriptorType = USB_DT_STRING,\n"
|
||||||
"\t.wData = {", i, i, len);
|
"\t.wData = {", i, i, len);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -72,9 +72,9 @@
|
||||||
|
|
||||||
static int past_manifest = 0;
|
static int past_manifest = 0;
|
||||||
static int switch_to_ram = 0; /* IRQ handler requests main to jump to RAM */
|
static int switch_to_ram = 0; /* IRQ handler requests main to jump to RAM */
|
||||||
static u_int16_t usb_if_nr = 0; /* last SET_INTERFACE */
|
static uint16_t usb_if_nr = 0; /* last SET_INTERFACE */
|
||||||
static u_int16_t usb_if_alt_nr = 0; /* last SET_INTERFACE AltSetting */
|
static uint16_t usb_if_alt_nr = 0; /* last SET_INTERFACE AltSetting */
|
||||||
static u_int16_t usb_if_alt_nr_dnload = 0; /* AltSetting during last dnload */
|
static uint16_t usb_if_alt_nr_dnload = 0; /* AltSetting during last dnload */
|
||||||
|
|
||||||
static void __dfufunc udp_init(void)
|
static void __dfufunc udp_init(void)
|
||||||
{
|
{
|
||||||
|
@ -96,11 +96,11 @@ static void __dfufunc udp_init(void)
|
||||||
static void __dfufunc udp_ep0_send_zlp(void);
|
static void __dfufunc udp_ep0_send_zlp(void);
|
||||||
|
|
||||||
/* Send Data through the control endpoint */
|
/* Send Data through the control endpoint */
|
||||||
static void __dfufunc udp_ep0_send_data(const char *pData, u_int32_t length,
|
static void __dfufunc udp_ep0_send_data(const char *pData, uint32_t length,
|
||||||
u_int32_t window_length)
|
uint32_t window_length)
|
||||||
{
|
{
|
||||||
AT91PS_UDP pUdp = AT91C_BASE_UDP;
|
AT91PS_UDP pUdp = AT91C_BASE_UDP;
|
||||||
u_int32_t cpt = 0, len_remain;
|
uint32_t cpt = 0, len_remain;
|
||||||
AT91_REG csr;
|
AT91_REG csr;
|
||||||
|
|
||||||
len_remain = MIN(length, window_length);
|
len_remain = MIN(length, window_length);
|
||||||
|
@ -147,12 +147,12 @@ static void __dfufunc udp_ep0_send_data(const char *pData, u_int32_t length,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* receive data from EP0 */
|
/* receive data from EP0 */
|
||||||
static int __dfufunc udp_ep0_recv_data(u_int8_t *data, u_int16_t len)
|
static int __dfufunc udp_ep0_recv_data(uint8_t *data, uint16_t len)
|
||||||
{
|
{
|
||||||
AT91PS_UDP pUdp = AT91C_BASE_UDP;
|
AT91PS_UDP pUdp = AT91C_BASE_UDP;
|
||||||
AT91_REG csr;
|
AT91_REG csr;
|
||||||
u_int16_t i, num_rcv;
|
uint16_t i, num_rcv;
|
||||||
u_int32_t num_rcv_total = 0;
|
uint32_t num_rcv_total = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* FIXME: do we need to check whether we've been interrupted
|
/* FIXME: do we need to check whether we've been interrupted
|
||||||
|
@ -206,10 +206,10 @@ static void __dfufunc udp_ep0_send_stall(void)
|
||||||
|
|
||||||
|
|
||||||
static int first_download = 1;
|
static int first_download = 1;
|
||||||
static u_int8_t *ptr, *ptr_max;
|
static uint8_t *ptr, *ptr_max;
|
||||||
static __dfudata u_int8_t dfu_status;
|
static __dfudata uint8_t dfu_status;
|
||||||
__dfudata u_int32_t dfu_state = DFU_STATE_appIDLE;
|
__dfudata uint32_t dfu_state = DFU_STATE_appIDLE;
|
||||||
static u_int32_t pagebuf32[AT91C_IFLASH_PAGE_SIZE/4];
|
static uint32_t pagebuf32[AT91C_IFLASH_PAGE_SIZE/4];
|
||||||
|
|
||||||
static void chk_first_dnload_set_ptr(void)
|
static void chk_first_dnload_set_ptr(void)
|
||||||
{
|
{
|
||||||
|
@ -218,25 +218,25 @@ static void chk_first_dnload_set_ptr(void)
|
||||||
|
|
||||||
switch (usb_if_alt_nr) {
|
switch (usb_if_alt_nr) {
|
||||||
case 0:
|
case 0:
|
||||||
ptr = (u_int8_t *) AT91C_IFLASH + SAM7DFU_SIZE;
|
ptr = (uint8_t *) AT91C_IFLASH + SAM7DFU_SIZE;
|
||||||
ptr_max = AT91C_IFLASH + AT91C_IFLASH_SIZE - ENVIRONMENT_SIZE;
|
ptr_max = AT91C_IFLASH + AT91C_IFLASH_SIZE - ENVIRONMENT_SIZE;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ptr = (u_int8_t *) AT91C_IFLASH;
|
ptr = (uint8_t *) AT91C_IFLASH;
|
||||||
ptr_max = AT91C_IFLASH + SAM7DFU_SIZE;
|
ptr_max = AT91C_IFLASH + SAM7DFU_SIZE;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ptr = (u_int8_t *) AT91C_ISRAM + SAM7DFU_RAM_SIZE;
|
ptr = (uint8_t *) AT91C_ISRAM + SAM7DFU_RAM_SIZE;
|
||||||
ptr_max = AT91C_ISRAM + AT91C_ISRAM_SIZE;
|
ptr_max = AT91C_ISRAM + AT91C_ISRAM_SIZE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
first_download = 0;
|
first_download = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __dfufunc handle_dnload_flash(u_int16_t __unused val, u_int16_t len)
|
static int __dfufunc handle_dnload_flash(uint16_t __unused val, uint16_t len)
|
||||||
{
|
{
|
||||||
volatile u_int32_t *p;
|
volatile uint32_t *p;
|
||||||
u_int8_t *pagebuf = (u_int8_t *) pagebuf32;
|
uint8_t *pagebuf = (uint8_t *) pagebuf32;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DEBUGE("download ");
|
DEBUGE("download ");
|
||||||
|
@ -257,7 +257,7 @@ static int __dfufunc handle_dnload_flash(u_int16_t __unused val, u_int16_t len)
|
||||||
return RET_STALL;
|
return RET_STALL;
|
||||||
}
|
}
|
||||||
chk_first_dnload_set_ptr();
|
chk_first_dnload_set_ptr();
|
||||||
p = (volatile u_int32_t *)ptr;
|
p = (volatile uint32_t *)ptr;
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
DEBUGP("zero-size write -> MANIFEST_SYNC ");
|
DEBUGP("zero-size write -> MANIFEST_SYNC ");
|
||||||
|
@ -293,13 +293,13 @@ static int __dfufunc handle_dnload_flash(u_int16_t __unused val, u_int16_t len)
|
||||||
flash_page(p-1);
|
flash_page(p-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr = (u_int8_t *) p;
|
ptr = (uint8_t *) p;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return RET_ZLP;
|
return RET_ZLP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __dfufunc handle_dnload_ram(u_int16_t __unused val, u_int16_t len)
|
static int __dfufunc handle_dnload_ram(uint16_t __unused val, uint16_t len)
|
||||||
{
|
{
|
||||||
DEBUGE("download ");
|
DEBUGE("download ");
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ static int __dfufunc handle_dnload_ram(u_int16_t __unused val, u_int16_t len)
|
||||||
return RET_ZLP;
|
return RET_ZLP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __dfufunc handle_dnload(u_int16_t val, u_int16_t len)
|
static int __dfufunc handle_dnload(uint16_t val, uint16_t len)
|
||||||
{
|
{
|
||||||
usb_if_alt_nr_dnload = usb_if_alt_nr;
|
usb_if_alt_nr_dnload = usb_if_alt_nr;
|
||||||
switch (usb_if_alt_nr) {
|
switch (usb_if_alt_nr) {
|
||||||
|
@ -350,8 +350,8 @@ static int __dfufunc handle_dnload(u_int16_t val, u_int16_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define AT91C_IFLASH_END ((u_int8_t *)AT91C_IFLASH + AT91C_IFLASH_SIZE)
|
#define AT91C_IFLASH_END ((uint8_t *)AT91C_IFLASH + AT91C_IFLASH_SIZE)
|
||||||
static __dfufunc int handle_upload(u_int16_t __unused val, u_int16_t len)
|
static __dfufunc int handle_upload(uint16_t __unused val, uint16_t len)
|
||||||
{
|
{
|
||||||
DEBUGE("upload ");
|
DEBUGE("upload ");
|
||||||
if (len > AT91C_IFLASH_PAGE_SIZE) {
|
if (len > AT91C_IFLASH_PAGE_SIZE) {
|
||||||
|
@ -364,7 +364,7 @@ static __dfufunc int handle_upload(u_int16_t __unused val, u_int16_t len)
|
||||||
chk_first_dnload_set_ptr();
|
chk_first_dnload_set_ptr();
|
||||||
|
|
||||||
if (ptr + len > AT91C_IFLASH_END) {
|
if (ptr + len > AT91C_IFLASH_END) {
|
||||||
len = AT91C_IFLASH_END - (u_int8_t *)ptr;
|
len = AT91C_IFLASH_END - (uint8_t *)ptr;
|
||||||
first_download = 1;
|
first_download = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ static __dfufunc int handle_upload(u_int16_t __unused val, u_int16_t len)
|
||||||
static __dfufunc void handle_getstatus(void)
|
static __dfufunc void handle_getstatus(void)
|
||||||
{
|
{
|
||||||
struct dfu_status dstat;
|
struct dfu_status dstat;
|
||||||
u_int32_t fsr = AT91F_MC_EFC_GetStatus(AT91C_BASE_MC);
|
uint32_t fsr = AT91F_MC_EFC_GetStatus(AT91C_BASE_MC);
|
||||||
|
|
||||||
DEBUGE("getstatus(fsr=0x%08x) ", fsr);
|
DEBUGE("getstatus(fsr=0x%08x) ", fsr);
|
||||||
|
|
||||||
|
@ -416,15 +416,15 @@ static __dfufunc void handle_getstatus(void)
|
||||||
|
|
||||||
static void __dfufunc handle_getstate(void)
|
static void __dfufunc handle_getstate(void)
|
||||||
{
|
{
|
||||||
u_int8_t u8 = dfu_state;
|
uint8_t u8 = dfu_state;
|
||||||
DEBUGE("getstate ");
|
DEBUGE("getstate ");
|
||||||
|
|
||||||
udp_ep0_send_data((char *)&u8, sizeof(u8), sizeof(u8));
|
udp_ep0_send_data((char *)&u8, sizeof(u8), sizeof(u8));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* callback function for DFU requests */
|
/* callback function for DFU requests */
|
||||||
int __dfufunc dfu_ep0_handler(u_int8_t __unused req_type, u_int8_t req,
|
int __dfufunc dfu_ep0_handler(uint8_t __unused req_type, uint8_t req,
|
||||||
u_int16_t val, u_int16_t len)
|
uint16_t val, uint16_t len)
|
||||||
{
|
{
|
||||||
int rc, ret = RET_NOTHING;
|
int rc, ret = RET_NOTHING;
|
||||||
|
|
||||||
|
@ -473,11 +473,11 @@ int __dfufunc dfu_ep0_handler(u_int8_t __unused req_type, u_int8_t req,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
dfu_state = DFU_STATE_dfuDNLOAD_SYNC;
|
dfu_state = DFU_STATE_dfuDNLOAD_SYNC;
|
||||||
ptr = (u_int8_t *) AT91C_IFLASH + SAM7DFU_SIZE;
|
ptr = (uint8_t *) AT91C_IFLASH + SAM7DFU_SIZE;
|
||||||
ret = handle_dnload(val, len);
|
ret = handle_dnload(val, len);
|
||||||
break;
|
break;
|
||||||
case USB_REQ_DFU_UPLOAD:
|
case USB_REQ_DFU_UPLOAD:
|
||||||
ptr = (u_int8_t *) AT91C_IFLASH + SAM7DFU_SIZE;
|
ptr = (uint8_t *) AT91C_IFLASH + SAM7DFU_SIZE;
|
||||||
dfu_state = DFU_STATE_dfuUPLOAD_IDLE;
|
dfu_state = DFU_STATE_dfuUPLOAD_IDLE;
|
||||||
handle_upload(val, len);
|
handle_upload(val, len);
|
||||||
break;
|
break;
|
||||||
|
@ -652,7 +652,7 @@ out:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u_int8_t cur_config;
|
static uint8_t cur_config;
|
||||||
|
|
||||||
/* USB DFU Device descriptor in DFU mode */
|
/* USB DFU Device descriptor in DFU mode */
|
||||||
__dfustruct const struct usb_device_descriptor dfu_dev_descriptor = {
|
__dfustruct const struct usb_device_descriptor dfu_dev_descriptor = {
|
||||||
|
@ -749,9 +749,9 @@ __dfustruct const struct _dfu_desc dfu_cfg_descriptor = {
|
||||||
static __dfufunc void dfu_udp_ep0_handler(void)
|
static __dfufunc void dfu_udp_ep0_handler(void)
|
||||||
{
|
{
|
||||||
AT91PS_UDP pUDP = AT91C_BASE_UDP;
|
AT91PS_UDP pUDP = AT91C_BASE_UDP;
|
||||||
u_int8_t bmRequestType, bRequest;
|
uint8_t bmRequestType, bRequest;
|
||||||
u_int16_t wValue, wIndex, wLength, wStatus;
|
uint16_t wValue, wIndex, wLength, wStatus;
|
||||||
u_int32_t csr = pUDP->UDP_CSR[0];
|
uint32_t csr = pUDP->UDP_CSR[0];
|
||||||
|
|
||||||
DEBUGE("CSR=0x%04x ", csr);
|
DEBUGE("CSR=0x%04x ", csr);
|
||||||
|
|
||||||
|
@ -798,7 +798,7 @@ static __dfufunc void dfu_udp_ep0_handler(void)
|
||||||
/* Handle supported standard device request Cf Table 9-3 in USB
|
/* Handle supported standard device request Cf Table 9-3 in USB
|
||||||
* speciication Rev 1.1 */
|
* speciication Rev 1.1 */
|
||||||
switch ((bRequest << 8) | bmRequestType) {
|
switch ((bRequest << 8) | bmRequestType) {
|
||||||
u_int8_t desc_type, desc_index;
|
uint8_t desc_type, desc_index;
|
||||||
case STD_GET_DESCRIPTOR:
|
case STD_GET_DESCRIPTOR:
|
||||||
DEBUGE("GET_DESCRIPTOR ");
|
DEBUGE("GET_DESCRIPTOR ");
|
||||||
desc_type = wValue >> 8;
|
desc_type = wValue >> 8;
|
||||||
|
|
|
@ -124,13 +124,13 @@ struct _dfu_desc {
|
||||||
|
|
||||||
struct dfuapi {
|
struct dfuapi {
|
||||||
void (*udp_init)(void);
|
void (*udp_init)(void);
|
||||||
void (*ep0_send_data)(const char *data, u_int32_t len, u_int32_t wlen);
|
void (*ep0_send_data)(const char *data, uint32_t len, uint32_t wlen);
|
||||||
void (*ep0_send_zlp)(void);
|
void (*ep0_send_zlp)(void);
|
||||||
void (*ep0_send_stall)(void);
|
void (*ep0_send_stall)(void);
|
||||||
int (*dfu_ep0_handler)(u_int8_t req_type, u_int8_t req,
|
int (*dfu_ep0_handler)(uint8_t req_type, uint8_t req,
|
||||||
u_int16_t val, u_int16_t len);
|
uint16_t val, uint16_t len);
|
||||||
void (*dfu_switch)(void);
|
void (*dfu_switch)(void);
|
||||||
u_int32_t *dfu_state;
|
uint32_t *dfu_state;
|
||||||
const struct usb_device_descriptor *dfu_dev_descriptor;
|
const struct usb_device_descriptor *dfu_dev_descriptor;
|
||||||
const struct _dfu_desc *dfu_cfg_descriptor;
|
const struct _dfu_desc *dfu_cfg_descriptor;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct blinker {
|
||||||
enum blinkcode_state state;
|
enum blinkcode_state state;
|
||||||
int num;
|
int num;
|
||||||
int cur;
|
int cur;
|
||||||
u_int8_t led;
|
uint8_t led;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct blinker blink_state[NUM_LEDS];
|
static struct blinker blink_state[NUM_LEDS];
|
||||||
|
|
|
@ -78,7 +78,7 @@ static void Send_reset(void)
|
||||||
//* Object : C handler interrupt function called by the sysirq
|
//* Object : C handler interrupt function called by the sysirq
|
||||||
//* demultiplexer
|
//* demultiplexer
|
||||||
//*----------------------------------------------------------------------------
|
//*----------------------------------------------------------------------------
|
||||||
static void DBGU_irq_handler(u_int32_t sr)
|
static void DBGU_irq_handler(uint32_t sr)
|
||||||
{
|
{
|
||||||
static char value;
|
static char value;
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void fifo_check_raise_int(struct fifo *fifo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int16_t fifo_data_put(struct fifo *fifo, u_int16_t len, u_int8_t *data)
|
uint16_t fifo_data_put(struct fifo *fifo, uint16_t len, uint8_t *data)
|
||||||
{
|
{
|
||||||
if (len > fifo_available(fifo)) {
|
if (len > fifo_available(fifo)) {
|
||||||
len = fifo_available(fifo);
|
len = fifo_available(fifo);
|
||||||
|
@ -71,7 +71,7 @@ u_int16_t fifo_data_put(struct fifo *fifo, u_int16_t len, u_int8_t *data)
|
||||||
fifo->producer += len;
|
fifo->producer += len;
|
||||||
} else {
|
} else {
|
||||||
/* difficult: wrap around */
|
/* difficult: wrap around */
|
||||||
u_int16_t chunk_len;
|
uint16_t chunk_len;
|
||||||
|
|
||||||
chunk_len = fifo->size - fifo->producer;
|
chunk_len = fifo->size - fifo->producer;
|
||||||
memcpy(&fifo->data[fifo->producer], data, chunk_len);
|
memcpy(&fifo->data[fifo->producer], data, chunk_len);
|
||||||
|
@ -86,9 +86,9 @@ u_int16_t fifo_data_put(struct fifo *fifo, u_int16_t len, u_int8_t *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int16_t fifo_data_get(struct fifo *fifo, u_int16_t len, u_int8_t *data)
|
uint16_t fifo_data_get(struct fifo *fifo, uint16_t len, uint8_t *data)
|
||||||
{
|
{
|
||||||
u_int16_t avail = fifo_available(fifo);
|
uint16_t avail = fifo_available(fifo);
|
||||||
|
|
||||||
if (avail < len)
|
if (avail < len)
|
||||||
len = avail;
|
len = avail;
|
||||||
|
@ -98,7 +98,7 @@ u_int16_t fifo_data_get(struct fifo *fifo, u_int16_t len, u_int8_t *data)
|
||||||
memcpy(data, &fifo->data[fifo->consumer], len);
|
memcpy(data, &fifo->data[fifo->consumer], len);
|
||||||
} else {
|
} else {
|
||||||
/* difficult case: wrap */
|
/* difficult case: wrap */
|
||||||
u_int16_t chunk_len = fifo->size - fifo->consumer;
|
uint16_t chunk_len = fifo->size - fifo->consumer;
|
||||||
memcpy(data, &fifo->data[fifo->consumer], chunk_len);
|
memcpy(data, &fifo->data[fifo->consumer], chunk_len);
|
||||||
memcpy(data+chunk_len, &fifo->data[0], len - chunk_len);
|
memcpy(data+chunk_len, &fifo->data[0], len - chunk_len);
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,8 @@ u_int16_t fifo_data_get(struct fifo *fifo, u_int16_t len, u_int8_t *data)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fifo_init(struct fifo *fifo, u_int16_t size,
|
int fifo_init(struct fifo *fifo, uint16_t size,
|
||||||
void (*cb)(struct fifo *fifo, u_int8_t event, void *data), void *cb_data)
|
void (*cb)(struct fifo *fifo, uint8_t event, void *data), void *cb_data)
|
||||||
{
|
{
|
||||||
if (size > sizeof(fifo->data))
|
if (size > sizeof(fifo->data))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -6,23 +6,23 @@
|
||||||
#define FIFO_SIZE 1024
|
#define FIFO_SIZE 1024
|
||||||
|
|
||||||
struct fifo {
|
struct fifo {
|
||||||
u_int16_t size; /* actual FIFO size, can be smaller than 'data' */
|
uint16_t size; /* actual FIFO size, can be smaller than 'data' */
|
||||||
u_int16_t producer; /* index of producer */
|
uint16_t producer; /* index of producer */
|
||||||
u_int16_t consumer; /* index of consumer */
|
uint16_t consumer; /* index of consumer */
|
||||||
u_int16_t watermark;
|
uint16_t watermark;
|
||||||
u_int8_t irq;
|
uint8_t irq;
|
||||||
u_int8_t irq_en;
|
uint8_t irq_en;
|
||||||
u_int8_t status;
|
uint8_t status;
|
||||||
void (*callback)(struct fifo *fifo, u_int8_t event, void *data);
|
void (*callback)(struct fifo *fifo, uint8_t event, void *data);
|
||||||
void *cb_data;
|
void *cb_data;
|
||||||
u_int8_t data[FIFO_SIZE];
|
uint8_t data[FIFO_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern int fifo_init(struct fifo *fifo, u_int16_t size,
|
extern int fifo_init(struct fifo *fifo, uint16_t size,
|
||||||
void (*callback)(struct fifo *fifo, u_int8_t event, void *data), void *cb_data);
|
void (*callback)(struct fifo *fifo, uint8_t event, void *data), void *cb_data);
|
||||||
extern u_int16_t fifo_data_get(struct fifo *fifo, u_int16_t len, u_int8_t *data);
|
extern uint16_t fifo_data_get(struct fifo *fifo, uint16_t len, uint8_t *data);
|
||||||
extern u_int16_t fifo_data_put(struct fifo *fifo, u_int16_t len, u_int8_t *data);
|
extern uint16_t fifo_data_put(struct fifo *fifo, uint16_t len, uint8_t *data);
|
||||||
extern int fifo_available(struct fifo *fifo);
|
extern int fifo_available(struct fifo *fifo);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,34 +13,34 @@
|
||||||
#define EFCS_CMD_CLEAR_NVM_BIT 0xd
|
#define EFCS_CMD_CLEAR_NVM_BIT 0xd
|
||||||
#define EFCS_CMD_SET_SECURITY_BIT 0xf
|
#define EFCS_CMD_SET_SECURITY_BIT 0xf
|
||||||
|
|
||||||
static u_int16_t page_from_ramaddr(const void *addr)
|
static uint16_t page_from_ramaddr(const void *addr)
|
||||||
{
|
{
|
||||||
u_int32_t ramaddr = (u_int32_t) addr;
|
uint32_t ramaddr = (uint32_t) addr;
|
||||||
ramaddr -= (u_int32_t) AT91C_IFLASH;
|
ramaddr -= (uint32_t) AT91C_IFLASH;
|
||||||
return ((ramaddr >> AT91C_IFLASH_PAGE_SHIFT));
|
return ((ramaddr >> AT91C_IFLASH_PAGE_SHIFT));
|
||||||
}
|
}
|
||||||
#define PAGES_PER_LOCKREGION (AT91C_IFLASH_LOCK_REGION_SIZE>>AT91C_IFLASH_PAGE_SHIFT)
|
#define PAGES_PER_LOCKREGION (AT91C_IFLASH_LOCK_REGION_SIZE>>AT91C_IFLASH_PAGE_SHIFT)
|
||||||
#define IS_FIRST_PAGE_OF_LOCKREGION(x) ((x % PAGES_PER_LOCKREGION) == 0)
|
#define IS_FIRST_PAGE_OF_LOCKREGION(x) ((x % PAGES_PER_LOCKREGION) == 0)
|
||||||
#define LOCKREGION_FROM_PAGE(x) (x / PAGES_PER_LOCKREGION)
|
#define LOCKREGION_FROM_PAGE(x) (x / PAGES_PER_LOCKREGION)
|
||||||
|
|
||||||
static int is_page_locked(u_int16_t page)
|
static int is_page_locked(uint16_t page)
|
||||||
{
|
{
|
||||||
u_int16_t lockregion = LOCKREGION_FROM_PAGE(page);
|
uint16_t lockregion = LOCKREGION_FROM_PAGE(page);
|
||||||
|
|
||||||
return (AT91C_BASE_MC->MC_FSR & (lockregion << 16));
|
return (AT91C_BASE_MC->MC_FSR & (lockregion << 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unlock_page(u_int16_t page)
|
static void unlock_page(uint16_t page)
|
||||||
{
|
{
|
||||||
page &= 0x3ff;
|
page &= 0x3ff;
|
||||||
AT91F_MC_EFC_PerformCmd(AT91C_BASE_MC, AT91C_MC_FCMD_UNLOCK |
|
AT91F_MC_EFC_PerformCmd(AT91C_BASE_MC, AT91C_MC_FCMD_UNLOCK |
|
||||||
AT91C_MC_CORRECT_KEY | (page << 8));
|
AT91C_MC_CORRECT_KEY | (page << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_page(u_int8_t *addr)
|
void flash_page(uint8_t *addr)
|
||||||
{
|
{
|
||||||
u_int16_t page = page_from_ramaddr(addr) & 0x3ff;
|
uint16_t page = page_from_ramaddr(addr) & 0x3ff;
|
||||||
u_int32_t fsr = AT91F_MC_EFC_GetStatus(AT91C_BASE_MC);
|
uint32_t fsr = AT91F_MC_EFC_GetStatus(AT91C_BASE_MC);
|
||||||
DEBUGP("flash_page(0x%x=%u) ", addr, page);
|
DEBUGP("flash_page(0x%x=%u) ", addr, page);
|
||||||
|
|
||||||
if (is_page_locked(page)) {
|
if (is_page_locked(page)) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _FLASH_H
|
#ifndef _FLASH_H
|
||||||
#define _FLASH_H
|
#define _FLASH_H
|
||||||
extern void flash_page(u_int8_t *addr);
|
extern void flash_page(uint8_t *addr);
|
||||||
extern void flash_init(void);
|
extern void flash_init(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,8 +94,8 @@ static const struct dfuapi *dfu = DFU_API_LOCATION;
|
||||||
static struct udp_pcd upcd;
|
static struct udp_pcd upcd;
|
||||||
|
|
||||||
struct epstate {
|
struct epstate {
|
||||||
u_int32_t state_busy;
|
uint32_t state_busy;
|
||||||
u_int32_t state_pending;
|
uint32_t state_pending;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct epstate epstate[] = {
|
static const struct epstate epstate[] = {
|
||||||
|
@ -140,7 +140,7 @@ void udp_unthrottle(void)
|
||||||
|
|
||||||
int udp_refill_ep(int ep)
|
int udp_refill_ep(int ep)
|
||||||
{
|
{
|
||||||
u_int16_t i;
|
uint16_t i;
|
||||||
AT91PS_UDP pUDP = upcd.pUdp;
|
AT91PS_UDP pUDP = upcd.pUdp;
|
||||||
struct req_ctx *rctx;
|
struct req_ctx *rctx;
|
||||||
unsigned int start, end;
|
unsigned int start, end;
|
||||||
|
@ -231,7 +231,7 @@ int udp_refill_ep(int ep)
|
||||||
|
|
||||||
static void udp_irq(void)
|
static void udp_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t csr;
|
uint32_t csr;
|
||||||
AT91PS_UDP pUDP = upcd.pUdp;
|
AT91PS_UDP pUDP = upcd.pUdp;
|
||||||
AT91_REG isr = pUDP->UDP_ISR;
|
AT91_REG isr = pUDP->UDP_ISR;
|
||||||
|
|
||||||
|
@ -270,8 +270,8 @@ static void udp_irq(void)
|
||||||
udp_ep0_handler();
|
udp_ep0_handler();
|
||||||
}
|
}
|
||||||
if (isr & AT91C_UDP_EPINT1) {
|
if (isr & AT91C_UDP_EPINT1) {
|
||||||
u_int32_t cur_rcv_bank = upcd.cur_rcv_bank;
|
uint32_t cur_rcv_bank = upcd.cur_rcv_bank;
|
||||||
u_int16_t i, pkt_size;
|
uint16_t i, pkt_size;
|
||||||
struct req_ctx *rctx;
|
struct req_ctx *rctx;
|
||||||
|
|
||||||
csr = pUDP->UDP_CSR[1];
|
csr = pUDP->UDP_CSR[1];
|
||||||
|
@ -471,9 +471,9 @@ void udp_reset(void)
|
||||||
static void udp_ep0_handler(void)
|
static void udp_ep0_handler(void)
|
||||||
{
|
{
|
||||||
AT91PS_UDP pUDP = upcd.pUdp;
|
AT91PS_UDP pUDP = upcd.pUdp;
|
||||||
u_int8_t bmRequestType, bRequest;
|
uint8_t bmRequestType, bRequest;
|
||||||
u_int16_t wValue, wIndex, wLength, wStatus;
|
uint16_t wValue, wIndex, wLength, wStatus;
|
||||||
u_int32_t csr = pUDP->UDP_CSR[0];
|
uint32_t csr = pUDP->UDP_CSR[0];
|
||||||
|
|
||||||
DEBUGE("CSR=0x%04x ", csr);
|
DEBUGE("CSR=0x%04x ", csr);
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ static void udp_ep0_handler(void)
|
||||||
/* Handle supported standard device request Cf Table 9-3 in USB
|
/* Handle supported standard device request Cf Table 9-3 in USB
|
||||||
* speciication Rev 1.1 */
|
* speciication Rev 1.1 */
|
||||||
switch ((bRequest << 8) | bmRequestType) {
|
switch ((bRequest << 8) | bmRequestType) {
|
||||||
u_int8_t desc_type, desc_index;
|
uint8_t desc_type, desc_index;
|
||||||
case STD_GET_DESCRIPTOR:
|
case STD_GET_DESCRIPTOR:
|
||||||
DEBUGE("GET_DESCRIPTOR(wValue=0x%04x, wIndex=0x%04x) ",
|
DEBUGE("GET_DESCRIPTOR(wValue=0x%04x, wIndex=0x%04x) ",
|
||||||
wValue, wIndex);
|
wValue, wIndex);
|
||||||
|
|
|
@ -27,17 +27,17 @@
|
||||||
|
|
||||||
struct pioirq_state {
|
struct pioirq_state {
|
||||||
irq_handler_t *handlers[NR_PIO];
|
irq_handler_t *handlers[NR_PIO];
|
||||||
u_int32_t usbmask;
|
uint32_t usbmask;
|
||||||
u_int32_t usb_throttled; /* atomic? */
|
uint32_t usb_throttled; /* atomic? */
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct pioirq_state pirqs;
|
static struct pioirq_state pirqs;
|
||||||
|
|
||||||
/* low-level handler, used by Cstartup_app.S PIOA fast forcing and
|
/* low-level handler, used by Cstartup_app.S PIOA fast forcing and
|
||||||
* by regular interrupt handler below */
|
* by regular interrupt handler below */
|
||||||
void __ramfunc __pio_irq_demux(u_int32_t pio)
|
void __ramfunc __pio_irq_demux(uint32_t pio)
|
||||||
{
|
{
|
||||||
u_int8_t send_usb = 0;
|
uint8_t send_usb = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//DEBUGPCRF("PIO_ISR_STATUS = 0x%08x", pio);
|
//DEBUGPCRF("PIO_ISR_STATUS = 0x%08x", pio);
|
||||||
|
@ -59,15 +59,15 @@ void __ramfunc __pio_irq_demux(u_int32_t pio)
|
||||||
pirqs.usb_throttled = 1;
|
pirqs.usb_throttled = 1;
|
||||||
} else {
|
} else {
|
||||||
struct openpcd_hdr *opcdh;
|
struct openpcd_hdr *opcdh;
|
||||||
u_int32_t *regmask;
|
uint32_t *regmask;
|
||||||
opcdh = (struct openpcd_hdr *) irq_rctx->data;
|
opcdh = (struct openpcd_hdr *) irq_rctx->data;
|
||||||
regmask = (u_int32_t *) (irq_rctx->data + sizeof(*opcdh));
|
regmask = (uint32_t *) (irq_rctx->data + sizeof(*opcdh));
|
||||||
opcdh->cmd = OPENPCD_CMD_PIO_IRQ;
|
opcdh->cmd = OPENPCD_CMD_PIO_IRQ;
|
||||||
opcdh->reg = 0x00;
|
opcdh->reg = 0x00;
|
||||||
opcdh->flags = 0x00;
|
opcdh->flags = 0x00;
|
||||||
opcdh->val = 0x00;
|
opcdh->val = 0x00;
|
||||||
|
|
||||||
irq_rctx->tot_len = sizeof(*opcdh) + sizeof(u_int32_t);
|
irq_rctx->tot_len = sizeof(*opcdh) + sizeof(uint32_t);
|
||||||
req_ctx_set_state(irq_rctx, RCTX_STATE_UDP_EP3_PENDING);
|
req_ctx_set_state(irq_rctx, RCTX_STATE_UDP_EP3_PENDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,23 +78,23 @@ void __ramfunc __pio_irq_demux(u_int32_t pio)
|
||||||
/* regular interrupt handler, in case fast forcing for PIOA disabled */
|
/* regular interrupt handler, in case fast forcing for PIOA disabled */
|
||||||
static void pio_irq_demux(void)
|
static void pio_irq_demux(void)
|
||||||
{
|
{
|
||||||
u_int32_t pio = AT91F_PIO_GetInterruptStatus(AT91C_BASE_PIOA);
|
uint32_t pio = AT91F_PIO_GetInterruptStatus(AT91C_BASE_PIOA);
|
||||||
__pio_irq_demux(pio);
|
__pio_irq_demux(pio);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pio_irq_enable(u_int32_t pio)
|
void pio_irq_enable(uint32_t pio)
|
||||||
{
|
{
|
||||||
AT91F_PIO_InterruptEnable(AT91C_BASE_PIOA, pio);
|
AT91F_PIO_InterruptEnable(AT91C_BASE_PIOA, pio);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pio_irq_disable(u_int32_t pio)
|
void pio_irq_disable(uint32_t pio)
|
||||||
{
|
{
|
||||||
AT91F_PIO_InterruptDisable(AT91C_BASE_PIOA, pio);
|
AT91F_PIO_InterruptDisable(AT91C_BASE_PIOA, pio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pio_irq_register(u_int32_t pio, irq_handler_t *handler)
|
int pio_irq_register(uint32_t pio, irq_handler_t *handler)
|
||||||
{
|
{
|
||||||
u_int8_t num = ffs(pio);
|
uint8_t num = ffs(pio);
|
||||||
|
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -111,9 +111,9 @@ int pio_irq_register(u_int32_t pio, irq_handler_t *handler)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pio_irq_unregister(u_int32_t pio)
|
void pio_irq_unregister(uint32_t pio)
|
||||||
{
|
{
|
||||||
u_int8_t num = ffs(pio);
|
uint8_t num = ffs(pio);
|
||||||
|
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
#define _PIO_IRQ_H
|
#define _PIO_IRQ_H
|
||||||
|
|
||||||
#define NR_PIO 32
|
#define NR_PIO 32
|
||||||
typedef void irq_handler_t(u_int32_t pio);
|
typedef void irq_handler_t(uint32_t pio);
|
||||||
|
|
||||||
extern void pio_irq_enable(u_int32_t pio);
|
extern void pio_irq_enable(uint32_t pio);
|
||||||
extern void pio_irq_disable(u_int32_t pio);
|
extern void pio_irq_disable(uint32_t pio);
|
||||||
extern int pio_irq_register(u_int32_t pio, irq_handler_t *func);
|
extern int pio_irq_register(uint32_t pio, irq_handler_t *func);
|
||||||
extern void pio_irq_unregister(u_int32_t pio);
|
extern void pio_irq_unregister(uint32_t pio);
|
||||||
extern void pio_irq_init(void);
|
extern void pio_irq_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,7 +103,7 @@ void timer_add(struct timer_list *tl)
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pit_irq(u_int32_t sr)
|
static void pit_irq(uint32_t sr)
|
||||||
{
|
{
|
||||||
struct timer_list *tl, *next;
|
struct timer_list *tl, *next;
|
||||||
|
|
||||||
|
@ -125,21 +125,21 @@ static void pit_irq(u_int32_t sr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pit_mdelay(u_int32_t ms)
|
void pit_mdelay(uint32_t ms)
|
||||||
{
|
{
|
||||||
u_int32_t end;
|
uint32_t end;
|
||||||
|
|
||||||
end = (AT91F_PITGetPIIR(AT91C_BASE_PITC) + ms) % 20;
|
end = (AT91F_PITGetPIIR(AT91C_BASE_PITC) + ms) % 20;
|
||||||
|
|
||||||
while (end < AT91F_PITGetPIIR(AT91C_BASE_PITC)) { }
|
while (end < AT91F_PITGetPIIR(AT91C_BASE_PITC)) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
void mdelay(u_int32_t ms)
|
void mdelay(uint32_t ms)
|
||||||
{
|
{
|
||||||
return pit_mdelay(ms);
|
return pit_mdelay(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usleep(u_int32_t us)
|
void usleep(uint32_t us)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
return pit_mdelay(us/1000);
|
return pit_mdelay(us/1000);
|
||||||
|
|
|
@ -20,6 +20,6 @@ extern void timer_add(struct timer_list *timer);
|
||||||
extern int timer_del(struct timer_list *timer);
|
extern int timer_del(struct timer_list *timer);
|
||||||
|
|
||||||
extern void pit_init(void);
|
extern void pit_init(void);
|
||||||
extern void pit_mdelay(u_int32_t ms);
|
extern void pit_mdelay(uint32_t ms);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
static AT91PS_PWMC pwm = AT91C_BASE_PWMC;
|
static AT91PS_PWMC pwm = AT91C_BASE_PWMC;
|
||||||
|
|
||||||
/* find highest bit set. returns bit (32..1) or 0 in case no bit set */
|
/* find highest bit set. returns bit (32..1) or 0 in case no bit set */
|
||||||
static int fhs(u_int32_t val)
|
static int fhs(uint32_t val)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -55,16 +55,16 @@ static int fhs(u_int32_t val)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set frequency of PWM signal to freq */
|
/* set frequency of PWM signal to freq */
|
||||||
int pwm_freq_set(int channel, u_int32_t freq)
|
int pwm_freq_set(int channel, uint32_t freq)
|
||||||
{
|
{
|
||||||
/* in order to get maximum resolution, the pre-scaler must be set to
|
/* in order to get maximum resolution, the pre-scaler must be set to
|
||||||
* something like freq << 16. However, the mimimum pre-scaled frequency
|
* something like freq << 16. However, the mimimum pre-scaled frequency
|
||||||
* we can get is MCLK (48MHz), the minimum is MCLK/(1024*255) =
|
* we can get is MCLK (48MHz), the minimum is MCLK/(1024*255) =
|
||||||
* 48MHz/261120 = 183Hz */
|
* 48MHz/261120 = 183Hz */
|
||||||
u_int32_t overall_div;
|
uint32_t overall_div;
|
||||||
u_int32_t presc_total;
|
uint32_t presc_total;
|
||||||
u_int8_t cpre = 0;
|
uint8_t cpre = 0;
|
||||||
u_int16_t cprd;
|
uint16_t cprd;
|
||||||
|
|
||||||
if (freq > MCLK)
|
if (freq > MCLK)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
@ -104,9 +104,9 @@ void pwm_stop(int channel)
|
||||||
AT91F_PWMC_StopChannel(AT91C_BASE_PWMC, (1 << channel));
|
AT91F_PWMC_StopChannel(AT91C_BASE_PWMC, (1 << channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwm_duty_set_percent(int channel, u_int16_t duty)
|
void pwm_duty_set_percent(int channel, uint16_t duty)
|
||||||
{
|
{
|
||||||
u_int32_t tmp = pwm->PWMC_CH[channel].PWMC_CPRDR & 0xffff;
|
uint32_t tmp = pwm->PWMC_CH[channel].PWMC_CPRDR & 0xffff;
|
||||||
|
|
||||||
tmp = tmp << 16; /* extend value by 2^16 */
|
tmp = tmp << 16; /* extend value by 2^16 */
|
||||||
tmp = tmp / 100; /* tmp = 1 % of extended cprd */
|
tmp = tmp / 100; /* tmp = 1 % of extended cprd */
|
||||||
|
@ -120,7 +120,7 @@ void pwm_duty_set_percent(int channel, u_int16_t duty)
|
||||||
static int pwm_usb_in(struct req_ctx *rctx)
|
static int pwm_usb_in(struct req_ctx *rctx)
|
||||||
{
|
{
|
||||||
struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
|
struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
|
||||||
u_int32_t *freq;
|
uint32_t *freq;
|
||||||
|
|
||||||
switch (poh->cmd) {
|
switch (poh->cmd) {
|
||||||
case OPENPCD_CMD_PWM_ENABLE:
|
case OPENPCD_CMD_PWM_ENABLE:
|
||||||
|
@ -138,7 +138,7 @@ static int pwm_usb_in(struct req_ctx *rctx)
|
||||||
case OPENPCD_CMD_PWM_FREQ_SET:
|
case OPENPCD_CMD_PWM_FREQ_SET:
|
||||||
if (rctx->tot_len < sizeof(*poh)+4)
|
if (rctx->tot_len < sizeof(*poh)+4)
|
||||||
break;
|
break;
|
||||||
freq = (u_int32_t *) ((unsigned char *) poh) + sizeof(*poh);
|
freq = (uint32_t *) ((unsigned char *) poh) + sizeof(*poh);
|
||||||
pwm_freq_set(0, *freq);
|
pwm_freq_set(0, *freq);
|
||||||
break;
|
break;
|
||||||
case OPENPCD_CMD_PWM_FREQ_GET:
|
case OPENPCD_CMD_PWM_FREQ_GET:
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef _PWM_H
|
#ifndef _PWM_H
|
||||||
#define _PWM_H
|
#define _PWM_H
|
||||||
|
|
||||||
extern void pwm_freq_set(int channel, u_int32_t freq);
|
extern void pwm_freq_set(int channel, uint32_t freq);
|
||||||
extern void pwm_start(int channel);
|
extern void pwm_start(int channel);
|
||||||
extern void pwm_stop(int channel);
|
extern void pwm_stop(int channel);
|
||||||
extern void pwm_duty_set_percent(int channel, u_int16_t duty);
|
extern void pwm_duty_set_percent(int channel, uint16_t duty);
|
||||||
extern void pwm_init(void);
|
extern void pwm_init(void);
|
||||||
extern void pwm_fini(void);
|
extern void pwm_fini(void);
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
|
|
||||||
#define NUM_REQ_CTX (NUM_RCTX_SMALL+NUM_RCTX_LARGE)
|
#define NUM_REQ_CTX (NUM_RCTX_SMALL+NUM_RCTX_LARGE)
|
||||||
|
|
||||||
static u_int8_t rctx_data[NUM_RCTX_SMALL][RCTX_SIZE_SMALL];
|
static uint8_t rctx_data[NUM_RCTX_SMALL][RCTX_SIZE_SMALL];
|
||||||
static u_int8_t rctx_data_large[NUM_RCTX_LARGE][RCTX_SIZE_LARGE];
|
static uint8_t rctx_data_large[NUM_RCTX_LARGE][RCTX_SIZE_LARGE];
|
||||||
|
|
||||||
static struct req_ctx req_ctx[NUM_REQ_CTX];
|
static struct req_ctx req_ctx[NUM_REQ_CTX];
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ struct req_ctx __ramfunc *req_ctx_find_get(int large,
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int8_t req_ctx_num(struct req_ctx *ctx)
|
uint8_t req_ctx_num(struct req_ctx *ctx)
|
||||||
{
|
{
|
||||||
return ctx - req_ctx;
|
return ctx - req_ctx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
#include <lib_AT91SAM7.h>
|
#include <lib_AT91SAM7.h>
|
||||||
|
|
||||||
struct req_ctx {
|
struct req_ctx {
|
||||||
volatile u_int32_t state;
|
volatile uint32_t state;
|
||||||
volatile struct req_ctx *prev, *next;
|
volatile struct req_ctx *prev, *next;
|
||||||
u_int16_t size;
|
uint16_t size;
|
||||||
u_int16_t tot_len;
|
uint16_t tot_len;
|
||||||
u_int8_t *data;
|
uint8_t *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RCTX_STATE_FREE 0
|
#define RCTX_STATE_FREE 0
|
||||||
|
@ -45,7 +45,7 @@ extern struct req_ctx __ramfunc *req_ctx_find_get(int large, unsigned long old_s
|
||||||
extern struct req_ctx *req_ctx_find_busy(void);
|
extern struct req_ctx *req_ctx_find_busy(void);
|
||||||
extern void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state);
|
extern void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state);
|
||||||
extern void req_ctx_put(struct req_ctx *ctx);
|
extern void req_ctx_put(struct req_ctx *ctx);
|
||||||
extern u_int8_t req_ctx_num(struct req_ctx *ctx);
|
extern uint8_t req_ctx_num(struct req_ctx *ctx);
|
||||||
unsigned int req_ctx_count(unsigned long state);
|
unsigned int req_ctx_count(unsigned long state);
|
||||||
|
|
||||||
#endif /* _REQ_CTX_H */
|
#endif /* _REQ_CTX_H */
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
|
|
||||||
static sysirq_hdlr *sysirq_hdlrs[AT91SAM7_SYSIRQ_COUNT];
|
static sysirq_hdlr *sysirq_hdlrs[AT91SAM7_SYSIRQ_COUNT];
|
||||||
|
|
||||||
void sys_irq(u_int32_t previous_pc)
|
void sys_irq(uint32_t previous_pc)
|
||||||
{
|
{
|
||||||
u_int32_t sr;
|
uint32_t sr;
|
||||||
|
|
||||||
/* Somehow Atmel decided to do really stupid interrupt sharing
|
/* Somehow Atmel decided to do really stupid interrupt sharing
|
||||||
* for commonly-used interrupts such as the timer irq */
|
* for commonly-used interrupts such as the timer irq */
|
||||||
|
|
|
@ -14,7 +14,7 @@ enum sysirqs {
|
||||||
AT91SAM7_SYSIRQ_COUNT
|
AT91SAM7_SYSIRQ_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void sysirq_hdlr(u_int32_t sr);
|
typedef void sysirq_hdlr(uint32_t sr);
|
||||||
|
|
||||||
extern void sysirq_register(enum sysirqs irq, sysirq_hdlr *hdlr);
|
extern void sysirq_register(enum sysirqs irq, sysirq_hdlr *hdlr);
|
||||||
extern void sysirq_init(void);
|
extern void sysirq_init(void);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
static AT91PS_TCB tcb = AT91C_BASE_TCB;
|
static AT91PS_TCB tcb = AT91C_BASE_TCB;
|
||||||
|
|
||||||
/* set carrier divider to a specific */
|
/* set carrier divider to a specific */
|
||||||
void tc_cdiv_set_divider(u_int16_t div)
|
void tc_cdiv_set_divider(uint16_t div)
|
||||||
{
|
{
|
||||||
tcb->TCB_TC0.TC_RC = div;
|
tcb->TCB_TC0.TC_RC = div;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
static AT91PS_TCB tcb;
|
static AT91PS_TCB tcb;
|
||||||
|
|
||||||
extern void tc_cdiv_phase_add(int16_t inc);
|
extern void tc_cdiv_phase_add(int16_t inc);
|
||||||
extern void tc_cdiv_set_divider(u_int16_t div);
|
extern void tc_cdiv_set_divider(uint16_t div);
|
||||||
|
|
||||||
static inline void tc_cdiv_phase_inc(void)
|
static inline void tc_cdiv_phase_inc(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
|
|
||||||
static usb_cmd_fn *cmd_hdlrs[16];
|
static usb_cmd_fn *cmd_hdlrs[16];
|
||||||
|
|
||||||
int usb_hdlr_register(usb_cmd_fn *hdlr, u_int8_t class)
|
int usb_hdlr_register(usb_cmd_fn *hdlr, uint8_t class)
|
||||||
{
|
{
|
||||||
cmd_hdlrs[class] = hdlr;
|
cmd_hdlrs[class] = hdlr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_hdlr_unregister(u_int8_t class)
|
void usb_hdlr_unregister(uint8_t class)
|
||||||
{
|
{
|
||||||
cmd_hdlrs[class] = NULL;
|
cmd_hdlrs[class] = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ enum usbapi_err {
|
||||||
|
|
||||||
typedef int usb_cmd_fn(struct req_ctx *rctx);
|
typedef int usb_cmd_fn(struct req_ctx *rctx);
|
||||||
|
|
||||||
extern int usb_hdlr_register(usb_cmd_fn *hdlr, u_int8_t class);
|
extern int usb_hdlr_register(usb_cmd_fn *hdlr, uint8_t class);
|
||||||
extern void usb_hdlr_unregister(u_int8_t class);
|
extern void usb_hdlr_unregister(uint8_t class);
|
||||||
|
|
||||||
extern void usb_in_process(void);
|
extern void usb_in_process(void);
|
||||||
extern void usb_out_process(void);
|
extern void usb_out_process(void);
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
|
|
||||||
#define OPENPCD_API_VERSION (0x01)
|
#define OPENPCD_API_VERSION (0x01)
|
||||||
#define CONFIG_AREA_ADDR ((void*)(AT91C_IFLASH + AT91C_IFLASH_SIZE - ENVIRONMENT_SIZE))
|
#define CONFIG_AREA_ADDR ((void*)(AT91C_IFLASH + AT91C_IFLASH_SIZE - ENVIRONMENT_SIZE))
|
||||||
#define CONFIG_AREA_WORDS ( AT91C_IFLASH_PAGE_SIZE/sizeof(u_int32_t) )
|
#define CONFIG_AREA_WORDS ( AT91C_IFLASH_PAGE_SIZE/sizeof(uint32_t) )
|
||||||
|
|
||||||
volatile u_int32_t config_stack[ CONFIG_AREA_WORDS ];
|
volatile uint32_t config_stack[ CONFIG_AREA_WORDS ];
|
||||||
|
|
||||||
static int gen_setenv(const void* buffer,int len)
|
static int gen_setenv(const void* buffer,int len)
|
||||||
{
|
{
|
||||||
volatile unsigned int i;
|
volatile unsigned int i;
|
||||||
u_int32_t *dst;
|
uint32_t *dst;
|
||||||
|
|
||||||
if( len >= sizeof(config_stack) )
|
if( len >= sizeof(config_stack) )
|
||||||
len=sizeof(config_stack);
|
len=sizeof(config_stack);
|
||||||
|
@ -35,7 +35,7 @@ static int gen_setenv(const void* buffer,int len)
|
||||||
/* retrieve current content to allow partial flashing */
|
/* retrieve current content to allow partial flashing */
|
||||||
|
|
||||||
/* flash changes */
|
/* flash changes */
|
||||||
dst=(u_int32_t*)CONFIG_AREA_ADDR;
|
dst=(uint32_t*)CONFIG_AREA_ADDR;
|
||||||
for(i=0;i<CONFIG_AREA_WORDS;i++)
|
for(i=0;i<CONFIG_AREA_WORDS;i++)
|
||||||
*dst++=config_stack[i];
|
*dst++=config_stack[i];
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ static int gen_usb_rx(struct req_ctx *rctx)
|
||||||
struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
|
struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
|
||||||
struct openpcd_compile_version *ver =
|
struct openpcd_compile_version *ver =
|
||||||
(struct openpcd_compile_version *)poh->data;
|
(struct openpcd_compile_version *)poh->data;
|
||||||
u_int32_t len = rctx->tot_len-sizeof(*poh);
|
uint32_t len = rctx->tot_len-sizeof(*poh);
|
||||||
|
|
||||||
/* initialize transmit length to header length */
|
/* initialize transmit length to header length */
|
||||||
rctx->tot_len = sizeof(*poh);
|
rctx->tot_len = sizeof(*poh);
|
||||||
|
@ -107,7 +107,7 @@ static int gen_usb_rx(struct req_ctx *rctx)
|
||||||
poh->flags |= OPENPCD_FLAG_RESPOND;
|
poh->flags |= OPENPCD_FLAG_RESPOND;
|
||||||
#ifdef PCD
|
#ifdef PCD
|
||||||
rctx->tot_len += 4;
|
rctx->tot_len += 4;
|
||||||
if (rc632_get_serial(NULL, (u_int32_t *)poh->data) < 0) {
|
if (rc632_get_serial(NULL, (uint32_t *)poh->data) < 0) {
|
||||||
DEBUGP("ERROR) ");
|
DEBUGP("ERROR) ");
|
||||||
return USB_ERR(USB_ERR_CMD_NOT_IMPL);
|
return USB_ERR(USB_ERR_CMD_NOT_IMPL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef _USBAPI_GENERIC_H
|
#ifndef _USBAPI_GENERIC_H
|
||||||
#define _USBAPI_GENERIC_H
|
#define _USBAPI_GENERIC_H
|
||||||
extern void usbcmd_gen_init(void);
|
extern void usbcmd_gen_init(void);
|
||||||
extern int gen_setenv(void* data,u_int32_t pos,u_int32_t length);
|
extern int gen_setenv(void* data,uint32_t pos,uint32_t length);
|
||||||
extern int gen_getenv(void* data,u_int32_t pos,u_int32_t length);
|
extern int gen_getenv(void* data,uint32_t pos,uint32_t length);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#undef WDT_DEBUG
|
#undef WDT_DEBUG
|
||||||
#endif/*WDT_DEBUG*/
|
#endif/*WDT_DEBUG*/
|
||||||
|
|
||||||
static void wdt_irq(u_int32_t sr)
|
static void wdt_irq(uint32_t sr)
|
||||||
{
|
{
|
||||||
if (sr & 1)
|
if (sr & 1)
|
||||||
AT91F_DBGU_Frame("================> WATCHDOG EXPIRED !!!!!\n\r");
|
AT91F_DBGU_Frame("================> WATCHDOG EXPIRED !!!!!\n\r");
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
struct opcd_cmd_hdr {
|
struct opcd_cmd_hdr {
|
||||||
u_int8_t cmd;
|
uint8_t cmd;
|
||||||
u_int8_t arg1;
|
uint8_t arg1;
|
||||||
u_int16_t arg2;
|
uint16_t arg2;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
enum opcd_cmd {
|
enum opcd_cmd {
|
||||||
|
@ -28,8 +28,8 @@ enum opcd_cmd {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct opcd_status_hdr {
|
struct opcd_status_hdr {
|
||||||
u_int8_t cause, /* interrupt cause register RC632 */
|
uint8_t cause, /* interrupt cause register RC632 */
|
||||||
u_int8_t prim_status, /* primary status register RC632 */
|
uint8_t prim_status, /* primary status register RC632 */
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#endif /* _OPENPCD_H */
|
#endif /* _OPENPCD_H */
|
||||||
|
|
|
@ -59,30 +59,30 @@ int _main_dbgu(char key)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct openpcd_l2_connectinfo {
|
struct openpcd_l2_connectinfo {
|
||||||
u_int32_t proto_supported;
|
uint32_t proto_supported;
|
||||||
|
|
||||||
u_int8_t speed_rx;
|
uint8_t speed_rx;
|
||||||
u_int8_t speed_tx;
|
uint8_t speed_tx;
|
||||||
|
|
||||||
u_int8_t uid_len;
|
uint8_t uid_len;
|
||||||
u_int8_t uid[10];
|
uint8_t uid[10];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct openpcd_proto_connectinfo {
|
struct openpcd_proto_connectinfo {
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct openpcd_proto_tcl_connectinfo {
|
struct openpcd_proto_tcl_connectinfo {
|
||||||
u_int8_t fsc;
|
uint8_t fsc;
|
||||||
u_int8_t fsd;
|
uint8_t fsd;
|
||||||
u_int8_t ta;
|
uint8_t ta;
|
||||||
u_int8_t sfgt;
|
uint8_t sfgt;
|
||||||
|
|
||||||
u_int8_t flags;
|
uint8_t flags;
|
||||||
u_int8_t cid;
|
uint8_t cid;
|
||||||
u_int8_t nad;
|
uint8_t nad;
|
||||||
|
|
||||||
u_int8_t ats_tot_len;
|
uint8_t ats_tot_len;
|
||||||
u_int8_t ats_snippet[0];
|
uint8_t ats_snippet[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
static int init_proto(void)
|
static int init_proto(void)
|
||||||
|
|
|
@ -40,7 +40,7 @@ static struct rfid_reader_handle *rh;
|
||||||
static struct rfid_layer2_handle *l2h;
|
static struct rfid_layer2_handle *l2h;
|
||||||
static struct rfid_protocol_handle *ph;
|
static struct rfid_protocol_handle *ph;
|
||||||
|
|
||||||
static u_int8_t sector = 0;
|
static uint8_t sector = 0;
|
||||||
|
|
||||||
void _init_func(void)
|
void _init_func(void)
|
||||||
{
|
{
|
||||||
|
@ -74,30 +74,30 @@ int _main_dbgu(char key)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct openpcd_l2_connectinfo {
|
struct openpcd_l2_connectinfo {
|
||||||
u_int32_t proto_supported;
|
uint32_t proto_supported;
|
||||||
|
|
||||||
u_int8_t speed_rx;
|
uint8_t speed_rx;
|
||||||
u_int8_t speed_tx;
|
uint8_t speed_tx;
|
||||||
|
|
||||||
u_int8_t uid_len;
|
uint8_t uid_len;
|
||||||
u_int8_t uid[10];
|
uint8_t uid[10];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct openpcd_proto_connectinfo {
|
struct openpcd_proto_connectinfo {
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct openpcd_proto_tcl_connectinfo {
|
struct openpcd_proto_tcl_connectinfo {
|
||||||
u_int8_t fsc;
|
uint8_t fsc;
|
||||||
u_int8_t fsd;
|
uint8_t fsd;
|
||||||
u_int8_t ta;
|
uint8_t ta;
|
||||||
u_int8_t sfgt;
|
uint8_t sfgt;
|
||||||
|
|
||||||
u_int8_t flags;
|
uint8_t flags;
|
||||||
u_int8_t cid;
|
uint8_t cid;
|
||||||
u_int8_t nad;
|
uint8_t nad;
|
||||||
|
|
||||||
u_int8_t ats_tot_len;
|
uint8_t ats_tot_len;
|
||||||
u_int8_t ats_snippet[0];
|
uint8_t ats_snippet[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* mifare classic helper */
|
/* mifare classic helper */
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#define RAH NULL
|
#define RAH NULL
|
||||||
|
|
||||||
u_int32_t delay_scan,delay_blink,last_uid,last_polled_uid;
|
uint32_t delay_scan,delay_blink,last_uid,last_polled_uid;
|
||||||
static struct rfid_reader_handle *rh;
|
static struct rfid_reader_handle *rh;
|
||||||
static struct rfid_layer2_handle *l2h;
|
static struct rfid_layer2_handle *l2h;
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ static int usb_presence_rx(struct req_ctx *rctx)
|
||||||
if(last_polled_uid)
|
if(last_polled_uid)
|
||||||
{
|
{
|
||||||
rctx->tot_len += 4;
|
rctx->tot_len += 4;
|
||||||
poh->data[0]=(u_int8_t)(last_polled_uid>>24);
|
poh->data[0]=(uint8_t)(last_polled_uid>>24);
|
||||||
poh->data[1]=(u_int8_t)(last_polled_uid>>16);
|
poh->data[1]=(uint8_t)(last_polled_uid>>16);
|
||||||
poh->data[2]=(u_int8_t)(last_polled_uid>> 8);
|
poh->data[2]=(uint8_t)(last_polled_uid>> 8);
|
||||||
poh->data[3]=(u_int8_t)(last_polled_uid );
|
poh->data[3]=(uint8_t)(last_polled_uid );
|
||||||
last_polled_uid=0;
|
last_polled_uid=0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -124,16 +124,16 @@ int _main_dbgu(char key)
|
||||||
|
|
||||||
void _main_func(void)
|
void _main_func(void)
|
||||||
{
|
{
|
||||||
u_int32_t uid;
|
uint32_t uid;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = rfid_layer2_open(l2h);
|
status = rfid_layer2_open(l2h);
|
||||||
if (status >= 0 && l2h->uid_len==4)
|
if (status >= 0 && l2h->uid_len==4)
|
||||||
{
|
{
|
||||||
uid=((u_int32_t)l2h->uid[0]) |
|
uid=((uint32_t)l2h->uid[0]) |
|
||||||
((u_int32_t)l2h->uid[1])<< 8|
|
((uint32_t)l2h->uid[1])<< 8|
|
||||||
((u_int32_t)l2h->uid[2])<<16|
|
((uint32_t)l2h->uid[2])<<16|
|
||||||
((u_int32_t)l2h->uid[3])<<24;
|
((uint32_t)l2h->uid[3])<<24;
|
||||||
|
|
||||||
delay_scan=100;
|
delay_scan=100;
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,14 @@
|
||||||
|
|
||||||
#define RAH NULL
|
#define RAH NULL
|
||||||
|
|
||||||
static u_int8_t force_100ask = 1;
|
static uint8_t force_100ask = 1;
|
||||||
static u_int8_t mod_conductance = 0x3f;
|
static uint8_t mod_conductance = 0x3f;
|
||||||
static u_int8_t cw_conductance = 0x3f;
|
static uint8_t cw_conductance = 0x3f;
|
||||||
static u_int16_t duty_percent = 22;
|
static uint16_t duty_percent = 22;
|
||||||
|
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
static u_int32_t pwm_freq[] = { 105937, 211875, 423750, 847500 };
|
static uint32_t pwm_freq[] = { 105937, 211875, 423750, 847500 };
|
||||||
static u_int8_t pwm_freq_idx = 0;
|
static uint8_t pwm_freq_idx = 0;
|
||||||
|
|
||||||
static void rc632_modulate_mfin()
|
static void rc632_modulate_mfin()
|
||||||
{
|
{
|
||||||
|
@ -61,11 +61,11 @@ static void rc632_modulate_mfin()
|
||||||
#define COND_MANT(x) (x & 0x0f)
|
#define COND_MANT(x) (x & 0x0f)
|
||||||
#define COND_EXP(x) ((x & 0x30) >> 4)
|
#define COND_EXP(x) ((x & 0x30) >> 4)
|
||||||
|
|
||||||
static const u_int16_t rsrel_expfact[] = { 1000, 1925, 3706, 7133 };
|
static const uint16_t rsrel_expfact[] = { 1000, 1925, 3706, 7133 };
|
||||||
|
|
||||||
static u_int32_t calc_conduct_rel(u_int8_t inp)
|
static uint32_t calc_conduct_rel(uint8_t inp)
|
||||||
{
|
{
|
||||||
u_int32_t cond_rel;
|
uint32_t cond_rel;
|
||||||
|
|
||||||
cond_rel = COND_MANT(inp) * rsrel_expfact[COND_EXP(inp)];
|
cond_rel = COND_MANT(inp) * rsrel_expfact[COND_EXP(inp)];
|
||||||
cond_rel = cond_rel / 1000;
|
cond_rel = cond_rel / 1000;
|
||||||
|
@ -73,14 +73,14 @@ static u_int32_t calc_conduct_rel(u_int8_t inp)
|
||||||
return cond_rel;
|
return cond_rel;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u_int8_t rsrel_table[] = {
|
static const uint8_t rsrel_table[] = {
|
||||||
0, 16, 32, 48, 1, 17, 2, 3, 33, 18, 4, 5, 19, 6, 7, 49, 34, 20,
|
0, 16, 32, 48, 1, 17, 2, 3, 33, 18, 4, 5, 19, 6, 7, 49, 34, 20,
|
||||||
8, 9, 21, 10, 11, 35, 22, 12, 13, 23, 14, 50, 36, 15, 24, 25,
|
8, 9, 21, 10, 11, 35, 22, 12, 13, 23, 14, 50, 36, 15, 24, 25,
|
||||||
37, 26, 27, 51, 38, 28, 29, 39, 30, 52, 31, 40, 41, 53, 42, 43,
|
37, 26, 27, 51, 38, 28, 29, 39, 30, 52, 31, 40, 41, 53, 42, 43,
|
||||||
54, 44, 45, 55, 46, 47, 56, 57, 58, 59, 60, 61, 62, 63 };
|
54, 44, 45, 55, 46, 47, 56, 57, 58, 59, 60, 61, 62, 63 };
|
||||||
|
|
||||||
|
|
||||||
static const u_int16_t cdivs[] = { 128, 64, 32, 16 };
|
static const uint16_t cdivs[] = { 128, 64, 32, 16 };
|
||||||
static int cdiv_idx = 0;
|
static int cdiv_idx = 0;
|
||||||
|
|
||||||
static void help(void)
|
static void help(void)
|
||||||
|
|
|
@ -83,25 +83,25 @@ static const char frame_14443a[] = {
|
||||||
0x00, 0xff, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
|
0x00, 0xff, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void reg_inc(u_int8_t reg)
|
static void reg_inc(uint8_t reg)
|
||||||
{
|
{
|
||||||
u_int8_t val;
|
uint8_t val;
|
||||||
opcd_rc632_reg_read(RAH, reg, &val);
|
opcd_rc632_reg_read(RAH, reg, &val);
|
||||||
opcd_rc632_reg_write(RAH, reg, val++);
|
opcd_rc632_reg_write(RAH, reg, val++);
|
||||||
DEBUGPCRF("reg 0x%02x = 0x%02x", reg, val);
|
DEBUGPCRF("reg 0x%02x = 0x%02x", reg, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reg_dec(u_int8_t reg)
|
static void reg_dec(uint8_t reg)
|
||||||
{
|
{
|
||||||
u_int8_t val;
|
uint8_t val;
|
||||||
opcd_rc632_reg_read(RAH, reg, &val);
|
opcd_rc632_reg_read(RAH, reg, &val);
|
||||||
opcd_rc632_reg_write(RAH, reg, val--);
|
opcd_rc632_reg_write(RAH, reg, val--);
|
||||||
DEBUGPCRF("reg 0x%02x = 0x%02x", reg, val);
|
DEBUGPCRF("reg 0x%02x = 0x%02x", reg, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u_int8_t ana_out_sel;
|
static uint8_t ana_out_sel;
|
||||||
static u_int8_t mfout_sel;
|
static uint8_t mfout_sel;
|
||||||
static u_int8_t speed_idx;
|
static uint8_t speed_idx;
|
||||||
|
|
||||||
static void help(void)
|
static void help(void)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,7 @@ static void help(void)
|
||||||
"{: dev cdiv }: inc cdiv");
|
"{: dev cdiv }: inc cdiv");
|
||||||
}
|
}
|
||||||
|
|
||||||
static u_int16_t cdivs[] = { 128, 64, 32, 16 };
|
static uint16_t cdivs[] = { 128, 64, 32, 16 };
|
||||||
|
|
||||||
int _main_dbgu(char key)
|
int _main_dbgu(char key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ static const AT91PS_SPI pSPI = AT91C_BASE_SPI;
|
||||||
/* SPI irq handler */
|
/* SPI irq handler */
|
||||||
static void spi_irq(void)
|
static void spi_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t status = pSPI->SPI_SR;
|
uint32_t status = pSPI->SPI_SR;
|
||||||
|
|
||||||
DEBUGPSPIIRQ("spi_irq: 0x%08x ", status);
|
DEBUGPSPIIRQ("spi_irq: 0x%08x ", status);
|
||||||
|
|
||||||
|
@ -95,8 +95,8 @@ static void spi_irq(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPI_USES_DMA
|
#ifdef SPI_USES_DMA
|
||||||
static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
static int spi_transceive(const uint8_t *tx_data, uint16_t tx_len,
|
||||||
u_int8_t *rx_data, u_int16_t *rx_len)
|
uint8_t *rx_data, uint16_t *rx_len)
|
||||||
{
|
{
|
||||||
DEBUGPSPI("DMA Xfer tx=%s\r\n", hexdump(tx_data, tx_len));
|
DEBUGPSPI("DMA Xfer tx=%s\r\n", hexdump(tx_data, tx_len));
|
||||||
if (*rx_len < tx_len) {
|
if (*rx_len < tx_len) {
|
||||||
|
@ -129,12 +129,12 @@ static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* stupid polling transceiver routine */
|
/* stupid polling transceiver routine */
|
||||||
static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
static int spi_transceive(const uint8_t *tx_data, uint16_t tx_len,
|
||||||
u_int8_t *rx_data, u_int16_t *rx_len)
|
uint8_t *rx_data, uint16_t *rx_len)
|
||||||
{
|
{
|
||||||
u_int16_t tx_cur = 0;
|
uint16_t tx_cur = 0;
|
||||||
u_int16_t rx_len_max = 0;
|
uint16_t rx_len_max = 0;
|
||||||
u_int16_t rx_cnt = 0;
|
uint16_t rx_cnt = 0;
|
||||||
|
|
||||||
/* disable RC632 interrupt because it wants to do SPI transactions */
|
/* disable RC632 interrupt because it wants to do SPI transactions */
|
||||||
AT91F_AIC_DisableIt(AT91C_BASE_AIC, OPENPCD_IRQ_RC632);
|
AT91F_AIC_DisableIt(AT91C_BASE_AIC, OPENPCD_IRQ_RC632);
|
||||||
|
@ -148,8 +148,8 @@ static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
||||||
|
|
||||||
//AT91F_SPI_Enable(pSPI);
|
//AT91F_SPI_Enable(pSPI);
|
||||||
while (1) {
|
while (1) {
|
||||||
u_int32_t sr = pSPI->SPI_SR;
|
uint32_t sr = pSPI->SPI_SR;
|
||||||
u_int8_t tmp;
|
uint8_t tmp;
|
||||||
if (sr & AT91C_SPI_RDRF) {
|
if (sr & AT91C_SPI_RDRF) {
|
||||||
tmp = pSPI->SPI_RDR;
|
tmp = pSPI->SPI_RDR;
|
||||||
rx_cnt++;
|
rx_cnt++;
|
||||||
|
@ -181,8 +181,8 @@ static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
||||||
/* static buffers used by RC632 access primitives below.
|
/* static buffers used by RC632 access primitives below.
|
||||||
* Since we only have one */
|
* Since we only have one */
|
||||||
|
|
||||||
static u_int8_t spi_outbuf[SPI_MAX_XFER_LEN];
|
static uint8_t spi_outbuf[SPI_MAX_XFER_LEN];
|
||||||
static u_int8_t spi_inbuf[SPI_MAX_XFER_LEN];
|
static uint8_t spi_inbuf[SPI_MAX_XFER_LEN];
|
||||||
|
|
||||||
#define FIFO_ADDR (RC632_REG_FIFO_DATA << 1)
|
#define FIFO_ADDR (RC632_REG_FIFO_DATA << 1)
|
||||||
|
|
||||||
|
@ -191,9 +191,9 @@ static u_int8_t spi_inbuf[SPI_MAX_XFER_LEN];
|
||||||
/* RC632 access primitives */
|
/* RC632 access primitives */
|
||||||
|
|
||||||
int opcd_rc632_reg_write(struct rfid_asic_handle *hdl,
|
int opcd_rc632_reg_write(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t addr, u_int8_t data)
|
uint8_t addr, uint8_t data)
|
||||||
{
|
{
|
||||||
u_int16_t rx_len = 2;
|
uint16_t rx_len = 2;
|
||||||
|
|
||||||
DEBUG632("[0x%02x] <= 0x%02x", addr, data);
|
DEBUG632("[0x%02x] <= 0x%02x", addr, data);
|
||||||
|
|
||||||
|
@ -208,13 +208,13 @@ int opcd_rc632_reg_write(struct rfid_asic_handle *hdl,
|
||||||
#define RC632_REGSET_START 0x10
|
#define RC632_REGSET_START 0x10
|
||||||
#define RC632_REGSET_END 0x3f
|
#define RC632_REGSET_END 0x3f
|
||||||
#define RC632_REGSET_MAXSIZE (RC632_REGSET_END-RC632_REGSET_START)
|
#define RC632_REGSET_MAXSIZE (RC632_REGSET_END-RC632_REGSET_START)
|
||||||
static u_int8_t regset_buf[RC632_REGSET_MAXSIZE * 2];
|
static uint8_t regset_buf[RC632_REGSET_MAXSIZE * 2];
|
||||||
|
|
||||||
int opcd_rc632_reg_write_set(struct rfid_asic_handle *hdl,
|
int opcd_rc632_reg_write_set(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t *regs, int len)
|
uint8_t *regs, int len)
|
||||||
{
|
{
|
||||||
u_int8_t i, j = 0;
|
uint8_t i, j = 0;
|
||||||
u_int16_t rx_len;
|
uint16_t rx_len;
|
||||||
|
|
||||||
if (len > RC632_REGSET_MAXSIZE)
|
if (len > RC632_REGSET_MAXSIZE)
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
|
@ -232,9 +232,9 @@ int opcd_rc632_reg_write_set(struct rfid_asic_handle *hdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
int opcd_rc632_fifo_write(struct rfid_asic_handle *hdl,
|
int opcd_rc632_fifo_write(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t len, u_int8_t *data, u_int8_t flags)
|
uint8_t len, uint8_t *data, uint8_t flags)
|
||||||
{
|
{
|
||||||
u_int16_t rx_len = sizeof(spi_inbuf);
|
uint16_t rx_len = sizeof(spi_inbuf);
|
||||||
if (len > sizeof(spi_outbuf)-1)
|
if (len > sizeof(spi_outbuf)-1)
|
||||||
len = sizeof(spi_outbuf)-1;
|
len = sizeof(spi_outbuf)-1;
|
||||||
|
|
||||||
|
@ -247,9 +247,9 @@ int opcd_rc632_fifo_write(struct rfid_asic_handle *hdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
int opcd_rc632_reg_read(struct rfid_asic_handle *hdl,
|
int opcd_rc632_reg_read(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t addr, u_int8_t *val)
|
uint8_t addr, uint8_t *val)
|
||||||
{
|
{
|
||||||
u_int16_t rx_len = 2;
|
uint16_t rx_len = 2;
|
||||||
|
|
||||||
addr = (addr << 1) & 0x7e;
|
addr = (addr << 1) & 0x7e;
|
||||||
|
|
||||||
|
@ -265,12 +265,12 @@ int opcd_rc632_reg_read(struct rfid_asic_handle *hdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
int opcd_rc632_fifo_read(struct rfid_asic_handle *hdl,
|
int opcd_rc632_fifo_read(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t max_len, u_int8_t *data)
|
uint8_t max_len, uint8_t *data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u_int8_t fifo_length;
|
uint8_t fifo_length;
|
||||||
u_int8_t i;
|
uint8_t i;
|
||||||
u_int16_t rx_len;
|
uint16_t rx_len;
|
||||||
|
|
||||||
ret = opcd_rc632_reg_read(hdl, RC632_REG_FIFO_LENGTH, &fifo_length);
|
ret = opcd_rc632_reg_read(hdl, RC632_REG_FIFO_LENGTH, &fifo_length);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -296,9 +296,9 @@ int opcd_rc632_fifo_read(struct rfid_asic_handle *hdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
int opcd_rc632_set_bits(struct rfid_asic_handle *hdl,
|
int opcd_rc632_set_bits(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t reg, u_int8_t bits)
|
uint8_t reg, uint8_t bits)
|
||||||
{
|
{
|
||||||
u_int8_t val;
|
uint8_t val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = opcd_rc632_reg_read(hdl, reg, &val);
|
ret = opcd_rc632_reg_read(hdl, reg, &val);
|
||||||
|
@ -311,9 +311,9 @@ int opcd_rc632_set_bits(struct rfid_asic_handle *hdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
int opcd_rc632_clear_bits(struct rfid_asic_handle *hdl,
|
int opcd_rc632_clear_bits(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t reg, u_int8_t bits)
|
uint8_t reg, uint8_t bits)
|
||||||
{
|
{
|
||||||
u_int8_t val;
|
uint8_t val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = opcd_rc632_reg_read(hdl, reg, &val);
|
ret = opcd_rc632_reg_read(hdl, reg, &val);
|
||||||
|
@ -331,7 +331,7 @@ static void rc632_irq(void)
|
||||||
{
|
{
|
||||||
struct req_ctx *irq_rctx;
|
struct req_ctx *irq_rctx;
|
||||||
struct openpcd_hdr *irq_opcdh;
|
struct openpcd_hdr *irq_opcdh;
|
||||||
u_int8_t cause;
|
uint8_t cause;
|
||||||
|
|
||||||
/* CL RC632 has interrupted us */
|
/* CL RC632 has interrupted us */
|
||||||
opcd_rc632_reg_read(NULL, RC632_REG_INTERRUPT_RQ, &cause);
|
opcd_rc632_reg_read(NULL, RC632_REG_INTERRUPT_RQ, &cause);
|
||||||
|
@ -392,7 +392,7 @@ void rc632_unthrottle(void)
|
||||||
AT91F_AIC_EnableIt(AT91C_BASE_AIC, OPENPCD_IRQ_RC632);
|
AT91F_AIC_EnableIt(AT91C_BASE_AIC, OPENPCD_IRQ_RC632);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rc632_power(u_int8_t up)
|
void rc632_power(uint8_t up)
|
||||||
{
|
{
|
||||||
DEBUGPCRF("powering %s RC632", up ? "up" : "down");
|
DEBUGPCRF("powering %s RC632", up ? "up" : "down");
|
||||||
if (up)
|
if (up)
|
||||||
|
@ -414,7 +414,7 @@ void rc632_reset(void)
|
||||||
|
|
||||||
/* wait for startup phase to finish */
|
/* wait for startup phase to finish */
|
||||||
while (1) {
|
while (1) {
|
||||||
u_int8_t val;
|
uint8_t val;
|
||||||
opcd_rc632_reg_read(NULL, RC632_REG_COMMAND, &val);
|
opcd_rc632_reg_read(NULL, RC632_REG_COMMAND, &val);
|
||||||
if (val == 0x00)
|
if (val == 0x00)
|
||||||
break;
|
break;
|
||||||
|
@ -427,7 +427,7 @@ void rc632_reset(void)
|
||||||
static int rc632_usb_in(struct req_ctx *rctx)
|
static int rc632_usb_in(struct req_ctx *rctx)
|
||||||
{
|
{
|
||||||
struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
|
struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
|
||||||
u_int16_t len = rctx->tot_len-sizeof(*poh);
|
uint16_t len = rctx->tot_len-sizeof(*poh);
|
||||||
|
|
||||||
/* initialize transmit length to header length */
|
/* initialize transmit length to header length */
|
||||||
rctx->tot_len = sizeof(*poh);
|
rctx->tot_len = sizeof(*poh);
|
||||||
|
@ -443,7 +443,7 @@ static int rc632_usb_in(struct req_ctx *rctx)
|
||||||
/* FIFO read always has to provoke a response */
|
/* FIFO read always has to provoke a response */
|
||||||
poh->flags &= OPENPCD_FLAG_RESPOND;
|
poh->flags &= OPENPCD_FLAG_RESPOND;
|
||||||
{
|
{
|
||||||
u_int16_t req_len = poh->val, remain_len = req_len, pih_len;
|
uint16_t req_len = poh->val, remain_len = req_len, pih_len;
|
||||||
#if 0
|
#if 0
|
||||||
if (req_len > MAX_PAYLOAD_LEN) {
|
if (req_len > MAX_PAYLOAD_LEN) {
|
||||||
pih_len = MAX_PAYLOAD_LEN;
|
pih_len = MAX_PAYLOAD_LEN;
|
||||||
|
@ -598,9 +598,9 @@ void rc632_exit(void)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static int rc632_reg_write_verify(struct rfid_asic_handle *hdl,
|
static int rc632_reg_write_verify(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t reg, u_int8_t val)
|
uint8_t reg, uint8_t val)
|
||||||
{
|
{
|
||||||
u_int8_t tmp;
|
uint8_t tmp;
|
||||||
|
|
||||||
opcd_rc632_reg_write(hdl, reg, val);
|
opcd_rc632_reg_write(hdl, reg, val);
|
||||||
opcd_rc632_reg_read(hdl, reg, &tmp);
|
opcd_rc632_reg_read(hdl, reg, &tmp);
|
||||||
|
@ -612,11 +612,11 @@ static int rc632_reg_write_verify(struct rfid_asic_handle *hdl,
|
||||||
|
|
||||||
int rc632_dump(void)
|
int rc632_dump(void)
|
||||||
{
|
{
|
||||||
u_int8_t i;
|
uint8_t i;
|
||||||
u_int16_t rx_len = sizeof(spi_inbuf);
|
uint16_t rx_len = sizeof(spi_inbuf);
|
||||||
|
|
||||||
for (i = 0; i <= 0x3f; i++) {
|
for (i = 0; i <= 0x3f; i++) {
|
||||||
u_int8_t reg = i;
|
uint8_t reg = i;
|
||||||
if (reg == RC632_REG_FIFO_DATA)
|
if (reg == RC632_REG_FIFO_DATA)
|
||||||
reg = 0x3e;
|
reg = 0x3e;
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,17 @@
|
||||||
#include <librfid/rfid_asic.h>
|
#include <librfid/rfid_asic.h>
|
||||||
|
|
||||||
extern int opcd_rc632_reg_write(struct rfid_asic_handle *hdl,
|
extern int opcd_rc632_reg_write(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t addr, u_int8_t data);
|
uint8_t addr, uint8_t data);
|
||||||
extern int opcd_rc632_fifo_write(struct rfid_asic_handle *hdl,
|
extern int opcd_rc632_fifo_write(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t len, u_int8_t *data, u_int8_t flags);
|
uint8_t len, uint8_t *data, uint8_t flags);
|
||||||
extern int opcd_rc632_reg_read(struct rfid_asic_handle *hdl,
|
extern int opcd_rc632_reg_read(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t addr, u_int8_t *val);
|
uint8_t addr, uint8_t *val);
|
||||||
extern int opcd_rc632_fifo_read(struct rfid_asic_handle *hdl,
|
extern int opcd_rc632_fifo_read(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t max_len, u_int8_t *data);
|
uint8_t max_len, uint8_t *data);
|
||||||
extern int opcd_rc632_clear_bits(struct rfid_asic_handle *hdl,
|
extern int opcd_rc632_clear_bits(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t reg, u_int8_t bits);
|
uint8_t reg, uint8_t bits);
|
||||||
extern int opcd_rc632_set_bits(struct rfid_asic_handle *hdl,
|
extern int opcd_rc632_set_bits(struct rfid_asic_handle *hdl,
|
||||||
u_int8_t reg, u_int8_t bits);
|
uint8_t reg, uint8_t bits);
|
||||||
|
|
||||||
extern void rc632_init(void);
|
extern void rc632_init(void);
|
||||||
extern void rc632_exit(void);
|
extern void rc632_exit(void);
|
||||||
|
@ -27,6 +27,6 @@ extern void rc632_unthrottle(void);
|
||||||
extern int rc632_test(struct rfid_asic_handle *hdl);
|
extern int rc632_test(struct rfid_asic_handle *hdl);
|
||||||
extern int rc632_dump(void);
|
extern int rc632_dump(void);
|
||||||
|
|
||||||
extern void rc632_power(u_int8_t up);
|
extern void rc632_power(uint8_t up);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,10 +49,10 @@ struct rfid_asic rc632;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rc632_set_bit_mask(struct rfid_asic_handle *handle,
|
rc632_set_bit_mask(struct rfid_asic_handle *handle,
|
||||||
u_int8_t reg, u_int8_t mask, u_int8_t val)
|
uint8_t reg, uint8_t mask, uint8_t val)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u_int8_t tmp;
|
uint8_t tmp;
|
||||||
|
|
||||||
ret = opcd_rc632_reg_read(handle, reg, &tmp);
|
ret = opcd_rc632_reg_read(handle, reg, &tmp);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -98,10 +98,10 @@ rc632_power_down(struct rfid_asic_handle *handle)
|
||||||
|
|
||||||
int
|
int
|
||||||
rc632_write_eeprom(struct rfid_asic_handle *handle,
|
rc632_write_eeprom(struct rfid_asic_handle *handle,
|
||||||
u_int16_t addr, u_int8_t len, u_int8_t *data)
|
uint16_t addr, uint8_t len, uint8_t *data)
|
||||||
{
|
{
|
||||||
u_int8_t sndbuf[MAX_WRITE_LEN + 2];
|
uint8_t sndbuf[MAX_WRITE_LEN + 2];
|
||||||
u_int8_t reg;
|
uint8_t reg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (len > MAX_WRITE_LEN)
|
if (len > MAX_WRITE_LEN)
|
||||||
|
@ -146,11 +146,11 @@ rc632_write_eeprom(struct rfid_asic_handle *handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rc632_read_eeprom(struct rfid_asic_handle *handle, u_int16_t addr, u_int8_t len,
|
rc632_read_eeprom(struct rfid_asic_handle *handle, uint16_t addr, uint8_t len,
|
||||||
u_int8_t *recvbuf)
|
uint8_t *recvbuf)
|
||||||
{
|
{
|
||||||
u_int8_t sndbuf[3];
|
uint8_t sndbuf[3];
|
||||||
u_int8_t err;
|
uint8_t err;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sndbuf[0] = (addr & 0xff);
|
sndbuf[0] = (addr & 0xff);
|
||||||
|
@ -187,8 +187,8 @@ rc632_read_eeprom(struct rfid_asic_handle *handle, u_int16_t addr, u_int8_t len,
|
||||||
#define RC632_E2_RS_MAX_P 14
|
#define RC632_E2_RS_MAX_P 14
|
||||||
|
|
||||||
int rc632_get_serial(struct rfid_asic_handle *handle,
|
int rc632_get_serial(struct rfid_asic_handle *handle,
|
||||||
u_int32_t *serial)
|
uint32_t *serial)
|
||||||
{
|
{
|
||||||
return rc632_read_eeprom(handle, RC632_E2_PRODUCT_SERIAL,
|
return rc632_read_eeprom(handle, RC632_E2_PRODUCT_SERIAL,
|
||||||
4, (u_int8_t *)serial);
|
4, (uint8_t *)serial);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ int
|
||||||
rc632_turn_off_rf(struct rfid_asic_handle *handle);
|
rc632_turn_off_rf(struct rfid_asic_handle *handle);
|
||||||
|
|
||||||
int
|
int
|
||||||
rc632_read_eeprom(struct rfid_asic_handle *handle, u_int16_t addr, u_int8_t len,
|
rc632_read_eeprom(struct rfid_asic_handle *handle, uint16_t addr, uint8_t len,
|
||||||
u_int8_t *recvbuf);
|
uint8_t *recvbuf);
|
||||||
|
|
||||||
int rc632_get_serial(struct rfid_asic_handle *handle,
|
int rc632_get_serial(struct rfid_asic_handle *handle,
|
||||||
u_int32_t *serial);
|
uint32_t *serial);
|
||||||
#endif /* _RC632_HIGHLEVEL_H */
|
#endif /* _RC632_HIGHLEVEL_H */
|
||||||
|
|
|
@ -57,7 +57,7 @@ static struct adc_state adc_state;
|
||||||
|
|
||||||
static void adc_irq(void)
|
static void adc_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t sr = adc->ADC_SR;
|
uint32_t sr = adc->ADC_SR;
|
||||||
struct req_ctx *rctx = adc_state.rctx;
|
struct req_ctx *rctx = adc_state.rctx;
|
||||||
|
|
||||||
DEBUGADC("adc_irq(SR=0x%08x, IMR=0x%08x, state=%u): ",
|
DEBUGADC("adc_irq(SR=0x%08x, IMR=0x%08x, state=%u): ",
|
||||||
|
@ -102,12 +102,12 @@ static void adc_irq(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
u_int16_t adc_read_fieldstr(void)
|
uint16_t adc_read_fieldstr(void)
|
||||||
{
|
{
|
||||||
return adc->ADC_CDR4;
|
return adc->ADC_CDR4;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int16_T adc_read_pll_dem(void)
|
uint16_T adc_read_pll_dem(void)
|
||||||
{
|
{
|
||||||
return adc
|
return adc
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _DA_H
|
#ifndef _DA_H
|
||||||
#define _DA_H
|
#define _DA_H
|
||||||
|
|
||||||
extern void da_comp_carr(u_int8_t position);
|
extern void da_comp_carr(uint8_t position);
|
||||||
extern void da_init(void);
|
extern void da_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
|
|
||||||
static struct decoder_algo *decoder_algo[DECODER_NUM_ALGOS];
|
static struct decoder_algo *decoder_algo[DECODER_NUM_ALGOS];
|
||||||
|
|
||||||
static int get_next_data(struct decoder_state *st, u_int8_t *data)
|
static int get_next_data(struct decoder_state *st, uint8_t *data)
|
||||||
{
|
{
|
||||||
u_int8_t parity_sample;
|
uint8_t parity_sample;
|
||||||
u_int32_t bytesample;
|
uint32_t bytesample;
|
||||||
|
|
||||||
bytesample = st->algo->get_next_bytesample(st, &parity_sample);
|
bytesample = st->algo->get_next_bytesample(st, &parity_sample);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ static int get_next_data(struct decoder_state *st, u_int8_t *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* iterate over sample buffer (size N bytes) and decode data */
|
/* iterate over sample buffer (size N bytes) and decode data */
|
||||||
int decoder_decode(u_int8_t algo, const char *sample_buf,
|
int decoder_decode(uint8_t algo, const char *sample_buf,
|
||||||
int sample_buf_size, char *data_buf)
|
int sample_buf_size, char *data_buf)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
@ -46,7 +46,7 @@ int decoder_decode(u_int8_t algo, const char *sample_buf,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
st.buf = sample_buf;
|
st.buf = sample_buf;
|
||||||
st.buf32 = (u_int32_t *) st.buf;
|
st.buf32 = (uint32_t *) st.buf;
|
||||||
st.bit_ofs = 0;
|
st.bit_ofs = 0;
|
||||||
st.algo = decoder_algo[algo];
|
st.algo = decoder_algo[algo];
|
||||||
|
|
||||||
|
|
|
@ -4,22 +4,22 @@
|
||||||
struct decoder_state;
|
struct decoder_state;
|
||||||
|
|
||||||
struct decoder_algo {
|
struct decoder_algo {
|
||||||
u_int8_t oversampling_rate;
|
uint8_t oversampling_rate;
|
||||||
u_int8_t bits_per_sampled_char;
|
uint8_t bits_per_sampled_char;
|
||||||
u_int32_t bytesample_mask;
|
uint32_t bytesample_mask;
|
||||||
int (*decode_sample)(const u_int32_t sample, u_int8_t data);
|
int (*decode_sample)(const uint32_t sample, uint8_t data);
|
||||||
u_int32_t (*get_next_bytesample)(struct decoder_state *st, u_int8_t *parity_sample);
|
uint32_t (*get_next_bytesample)(struct decoder_state *st, uint8_t *parity_sample);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct decoder_state {
|
struct decoder_state {
|
||||||
struct decoder_algo *algo;
|
struct decoder_algo *algo;
|
||||||
u_int8_t bit_ofs;
|
uint8_t bit_ofs;
|
||||||
const char *buf;
|
const char *buf;
|
||||||
const u_int32_t *buf32;
|
const uint32_t *buf32;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int decoder_register(int algnum, struct decoder_algo *algo);
|
extern int decoder_register(int algnum, struct decoder_algo *algo);
|
||||||
extern int decoder_decode(u_int8_t algo, const char *sample_buf,
|
extern int decoder_decode(uint8_t algo, const char *sample_buf,
|
||||||
int sample_buf_size, char *data_buf);
|
int sample_buf_size, char *data_buf);
|
||||||
|
|
||||||
#define DECODER_MILLER 0
|
#define DECODER_MILLER 0
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
#define SEQ_Z 0x1
|
#define SEQ_Z 0x1
|
||||||
|
|
||||||
/* decode a single sampled bit */
|
/* decode a single sampled bit */
|
||||||
static u_int8_t miller_decode_sampled_bit(u_int32_t sampled_bit)
|
static uint8_t miller_decode_sampled_bit(uint32_t sampled_bit)
|
||||||
{
|
{
|
||||||
switch (sampled_bit) {
|
switch (sampled_bit) {
|
||||||
case SEQ_X:
|
case SEQ_X:
|
||||||
|
@ -73,13 +73,13 @@ static u_int8_t miller_decode_sampled_bit(u_int32_t sampled_bit)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode a single 32bit data sample of an 8bit miller encoded word */
|
/* decode a single 32bit data sample of an 8bit miller encoded word */
|
||||||
static int miller_decode_sample(u_int32_t sample, u_int8_t *data)
|
static int miller_decode_sample(uint32_t sample, uint8_t *data)
|
||||||
{
|
{
|
||||||
u_int8_t ret = 0;
|
uint8_t ret = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(sample)/OVERSAMPLING_RATE; i++) {
|
for (i = 0; i < sizeof(sample)/OVERSAMPLING_RATE; i++) {
|
||||||
u_int8_t bit = miller_decode_sampled_bit(sample & 0xf);
|
uint8_t bit = miller_decode_sampled_bit(sample & 0xf);
|
||||||
|
|
||||||
if (bit == 1)
|
if (bit == 1)
|
||||||
ret |= 1;
|
ret |= 1;
|
||||||
|
@ -98,10 +98,10 @@ static int miller_decode_sample(u_int32_t sample, u_int8_t *data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u_int32_t get_next_bytesample(struct decoder_state *ms,
|
static uint32_t get_next_bytesample(struct decoder_state *ms,
|
||||||
u_int8_t *parity_sample)
|
uint8_t *parity_sample)
|
||||||
{
|
{
|
||||||
u_int32_t ret = 0;
|
uint32_t ret = 0;
|
||||||
|
|
||||||
/* get remaining bits from the current word */
|
/* get remaining bits from the current word */
|
||||||
ret = *(ms->buf32) >> ms->bit_ofs;
|
ret = *(ms->buf32) >> ms->bit_ofs;
|
||||||
|
|
|
@ -60,12 +60,12 @@
|
||||||
/* currently this code will only work with oversampling_rate == 1 */
|
/* currently this code will only work with oversampling_rate == 1 */
|
||||||
#define OVERSAMPLING_RATE 1
|
#define OVERSAMPLING_RATE 1
|
||||||
|
|
||||||
static u_int32_t get_next_bytesample(struct decoder_state *st,
|
static uint32_t get_next_bytesample(struct decoder_state *st,
|
||||||
u_int8_t *parity_sample)
|
uint8_t *parity_sample)
|
||||||
{
|
{
|
||||||
u_int32_t ret = 0;
|
uint32_t ret = 0;
|
||||||
u_int8_t bits_per_sampled_char = st->algo->bits_per_sampled_char;
|
uint8_t bits_per_sampled_char = st->algo->bits_per_sampled_char;
|
||||||
u_int8_t bytesample_mask = st->algo->bytesample_mask;
|
uint8_t bytesample_mask = st->algo->bytesample_mask;
|
||||||
|
|
||||||
/* FIXME: shift start and stop bit into parity_sample and just
|
/* FIXME: shift start and stop bit into parity_sample and just
|
||||||
* return plain 8-bit data word */
|
* return plain 8-bit data word */
|
||||||
|
@ -83,7 +83,7 @@ static u_int32_t get_next_bytesample(struct decoder_state *st,
|
||||||
return ret & bytesample_mask;
|
return ret & bytesample_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nrzl_decode_sample(const u_int32_t sample, u_int8_t *data)
|
static int nrzl_decode_sample(const uint32_t sample, uint8_t *data)
|
||||||
{
|
{
|
||||||
*data = (sample >> 1) & 0xff;
|
*data = (sample >> 1) & 0xff;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
#define MANCHESTER_SEQ_E 0x5500
|
#define MANCHESTER_SEQ_E 0x5500
|
||||||
#define MANCHESTER_SEQ_F 0x5555
|
#define MANCHESTER_SEQ_F 0x5555
|
||||||
|
|
||||||
static u_int32_t manchester_sample_size(u_int8_t frame_bytelen)
|
static uint32_t manchester_sample_size(uint8_t frame_bytelen)
|
||||||
{
|
{
|
||||||
/* 16 bits (2 bytes) per bit => 16 bytes samples per data byte,
|
/* 16 bits (2 bytes) per bit => 16 bytes samples per data byte,
|
||||||
* plus 16bit (2 bytes) parity per data byte
|
* plus 16bit (2 bytes) parity per data byte
|
||||||
|
@ -60,13 +60,13 @@ static u_int32_t manchester_sample_size(u_int8_t frame_bytelen)
|
||||||
struct manch_enc_state {
|
struct manch_enc_state {
|
||||||
const char *data;
|
const char *data;
|
||||||
char *samples;
|
char *samples;
|
||||||
u_int16_t *samples16;
|
uint16_t *samples16;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void manchester_enc_byte(struct manch_enc_state *mencs, u_int8_t data)
|
static void manchester_enc_byte(struct manch_enc_state *mencs, uint8_t data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u_int8_t sum_1 = 0;
|
uint8_t sum_1 = 0;
|
||||||
|
|
||||||
/* append 8 sample blobs, one for each bit */
|
/* append 8 sample blobs, one for each bit */
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
|
@ -86,8 +86,8 @@ static void manchester_enc_byte(struct manch_enc_state *mencs, u_int8_t data)
|
||||||
mencs->samples16++
|
mencs->samples16++
|
||||||
}
|
}
|
||||||
|
|
||||||
int manchester_encode(char *sample_buf, u_int16_t sample_buf_len,
|
int manchester_encode(char *sample_buf, uint16_t sample_buf_len,
|
||||||
const char *data, u_int8_t data_len)
|
const char *data, uint8_t data_len)
|
||||||
{
|
{
|
||||||
int i, enc_size;
|
int i, enc_size;
|
||||||
struct manch_enc_state mencs
|
struct manch_enc_state mencs
|
||||||
|
@ -112,10 +112,10 @@ int manchester_encode(char *sample_buf, u_int16_t sample_buf_len,
|
||||||
#define BPSK_SPEED_212
|
#define BPSK_SPEED_212
|
||||||
|
|
||||||
|
|
||||||
static u_int32_t bpsk_sample_size(u_int8_t frame_bytelen)
|
static uint32_t bpsk_sample_size(uint8_t frame_bytelen)
|
||||||
|
|
||||||
int bpsk_encode(char *sample_buf, u_int16_t sample_buf_len,
|
int bpsk_encode(char *sample_buf, uint16_t sample_buf_len,
|
||||||
const char *data, u_int8_t data_len)
|
const char *data, uint8_t data_len)
|
||||||
{
|
{
|
||||||
/* burst of 32 sub carrier cycles */
|
/* burst of 32 sub carrier cycles */
|
||||||
memset(sample_buf, 0x55, 8);
|
memset(sample_buf, 0x55, 8);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "../openpcd.h"
|
#include "../openpcd.h"
|
||||||
|
|
||||||
void load_mod_level(u_int8_t level)
|
void load_mod_level(uint8_t level)
|
||||||
{
|
{
|
||||||
if (level > 3)
|
if (level > 3)
|
||||||
level = 3;
|
level = 3;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _LOAD_MODULATION_H
|
#ifndef _LOAD_MODULATION_H
|
||||||
#define _LOAD_MODULATION_H
|
#define _LOAD_MODULATION_H
|
||||||
|
|
||||||
extern void load_mod_level(u_int8_t level);
|
extern void load_mod_level(uint8_t level);
|
||||||
extern void load_mod_init(void);
|
extern void load_mod_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,15 +35,15 @@
|
||||||
#include <picc/ssc_picc.h>
|
#include <picc/ssc_picc.h>
|
||||||
#include <picc/load_modulation.h>
|
#include <picc/load_modulation.h>
|
||||||
|
|
||||||
static const u_int16_t cdivs[] = { 8192, 2048, 1024, 512, 128, 64, 32, 16 };
|
static const uint16_t cdivs[] = { 8192, 2048, 1024, 512, 128, 64, 32, 16 };
|
||||||
static u_int8_t cdiv_idx = 6;
|
static uint8_t cdiv_idx = 6;
|
||||||
|
|
||||||
static u_int16_t duty_percent = 22;
|
static uint16_t duty_percent = 22;
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
static u_int32_t pwm_freq[] = { 105937, 211875, 423750, 847500 };
|
static uint32_t pwm_freq[] = { 105937, 211875, 423750, 847500 };
|
||||||
static u_int8_t pwm_freq_idx = 0;
|
static uint8_t pwm_freq_idx = 0;
|
||||||
|
|
||||||
static u_int8_t load_mod = 0;
|
static uint8_t load_mod = 0;
|
||||||
|
|
||||||
#define DA_BASELINE 192
|
#define DA_BASELINE 192
|
||||||
|
|
||||||
|
@ -88,10 +88,10 @@ static void help(void)
|
||||||
|
|
||||||
int _main_dbgu(char key)
|
int _main_dbgu(char key)
|
||||||
{
|
{
|
||||||
static u_int8_t poti = DA_BASELINE;
|
static uint8_t poti = DA_BASELINE;
|
||||||
static u_int8_t pll_inh = 1;
|
static uint8_t pll_inh = 1;
|
||||||
static u_int8_t ssc_mode = 1;
|
static uint8_t ssc_mode = 1;
|
||||||
static u_int8_t sync_enabled = 0;
|
static uint8_t sync_enabled = 0;
|
||||||
|
|
||||||
DEBUGPCRF("main_dbgu");
|
DEBUGPCRF("main_dbgu");
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* Our registers, including their power-up default values */
|
/* Our registers, including their power-up default values */
|
||||||
static u_int16_t opicc_regs[_OPICC_NUM_REGS] = {
|
static uint16_t opicc_regs[_OPICC_NUM_REGS] = {
|
||||||
[OPICC_REG_14443A_UIDLEN] = 4,
|
[OPICC_REG_14443A_UIDLEN] = 4,
|
||||||
[OPICC_REG_14443A_FDT0] = 1236,
|
[OPICC_REG_14443A_FDT0] = 1236,
|
||||||
[OPICC_REG_14443A_FDT1] = 1172,
|
[OPICC_REG_14443A_FDT1] = 1172,
|
||||||
|
@ -30,14 +30,14 @@ static u_int16_t opicc_regs[_OPICC_NUM_REGS] = {
|
||||||
[OPICC_REG_RX_COMP_LEVEL] = 0,
|
[OPICC_REG_RX_COMP_LEVEL] = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
u_int16_t opicc_reg_read(enum opicc_reg reg)
|
uint16_t opicc_reg_read(enum opicc_reg reg)
|
||||||
{
|
{
|
||||||
if (reg < _OPICC_NUM_REGS)
|
if (reg < _OPICC_NUM_REGS)
|
||||||
return opicc_regs[reg];
|
return opicc_regs[reg];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void opicc_reg_write(enum opicc_reg reg, u_int16_t val)
|
void opicc_reg_write(enum opicc_reg reg, uint16_t val)
|
||||||
{
|
{
|
||||||
if (reg < _OPICC_NUM_REGS)
|
if (reg < _OPICC_NUM_REGS)
|
||||||
opicc_regs[reg] = val;
|
opicc_regs[reg] = val;
|
||||||
|
@ -52,7 +52,7 @@ void opicc_reg_write(enum opicc_reg reg, u_int16_t val)
|
||||||
static int opicc_reg_usb_in(struct req_ctx *rctx)
|
static int opicc_reg_usb_in(struct req_ctx *rctx)
|
||||||
{
|
{
|
||||||
struct openpcd_hdr *poh = (struct openpcd_hdr *) &rctx->data[0];
|
struct openpcd_hdr *poh = (struct openpcd_hdr *) &rctx->data[0];
|
||||||
u_int16_t *val16 = (u_int16_t *) poh->data;
|
uint16_t *val16 = (uint16_t *) poh->data;
|
||||||
|
|
||||||
poh->val = 0;
|
poh->val = 0;
|
||||||
rctx->tot_len = sizeof(*poh);
|
rctx->tot_len = sizeof(*poh);
|
||||||
|
@ -60,11 +60,11 @@ static int opicc_reg_usb_in(struct req_ctx *rctx)
|
||||||
switch (poh->cmd) {
|
switch (poh->cmd) {
|
||||||
case OPENPCD_CMD_PICC_REG_READ:
|
case OPENPCD_CMD_PICC_REG_READ:
|
||||||
*val16 = opicc_reg_read(poh->reg);
|
*val16 = opicc_reg_read(poh->reg);
|
||||||
rctx->tot_len += sizeof(u_int16_t);
|
rctx->tot_len += sizeof(uint16_t);
|
||||||
poh->flags |= OPENPCD_FLAG_RESPOND;
|
poh->flags |= OPENPCD_FLAG_RESPOND;
|
||||||
break;
|
break;
|
||||||
case OPENPCD_CMD_PICC_REG_WRITE:
|
case OPENPCD_CMD_PICC_REG_WRITE:
|
||||||
if (rctx->tot_len < sizeof(*poh) + sizeof(u_int16_t)) {
|
if (rctx->tot_len < sizeof(*poh) + sizeof(uint16_t)) {
|
||||||
/* we only have an 8bit write */
|
/* we only have an 8bit write */
|
||||||
opicc_reg_write(poh->reg, poh->val);
|
opicc_reg_write(poh->reg, poh->val);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
u_int16_t opicc_reg_read(enum opicc_reg reg);
|
uint16_t opicc_reg_read(enum opicc_reg reg);
|
||||||
void opicc_reg_write(enum opicc_reg reg, u_int16_t val);
|
void opicc_reg_write(enum opicc_reg reg, uint16_t val);
|
||||||
#else
|
#else
|
||||||
u_int16_t opicc_regs[_OPICC_NUM_REGS];
|
uint16_t opicc_regs[_OPICC_NUM_REGS];
|
||||||
#define opicc_reg_read(x) (opicc_regs[x])
|
#define opicc_reg_read(x) (opicc_regs[x])
|
||||||
#define opicc_reg_write(x, y) (opicc_regs[x] = y)
|
#define opicc_reg_write(x, y) (opicc_regs[x] = y)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
struct piccsim_state {
|
struct piccsim_state {
|
||||||
enum rfid_layer2_id l2prot;
|
enum rfid_layer2_id l2prot;
|
||||||
unsigned char uid[10];
|
unsigned char uid[10];
|
||||||
u_int8_t uid_len;
|
uint8_t uid_len;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
enum iso14443a_state state;
|
enum iso14443a_state state;
|
||||||
enum iso14443a_level level;
|
enum iso14443a_level level;
|
||||||
u_int32_t flags;
|
uint32_t flags;
|
||||||
} iso14443a;
|
} iso14443a;
|
||||||
struct {
|
struct {
|
||||||
} iso14443b;
|
} iso14443b;
|
||||||
} l2;
|
} l2;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
u_int32_t flags;
|
uint32_t flags;
|
||||||
} proto;
|
} proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ int pll_is_locked(void)
|
||||||
return AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_LOCK);
|
return AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pll_lock_change_cb(u_int32_t pio)
|
static void pll_lock_change_cb(uint32_t pio)
|
||||||
{
|
{
|
||||||
DEBUGPCRF("PLL LOCK: %d", pll_is_locked());
|
DEBUGPCRF("PLL LOCK: %d", pll_is_locked());
|
||||||
#if 1
|
#if 1
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
static const AT91PS_SPI spi = AT91C_BASE_SPI;
|
static const AT91PS_SPI spi = AT91C_BASE_SPI;
|
||||||
|
|
||||||
void poti_comp_carr(u_int8_t position)
|
void poti_comp_carr(uint8_t position)
|
||||||
{
|
{
|
||||||
volatile int i;
|
volatile int i;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _POTI_H
|
#ifndef _POTI_H
|
||||||
#define _POTI_H
|
#define _POTI_H
|
||||||
|
|
||||||
extern void poti_comp_carr(u_int8_t position);
|
extern void poti_comp_carr(uint8_t position);
|
||||||
extern void poti_init(void);
|
extern void poti_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct ssc_state {
|
||||||
};
|
};
|
||||||
static struct ssc_state ssc_state;
|
static struct ssc_state ssc_state;
|
||||||
|
|
||||||
static const u_int16_t ssc_dmasize[] = {
|
static const uint16_t ssc_dmasize[] = {
|
||||||
[SSC_MODE_NONE] = 16,
|
[SSC_MODE_NONE] = 16,
|
||||||
[SSC_MODE_14443A_SHORT] = 16, /* 64 bytes */
|
[SSC_MODE_14443A_SHORT] = 16, /* 64 bytes */
|
||||||
[SSC_MODE_14443A_STANDARD] = 16, /* 64 bytes */
|
[SSC_MODE_14443A_STANDARD] = 16, /* 64 bytes */
|
||||||
|
@ -91,8 +91,8 @@ static const u_int16_t ssc_dmasize[] = {
|
||||||
|
|
||||||
void ssc_rx_mode_set(enum ssc_mode ssc_mode)
|
void ssc_rx_mode_set(enum ssc_mode ssc_mode)
|
||||||
{
|
{
|
||||||
u_int8_t data_len, num_data, sync_len;
|
uint8_t data_len, num_data, sync_len;
|
||||||
u_int32_t start_cond;
|
uint32_t start_cond;
|
||||||
|
|
||||||
/* disable Rx and all Rx interrupt sources */
|
/* disable Rx and all Rx interrupt sources */
|
||||||
AT91F_SSC_DisableRx(AT91C_BASE_SSC);
|
AT91F_SSC_DisableRx(AT91C_BASE_SSC);
|
||||||
|
@ -151,8 +151,8 @@ out_set_mode:
|
||||||
|
|
||||||
static void ssc_tx_mode_set(enum ssc_mode ssc_mode)
|
static void ssc_tx_mode_set(enum ssc_mode ssc_mode)
|
||||||
{
|
{
|
||||||
u_int8_t data_len, num_data, sync_len;
|
uint8_t data_len, num_data, sync_len;
|
||||||
u_int32_t start_cond;
|
uint32_t start_cond;
|
||||||
|
|
||||||
/* disable Tx */
|
/* disable Tx */
|
||||||
AT91F_SSC_DisableTx(AT91C_BASE_SSC);
|
AT91F_SSC_DisableTx(AT91C_BASE_SSC);
|
||||||
|
@ -308,7 +308,7 @@ static int8_t ssc_rx_refill(void)
|
||||||
|
|
||||||
static void __ramfunc ssc_irq(void)
|
static void __ramfunc ssc_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t ssc_sr = ssc->SSC_SR;
|
uint32_t ssc_sr = ssc->SSC_SR;
|
||||||
int i, *tmp, emptyframe = 0;
|
int i, *tmp, emptyframe = 0;
|
||||||
DEBUGP("ssc_sr=0x%08x, mode=%u: ", ssc_sr, ssc_state.mode);
|
DEBUGP("ssc_sr=0x%08x, mode=%u: ", ssc_sr, ssc_state.mode);
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ static void __ramfunc ssc_irq(void)
|
||||||
/* Experimental start SSC on frame, stop on FFFFFFFF */
|
/* Experimental start SSC on frame, stop on FFFFFFFF */
|
||||||
if (ssc_state.mode == SSC_MODE_CONTINUOUS) {
|
if (ssc_state.mode == SSC_MODE_CONTINUOUS) {
|
||||||
//ssc->SSC_RCMR = (ssc->SSC_RCMR & ~AT91C_SSC_START) | AT91C_SSC_START_CONTINOUS;
|
//ssc->SSC_RCMR = (ssc->SSC_RCMR & ~AT91C_SSC_START) | AT91C_SSC_START_CONTINOUS;
|
||||||
tmp = (u_int32_t*)ssc_state.rx_ctx[0]->data;
|
tmp = (uint32_t*)ssc_state.rx_ctx[0]->data;
|
||||||
for(i = ssc_state.rx_ctx[0]->size / 4; i >= 0 ; i--) {
|
for(i = ssc_state.rx_ctx[0]->size / 4; i >= 0 ; i--) {
|
||||||
if( *tmp++ == 0xFFFFFFFF ) {
|
if( *tmp++ == 0xFFFFFFFF ) {
|
||||||
*(tmp-1) = 0xAAAAAAAA; // debug marker
|
*(tmp-1) = 0xAAAAAAAA; // debug marker
|
||||||
|
@ -345,7 +345,7 @@ static void __ramfunc ssc_irq(void)
|
||||||
#endif
|
#endif
|
||||||
/* Ignore empty frames */
|
/* Ignore empty frames */
|
||||||
if (ssc_state.mode == SSC_MODE_CONTINUOUS) {
|
if (ssc_state.mode == SSC_MODE_CONTINUOUS) {
|
||||||
tmp = (u_int32_t*)ssc_state.rx_ctx[0]->data + MAX_HDRSIZE;
|
tmp = (uint32_t*)ssc_state.rx_ctx[0]->data + MAX_HDRSIZE;
|
||||||
emptyframe = 1;
|
emptyframe = 1;
|
||||||
for(i = (ssc_state.rx_ctx[0]->size-MAX_HDRSIZE) / 4 - 8/*WTF?*/; i > 0; i--) {
|
for(i = (ssc_state.rx_ctx[0]->size-MAX_HDRSIZE) / 4 - 8/*WTF?*/; i > 0; i--) {
|
||||||
if( *tmp++ != 0xFFFFFFFF ) {
|
if( *tmp++ != 0xFFFFFFFF ) {
|
||||||
|
@ -417,7 +417,7 @@ static void __ramfunc ssc_irq(void)
|
||||||
if (ssc_sr & AT91C_SSC_RXSYN)
|
if (ssc_sr & AT91C_SSC_RXSYN)
|
||||||
DEBUGP("RXSYN ");
|
DEBUGP("RXSYN ");
|
||||||
if (ssc_sr & AT91C_SSC_RXRDY) {
|
if (ssc_sr & AT91C_SSC_RXRDY) {
|
||||||
u_int32_t sample = ssc->SSC_RHR;
|
uint32_t sample = ssc->SSC_RHR;
|
||||||
DEBUGP("RXRDY=0x%08x ", sample);
|
DEBUGP("RXRDY=0x%08x ", sample);
|
||||||
/* Try to set FDT compare register ASAP */
|
/* Try to set FDT compare register ASAP */
|
||||||
if (sample == REQA) {
|
if (sample == REQA) {
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
//#define USE_IRQ
|
//#define USE_IRQ
|
||||||
|
|
||||||
static u_int8_t enabled;
|
static uint8_t enabled;
|
||||||
|
|
||||||
static void pio_data_change(u_int32_t pio)
|
static void pio_data_change(uint32_t pio)
|
||||||
{
|
{
|
||||||
DEBUGP("PIO_FRAME_IRQ: ");
|
DEBUGP("PIO_FRAME_IRQ: ");
|
||||||
/* we get one interrupt for each change. If now, after the
|
/* we get one interrupt for each change. If now, after the
|
||||||
|
@ -46,7 +46,7 @@ static void __ramfunc cdsync_cb(void)
|
||||||
void tc_cdiv_sync_reset(void)
|
void tc_cdiv_sync_reset(void)
|
||||||
{
|
{
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
u_int32_t tmp = *AT91C_PIOA_ISR;
|
uint32_t tmp = *AT91C_PIOA_ISR;
|
||||||
volatile int i;
|
volatile int i;
|
||||||
DEBUGPCRF("CDIV_SYNC_FLOP");
|
DEBUGPCRF("CDIV_SYNC_FLOP");
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
static AT91PS_TC tcfdt = AT91C_BASE_TC2;
|
static AT91PS_TC tcfdt = AT91C_BASE_TC2;
|
||||||
|
|
||||||
void tc_fdt_set(u_int16_t count)
|
void tc_fdt_set(uint16_t count)
|
||||||
{
|
{
|
||||||
tcfdt->TC_RA = count;
|
tcfdt->TC_RA = count;
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,14 @@ void tc_fdt_set(u_int16_t count)
|
||||||
|
|
||||||
/* 'count' number of carrier cycles after the last modulation pause,
|
/* 'count' number of carrier cycles after the last modulation pause,
|
||||||
* we deem the frame to have ended */
|
* we deem the frame to have ended */
|
||||||
void tc_frame_end_set(u_int16_t count)
|
void tc_frame_end_set(uint16_t count)
|
||||||
{
|
{
|
||||||
tcfdt->TC_RB = count;
|
tcfdt->TC_RB = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tc_fdt_irq(void)
|
static void tc_fdt_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t sr = tcfdt->TC_SR;
|
uint32_t sr = tcfdt->TC_SR;
|
||||||
DEBUGP("tc_fdt_irq: TC2_SR=0x%08x TC2_CV=0x%08x ",
|
DEBUGP("tc_fdt_irq: TC2_SR=0x%08x TC2_CV=0x%08x ",
|
||||||
sr, tcfdt->TC_CV);
|
sr, tcfdt->TC_CV);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
extern void tc_fdt_init(void);
|
extern void tc_fdt_init(void);
|
||||||
extern void tc_fdt_set(u_int16_t count);
|
extern void tc_fdt_set(uint16_t count);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -85,22 +85,22 @@ enum pts_state {
|
||||||
struct iso7816_3_handle {
|
struct iso7816_3_handle {
|
||||||
enum iso7816_3_state state;
|
enum iso7816_3_state state;
|
||||||
|
|
||||||
u_int8_t fi;
|
uint8_t fi;
|
||||||
u_int8_t di;
|
uint8_t di;
|
||||||
u_int8_t wi;
|
uint8_t wi;
|
||||||
u_int32_t waiting_time;
|
uint32_t waiting_time;
|
||||||
|
|
||||||
enum atr_state atr_state;
|
enum atr_state atr_state;
|
||||||
u_int8_t atr_idx;
|
uint8_t atr_idx;
|
||||||
u_int8_t atr_hist_len;
|
uint8_t atr_hist_len;
|
||||||
u_int8_t atr_last_td;
|
uint8_t atr_last_td;
|
||||||
u_int8_t atr[64];
|
uint8_t atr[64];
|
||||||
|
|
||||||
u_int16_t prot_t_supported;
|
uint16_t prot_t_supported;
|
||||||
|
|
||||||
enum pts_state pts_state;
|
enum pts_state pts_state;
|
||||||
u_int8_t pts_req[6];
|
uint8_t pts_req[6];
|
||||||
u_int8_t pts_resp[6];
|
uint8_t pts_resp[6];
|
||||||
|
|
||||||
struct simtrace_hdr sh;
|
struct simtrace_hdr sh;
|
||||||
|
|
||||||
|
@ -114,13 +114,13 @@ struct iso7816_3_handle isoh;
|
||||||
|
|
||||||
|
|
||||||
/* Table 6 from ISO 7816-3 */
|
/* Table 6 from ISO 7816-3 */
|
||||||
static const u_int16_t fi_table[] = {
|
static const uint16_t fi_table[] = {
|
||||||
372, 372, 558, 744, 1116, 1488, 1860, 0,
|
372, 372, 558, 744, 1116, 1488, 1860, 0,
|
||||||
0, 512, 768, 1024, 1536, 2048, 0, 0
|
0, 512, 768, 1024, 1536, 2048, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Table 7 from ISO 7816-3 */
|
/* Table 7 from ISO 7816-3 */
|
||||||
static const u_int8_t di_table[] = {
|
static const uint8_t di_table[] = {
|
||||||
0, 1, 2, 4, 8, 16, 32, 64,
|
0, 1, 2, 4, 8, 16, 32, 64,
|
||||||
12, 20, 2, 4, 8, 16, 32, 64,
|
12, 20, 2, 4, 8, 16, 32, 64,
|
||||||
};
|
};
|
||||||
|
@ -154,9 +154,9 @@ struct simtrace_stats *iso_uart_stats_get(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute the F/D ratio based on Fi and Di values */
|
/* compute the F/D ratio based on Fi and Di values */
|
||||||
static int compute_fidi_ratio(u_int8_t fi, u_int8_t di)
|
static int compute_fidi_ratio(uint8_t fi, uint8_t di)
|
||||||
{
|
{
|
||||||
u_int16_t f, d;
|
uint16_t f, d;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (fi >= ARRAY_SIZE(fi_table) ||
|
if (fi >= ARRAY_SIZE(fi_table) ||
|
||||||
|
@ -314,7 +314,7 @@ transition_to_tck(struct iso7816_3_handle *ih)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine the next ATR state based on received interface byte */
|
/* determine the next ATR state based on received interface byte */
|
||||||
static enum atr_state next_intb_state(struct iso7816_3_handle *ih, u_int8_t ch)
|
static enum atr_state next_intb_state(struct iso7816_3_handle *ih, uint8_t ch)
|
||||||
{
|
{
|
||||||
switch (ih->atr_state) {
|
switch (ih->atr_state) {
|
||||||
case ATR_S_WAIT_TD:
|
case ATR_S_WAIT_TD:
|
||||||
|
@ -359,7 +359,7 @@ from_tc:
|
||||||
|
|
||||||
/* process an incomng ATR byte */
|
/* process an incomng ATR byte */
|
||||||
static enum iso7816_3_state
|
static enum iso7816_3_state
|
||||||
process_byte_atr(struct iso7816_3_handle *ih, u_int8_t byte)
|
process_byte_atr(struct iso7816_3_handle *ih, uint8_t byte)
|
||||||
{
|
{
|
||||||
/* add byte to ATR buffer */
|
/* add byte to ATR buffer */
|
||||||
ih->atr[ih->atr_idx] = byte;
|
ih->atr[ih->atr_idx] = byte;
|
||||||
|
@ -412,9 +412,9 @@ static void set_pts_state(struct iso7816_3_handle *ih, enum pts_state new_ptss)
|
||||||
/* Determine the next PTS state */
|
/* Determine the next PTS state */
|
||||||
static enum pts_state next_pts_state(struct iso7816_3_handle *ih)
|
static enum pts_state next_pts_state(struct iso7816_3_handle *ih)
|
||||||
{
|
{
|
||||||
u_int8_t is_resp = ih->pts_state & 0x10;
|
uint8_t is_resp = ih->pts_state & 0x10;
|
||||||
u_int8_t sstate = ih->pts_state & 0x0f;
|
uint8_t sstate = ih->pts_state & 0x0f;
|
||||||
u_int8_t *pts_ptr;
|
uint8_t *pts_ptr;
|
||||||
|
|
||||||
if (!is_resp)
|
if (!is_resp)
|
||||||
pts_ptr = ih->pts_req;
|
pts_ptr = ih->pts_req;
|
||||||
|
@ -453,7 +453,7 @@ from_pts3:
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum iso7816_3_state
|
static enum iso7816_3_state
|
||||||
process_byte_pts(struct iso7816_3_handle *ih, u_int8_t byte)
|
process_byte_pts(struct iso7816_3_handle *ih, uint8_t byte)
|
||||||
{
|
{
|
||||||
switch (ih->pts_state) {
|
switch (ih->pts_state) {
|
||||||
case PTS_S_WAIT_REQ_PTSS:
|
case PTS_S_WAIT_REQ_PTSS:
|
||||||
|
@ -510,7 +510,7 @@ process_byte_pts(struct iso7816_3_handle *ih, u_int8_t byte)
|
||||||
return ISO7816_S_IN_PTS;
|
return ISO7816_S_IN_PTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_byte(struct iso7816_3_handle *ih, u_int8_t byte)
|
static void process_byte(struct iso7816_3_handle *ih, uint8_t byte)
|
||||||
{
|
{
|
||||||
int new_state = -1;
|
int new_state = -1;
|
||||||
struct req_ctx *rctx;
|
struct req_ctx *rctx;
|
||||||
|
@ -589,7 +589,7 @@ void iso_uart_flush(void)
|
||||||
void iso_uart_idleflush(void)
|
void iso_uart_idleflush(void)
|
||||||
{
|
{
|
||||||
static struct req_ctx *last_req = NULL;
|
static struct req_ctx *last_req = NULL;
|
||||||
static u_int16_t last_len = 0;
|
static uint16_t last_len = 0;
|
||||||
|
|
||||||
if (last_req == isoh.rctx &&
|
if (last_req == isoh.rctx &&
|
||||||
last_len == isoh.rctx->tot_len &&
|
last_len == isoh.rctx->tot_len &&
|
||||||
|
@ -603,8 +603,8 @@ void iso_uart_idleflush(void)
|
||||||
|
|
||||||
static __ramfunc void usart_irq(void)
|
static __ramfunc void usart_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t csr = usart->US_CSR;
|
uint32_t csr = usart->US_CSR;
|
||||||
u_int8_t octet;
|
uint8_t octet;
|
||||||
|
|
||||||
//DEBUGP("USART IRQ, CSR=0x%08x\n", csr);
|
//DEBUGP("USART IRQ, CSR=0x%08x\n", csr);
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ static __ramfunc void usart_irq(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (csr & (AT91C_US_PARE|AT91C_US_FRAME|AT91C_US_OVRE)) {
|
if (csr & (AT91C_US_PARE|AT91C_US_FRAME|AT91C_US_OVRE)) {
|
||||||
u_int8_t nb_err = usart->US_NER;
|
uint8_t nb_err = usart->US_NER;
|
||||||
/* FIXME: some error has occurrerd */
|
/* FIXME: some error has occurrerd */
|
||||||
//DEBUGP("NER=%02x ", nb_err);
|
//DEBUGP("NER=%02x ", nb_err);
|
||||||
/* clear the status */
|
/* clear the status */
|
||||||
|
@ -641,7 +641,7 @@ static __ramfunc void usart_irq(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handler for the RST input pin state change */
|
/* handler for the RST input pin state change */
|
||||||
static void reset_pin_irq(u_int32_t pio)
|
static void reset_pin_irq(uint32_t pio)
|
||||||
{
|
{
|
||||||
if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, pio)) {
|
if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, pio)) {
|
||||||
/* make sure to flush pending req_ctx */
|
/* make sure to flush pending req_ctx */
|
||||||
|
@ -659,7 +659,7 @@ static void reset_pin_irq(u_int32_t pio)
|
||||||
|
|
||||||
void iso_uart_dump(void)
|
void iso_uart_dump(void)
|
||||||
{
|
{
|
||||||
u_int32_t csr = usart->US_CSR;
|
uint32_t csr = usart->US_CSR;
|
||||||
|
|
||||||
DEBUGPCR("USART CSR=0x%08x", csr);
|
DEBUGPCR("USART CSR=0x%08x", csr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ int _main_dbgu(char key)
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
{
|
{
|
||||||
u_int32_t version;
|
uint32_t version;
|
||||||
int rc = prod_info_get(&version, NULL);
|
int rc = prod_info_get(&version, NULL);
|
||||||
if (rc >= 0)
|
if (rc >= 0)
|
||||||
DEBUGPCR("Version: 0x%08x\n", version);
|
DEBUGPCR("Version: 0x%08x\n", version);
|
||||||
|
|
|
@ -38,17 +38,17 @@
|
||||||
struct simtrace_prod_info
|
struct simtrace_prod_info
|
||||||
{
|
{
|
||||||
/* magic value */
|
/* magic value */
|
||||||
u_int32_t magic;
|
uint32_t magic;
|
||||||
/* unix timestamp of production date (0=unknown) */
|
/* unix timestamp of production date (0=unknown) */
|
||||||
u_int32_t production_ts;
|
uint32_t production_ts;
|
||||||
/* hardware version */
|
/* hardware version */
|
||||||
u_int32_t version;
|
uint32_t version;
|
||||||
/* re-works applied */
|
/* re-works applied */
|
||||||
u_int32_t reworks;
|
uint32_t reworks;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
|
||||||
int prod_info_write(u_int32_t ts, u_int32_t version, u_int32_t reworks)
|
int prod_info_write(uint32_t ts, uint32_t version, uint32_t reworks)
|
||||||
{
|
{
|
||||||
struct simtrace_prod_info pi = {
|
struct simtrace_prod_info pi = {
|
||||||
.magic = PRODINFO_MAGIC,
|
.magic = PRODINFO_MAGIC,
|
||||||
|
@ -56,8 +56,8 @@ int prod_info_write(u_int32_t ts, u_int32_t version, u_int32_t reworks)
|
||||||
.version = version,
|
.version = version,
|
||||||
.reworks = reworks,
|
.reworks = reworks,
|
||||||
};
|
};
|
||||||
u_int8_t *pi8 = (u_int8_t *) π
|
uint8_t *pi8 = (uint8_t *) π
|
||||||
u_int32_t addr = OTP_ADDR(OTP_REGION_PRODINFO);
|
uint32_t addr = OTP_ADDR(OTP_REGION_PRODINFO);
|
||||||
unsigned int rc;
|
unsigned int rc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ int prod_info_write(u_int32_t ts, u_int32_t version, u_int32_t reworks)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prod_info_get(u_int32_t *ver, u_int32_t *reworks)
|
int prod_info_get(uint32_t *ver, uint32_t *reworks)
|
||||||
{
|
{
|
||||||
struct simtrace_prod_info pi;
|
struct simtrace_prod_info pi;
|
||||||
u_int32_t addr = OTP_ADDR(OTP_REGION_PRODINFO);
|
uint32_t addr = OTP_ADDR(OTP_REGION_PRODINFO);
|
||||||
|
|
||||||
spiflash_otp_read(addr, (u_int8_t *) &pi, sizeof(pi));
|
spiflash_otp_read(addr, (uint8_t *) &pi, sizeof(pi));
|
||||||
|
|
||||||
if (pi.magic != PRODINFO_MAGIC)
|
if (pi.magic != PRODINFO_MAGIC)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
((c & 0xff) << 0))
|
((c & 0xff) << 0))
|
||||||
|
|
||||||
|
|
||||||
int prod_info_write(u_int32_t ts, u_int32_t version, u_int32_t reworks);
|
int prod_info_write(uint32_t ts, uint32_t version, uint32_t reworks);
|
||||||
int prod_info_get(u_int32_t *ver, u_int32_t *reworks);
|
int prod_info_get(uint32_t *ver, uint32_t *reworks);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,7 +48,7 @@ void sim_switch_mode(int connect_io, int connect_misc)
|
||||||
AT91F_PIO_SetOutput(AT91C_BASE_PIOA, SIMTRACE_PIO_SC_SW);
|
AT91F_PIO_SetOutput(AT91C_BASE_PIOA, SIMTRACE_PIO_SC_SW);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sw_sim_irq(u_int32_t pio)
|
static void sw_sim_irq(uint32_t pio)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, SIMTRACE_PIO_SW_SIM))
|
if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, SIMTRACE_PIO_SW_SIM))
|
||||||
|
@ -57,7 +57,7 @@ static void sw_sim_irq(u_int32_t pio)
|
||||||
DEBUGPCR("SIM card removed");
|
DEBUGPCR("SIM card removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vcc_phone_irq(u_int32_t pio)
|
static void vcc_phone_irq(uint32_t pio)
|
||||||
{
|
{
|
||||||
if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, SIMTRACE_PIO_VCC_PHONE)) {
|
if (!AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, SIMTRACE_PIO_VCC_PHONE)) {
|
||||||
DEBUGPCR("VCC_PHONE off");
|
DEBUGPCR("VCC_PHONE off");
|
||||||
|
|
|
@ -88,15 +88,15 @@ void spiflash_write_protect(int on)
|
||||||
|
|
||||||
static __ramfunc void spi_irq(void)
|
static __ramfunc void spi_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t status = pSPI->SPI_SR;
|
uint32_t status = pSPI->SPI_SR;
|
||||||
|
|
||||||
AT91F_AIC_ClearIt(AT91C_BASE_AIC, AT91C_ID_SPI);
|
AT91F_AIC_ClearIt(AT91C_BASE_AIC, AT91C_ID_SPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u_int8_t chipid_s25fl032p[3] = { 0x01, 0x02, 0x15 };
|
static const uint8_t chipid_s25fl032p[3] = { 0x01, 0x02, 0x15 };
|
||||||
|
|
||||||
static u_int8_t chip_id[3];
|
static uint8_t chip_id[3];
|
||||||
static u_int32_t otp_supported;
|
static uint32_t otp_supported;
|
||||||
|
|
||||||
void spiflash_init(void)
|
void spiflash_init(void)
|
||||||
{
|
{
|
||||||
|
@ -141,13 +141,13 @@ void spiflash_init(void)
|
||||||
otp_supported = 1;
|
otp_supported = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
static int spi_transceive(const uint8_t *tx_data, uint16_t tx_len,
|
||||||
u_int8_t *rx_data, u_int16_t *rx_len, u_int16_t rx_skip)
|
uint8_t *rx_data, uint16_t *rx_len, uint16_t rx_skip)
|
||||||
{
|
{
|
||||||
u_int16_t tx_cur = 0;
|
uint16_t tx_cur = 0;
|
||||||
u_int16_t rx_len_max = 0;
|
uint16_t rx_len_max = 0;
|
||||||
u_int16_t rx_cnt = 0;
|
uint16_t rx_cnt = 0;
|
||||||
u_int8_t tmp;
|
uint8_t tmp;
|
||||||
|
|
||||||
DEBUGPSPI("spi_transceive: enter(tx_len=%u) ", tx_len);
|
DEBUGPSPI("spi_transceive: enter(tx_len=%u) ", tx_len);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
||||||
|
|
||||||
//AT91F_SPI_Enable(pSPI);
|
//AT91F_SPI_Enable(pSPI);
|
||||||
while (1) {
|
while (1) {
|
||||||
u_int32_t sr = pSPI->SPI_SR;
|
uint32_t sr = pSPI->SPI_SR;
|
||||||
if (sr & AT91C_SPI_RDRF) {
|
if (sr & AT91C_SPI_RDRF) {
|
||||||
tmp = pSPI->SPI_RDR;
|
tmp = pSPI->SPI_RDR;
|
||||||
rx_cnt++;
|
rx_cnt++;
|
||||||
|
@ -199,11 +199,11 @@ static int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiflash_get_id(u_int8_t *id)
|
void spiflash_get_id(uint8_t *id)
|
||||||
{
|
{
|
||||||
const u_int8_t tx_data[] = { SPIF_CMD_RDID, 0, 0, 0 };
|
const uint8_t tx_data[] = { SPIF_CMD_RDID, 0, 0, 0 };
|
||||||
u_int8_t rx_data[] = { 0,0,0,0 };
|
uint8_t rx_data[] = { 0,0,0,0 };
|
||||||
u_int16_t rx_len = sizeof(rx_data);
|
uint16_t rx_len = sizeof(rx_data);
|
||||||
|
|
||||||
spi_transceive(tx_data, sizeof(tx_data), rx_data, &rx_len, 1);
|
spi_transceive(tx_data, sizeof(tx_data), rx_data, &rx_len, 1);
|
||||||
DEBUGPSPI("SPI ID: %02x %02x %02x\r\n",
|
DEBUGPSPI("SPI ID: %02x %02x %02x\r\n",
|
||||||
|
@ -213,9 +213,9 @@ void spiflash_get_id(u_int8_t *id)
|
||||||
|
|
||||||
int spiflash_read_status(void)
|
int spiflash_read_status(void)
|
||||||
{
|
{
|
||||||
const u_int8_t tx_data[] = { SPIF_CMD_RDSR, 0 };
|
const uint8_t tx_data[] = { SPIF_CMD_RDSR, 0 };
|
||||||
u_int8_t rx_data[1];
|
uint8_t rx_data[1];
|
||||||
u_int16_t rx_len = sizeof(rx_data);
|
uint16_t rx_len = sizeof(rx_data);
|
||||||
|
|
||||||
spi_transceive(tx_data, sizeof(tx_data), rx_data, &rx_len, 1);
|
spi_transceive(tx_data, sizeof(tx_data), rx_data, &rx_len, 1);
|
||||||
|
|
||||||
|
@ -226,14 +226,14 @@ int spiflash_read_status(void)
|
||||||
|
|
||||||
void spiflash_clear_status(void)
|
void spiflash_clear_status(void)
|
||||||
{
|
{
|
||||||
const u_int8_t tx_data[] = { SPIF_CMD_CLSR };
|
const uint8_t tx_data[] = { SPIF_CMD_CLSR };
|
||||||
|
|
||||||
spi_transceive(tx_data, sizeof(tx_data), NULL, 0, 0);
|
spi_transceive(tx_data, sizeof(tx_data), NULL, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int spiflash_write_enable(int enable)
|
int spiflash_write_enable(int enable)
|
||||||
{
|
{
|
||||||
u_int8_t tx_data[1];
|
uint8_t tx_data[1];
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
tx_data[0] = SPIF_CMD_WREN;
|
tx_data[0] = SPIF_CMD_WREN;
|
||||||
|
@ -245,9 +245,9 @@ int spiflash_write_enable(int enable)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spiflash_otp_read(u_int32_t otp_addr, u_int8_t *out, u_int16_t rx_len)
|
int spiflash_otp_read(uint32_t otp_addr, uint8_t *out, uint16_t rx_len)
|
||||||
{
|
{
|
||||||
u_int8_t tx_data[] = { SPIF_CMD_OTPR, 0, 0, 0, 0 };
|
uint8_t tx_data[] = { SPIF_CMD_OTPR, 0, 0, 0, 0 };
|
||||||
|
|
||||||
if (!otp_supported) {
|
if (!otp_supported) {
|
||||||
DEBUGP("OTP not supported!\r\n");
|
DEBUGP("OTP not supported!\r\n");
|
||||||
|
@ -269,9 +269,9 @@ int spiflash_otp_read(u_int32_t otp_addr, u_int8_t *out, u_int16_t rx_len)
|
||||||
return rx_len;
|
return rx_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spiflash_otp_write(u_int32_t otp_addr, u_int8_t data)
|
int spiflash_otp_write(uint32_t otp_addr, uint8_t data)
|
||||||
{
|
{
|
||||||
u_int8_t tx_data[] = { SPIF_CMD_OTPP, 0, 0, 0, 0 };
|
uint8_t tx_data[] = { SPIF_CMD_OTPP, 0, 0, 0, 0 };
|
||||||
|
|
||||||
if (!otp_supported) {
|
if (!otp_supported) {
|
||||||
DEBUGP("OTP not supported!\r\n");
|
DEBUGP("OTP not supported!\r\n");
|
||||||
|
@ -293,7 +293,7 @@ int spiflash_otp_write(u_int32_t otp_addr, u_int8_t data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int otp_region2addr(u_int8_t region)
|
static int otp_region2addr(uint8_t region)
|
||||||
{
|
{
|
||||||
/* see Figure 10.1 of S25FL032P data sheet */
|
/* see Figure 10.1 of S25FL032P data sheet */
|
||||||
if (region > 31 || region < 1)
|
if (region > 31 || region < 1)
|
||||||
|
@ -308,7 +308,7 @@ static int otp_region2addr(u_int8_t region)
|
||||||
return 0x112;
|
return 0x112;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int otp_region2bit(u_int8_t region)
|
static int otp_region2bit(uint8_t region)
|
||||||
{
|
{
|
||||||
/* see Figure 10.1 of S25FL032P data sheet */
|
/* see Figure 10.1 of S25FL032P data sheet */
|
||||||
if (region > 31 || region < 1)
|
if (region > 31 || region < 1)
|
||||||
|
@ -323,10 +323,10 @@ static int otp_region2bit(u_int8_t region)
|
||||||
return region - 1;
|
return region - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spiflash_otp_get_lock(u_int8_t region)
|
int spiflash_otp_get_lock(uint8_t region)
|
||||||
{
|
{
|
||||||
u_int32_t addr;
|
uint32_t addr;
|
||||||
u_int8_t bit, data;
|
uint8_t bit, data;
|
||||||
|
|
||||||
if (region > 31 || region < 1)
|
if (region > 31 || region < 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -342,10 +342,10 @@ int spiflash_otp_get_lock(u_int8_t region)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spiflash_otp_set_lock(u_int8_t region)
|
int spiflash_otp_set_lock(uint8_t region)
|
||||||
{
|
{
|
||||||
u_int32_t addr;
|
uint32_t addr;
|
||||||
u_int8_t bit;
|
uint8_t bit;
|
||||||
|
|
||||||
if (region > 31 || region < 1)
|
if (region > 31 || region < 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
#define OTP_ADDR(x) (0x114 + ( ((x) - 1) * 16 ) )
|
#define OTP_ADDR(x) (0x114 + ( ((x) - 1) * 16 ) )
|
||||||
|
|
||||||
void spiflash_init(void);
|
void spiflash_init(void);
|
||||||
void spiflash_get_id(u_int8_t *id);
|
void spiflash_get_id(uint8_t *id);
|
||||||
int spiflash_read_status(void);
|
int spiflash_read_status(void);
|
||||||
void spiflash_clear_status(void);
|
void spiflash_clear_status(void);
|
||||||
void spiflash_write_protect(int on);
|
void spiflash_write_protect(int on);
|
||||||
int spiflash_write_enable(int enable);
|
int spiflash_write_enable(int enable);
|
||||||
int spiflash_otp_read(u_int32_t otp_addr, u_int8_t *out, u_int16_t rx_len);
|
int spiflash_otp_read(uint32_t otp_addr, uint8_t *out, uint16_t rx_len);
|
||||||
int spiflash_otp_write(u_int32_t otp_addr, u_int8_t data);
|
int spiflash_otp_write(uint32_t otp_addr, uint8_t data);
|
||||||
int spiflash_otp_get_lock(u_int8_t region);
|
int spiflash_otp_get_lock(uint8_t region);
|
||||||
int spiflash_otp_set_lock(u_int8_t region);
|
int spiflash_otp_set_lock(uint8_t region);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,14 +26,14 @@
|
||||||
static AT91PS_TCB tcb;
|
static AT91PS_TCB tcb;
|
||||||
static AT91PS_TC tcetu = AT91C_BASE_TC0;
|
static AT91PS_TC tcetu = AT91C_BASE_TC0;
|
||||||
|
|
||||||
static u_int16_t waiting_time = 9600;
|
static uint16_t waiting_time = 9600;
|
||||||
static u_int16_t clocks_per_etu = 372;
|
static uint16_t clocks_per_etu = 372;
|
||||||
static u_int16_t wait_events;
|
static uint16_t wait_events;
|
||||||
|
|
||||||
static __ramfunc void tc_etu_irq(void)
|
static __ramfunc void tc_etu_irq(void)
|
||||||
{
|
{
|
||||||
u_int32_t sr = tcetu->TC_SR;
|
uint32_t sr = tcetu->TC_SR;
|
||||||
static u_int16_t nr_events;
|
static uint16_t nr_events;
|
||||||
|
|
||||||
if (sr & AT91C_TC_ETRGS) {
|
if (sr & AT91C_TC_ETRGS) {
|
||||||
/* external trigger, i.e. we have seen a bit on I/O */
|
/* external trigger, i.e. we have seen a bit on I/O */
|
||||||
|
@ -73,14 +73,14 @@ static void recalc_nr_events(void)
|
||||||
tcetu->TC_RC = clocks_per_etu * 12;
|
tcetu->TC_RC = clocks_per_etu * 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tc_etu_set_wtime(u_int16_t wtime)
|
void tc_etu_set_wtime(uint16_t wtime)
|
||||||
{
|
{
|
||||||
waiting_time = wtime;
|
waiting_time = wtime;
|
||||||
recalc_nr_events();
|
recalc_nr_events();
|
||||||
//DEBUGPCR("wtime=%u, actually waiting %u", wtime, wait_events * 12);
|
//DEBUGPCR("wtime=%u, actually waiting %u", wtime, wait_events * 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tc_etu_set_etu(u_int16_t etu)
|
void tc_etu_set_etu(uint16_t etu)
|
||||||
{
|
{
|
||||||
clocks_per_etu = etu;
|
clocks_per_etu = etu;
|
||||||
recalc_nr_events();
|
recalc_nr_events();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
void tc_etu_set_wtime(u_int16_t wtime);
|
void tc_etu_set_wtime(uint16_t wtime);
|
||||||
void tc_etu_set_etu(u_int16_t etu);
|
void tc_etu_set_etu(uint16_t etu);
|
||||||
void tc_etu_init(void);
|
void tc_etu_init(void);
|
||||||
|
|
Loading…
Reference in New Issue