mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
cleanup a LOT of trailing whitespaces
This commit is contained in:
+6
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Paparazzi $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ void _3dmg_capture_neutral ( void ) {
|
||||
state++; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define READ_LSB(my_short, my_char) { \
|
||||
{ \
|
||||
my_short += (((int16_t)my_char)&0x00FF); \
|
||||
@@ -119,7 +119,7 @@ static inline void on_3dmg_receive(uint8_t c) {
|
||||
case 12:
|
||||
READ_LSB(foo, c);
|
||||
/* accel_z_lsb */
|
||||
break ;
|
||||
break ;
|
||||
case 13:
|
||||
READ_MSB(_3dmg_roll_dot, c);
|
||||
break ;
|
||||
@@ -137,7 +137,7 @@ static inline void on_3dmg_receive(uint8_t c) {
|
||||
break ;
|
||||
case 18:
|
||||
READ_LSB(_3dmg_yaw_dot, c);
|
||||
break ;
|
||||
break ;
|
||||
case 19:
|
||||
READ_MSB(_3dmg_timer_tick, c);
|
||||
break ;
|
||||
@@ -145,7 +145,7 @@ static inline void on_3dmg_receive(uint8_t c) {
|
||||
READ_LSB(_3dmg_timer_tick, c);
|
||||
break ;
|
||||
case 21:
|
||||
checksum_read = (((uint16_t)c)&0x00FF)<<8;
|
||||
checksum_read = (((uint16_t)c)&0x00FF)<<8;
|
||||
state++;
|
||||
break ;
|
||||
case 22:
|
||||
|
||||
+68
-68
@@ -2,9 +2,9 @@
|
||||
|
||||
/************** Flower Navigation **********************************************/
|
||||
|
||||
/** Makes a flower pattern.
|
||||
/** Makes a flower pattern.
|
||||
CenterWP is the center of the flower. The Navigation Height is taken from this waypoint.
|
||||
EdgeWP defines the radius of the flower (distance from CenterWP to EdgeWP)
|
||||
EdgeWP defines the radius of the flower (distance from CenterWP to EdgeWP)
|
||||
*/
|
||||
|
||||
enum FlowerStatus { Outside, FlowerLine, Circle };
|
||||
@@ -39,7 +39,7 @@ bool_t InitializeFlower(uint8_t CenterWP, uint8_t EdgeWP)
|
||||
|
||||
EdgeCurrentX = waypoints[Edge].x - waypoints[Center].x;
|
||||
EdgeCurrentY = waypoints[Edge].y - waypoints[Center].y;
|
||||
|
||||
|
||||
Flowerradius = sqrt(EdgeCurrentX*EdgeCurrentX+EdgeCurrentY*EdgeCurrentY);
|
||||
|
||||
TransCurrentX = estimator_x - waypoints[Center].x;
|
||||
@@ -67,7 +67,7 @@ bool_t FlowerNav(void)
|
||||
TransCurrentX = estimator_x - waypoints[Center].x;
|
||||
TransCurrentY = estimator_y - waypoints[Center].y;
|
||||
DistanceFromCenter = sqrt(TransCurrentX*TransCurrentX+TransCurrentY*TransCurrentY);
|
||||
|
||||
|
||||
bool_t InCircle = TRUE;
|
||||
float CircleTheta;
|
||||
|
||||
@@ -79,7 +79,7 @@ bool_t FlowerNav(void)
|
||||
|
||||
switch(CFlowerStatus)
|
||||
{
|
||||
case Outside:
|
||||
case Outside:
|
||||
nav_route_xy(FlyFromX,FlyFromY,Fly2X,Fly2Y);
|
||||
if(InCircle)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ bool_t FlowerNav(void)
|
||||
if(InCircle)
|
||||
{
|
||||
EdgeCurrentX = waypoints[Edge].x - waypoints[Center].x;
|
||||
EdgeCurrentY = waypoints[Edge].y - waypoints[Center].y;
|
||||
EdgeCurrentY = waypoints[Edge].y - waypoints[Center].y;
|
||||
Flowerradius = sqrt(EdgeCurrentX*EdgeCurrentX+EdgeCurrentY*EdgeCurrentY);
|
||||
if(DistanceFromCenter > Flowerradius)
|
||||
CFlowerStatus = Outside;
|
||||
@@ -125,14 +125,14 @@ bool_t FlowerNav(void)
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/************** Bungee Takeoff **********************************************/
|
||||
|
||||
/** Takeoff functions for bungee takeoff.
|
||||
Run initialize function when the plane is on the bungee, the bungee is fully extended and you are ready to
|
||||
launch the plane. After initialized, the plane will follow a line drawn by the position of the plane on initialization and the
|
||||
position of the bungee (given in the arguments). Once the plane crosses the throttle line, which is perpendicular to the line the plane is following,
|
||||
/** Takeoff functions for bungee takeoff.
|
||||
Run initialize function when the plane is on the bungee, the bungee is fully extended and you are ready to
|
||||
launch the plane. After initialized, the plane will follow a line drawn by the position of the plane on initialization and the
|
||||
position of the bungee (given in the arguments). Once the plane crosses the throttle line, which is perpendicular to the line the plane is following,
|
||||
and intersects the position of the bungee (plus or minus a fixed distance (TakeOff_Distance in airframe file) from the bungee just in case the bungee doesn't release directly above the bungee) the prop will come on. The plane will then continue to follow the line until it has reached a specific
|
||||
height (defined in as Takeoff_Height in airframe file) above the bungee waypoint and speed (defined as Takeoff_Speed in the airframe file).
|
||||
|
||||
@@ -190,7 +190,7 @@ bool_t InitializeBungeeTakeoff(uint8_t BungeeWP)
|
||||
|
||||
//Find Launch line slope and Throttle line slope
|
||||
float MLaunch = Currenty/Currentx;
|
||||
|
||||
|
||||
//Find Throttle Point (the point where the throttle line and launch line intersect)
|
||||
if(Currentx < 0)
|
||||
throttlePx = TDistance/sqrt(MLaunch*MLaunch+1);
|
||||
@@ -210,7 +210,7 @@ bool_t InitializeBungeeTakeoff(uint8_t BungeeWP)
|
||||
if(Currenty > ((ThrottleSlope*Currentx)+ThrottleB))
|
||||
AboveLine = TRUE;
|
||||
else
|
||||
AboveLine = FALSE;
|
||||
AboveLine = FALSE;
|
||||
|
||||
//Enable Launch Status and turn kill throttle on
|
||||
CTakeoffStatus = Launch;
|
||||
@@ -234,11 +234,11 @@ bool_t BungeeTakeoff(void)
|
||||
switch(CTakeoffStatus)
|
||||
{
|
||||
case Launch:
|
||||
//Follow Launch Line
|
||||
//Follow Launch Line
|
||||
NavVerticalAutoThrottleMode(0);
|
||||
NavVerticalAltitudeMode(BungeeAlt+Takeoff_Height, 0.);
|
||||
nav_route_xy(initialx,initialy,throttlePx,throttlePy);
|
||||
|
||||
|
||||
kill_throttle = 1;
|
||||
|
||||
//recalculate lines if below min speed
|
||||
@@ -253,7 +253,7 @@ bool_t BungeeTakeoff(void)
|
||||
|
||||
//Find Launch line slope
|
||||
float MLaunch = Currenty/Currentx;
|
||||
|
||||
|
||||
//Find Throttle Point (the point where the throttle line and launch line intersect)
|
||||
if(Currentx < 0)
|
||||
throttlePx = TDistance/sqrt(MLaunch*MLaunch+1);
|
||||
@@ -273,7 +273,7 @@ bool_t BungeeTakeoff(void)
|
||||
if(Currenty > ((ThrottleSlope*Currentx)+ThrottleB))
|
||||
AboveLine = TRUE;
|
||||
else
|
||||
AboveLine = FALSE;
|
||||
AboveLine = FALSE;
|
||||
|
||||
//Translate the throttle point back
|
||||
throttlePx = throttlePx+(waypoints[BungeeWaypoint].x);
|
||||
@@ -300,12 +300,12 @@ bool_t BungeeTakeoff(void)
|
||||
NavVerticalThrottleMode(9600*(1));
|
||||
nav_route_xy(initialx,initialy,throttlePx,throttlePy);
|
||||
kill_throttle = 0;
|
||||
|
||||
|
||||
if((estimator_z > BungeeAlt+Takeoff_Height-10) && (estimator_hspeed_mod > Takeoff_Speed))
|
||||
{
|
||||
CTakeoffStatus = Finished;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
@@ -354,7 +354,7 @@ bool_t InitializePolygonSurvey(uint8_t EntryWP, uint8_t Size, float sw, float Or
|
||||
float XIntercept1 = 0;
|
||||
float XIntercept2 = 0;
|
||||
|
||||
SurveyTheta = RadOfDeg(Orientation);
|
||||
SurveyTheta = RadOfDeg(Orientation);
|
||||
PolySurveySweepNum = 0;
|
||||
PolySurveySweepBackNum = 0;
|
||||
|
||||
@@ -495,7 +495,7 @@ bool_t InitializePolygonSurvey(uint8_t EntryWP, uint8_t Size, float sw, float Or
|
||||
XIntercept1 = EvaluateLineForX(ys, Edges[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Find point to come from and point to go to
|
||||
if(fabs(EntryPoint.x - XIntercept2) <= fabs(EntryPoint.x - XIntercept1))
|
||||
{
|
||||
@@ -527,7 +527,7 @@ bool_t InitializePolygonSurvey(uint8_t EntryWP, uint8_t Size, float sw, float Or
|
||||
SurveyCircle.y = EntryPoint.y;
|
||||
|
||||
//Go into entry circle state
|
||||
CSurveyStatus = Entry;
|
||||
CSurveyStatus = Entry;
|
||||
LINE_STOP_FUNCTION;
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ bool_t PolygonSurvey(void)
|
||||
float XIntercept2 = 0;
|
||||
float DInt1 = 0;
|
||||
float DInt2 = 0;
|
||||
|
||||
|
||||
NavVerticalAutoThrottleMode(0); /* No pitch */
|
||||
NavVerticalAltitudeMode(waypoints[SurveyEntryWP].a, 0.);
|
||||
|
||||
@@ -560,7 +560,7 @@ bool_t PolygonSurvey(void)
|
||||
RotateAndTranslateToWorld(&C, 0, SmallestCorner.x, SmallestCorner.y);
|
||||
RotateAndTranslateToWorld(&C, SurveyTheta, 0, 0);
|
||||
|
||||
//follow the circle
|
||||
//follow the circle
|
||||
nav_circle_XY(C.x, C.y, SurveyRadius);
|
||||
|
||||
if(NavQdrCloseTo(SurveyCircleQdr) && NavCircleCount() > .1 && estimator_z > waypoints[SurveyEntryWP].a-10)
|
||||
@@ -603,7 +603,7 @@ bool_t PolygonSurvey(void)
|
||||
PolySurveySweepBackNum++;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
//Find y value of the first sweep
|
||||
ys = LastPoint.y+dSweep;
|
||||
}
|
||||
@@ -669,18 +669,18 @@ bool_t PolygonSurvey(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(fabs(LastPoint.x-SurveyToWP.x) > fabs(SurveyFromWP.x-SurveyToWP.x))
|
||||
SurveyCircle.x = LastPoint.x;
|
||||
else
|
||||
SurveyCircle.x = SurveyFromWP.x;
|
||||
|
||||
|
||||
|
||||
if(!SweepingBack)
|
||||
SurveyCircle.y = LastPoint.y+(dSweep/2);
|
||||
else
|
||||
SurveyCircle.y = LastPoint.y;
|
||||
SurveyCircle.y = LastPoint.y;
|
||||
|
||||
//Find the direction to circle
|
||||
if(ys > 0 && SurveyToWP.x > SurveyFromWP.x)
|
||||
@@ -691,7 +691,7 @@ bool_t PolygonSurvey(void)
|
||||
SurveyRadius = -dSweep/2;
|
||||
|
||||
//Go into circle state
|
||||
CSurveyStatus = SweepCircle;
|
||||
CSurveyStatus = SweepCircle;
|
||||
nav_init_stage();
|
||||
LINE_STOP_FUNCTION;
|
||||
PolySurveySweepNum++;
|
||||
@@ -705,7 +705,7 @@ bool_t PolygonSurvey(void)
|
||||
RotateAndTranslateToWorld(&C, 0, SmallestCorner.x, SmallestCorner.y);
|
||||
RotateAndTranslateToWorld(&C, SurveyTheta, 0, 0);
|
||||
|
||||
//follow the circle
|
||||
//follow the circle
|
||||
nav_circle_XY(C.x, C.y, SurveyRadius);
|
||||
|
||||
if(NavQdrCloseTo(SurveyCircleQdr) && NavCircleCount() > 0)
|
||||
@@ -759,7 +759,7 @@ bool_t VerticalRaster(uint8_t l1, uint8_t l2, float radius, float AltSweep) {
|
||||
struct point l2_c3 = { waypoints[l1].x + radius * -u_y,
|
||||
waypoints[l1].y + radius * u_x,
|
||||
alt };
|
||||
|
||||
|
||||
struct point l1_c1 = { waypoints[l2].x + radius * -u_y,
|
||||
waypoints[l2].y + radius * u_x,
|
||||
alt };
|
||||
@@ -770,18 +770,18 @@ bool_t VerticalRaster(uint8_t l1, uint8_t l2, float radius, float AltSweep) {
|
||||
waypoints[l2].y + radius * -u_x,
|
||||
alt };
|
||||
float qdr_out_2_1 = M_PI/3. - atan2(u_y, u_x);
|
||||
|
||||
|
||||
float qdr_out_2_2 = -M_PI/3. - atan2(u_y, u_x);
|
||||
float qdr_out_2_3 = M_PI - atan2(u_y, u_x);
|
||||
|
||||
/* Vertical target */
|
||||
NavVerticalAutoThrottleMode(0); /* No pitch */
|
||||
NavVerticalAltitudeMode(WaypointAlt(l1), 0.);
|
||||
|
||||
|
||||
switch (line_status) {
|
||||
case LR12: /* From wp l2 to wp l1 */
|
||||
NavSegment(l2, l1);
|
||||
if (NavApproachingFrom(l1, l2, CARROT)) {
|
||||
if (NavApproachingFrom(l1, l2, CARROT)) {
|
||||
line_status = LQC21;
|
||||
waypoints[l1].a = waypoints[l1].a+AltSweep;
|
||||
nav_init_stage();
|
||||
@@ -810,7 +810,7 @@ bool_t VerticalRaster(uint8_t l1, uint8_t l2, float radius, float AltSweep) {
|
||||
break;
|
||||
case LR21: /* From wp l1 to wp l2 */
|
||||
NavSegment(l1, l2);
|
||||
if (NavApproachingFrom(l2, l1, CARROT)) {
|
||||
if (NavApproachingFrom(l2, l1, CARROT)) {
|
||||
line_status = LQC12;
|
||||
waypoints[l1].a = waypoints[l1].a+AltSweep;
|
||||
nav_init_stage();
|
||||
@@ -885,9 +885,9 @@ bool_t InitializeSkidLanding(uint8_t AFWP, uint8_t TDWP, float radius)
|
||||
FinalLandAltitude = Landing_FinalHeight;
|
||||
FinalLandCount = 1;
|
||||
waypoints[AFWaypoint].a = waypoints[TDWaypoint].a + Landing_AFHeight;
|
||||
|
||||
|
||||
float x_0 = waypoints[TDWaypoint].x - waypoints[AFWaypoint].x;
|
||||
float y_0 = waypoints[TDWaypoint].y - waypoints[AFWaypoint].y;
|
||||
float y_0 = waypoints[TDWaypoint].y - waypoints[AFWaypoint].y;
|
||||
|
||||
/* Unit vector from AF to TD */
|
||||
float d = sqrt(x_0*x_0+y_0*y_0);
|
||||
@@ -895,8 +895,8 @@ bool_t InitializeSkidLanding(uint8_t AFWP, uint8_t TDWP, float radius)
|
||||
float y_1 = y_0 / d;
|
||||
|
||||
LandCircle.x = waypoints[AFWaypoint].x + y_1 * LandRadius;
|
||||
LandCircle.y = waypoints[AFWaypoint].y - x_1 * LandRadius;
|
||||
|
||||
LandCircle.y = waypoints[AFWaypoint].y - x_1 * LandRadius;
|
||||
|
||||
LandCircleQDR = atan2(waypoints[AFWaypoint].x-LandCircle.x, waypoints[AFWaypoint].y-LandCircle.y);
|
||||
|
||||
if(LandRadius > 0)
|
||||
@@ -909,8 +909,8 @@ bool_t InitializeSkidLanding(uint8_t AFWP, uint8_t TDWP, float radius)
|
||||
ApproachQDR = LandCircleQDR+RadOfDeg(90);
|
||||
LandCircleQDR = LandCircleQDR+RadOfDeg(45);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -920,49 +920,49 @@ bool_t SkidLanding(void)
|
||||
{
|
||||
case CircleDown:
|
||||
NavVerticalAutoThrottleMode(0); /* No pitch */
|
||||
|
||||
|
||||
if(NavCircleCount() < .1)
|
||||
{
|
||||
NavVerticalAltitudeMode(LandAppAlt, 0);
|
||||
}
|
||||
else
|
||||
NavVerticalAltitudeMode(waypoints[AFWaypoint].a, 0);
|
||||
|
||||
nav_circle_XY(LandCircle.x, LandCircle.y, LandRadius);
|
||||
|
||||
|
||||
nav_circle_XY(LandCircle.x, LandCircle.y, LandRadius);
|
||||
|
||||
if(estimator_z < waypoints[AFWaypoint].a + 5)
|
||||
{
|
||||
CLandingStatus = LandingWait;
|
||||
nav_init_stage();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case LandingWait:
|
||||
NavVerticalAutoThrottleMode(0); /* No pitch */
|
||||
NavVerticalAltitudeMode(waypoints[AFWaypoint].a, 0);
|
||||
nav_circle_XY(LandCircle.x, LandCircle.y, LandRadius);
|
||||
|
||||
|
||||
if(NavCircleCount() > 0.5 && NavQdrCloseTo(DegOfRad(ApproachQDR)))
|
||||
{
|
||||
CLandingStatus = Approach;
|
||||
nav_init_stage();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Approach:
|
||||
kill_throttle = 1;
|
||||
NavVerticalAutoThrottleMode(0); /* No pitch */
|
||||
NavVerticalAltitudeMode(waypoints[AFWaypoint].a, 0);
|
||||
nav_circle_XY(LandCircle.x, LandCircle.y, LandRadius);
|
||||
|
||||
|
||||
if(NavQdrCloseTo(DegOfRad(LandCircleQDR)))
|
||||
{
|
||||
CLandingStatus = Final;
|
||||
nav_init_stage();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Final:
|
||||
kill_throttle = 1;
|
||||
NavVerticalAutoThrottleMode(0);
|
||||
@@ -974,9 +974,9 @@ bool_t SkidLanding(void)
|
||||
FinalLandCount++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -1049,46 +1049,46 @@ bool_t FlightLine(uint8_t From_WP, uint8_t To_WP, float radius, float Space_Befo
|
||||
CFLStatus = FLCircleS;
|
||||
nav_init_stage();
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case FLCircleS:
|
||||
|
||||
NavVerticalAutoThrottleMode(0); /* No pitch */
|
||||
NavVerticalAltitudeMode(waypoints[From_WP].a, 0);
|
||||
|
||||
|
||||
nav_circle_XY(FLCircle.x, FLCircle.y, FLRadius);
|
||||
|
||||
|
||||
if(NavCircleCount() > 0.2 && NavQdrCloseTo(DegOfRad(FLQDR)))
|
||||
{
|
||||
CFLStatus = FLLine;
|
||||
LINE_START_FUNCTION;
|
||||
nav_init_stage();
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case FLLine:
|
||||
|
||||
NavVerticalAutoThrottleMode(0); /* No pitch */
|
||||
NavVerticalAltitudeMode(waypoints[From_WP].a, 0);
|
||||
|
||||
|
||||
nav_route_xy(FLFROMWP.x,FLFROMWP.y,FLTOWP.x,FLTOWP.y);
|
||||
|
||||
|
||||
|
||||
if(nav_approaching_xy(FLTOWP.x,FLTOWP.y,FLFROMWP.x,FLFROMWP.y, 0))
|
||||
{
|
||||
CFLStatus = FLFinished;
|
||||
LINE_STOP_FUNCTION;
|
||||
nav_init_stage();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLFinished:
|
||||
CFLStatus = FLInitialize;
|
||||
nav_init_stage();
|
||||
return FALSE;
|
||||
break;
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -1100,7 +1100,7 @@ static uint8_t FLBlockCount = 0;
|
||||
bool_t FlightLineBlock(uint8_t First_WP, uint8_t Last_WP, float radius, float Space_Before, float Space_After)
|
||||
{
|
||||
if(First_WP < Last_WP)
|
||||
{
|
||||
{
|
||||
FlightLine(First_WP+FLBlockCount, First_WP+FLBlockCount+1, radius, Space_Before, Space_After);
|
||||
|
||||
if(CFLStatus == FLInitialize)
|
||||
@@ -1113,9 +1113,9 @@ bool_t FlightLineBlock(uint8_t First_WP, uint8_t Last_WP, float radius, float Sp
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
FlightLine(First_WP-FLBlockCount, First_WP-FLBlockCount-1, radius, Space_Before, Space_After);
|
||||
FlightLine(First_WP-FLBlockCount, First_WP-FLBlockCount-1, radius, Space_Before, Space_After);
|
||||
|
||||
if(CFLStatus == FLInitialize)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+19
-19
@@ -8,9 +8,9 @@
|
||||
|
||||
X = [ z zdot bias ]
|
||||
|
||||
temps :
|
||||
temps :
|
||||
predict 86us
|
||||
update 46us
|
||||
update 46us
|
||||
|
||||
*/
|
||||
/* initial covariance diagonal */
|
||||
@@ -37,7 +37,7 @@ void agl_vf_init(float init_z, float init_zdot, float init_bias) {
|
||||
agl_vf_bias = init_bias;
|
||||
int i, j;
|
||||
for (i=0; i<STATE_SIZE; i++) {
|
||||
for (j=0; j<STATE_SIZE; j++)
|
||||
for (j=0; j<STATE_SIZE; j++)
|
||||
agl_vf_P[i][j] = 0.;
|
||||
agl_vf_P[i][i] = INIT_PXX;
|
||||
}
|
||||
@@ -51,15 +51,15 @@ void agl_vf_init(float init_z, float init_zdot, float init_bias) {
|
||||
F = [ 1 dt -dt^2/2
|
||||
0 1 -dt
|
||||
0 0 1 ];
|
||||
|
||||
|
||||
B = [ dt^2/2 dt 0]';
|
||||
|
||||
|
||||
Q = [ 0.01 0 0
|
||||
0 0.01 0
|
||||
0 0 0.001 ];
|
||||
|
||||
|
||||
Xk1 = F * Xk0 + B * accel;
|
||||
|
||||
|
||||
Pk1 = F * Pk0 * F' + Q;
|
||||
|
||||
*/
|
||||
@@ -67,18 +67,18 @@ void agl_vf_predict(float accel) {
|
||||
/* update state */
|
||||
float u = accel + 9.81;
|
||||
agl_vf_z = agl_vf_z + DT_VFILTER * agl_vf_zdot;
|
||||
agl_vf_zdot = agl_vf_zdot + DT_VFILTER * ( u - agl_vf_bias);
|
||||
agl_vf_zdot = agl_vf_zdot + DT_VFILTER * ( u - agl_vf_bias);
|
||||
/* update covariance */
|
||||
const float FPF00 = agl_vf_P[0][0] + DT_VFILTER * ( agl_vf_P[1][0] + agl_vf_P[0][1] + DT_VFILTER * agl_vf_P[1][1] );
|
||||
const float FPF00 = agl_vf_P[0][0] + DT_VFILTER * ( agl_vf_P[1][0] + agl_vf_P[0][1] + DT_VFILTER * agl_vf_P[1][1] );
|
||||
const float FPF01 = agl_vf_P[0][1] + DT_VFILTER * ( agl_vf_P[1][1] - agl_vf_P[0][2] - DT_VFILTER * agl_vf_P[1][2] );
|
||||
const float FPF02 = agl_vf_P[0][2] + DT_VFILTER * ( agl_vf_P[1][2] );
|
||||
const float FPF10 = agl_vf_P[1][0] + DT_VFILTER * (-agl_vf_P[2][0] + agl_vf_P[1][1] - DT_VFILTER * agl_vf_P[2][1] );
|
||||
const float FPF11 = agl_vf_P[1][1] + DT_VFILTER * (-agl_vf_P[2][1] - agl_vf_P[1][2] + DT_VFILTER * agl_vf_P[2][2] );
|
||||
const float FPF10 = agl_vf_P[1][0] + DT_VFILTER * (-agl_vf_P[2][0] + agl_vf_P[1][1] - DT_VFILTER * agl_vf_P[2][1] );
|
||||
const float FPF11 = agl_vf_P[1][1] + DT_VFILTER * (-agl_vf_P[2][1] - agl_vf_P[1][2] + DT_VFILTER * agl_vf_P[2][2] );
|
||||
const float FPF12 = agl_vf_P[1][2] + DT_VFILTER * (-agl_vf_P[2][2] );
|
||||
const float FPF20 = agl_vf_P[2][0] + DT_VFILTER * ( agl_vf_P[2][1] );
|
||||
const float FPF21 = agl_vf_P[2][1] + DT_VFILTER * (-agl_vf_P[2][2] );
|
||||
const float FPF22 = agl_vf_P[2][2];
|
||||
|
||||
|
||||
agl_vf_P[0][0] = FPF00 + Qzz;
|
||||
agl_vf_P[0][1] = FPF01;
|
||||
agl_vf_P[0][2] = FPF02;
|
||||
@@ -109,13 +109,13 @@ void agl_vf_update(float z_meas) {
|
||||
|
||||
const float y = z_meas - agl_vf_z;
|
||||
const float S = agl_vf_P[0][0] + R;
|
||||
const float K1 = agl_vf_P[0][0] * 1/S;
|
||||
const float K2 = agl_vf_P[1][0] * 1/S;
|
||||
const float K3 = agl_vf_P[2][0] * 1/S;
|
||||
|
||||
agl_vf_z = agl_vf_z + K1 * y;
|
||||
agl_vf_zdot = agl_vf_zdot + K2 * y;
|
||||
agl_vf_bias = agl_vf_bias + K3 * y;
|
||||
const float K1 = agl_vf_P[0][0] * 1/S;
|
||||
const float K2 = agl_vf_P[1][0] * 1/S;
|
||||
const float K3 = agl_vf_P[2][0] * 1/S;
|
||||
|
||||
agl_vf_z = agl_vf_z + K1 * y;
|
||||
agl_vf_zdot = agl_vf_zdot + K2 * y;
|
||||
agl_vf_bias = agl_vf_bias + K3 * y;
|
||||
|
||||
const float P11 = (1. - K1) * agl_vf_P[0][0];
|
||||
const float P12 = (1. - K1) * agl_vf_P[0][1];
|
||||
|
||||
+26
-26
@@ -4,9 +4,9 @@
|
||||
|
||||
X = [ z zdot bias ]
|
||||
|
||||
temps :
|
||||
temps :
|
||||
predict 86us
|
||||
update 46us
|
||||
update 46us
|
||||
|
||||
*/
|
||||
/* initial covariance diagonal */
|
||||
@@ -31,7 +31,7 @@ void alt_vf_init(float init_z, float init_zdot, float init_bias) {
|
||||
alt_vf_bias = init_bias;
|
||||
int i, j;
|
||||
for (i=0; i<STATE_SIZE; i++) {
|
||||
for (j=0; j<STATE_SIZE; j++)
|
||||
for (j=0; j<STATE_SIZE; j++)
|
||||
alt_vf_P[i][j] = 0.;
|
||||
alt_vf_P[i][i] = INIT_PXX;
|
||||
}
|
||||
@@ -44,15 +44,15 @@ void alt_vf_init(float init_z, float init_zdot, float init_bias) {
|
||||
F = [ 1 dt -dt^2/2
|
||||
0 1 -dt
|
||||
0 0 1 ];
|
||||
|
||||
|
||||
B = [ dt^2/2 dt 0]';
|
||||
|
||||
|
||||
Q = [ 0.01 0 0
|
||||
0 0.01 0
|
||||
0 0 0.001 ];
|
||||
|
||||
|
||||
Xk1 = F * Xk0 + B * accel;
|
||||
|
||||
|
||||
Pk1 = F * Pk0 * F' + Q;
|
||||
|
||||
*/
|
||||
@@ -60,18 +60,18 @@ void alt_vf_predict(float accel) {
|
||||
/* update state */
|
||||
float u = accel + 9.81;
|
||||
alt_vf_z = alt_vf_z + DT_VFILTER * alt_vf_zdot;
|
||||
alt_vf_zdot = alt_vf_zdot + DT_VFILTER * ( u - alt_vf_bias);
|
||||
alt_vf_zdot = alt_vf_zdot + DT_VFILTER * ( u - alt_vf_bias);
|
||||
/* update covariance */
|
||||
const float FPF00 = alt_vf_P[0][0] + DT_VFILTER * ( alt_vf_P[1][0] + alt_vf_P[0][1] + DT_VFILTER * alt_vf_P[1][1] );
|
||||
const float FPF00 = alt_vf_P[0][0] + DT_VFILTER * ( alt_vf_P[1][0] + alt_vf_P[0][1] + DT_VFILTER * alt_vf_P[1][1] );
|
||||
const float FPF01 = alt_vf_P[0][1] + DT_VFILTER * ( alt_vf_P[1][1] - alt_vf_P[0][2] - DT_VFILTER * alt_vf_P[1][2] );
|
||||
const float FPF02 = alt_vf_P[0][2] + DT_VFILTER * ( alt_vf_P[1][2] );
|
||||
const float FPF10 = alt_vf_P[1][0] + DT_VFILTER * (-alt_vf_P[2][0] + alt_vf_P[1][1] - DT_VFILTER * alt_vf_P[2][1] );
|
||||
const float FPF11 = alt_vf_P[1][1] + DT_VFILTER * (-alt_vf_P[2][1] - alt_vf_P[1][2] + DT_VFILTER * alt_vf_P[2][2] );
|
||||
const float FPF10 = alt_vf_P[1][0] + DT_VFILTER * (-alt_vf_P[2][0] + alt_vf_P[1][1] - DT_VFILTER * alt_vf_P[2][1] );
|
||||
const float FPF11 = alt_vf_P[1][1] + DT_VFILTER * (-alt_vf_P[2][1] - alt_vf_P[1][2] + DT_VFILTER * alt_vf_P[2][2] );
|
||||
const float FPF12 = alt_vf_P[1][2] + DT_VFILTER * (-alt_vf_P[2][2] );
|
||||
const float FPF20 = alt_vf_P[2][0] + DT_VFILTER * ( alt_vf_P[2][1] );
|
||||
const float FPF21 = alt_vf_P[2][1] + DT_VFILTER * (-alt_vf_P[2][2] );
|
||||
const float FPF22 = alt_vf_P[2][2];
|
||||
|
||||
|
||||
alt_vf_P[0][0] = FPF00 + Qzz;
|
||||
alt_vf_P[0][1] = FPF01;
|
||||
alt_vf_P[0][2] = FPF02;
|
||||
@@ -103,13 +103,13 @@ void alt_vf_update_z(float z_meas) {
|
||||
|
||||
const float y = z_meas - alt_vf_z;
|
||||
const float S = alt_vf_P[0][0] + R;
|
||||
const float K1 = alt_vf_P[0][0] * 1/S;
|
||||
const float K2 = alt_vf_P[1][0] * 1/S;
|
||||
const float K3 = alt_vf_P[2][0] * 1/S;
|
||||
|
||||
alt_vf_z = alt_vf_z + K1 * y;
|
||||
alt_vf_zdot = alt_vf_zdot + K2 * y;
|
||||
alt_vf_bias = alt_vf_bias + K3 * y;
|
||||
const float K1 = alt_vf_P[0][0] * 1/S;
|
||||
const float K2 = alt_vf_P[1][0] * 1/S;
|
||||
const float K3 = alt_vf_P[2][0] * 1/S;
|
||||
|
||||
alt_vf_z = alt_vf_z + K1 * y;
|
||||
alt_vf_zdot = alt_vf_zdot + K2 * y;
|
||||
alt_vf_bias = alt_vf_bias + K3 * y;
|
||||
|
||||
const float P11 = (1. - K1) * alt_vf_P[0][0];
|
||||
const float P12 = (1. - K1) * alt_vf_P[0][1];
|
||||
@@ -150,13 +150,13 @@ void alt_vf_update_z(float z_meas) {
|
||||
void alt_vf_update_vz(float vz) {
|
||||
const float yd = vz - alt_vf_zdot;
|
||||
const float S = alt_vf_P[1][1] + R;
|
||||
const float K1 = alt_vf_P[0][1] * 1/S;
|
||||
const float K2 = alt_vf_P[1][1] * 1/S;
|
||||
const float K3 = alt_vf_P[2][1] * 1/S;
|
||||
|
||||
alt_vf_z = alt_vf_z + K1 * yd;
|
||||
alt_vf_zdot = alt_vf_zdot + K2 * yd;
|
||||
alt_vf_bias = alt_vf_bias + K3 * yd;
|
||||
const float K1 = alt_vf_P[0][1] * 1/S;
|
||||
const float K2 = alt_vf_P[1][1] * 1/S;
|
||||
const float K3 = alt_vf_P[2][1] * 1/S;
|
||||
|
||||
alt_vf_z = alt_vf_z + K1 * yd;
|
||||
alt_vf_zdot = alt_vf_zdot + K2 * yd;
|
||||
alt_vf_bias = alt_vf_bias + K3 * yd;
|
||||
|
||||
const float P11 = -K1 * alt_vf_P[1][0] + alt_vf_P[0][0];
|
||||
const float P12 = -K1 * alt_vf_P[1][1] + alt_vf_P[0][1];
|
||||
|
||||
@@ -77,7 +77,7 @@ bool_t nav_anemotaxis( uint8_t c, uint8_t c1, uint8_t c2, uint8_t plume ) {
|
||||
waypoints[c].y = waypoints[c2].y + DEFAULT_CIRCLE_RADIUS*upwind_y;
|
||||
|
||||
// DownlinkSendWp(c);
|
||||
|
||||
|
||||
sign = -sign;
|
||||
status = UTURN;
|
||||
nav_init_stage();
|
||||
@@ -88,7 +88,7 @@ bool_t nav_anemotaxis( uint8_t c, uint8_t c1, uint8_t c2, uint8_t plume ) {
|
||||
waypoints[c].y = estimator_y + DEFAULT_CIRCLE_RADIUS*upwind_y;
|
||||
|
||||
// DownlinkSendWp(c);
|
||||
|
||||
|
||||
sign = -sign;
|
||||
status = UTURN;
|
||||
nav_init_stage();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Paparazzi $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2006- Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ float ant_track_azim;
|
||||
float ant_track_elev;
|
||||
uint8_t ant_track_id;
|
||||
|
||||
int32_t nav_utm_east0;
|
||||
int32_t nav_utm_east0;
|
||||
int32_t nav_utm_north0;
|
||||
uint8_t nav_utm_zone0;
|
||||
const float ant_track_gnd_alt = 185.;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <avr/io.h>
|
||||
|
||||
/*
|
||||
Slave address
|
||||
Slave address
|
||||
front = 0x52
|
||||
back = 0x54
|
||||
right = 0x56
|
||||
@@ -65,9 +65,9 @@ void dc_mc_link_periodic(void) {
|
||||
|
||||
#include "led.h"
|
||||
|
||||
ISR (TWI_vect) {
|
||||
ISR (TWI_vect) {
|
||||
switch (TWSR & 0xF8) {
|
||||
case SR_SLA_ACK:
|
||||
case SR_SLA_ACK:
|
||||
// LED_OFF(1);
|
||||
dc_mc_link_twi_rx_buf_idx = 0;
|
||||
TWCR |= _BV(TWINT) | _BV(TWEA);
|
||||
@@ -86,16 +86,16 @@ ISR (TWI_vect) {
|
||||
// LED_ON(1);
|
||||
dc_mc_link_event = TRUE;
|
||||
break;
|
||||
case SW_SLA_ACK:
|
||||
case SW_SLA_ACK:
|
||||
case SW_DATA_ACK:
|
||||
TWCR |= (1<<TWINT);
|
||||
break;
|
||||
case TWI_BUS_ERR_2:
|
||||
case TWI_BUS_ERR_1:
|
||||
TWCR |=(1<<TWSTO) | (1<<TWINT);
|
||||
TWCR |=(1<<TWSTO) | (1<<TWINT);
|
||||
TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE); // TWI Reset
|
||||
break;
|
||||
|
||||
|
||||
// default:
|
||||
// LED_TOGGLE(1);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
void dc_mc_power_init(void) {
|
||||
/* OC1A output */
|
||||
DDRB |= _BV(1);
|
||||
DDRB |= _BV(1);
|
||||
|
||||
/* fast PWM TOP in ICR1 match in OCR1A */
|
||||
ICR1 = DC_MC_POWER_RESOLUTION;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
/** \file i2c_ap.c
|
||||
@@ -124,7 +124,7 @@ uint8_t i2c_start(void) {
|
||||
uint8_t i2c_sla(uint8_t a) {
|
||||
TWDR= a;
|
||||
TWCR=_BV(TWINT)|_BV(TWEN);
|
||||
|
||||
|
||||
while (! (TWCR & (1<<TWINT)));
|
||||
|
||||
return ((TWSR & 0xF8) != MT_SLA_ACK);
|
||||
@@ -133,7 +133,7 @@ uint8_t i2c_sla(uint8_t a) {
|
||||
uint8_t i2c_transmit(uint8_t byte) {
|
||||
TWDR= byte;
|
||||
TWCR=_BV(TWINT)|_BV(TWEN);
|
||||
|
||||
|
||||
while (! (TWCR & (1<<TWINT)));
|
||||
|
||||
/***/return I2C_NO_ERROR;
|
||||
@@ -155,7 +155,7 @@ void i2c_init(void) {
|
||||
TWBR = 72;
|
||||
cbi(TWSR, TWPS1);
|
||||
cbi(TWSR, TWPS0);
|
||||
/** 10 KHz
|
||||
/** 10 KHz
|
||||
TWBR = 198;
|
||||
cbi(TWSR, TWPS1);
|
||||
sbi(TWSR, TWPS0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
/** \file i2c_ap.h
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*\brief AVR low level hardware initialisation
|
||||
*\brief AVR low level hardware initialisation
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
/** \file interrupt_hw.h
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \brief handling of avr inter mcu link
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,7 @@ SIGNAL( MODEM_CLK_INT_SIG ) {
|
||||
/* start bit */
|
||||
if (tx_byte_idx == 0)
|
||||
cbi(MODEM_TX_PORT, MODEM_TX_DATA);
|
||||
/* 8 data bits */
|
||||
/* 8 data bits */
|
||||
else if (tx_byte_idx < 9) {
|
||||
if (tx_byte & 0x01)
|
||||
sbi(MODEM_TX_PORT, MODEM_TX_DATA);
|
||||
@@ -59,7 +59,7 @@ SIGNAL( MODEM_CLK_INT_SIG ) {
|
||||
}
|
||||
/* stop_bit */
|
||||
else {
|
||||
sbi(MODEM_TX_PORT, MODEM_TX_DATA);
|
||||
sbi(MODEM_TX_PORT, MODEM_TX_DATA);
|
||||
}
|
||||
tx_byte_idx++;
|
||||
/* next byte */
|
||||
@@ -70,7 +70,7 @@ SIGNAL( MODEM_CLK_INT_SIG ) {
|
||||
cbi( EIMSK, MODEM_CLK_INT );
|
||||
} else {
|
||||
/* else load next byte */
|
||||
MODEM_LOAD_NEXT_BYTE();
|
||||
MODEM_LOAD_NEXT_BYTE();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#define MODEM_TX_EN 7
|
||||
#define MODEM_TX_DATA 6
|
||||
|
||||
#ifdef CTL_BRD_V1_2
|
||||
#ifdef CTL_BRD_V1_2
|
||||
#define MODEM_CLK_DDR DDRD
|
||||
#define MODEM_CLK_PORT PORTD
|
||||
#define MODEM_CLK 0
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
* now, the time of the last pulse will be equal to the last pulse
|
||||
* we measured. Unfortunately, the Input Capture Flag (ICF1) will
|
||||
* not be set since the interrupt routine disables it.
|
||||
*
|
||||
*
|
||||
* Sync pulses are timed with Timer2, which runs at Clk/1024. This
|
||||
* is slow enough at both 4 and 8 Mhz to measure the lengthy (10ms
|
||||
* or longer) pulse.
|
||||
@@ -50,7 +50,7 @@
|
||||
uint16_t ppm_pulses[ PPM_NB_PULSES ];
|
||||
volatile bool_t ppm_valid;
|
||||
|
||||
/* MC3030, Trame PPM7: 25ms, 10.4 au neutre,
|
||||
/* MC3030, Trame PPM7: 25ms, 10.4 au neutre,
|
||||
sync pulse = 16.2ms with low value on every channels */
|
||||
|
||||
#if CLOCK == 8
|
||||
@@ -82,7 +82,7 @@ SIGNAL( SIG_INPUT_CAPTURE1 )
|
||||
#endif
|
||||
width = this - last;
|
||||
last = this;
|
||||
|
||||
|
||||
if( state == 0 ) {
|
||||
uint16_t end = TCNT2;
|
||||
#if CLOCK == 8
|
||||
@@ -93,7 +93,7 @@ SIGNAL( SIG_INPUT_CAPTURE1 )
|
||||
#endif
|
||||
sync_start = end;
|
||||
|
||||
/* The frame period of the mc3030 seems to be 25ms.
|
||||
/* The frame period of the mc3030 seems to be 25ms.
|
||||
* One pulse lasts from 1.05ms to 2.150ms.
|
||||
* Sync pulse is at least 7ms : (7000*CLOCK)/1024 = 109
|
||||
*/
|
||||
@@ -101,10 +101,10 @@ SIGNAL( SIG_INPUT_CAPTURE1 )
|
||||
diff < LONG_SYS_TICS_OF_USEC(PPM_SYNC_MAX_LEN) ) {
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Read a data pulses */
|
||||
if( width > SYS_TICS_OF_USEC(PPM_DATA_MAX_LEN) ||
|
||||
if( width > SYS_TICS_OF_USEC(PPM_DATA_MAX_LEN) ||
|
||||
width < SYS_TICS_OF_USEC(PPM_DATA_MIN_LEN))
|
||||
RestartPpmCycle();
|
||||
ppm_pulses[state - 1] = width;
|
||||
@@ -112,7 +112,7 @@ SIGNAL( SIG_INPUT_CAPTURE1 )
|
||||
if (state >= PPM_NB_PULSES) {
|
||||
ppm_valid = TRUE;
|
||||
RestartPpmCycle();
|
||||
} else
|
||||
} else
|
||||
state++;
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* If you require actual microsecond values, divide by CLOCK.
|
||||
* For an 8 Mhz clock and typical servo values, these will range
|
||||
* from 0x1F00 to 0x4000.
|
||||
*
|
||||
*
|
||||
* Copied from autopilot (autopilot.sf.net) thanx alot Trammell
|
||||
*
|
||||
* (c) 2002 Trammell Hudson <hudson@rotomotion.com>
|
||||
@@ -29,7 +29,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -62,10 +62,10 @@ ppm_init( void )
|
||||
#endif
|
||||
/* No noise cancelation */
|
||||
sbi( TCCR1B, ICNC1 );
|
||||
|
||||
|
||||
/* Set ICP to input, no internal pull up */
|
||||
cbi( PPM_DDR, PPM_PIN);
|
||||
|
||||
|
||||
/* Enable interrupt on input capture */
|
||||
sbi( TIMSK, TICIE1 );
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -81,10 +81,10 @@ void actuators_init( void ) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
* Interrupt routine
|
||||
*
|
||||
* write the next pulse width to OCR register and
|
||||
*
|
||||
* write the next pulse width to OCR register and
|
||||
* assert the servo signal. It will be cleared by
|
||||
* the following compare match.
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Implementation of command.h */
|
||||
|
||||
/*
|
||||
/*
|
||||
3 servos on OC3A OC3B OC3C using Timer3 prescaled at 8
|
||||
*/
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/** Implementation of actuators.h */
|
||||
|
||||
/*
|
||||
|
||||
|
||||
4 DC motor controller with mosfets on OCR1A OCR3A OCR3B OCR3C
|
||||
|
||||
*/
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
void actuators_init ( void ) {
|
||||
/* OC1A output */
|
||||
DDRB |= _BV(5);
|
||||
DDRB |= _BV(5);
|
||||
/* fast PWM, 10 bits */
|
||||
TCCR1A |= _BV(WGM10) | _BV(WGM11) | _BV(COM1A1);
|
||||
TCCR1B |= _BV(WGM12);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003-2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -94,8 +94,8 @@ volatile uint8_t spi_cur_slave;
|
||||
uint8_t spi_nb_ovrn;
|
||||
|
||||
void spi_init( void) {
|
||||
/* Set MOSI and SCK output, all others input */
|
||||
MASTER_SPI_DDR |= _BV(MASTER_SPI_MOSI_PIN)| _BV(MASTER_SPI_SCK_PIN);
|
||||
/* Set MOSI and SCK output, all others input */
|
||||
MASTER_SPI_DDR |= _BV(MASTER_SPI_MOSI_PIN)| _BV(MASTER_SPI_SCK_PIN);
|
||||
|
||||
/* enable pull up for miso */
|
||||
// SPI_PORT |= _BV(MASTER_SPI_MISO_PIN);
|
||||
@@ -108,7 +108,7 @@ void spi_init( void) {
|
||||
/* Set SS1 output */
|
||||
SetBit( MASTER_SPI_SS1_DDR, MASTER_SPI_SS1_PIN);
|
||||
/* SS1 idles high (don't select slave yet)*/
|
||||
|
||||
|
||||
/* Set SS2 output */
|
||||
SetBit( MASTER_SPI_SS2_DDR, MASTER_SPI_SS2_PIN);
|
||||
/* SS2 idles high (don't select slave yet)*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Paparazzi $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2005-2006 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ extern volatile uint8_t spi_idx_buf;
|
||||
|
||||
#ifdef SPI_MASTER
|
||||
|
||||
/* Enable SPI, Master, clock fck/16, interrupt */
|
||||
/* Enable SPI, Master, clock fck/16, interrupt */
|
||||
#define SpiStart() { \
|
||||
SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0); \
|
||||
uint8_t foo; \
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*\brief AVR timer functions
|
||||
*\brief AVR timer functions
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -111,7 +111,7 @@ static inline bool_t sys_time_periodic( void ) {
|
||||
|
||||
return (tmr2_ov_cnt & 0x1);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
//#define TMR2_PER_SEC 7812
|
||||
static inline bool_t sys_time_periodic( void ) {
|
||||
if( !bit_is_set( TIFR, TOV2 ) )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Paparazzi $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -48,29 +48,29 @@ static uint8_t tx_buf[ TX_BUF_SIZE ];
|
||||
*/
|
||||
|
||||
void uart0_init_tx( void ) {
|
||||
UBRRH = 0;
|
||||
UBRRH = 0;
|
||||
UBRRL = F_CPU/(16*UART0_BAUD)-1;
|
||||
|
||||
/* single speed */
|
||||
UCSRA = 0;
|
||||
/* Enable transmitter */
|
||||
UCSRB = _BV(TXEN);
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);
|
||||
/* single speed */
|
||||
UCSRA = 0;
|
||||
/* Enable transmitter */
|
||||
UCSRB = _BV(TXEN);
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);
|
||||
}
|
||||
|
||||
void uart0_init_rx( void ) {
|
||||
/* Enable receiver */
|
||||
UCSRB |= _BV(RXEN);
|
||||
/* Enable receiver */
|
||||
UCSRB |= _BV(RXEN);
|
||||
/* Enable uart receive interrupt */
|
||||
sbi( UCSRB, RXCIE );
|
||||
sbi( UCSRB, RXCIE );
|
||||
}
|
||||
|
||||
bool_t uart0_check_free_space( uint8_t len) {
|
||||
int8_t space;
|
||||
if ((space = (tx_tail - tx_head)) <= 0)
|
||||
space += TX_BUF_SIZE;
|
||||
|
||||
|
||||
return (uint8_t)(space - 1) >= len;
|
||||
}
|
||||
|
||||
@@ -119,11 +119,11 @@ void uart0_init_tx( void ) {
|
||||
UBRR0H = 0;
|
||||
UBRR0L = F_CPU/(16*UART0_BAUD)-1;
|
||||
|
||||
/* single speed */
|
||||
UCSR0A = 0;
|
||||
/* Enable transmitter */
|
||||
/* single speed */
|
||||
UCSR0A = 0;
|
||||
/* Enable transmitter */
|
||||
UCSR0B = _BV(TXEN);
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
UCSR0C = _BV(UCSZ1) | _BV(UCSZ0);
|
||||
|
||||
tx_head0 = 0;
|
||||
@@ -131,9 +131,9 @@ void uart0_init_tx( void ) {
|
||||
}
|
||||
|
||||
void uart0_init_rx( void ) {
|
||||
/* Enable receiver */
|
||||
/* Enable receiver */
|
||||
UCSR0B |= _BV(RXEN);
|
||||
|
||||
|
||||
/* Enable uart receive interrupt */
|
||||
sbi(UCSR0B, RXCIE );
|
||||
}
|
||||
@@ -142,7 +142,7 @@ bool_t uart0_check_free_space( uint8_t len) {
|
||||
int8_t space;
|
||||
if ((space = (tx_tail0 - tx_head0)) <= 0)
|
||||
space += TX_BUF_SIZE;
|
||||
|
||||
|
||||
return (uint16_t)(space - 1) >= len;
|
||||
}
|
||||
|
||||
@@ -190,14 +190,14 @@ uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE];
|
||||
|
||||
void uart1_init_tx( void ) {
|
||||
/* set baud rate */
|
||||
UBRR1H = 0;
|
||||
UBRR1H = 0;
|
||||
UBRR1L = F_CPU/(16*UART1_BAUD)-1;
|
||||
|
||||
/* single speed */
|
||||
UCSR1A = 0;
|
||||
/* Enable transmitter */
|
||||
/* single speed */
|
||||
UCSR1A = 0;
|
||||
/* Enable transmitter */
|
||||
UCSR1B = _BV(TXEN);
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
UCSR1C = _BV(UCSZ1) | _BV(UCSZ0);
|
||||
|
||||
tx_head1 = 0;
|
||||
@@ -205,17 +205,17 @@ void uart1_init_tx( void ) {
|
||||
}
|
||||
|
||||
void uart1_init_rx( void ) {
|
||||
/* Enable receiver */
|
||||
/* Enable receiver */
|
||||
UCSR1B |= _BV(RXEN);
|
||||
/* Enable uart receive interrupt */
|
||||
sbi(UCSR1B, RXCIE );
|
||||
sbi(UCSR1B, RXCIE );
|
||||
}
|
||||
|
||||
bool_t uart1_check_free_space( uint8_t len) {
|
||||
int8_t space;
|
||||
if ((space = (tx_tail1 - tx_head1)) <= 0)
|
||||
space += TX_BUF_SIZE;
|
||||
|
||||
|
||||
return (uint16_t)(space - 1) >= len;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -29,18 +29,18 @@ int main( void ) {
|
||||
|
||||
/* setup PC_TX as output */
|
||||
UART_PC_DDR |= _BV(UART_PC_TX);
|
||||
|
||||
|
||||
/* setup PC_RX as input, no pullup */
|
||||
UART_PC_DDR &= ~_BV(UART_PC_RX);
|
||||
UART_PC_PORT &= ~_BV(UART_PC_RX);
|
||||
|
||||
|
||||
/* setup PERPH_TX as output */
|
||||
UART_PERPH_DDR |= _BV(UART_PERPH_TX);
|
||||
|
||||
|
||||
/* setup PERPH_RX as input, no pullup */
|
||||
UART_PERPH_DDR &= ~_BV(UART_PERPH_RX);
|
||||
UART_PERPH_PORT &= ~_BV(UART_PERPH_RX);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (bit_is_set(UART_PERPH_PIN, UART_PERPH_RX)) {
|
||||
@@ -53,9 +53,9 @@ int main( void ) {
|
||||
} else {
|
||||
cbi(UART_PERPH_PORT, UART_PERPH_TX);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2008- ENAC
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define ADS8344_SS_IODIR IO0DIR
|
||||
#define ADS8344_SS_IOSET IO0SET
|
||||
#define ADS8344_SS_IOCLR IO0CLR
|
||||
#define ADS8344_SS_PIN 20
|
||||
#define ADS8344_SS_PIN 20
|
||||
|
||||
#define ADS8344Select() SetBit(ADS8344_SS_IOCLR,ADS8344_SS_PIN)
|
||||
#define ADS8344Unselect() SetBit(ADS8344_SS_IOSET,ADS8344_SS_PIN)
|
||||
@@ -67,7 +67,7 @@ uint16_t ADS8344_values[NB_CHANNELS];
|
||||
/* SSPCR0 settings */
|
||||
#define SSP_DSS 0x07 << 0 /* data size : 8 bits */
|
||||
#define SSP_FRF 0x00 << 4 /* frame format : SPI */
|
||||
#define SSP_CPOL 0x00 << 6 /* clock polarity : idle low */
|
||||
#define SSP_CPOL 0x00 << 6 /* clock polarity : idle low */
|
||||
#define SSP_CPHA 0x00 << 7 /* clock phase : 1 */
|
||||
#define SSP_SCR 0x0E << 8 /* serial clock rate : 1MHz */
|
||||
|
||||
@@ -87,17 +87,17 @@ void ADS8344_init( void ) {
|
||||
|
||||
/* setup pins for SSP (SCK, MISO, MOSI) */
|
||||
PINSEL1 |= 2 << 2 | 2 << 4 | 2 << 6;
|
||||
|
||||
|
||||
/* setup SSP */
|
||||
SSPCR0 = SSP_DSS | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR;
|
||||
SSPCR1 = SSP_LBM | SSP_MS | SSP_SOD;
|
||||
SSPCPSR = CPSDVSR; /* -> 50kHz */
|
||||
|
||||
|
||||
/* initialize interrupt vector */
|
||||
VICIntSelect &= ~VIC_BIT(VIC_SPI1); // SPI1 selected as IRQ
|
||||
VICIntEnable = VIC_BIT(VIC_SPI1); // SPI1 interrupt enabled
|
||||
VICVectCntl7 = VIC_ENABLE | VIC_SPI1;
|
||||
VICVectAddr7 = (uint32_t)SPI1_ISR; // address of the ISR
|
||||
VICVectAddr7 = (uint32_t)SPI1_ISR; // address of the ISR
|
||||
|
||||
/* setup slave select */
|
||||
/* configure SS pin */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2008- ENAC
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
* routines to operate properly with THUMB code. The MACRO performs
|
||||
* the following steps:
|
||||
*
|
||||
* 1 - Recover SPSR value from stack
|
||||
* 2 - and restore its value
|
||||
* 1 - Recover SPSR value from stack
|
||||
* 2 - and restore its value
|
||||
* 3 - Pop the return address & the saved general registers from
|
||||
* the IRQ stack & return
|
||||
*
|
||||
@@ -69,7 +69,7 @@
|
||||
* Description:
|
||||
* This function sets the IRQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
@@ -85,7 +85,7 @@ unsigned disableIRQ(void);
|
||||
* Description:
|
||||
* This function clears the IRQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
@@ -102,7 +102,7 @@ unsigned enableIRQ(void);
|
||||
* This function restores the IRQ disable bit in the status register
|
||||
* to the value contained within passed oldCPSR
|
||||
*
|
||||
* Calling Sequence:
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
@@ -118,7 +118,7 @@ unsigned restoreIRQ(unsigned oldCPSR);
|
||||
* Description:
|
||||
* This function sets the FIQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
@@ -134,7 +134,7 @@ unsigned disableFIQ(void);
|
||||
* Description:
|
||||
* This function clears the FIQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
@@ -151,7 +151,7 @@ unsigned enableFIQ(void);
|
||||
* This function restores the FIQ disable bit in the status register
|
||||
* to the value contained within passed oldCPSR
|
||||
*
|
||||
* Calling Sequence:
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
* Here you will define for what hardware-endpoint EFSL should be compiled.
|
||||
* Look in interfaces.h to see what systems are supported, and add your own
|
||||
* there if you need to write your own driver. Then, define the name you
|
||||
* there if you need to write your own driver. Then, define the name you
|
||||
* selected for your hardware there here. Make sure that you only select one
|
||||
* device!
|
||||
*/
|
||||
@@ -22,13 +22,13 @@
|
||||
/* defines the interface for LPC213x (0=SPI0 1=SPI1) */
|
||||
//#define HW_ENDPOINT_LPC2000_SPINUM (0)
|
||||
//#define HW_ENDPOINT_LPC2000_SPINUM (1)
|
||||
|
||||
|
||||
/*#define HW_ENDPOINT_DSP_TI6713_SD*/
|
||||
|
||||
|
||||
/* Memory configuration
|
||||
--------------------
|
||||
|
||||
|
||||
* Here you must configure wheter your processor can access memory byte
|
||||
* oriented. All x86 processors can do it, AVR's can do it to. Some DSP
|
||||
* or other microcontrollers can't. If you have an 8 bit system you're safe.
|
||||
@@ -40,9 +40,9 @@
|
||||
|
||||
/* Cache configuration
|
||||
-------------------
|
||||
|
||||
|
||||
* Here you must configure how much memory of cache you can/want to use.
|
||||
* The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means
|
||||
* The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means
|
||||
* 512 bytes cache, 4 means 2048 bytes cache. More is better.
|
||||
* The number after IOMAN_NUMITERATIONS should be untouched.
|
||||
* The last field (IOMAN_DO_MEMALLOC) is to tell ioman to allocate it's
|
||||
@@ -55,9 +55,9 @@
|
||||
#define IOMAN_NUMITERATIONS 3
|
||||
#define IOMAN_DO_MEMALLOC
|
||||
|
||||
/* Cluster pre-allocation
|
||||
/* Cluster pre-allocation
|
||||
----------------------
|
||||
|
||||
|
||||
* When writing files, the function that performs the actual write has to
|
||||
* calculate how many clusters it will need for that request. It then allocates
|
||||
* that number of new clusters to the file. Since this involves some calculations
|
||||
@@ -77,28 +77,28 @@
|
||||
|
||||
/* Endianess configuration
|
||||
-----------------------
|
||||
|
||||
|
||||
* Here you can configure wheter your architecture is little or big endian. This
|
||||
* is important since all FAT structures are stored in intel little endian order.
|
||||
* So if you have a big endian system the library has to convert all figures to
|
||||
* big endian in order to work.
|
||||
*/
|
||||
#define LITTLE_ENDIAN
|
||||
|
||||
|
||||
|
||||
/* Date and Time support
|
||||
---------------------
|
||||
|
||||
|
||||
* Here you can enable or disable date and time support. If you enable
|
||||
* it you will have to create 6 functions, that are described in the
|
||||
* EFSL manual. If the functions are not present when linking your
|
||||
* program with the library you will get unresolved dependencies.
|
||||
*/
|
||||
/*#define DATE_TIME_SUPPORT*/
|
||||
|
||||
|
||||
/* Error reporting support
|
||||
-----------------------
|
||||
|
||||
|
||||
* When you receive an error in userland, it usually only gives limited
|
||||
* information (most likely, fail or success). If error detection and
|
||||
* reporting is important for you, you can enable more detailed error
|
||||
@@ -118,9 +118,9 @@
|
||||
#define FULL_ERROR_SUPPORT
|
||||
/*#define BASE_ERROR_SUPPORT*/
|
||||
|
||||
/* List options
|
||||
/* List options
|
||||
------------
|
||||
|
||||
|
||||
* In this section youcan configure what kind of data you will get from
|
||||
* directory listing requests. Please refer to the documentation for
|
||||
* more information
|
||||
@@ -133,10 +133,10 @@
|
||||
|
||||
/* Debugging configuration
|
||||
-----------------------
|
||||
|
||||
|
||||
* Here you can configure the debugging behaviour. Debugging is different
|
||||
* on every platform (see debug.h for more information).
|
||||
* If your hardware has no means of output (printf) dont define any anything,
|
||||
* on every platform (see debug.h for more information).
|
||||
* If your hardware has no means of output (printf) dont define any anything,
|
||||
* and nothing will happen. For real world use debugging should be turned off.
|
||||
*/
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(HW_ENDPOINT_LINUX) || defined(HW_ENDPOINT_LINUX64)
|
||||
#define HW_ENDPOINT_LINUX_ALL
|
||||
#define HW_ENDPOINT_LINUX_ALL
|
||||
#endif
|
||||
|
||||
#ifdef HW_ENDPOINT_ATMEGA128_SD
|
||||
@@ -69,7 +69,7 @@
|
||||
#ifdef HW_ENDPOINT_LINUX_ALL
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#define TXT(x) x
|
||||
#define DBG(x) debug x
|
||||
#define FUNC_IN(x) debug_funcin(x)
|
||||
@@ -96,7 +96,7 @@
|
||||
#endif
|
||||
#ifdef HW_ENDPOINT_LPC2000_SD
|
||||
#include "interfaces/lpc2000_dbg_printf.h"
|
||||
|
||||
|
||||
#define TXT(x) x
|
||||
#define DBG(x) debug x
|
||||
#define FUNC_IN(x) ;
|
||||
|
||||
@@ -68,8 +68,8 @@ typedef struct PartitionField PartitionField;
|
||||
#define SIZE_PARTITION_FIELD 16
|
||||
|
||||
/***************************************************************************************\
|
||||
Disc
|
||||
--
|
||||
Disc
|
||||
--
|
||||
* CompactFlash* sourcedisc Pointer to the hardwareobject that this disc is on.
|
||||
* PartitionField* partitions Array of PartitionFields, containing the partition info
|
||||
\***************************************************************************************/
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
#define ioman_setError(ioman,errval) ioman->error = errval
|
||||
#define ioman_getError(ioman) ioman->error
|
||||
#else
|
||||
#define IOMAN_ERR_EUINT8
|
||||
#define ioman_setError(ioman,errval)
|
||||
#define IOMAN_ERR_EUINT8
|
||||
#define ioman_setError(ioman,errval)
|
||||
#define ioman_getError(ioman) 0
|
||||
#endif
|
||||
|
||||
@@ -68,8 +68,8 @@
|
||||
#define disc_setError(disc,errval) disc->error = errval
|
||||
#define disc_getError(disc) disc->error
|
||||
#else
|
||||
#define DISC_ERR_EUINT8
|
||||
#define disc_setError(disc,errval)
|
||||
#define DISC_ERR_EUINT8
|
||||
#define disc_setError(disc,errval)
|
||||
#define disc_getError(disc) 0
|
||||
#endif
|
||||
|
||||
@@ -78,8 +78,8 @@
|
||||
#define part_setError(part,errval) part->error = errval
|
||||
#define part_getError(part) part->error
|
||||
#else
|
||||
#define PART_ERR_EUINT8
|
||||
#define part_setError(part,errval)
|
||||
#define PART_ERR_EUINT8
|
||||
#define part_setError(part,errval)
|
||||
#define part_getError(part) 0
|
||||
#endif
|
||||
|
||||
@@ -88,8 +88,8 @@
|
||||
#define fs_setError(fs,errval) fs->error = errval
|
||||
#define fs_getError(fs) fs->error
|
||||
#else
|
||||
#define FILESYSTEM_ERR_EUINT8
|
||||
#define fs_setError(fs,errval)
|
||||
#define FILESYSTEM_ERR_EUINT8
|
||||
#define fs_setError(fs,errval)
|
||||
#define fs_getError(fs) 0
|
||||
#endif
|
||||
|
||||
@@ -98,8 +98,8 @@
|
||||
#define file_setError(file,errval) file->error = errval
|
||||
#define file_getError(file) file->error
|
||||
#else
|
||||
#define FILE_ERR_EUINT8
|
||||
#define file_setError(file,errval)
|
||||
#define FILE_ERR_EUINT8
|
||||
#define file_setError(file,errval)
|
||||
#define file_getError(file) 0
|
||||
#endif
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@
|
||||
#define FILE_STATUS_WRITE 1
|
||||
|
||||
/*****************************************************************************\
|
||||
* File
|
||||
* ------
|
||||
* FileRecord DirEntry Copy of the FileRecord for this file
|
||||
* File
|
||||
* ------
|
||||
* FileRecord DirEntry Copy of the FileRecord for this file
|
||||
* FileLocation Location Location of the direntry
|
||||
* FileSystem *fs Pointer to the filesystem this file is on
|
||||
* FileCache Cache Pointer to the cache object of the file
|
||||
* euint8 FileStatus Contains bitfield regarding filestatus
|
||||
* FileSystem *fs Pointer to the filesystem this file is on
|
||||
* FileCache Cache Pointer to the cache object of the file
|
||||
* euint8 FileStatus Contains bitfield regarding filestatus
|
||||
* euint32 FilePtr Offsetpointer for fread/fwrite functions
|
||||
* euint32 FileSize Working copy of the filesize, always use this,
|
||||
it is more up to date than DirEntry->FileSize,
|
||||
@@ -83,7 +83,7 @@ esint16 file_setpos(File *file,euint32 pos);
|
||||
euint32 file_fread(File *file,euint32 offset, euint32 size,euint8 *buf);
|
||||
euint32 file_read (File *file,euint32 size,euint8 *buf);
|
||||
euint32 file_fwrite(File* file,euint32 offset,euint32 size,euint8* buf);
|
||||
euint32 file_write (File* file,euint32 size,euint8* buf);
|
||||
euint32 file_write (File* file,euint32 size,euint8* buf);
|
||||
eint8* file_normalToFatName(eint8* filename,eint8* fatfilename);
|
||||
euint8 file_validateChar(euint8 c);
|
||||
void file_initFile(File *file, FileSystem *fs, FileLocation *loc);
|
||||
|
||||
@@ -51,16 +51,16 @@
|
||||
|
||||
/*****************************************************************************************\
|
||||
VolumeId
|
||||
------
|
||||
------
|
||||
* ushort BytesPerSector Must be 512 or shit happens.
|
||||
* uchar SectorsPerCluster Must be multiple of 2 (1,2,4,8,16 or 32)
|
||||
* ushort ReservedSectorCount Number of sectors after which the first FAT begins.
|
||||
* uchar NumberOfFats Should be 2
|
||||
* ushort RootEntryCount Number of filerecords the Rootdir can contain. NOT for FAT32
|
||||
* ushort SectorCount16 Number of Sectors for 12/16 bit FAT
|
||||
* ushort SectorCount16 Number of Sectors for 12/16 bit FAT
|
||||
* ushort FatSectorCount16 Number of Sectors for 1 FAT on FAT12/16 bit FAT's
|
||||
* ulong SectorCount32 Number of Sectors for 32 bit FAT
|
||||
* ulong FatSectorCount32 Number of Sectors for 1 FAT on FAT32
|
||||
* ulong FatSectorCount32 Number of Sectors for 1 FAT on FAT32
|
||||
* ulong RootCluster Clusternumber of the first cluster of the RootDir on FAT 32
|
||||
This is NOT a complete volumeId copy, no direct I/O is possible.
|
||||
\*****************************************************************************************/
|
||||
@@ -86,7 +86,7 @@ typedef struct VolumeId VolumeId;
|
||||
* ulong DataClusterCount Number of dataclusters. This number determines the FATType.
|
||||
* ulong FatSectorCount Number of sectors for 1 FAT, regardless of FATType
|
||||
* ulong SectorCount Number of sectors, regardless of FATType
|
||||
* ulong FirstSectorRootDir First sector of the RootDir.
|
||||
* ulong FirstSectorRootDir First sector of the RootDir.
|
||||
* uchar type Determines FATType (FAT12 FAT16 or FAT32 are defined)
|
||||
|
||||
\**************************************************************************************************/
|
||||
@@ -118,16 +118,16 @@ struct FileLocation{
|
||||
typedef struct FileLocation FileLocation;
|
||||
|
||||
/*****************************************************************************\
|
||||
* FileCache
|
||||
* -----------
|
||||
* This struct acts as cache for the current file. It contains the current
|
||||
* FATPointer (next location in the FAT table), LogicCluster
|
||||
* (the last part of the file that was read) and DataCluster
|
||||
* (the last cluster that was read).
|
||||
* FileCache
|
||||
* -----------
|
||||
* This struct acts as cache for the current file. It contains the current
|
||||
* FATPointer (next location in the FAT table), LogicCluster
|
||||
* (the last part of the file that was read) and DataCluster
|
||||
* (the last cluster that was read).
|
||||
* euint8 Linear For how many more clusters the file is nonfragmented
|
||||
* euint32 LogicCluster This field determines the n'th cluster of the file as current
|
||||
* euint32 DiscCluster If this field is 0, it means the cache is invalid. Otherwise
|
||||
it is the clusternumber corresponding with
|
||||
it is the clusternumber corresponding with
|
||||
logic(FirstCluster+LogicCluster).
|
||||
* euint32 FirstCluster First cluster of the chain. Zero or one are invalid.
|
||||
* euint32 LastCluster Last cluster of the chain (is not always filled in)
|
||||
|
||||
@@ -69,4 +69,4 @@
|
||||
#define PREINT (*((volatile unsigned short*) 0xE0024080))
|
||||
#define PREFRAC (*((volatile unsigned short*) 0xE0024084))
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
* LPC2000 ARM7 Interface (c)2005 Martin Thomas *
|
||||
\*****************************************************************************/
|
||||
|
||||
#ifndef __LPC2000_SPI_H_
|
||||
#define __LPC2000_SPI_H_
|
||||
#ifndef __LPC2000_SPI_H_
|
||||
#define __LPC2000_SPI_H_
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0x00
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
* (c)2006 Michael De Nil *
|
||||
\*****************************************************************************/
|
||||
|
||||
#ifndef __SD_H_
|
||||
#define __SD_H_
|
||||
#ifndef __SD_H_
|
||||
#define __SD_H_
|
||||
|
||||
#include "config.h"
|
||||
#include "types.h"
|
||||
|
||||
@@ -59,15 +59,15 @@ typedef struct IOManStack IOManStack;
|
||||
|
||||
struct IOManager{
|
||||
hwInterface *iface;
|
||||
|
||||
|
||||
euint8 *bufptr;
|
||||
euint16 numbuf;
|
||||
euint16 numit;
|
||||
|
||||
|
||||
IOMAN_ERR_EUINT8
|
||||
|
||||
|
||||
IOManStack stack[IOMAN_NUMBUFFER][IOMAN_NUMITERATIONS];
|
||||
|
||||
|
||||
euint32 sector[IOMAN_NUMBUFFER];
|
||||
euint8 status[IOMAN_NUMBUFFER];
|
||||
euint8 usage[IOMAN_NUMBUFFER];
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
typedef unsigned char euint8;
|
||||
typedef short eint16;
|
||||
typedef signed short esint16;
|
||||
typedef unsigned short euint16;
|
||||
typedef long eint32;
|
||||
typedef unsigned short euint16;
|
||||
typedef long eint32;
|
||||
typedef signed long esint32;
|
||||
typedef unsigned long euint32;
|
||||
#elif defined(HW_ENDPOINT_LINUX64)
|
||||
@@ -57,8 +57,8 @@
|
||||
typedef unsigned char euint8;
|
||||
typedef short eint16;
|
||||
typedef signed short esint16;
|
||||
typedef unsigned short euint16;
|
||||
typedef int eint32;
|
||||
typedef unsigned short euint16;
|
||||
typedef int eint32;
|
||||
typedef signed int esint32;
|
||||
typedef unsigned int euint32;
|
||||
#elif defined (HW_ENDPOINT_ATMEGA128_SD)
|
||||
@@ -67,18 +67,18 @@
|
||||
typedef unsigned char euint8;
|
||||
typedef short eint16;
|
||||
typedef signed short esint16;
|
||||
typedef unsigned short euint16;
|
||||
typedef long eint32;
|
||||
typedef unsigned short euint16;
|
||||
typedef long eint32;
|
||||
typedef signed long esint32;
|
||||
typedef unsigned long euint32;
|
||||
typedef unsigned long euint32;
|
||||
#elif defined(HW_ENDPOINT_DSP_TI6713_SD)
|
||||
typedef char eint8;
|
||||
typedef signed char esint8;
|
||||
typedef unsigned char euint8;
|
||||
typedef short eint16;
|
||||
typedef signed short esint16;
|
||||
typedef unsigned short euint16;
|
||||
typedef int eint32;
|
||||
typedef unsigned short euint16;
|
||||
typedef int eint32;
|
||||
typedef signed int esint32;
|
||||
typedef unsigned int euint32;
|
||||
#elif defined(NIOS_2)
|
||||
@@ -90,17 +90,17 @@
|
||||
typedef unsigned short euint16;
|
||||
typedef int eint32;
|
||||
typedef signed int esint32;
|
||||
typedef unsigned int euint32;
|
||||
typedef unsigned int euint32;
|
||||
#else
|
||||
typedef char eint8;
|
||||
typedef signed char esint8;
|
||||
typedef unsigned char euint8;
|
||||
typedef short eint16;
|
||||
typedef signed short esint16;
|
||||
typedef unsigned short euint16;
|
||||
typedef long eint32;
|
||||
typedef unsigned short euint16;
|
||||
typedef long eint32;
|
||||
typedef signed long esint32;
|
||||
typedef unsigned long euint32;
|
||||
typedef unsigned long euint32;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#ifdef HW_ENDPOINT_LINUX_ALL
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void debug(const eint8 *format, ...)
|
||||
* Description: This function prints debug output to the screen (target dependant)
|
||||
* and if DO_FUNC_DEBUG is defined also to a localfile.
|
||||
@@ -61,7 +61,7 @@ void debug(const eint8 *format, ...)
|
||||
extern FILE* debugfile;
|
||||
extern volatile euint8 tw;
|
||||
#endif
|
||||
|
||||
|
||||
va_start(ap, format);
|
||||
vprintf(format,ap);
|
||||
#ifdef DO_FUNC_DEBUG
|
||||
@@ -75,7 +75,7 @@ void debug(const eint8 *format, ...)
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void debug_funcin(const eint8 *format, ...)
|
||||
* Description: This function marks the entrance of a function, which
|
||||
* increments a tabfieldcounter. A tree like structure can the be found in the
|
||||
@@ -90,24 +90,24 @@ void debug_funcin(const eint8 *format, ...)
|
||||
va_list ap;
|
||||
extern FILE* debugfile;
|
||||
extern volatile unsigned char tw;
|
||||
|
||||
|
||||
if(debugfile==NULL)return;
|
||||
|
||||
|
||||
for(c=0;c<tw;c++){
|
||||
fprintf(debugfile," ");
|
||||
}
|
||||
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(debugfile,format,ap);
|
||||
va_end(ap);
|
||||
fprintf(debugfile,"\n");
|
||||
|
||||
|
||||
tw++;
|
||||
#endif
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void debug_funcout(const eint8 *format, ...)
|
||||
* Description: Decrements the tabfieldcounter. This function is called everywhere
|
||||
* a function is left.
|
||||
@@ -121,15 +121,15 @@ void debug_funcout(const eint8 *format, ...)
|
||||
va_list ap;
|
||||
extern FILE* debugfile;
|
||||
extern volatile euint8 tw;
|
||||
|
||||
|
||||
if(debugfile==NULL)return;
|
||||
|
||||
|
||||
if(tw>0)tw--;
|
||||
|
||||
|
||||
for(c=0;c<tw;c++){
|
||||
fprintf(debugfile," ");
|
||||
}
|
||||
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(debugfile,format,ap);
|
||||
va_end(ap);
|
||||
@@ -138,7 +138,7 @@ void debug_funcout(const eint8 *format, ...)
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void debug_init()
|
||||
* Description: This function optionally opens the debugfile, or does any other
|
||||
* initialisation to enable debugoutput.
|
||||
@@ -152,13 +152,13 @@ void debug_init()
|
||||
|
||||
debugfile=NULL;
|
||||
tw=0;
|
||||
|
||||
|
||||
debugfile=fopen("DBG.OUT","w");
|
||||
#endif
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void debug_end()
|
||||
* Description: This function closes the debugfile.
|
||||
* Return value: void
|
||||
@@ -167,7 +167,7 @@ void debug_end()
|
||||
{
|
||||
#ifdef DO_FUNC_DEBUG
|
||||
extern FILE* debugfile;
|
||||
|
||||
|
||||
fflush(debugfile);
|
||||
fclose(debugfile);
|
||||
#endif
|
||||
@@ -191,15 +191,15 @@ void debug(const eint8 *format, ...)
|
||||
va_list ap;
|
||||
euint8 i=0;
|
||||
eint8 c;
|
||||
|
||||
|
||||
va_start(ap, format);
|
||||
vsprintf_P(dbgstring, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
|
||||
|
||||
|
||||
while (( (c=dbgstring[i++]) && (i<90) ))
|
||||
debug_sendByte(c);
|
||||
|
||||
|
||||
if(i>=90)
|
||||
debug(PSTR("<BREAK>\n"));
|
||||
}
|
||||
@@ -208,16 +208,16 @@ void debug(const eint8 *format, ...)
|
||||
void debug_init(void)
|
||||
{
|
||||
unsigned short ubrr;
|
||||
|
||||
|
||||
ubrr = ((unsigned short)DEBUG_UBRR);
|
||||
|
||||
|
||||
switch(DEBUG_PORT){
|
||||
case 0:
|
||||
UBRR0H = (euint8) (ubrr>>8);
|
||||
UBRR0L = (euint8) (ubrr);
|
||||
UCSR0B = ( (1<<RXEN) | (1<<TXEN) );
|
||||
break;
|
||||
case 1:
|
||||
case 1:
|
||||
UBRR1H = (euint8) (ubrr>>8);
|
||||
UBRR1L = (euint8) (ubrr);
|
||||
UCSR1B = ( (1<<RXEN) | (1<<TXEN) );
|
||||
@@ -248,7 +248,7 @@ void debug_sendByte(euint8 data)
|
||||
UDR0 = data; /* Start transmittion */
|
||||
break;
|
||||
case 1:
|
||||
while ( !(UCSR1A & (1<<UDRE1)) )
|
||||
while ( !(UCSR1A & (1<<UDRE1)) )
|
||||
_NOP(); /* Wait for empty transmit buffer */
|
||||
UDR1 = data; /* Start transmittion */
|
||||
break;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "dir.h"
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void dir_getFileStructure(FileSystem *fs,FileRecord *filerec,FileLocation *loc)
|
||||
* Description: This function stores the filerecord located at loc in filerec.
|
||||
* It fetches the required sector for this.
|
||||
@@ -48,31 +48,31 @@ void dir_getFileStructure(FileSystem *fs,FileRecord *filerec,FileLocation *loc)
|
||||
buf=part_getSect(fs->part,loc->Sector,IOM_MODE_READONLY);
|
||||
*filerec=*(((FileRecord*)buf)+loc->Offset);
|
||||
part_relSect(fs->part,buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void dir_createDirectoryEntry(FileSystem *fs,FileRecord *filerec,FileLocation *loc)
|
||||
* Description: This function writes the filerecord stored in filerec to disc at
|
||||
* location loc.
|
||||
* location loc.
|
||||
* Return value: void
|
||||
*/
|
||||
void dir_createDirectoryEntry(FileSystem *fs,FileRecord *filerec,FileLocation *loc)
|
||||
{
|
||||
euint8 *buf;
|
||||
|
||||
|
||||
buf = part_getSect(fs->part,loc->Sector,IOM_MODE_READWRITE);
|
||||
memCpy(filerec,buf+(loc->Offset*sizeof(*filerec)),sizeof(*filerec));
|
||||
part_relSect(fs->part,buf);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void dir_createDefaultEntry(FileSystem *fs,FileRecord *filerec,eint8* fatfilename)
|
||||
* Description: This function fills in a filerecord with safe default values, and
|
||||
* a given fatfilename. If your system has a means of knowing time, here is an
|
||||
* excellent place to apply it to the filerecord.
|
||||
* a given fatfilename. If your system has a means of knowing time, here is an
|
||||
* excellent place to apply it to the filerecord.
|
||||
* Return value: void
|
||||
*/
|
||||
void dir_createDefaultEntry(FileSystem *fs,FileRecord *filerec,eint8* fatfilename)
|
||||
@@ -82,7 +82,7 @@ void dir_createDefaultEntry(FileSystem *fs,FileRecord *filerec,eint8* fatfilenam
|
||||
filerec->NTReserved=0x00;
|
||||
filerec->MilliSecTimeStamp=0x00;
|
||||
filerec->CreatedTime=time_getTime();
|
||||
filerec->CreatedDate=time_getDate();
|
||||
filerec->CreatedDate=time_getDate();
|
||||
filerec->AccessDate=filerec->CreatedDate;
|
||||
filerec->FirstClusterHigh=0x0000;
|
||||
filerec->WriteTime=filerec->CreatedTime;
|
||||
@@ -92,7 +92,7 @@ void dir_createDefaultEntry(FileSystem *fs,FileRecord *filerec,eint8* fatfilenam
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void dir_setFirstCluster(File *file,euint32 cluster_addr)
|
||||
* Description: This function requires modification to release it from
|
||||
* depending on the file object.
|
||||
@@ -101,15 +101,15 @@ void dir_createDefaultEntry(FileSystem *fs,FileRecord *filerec,eint8* fatfilenam
|
||||
void dir_setFirstCluster(FileSystem *fs,FileLocation *loc,euint32 cluster_addr)
|
||||
{
|
||||
euint8 *buf;
|
||||
|
||||
|
||||
buf = part_getSect(fs->part,loc->Sector,IOM_MODE_READWRITE);
|
||||
(((FileRecord*)buf)+loc->Offset)->FirstClusterHigh=cluster_addr>>16;
|
||||
(((FileRecord*)buf)+loc->Offset)->FirstClusterLow=cluster_addr&0xFFFF;
|
||||
(((FileRecord*)buf)+loc->Offset)->FirstClusterLow=cluster_addr&0xFFFF;
|
||||
part_relSect(fs->part,buf);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void dir_setFileSize(FileSystem *fs, FileLocation *loc,euint32 numbytes)
|
||||
* Description: This function changes the filesize recorded at loc->Sector
|
||||
* to 'numbytes'.
|
||||
@@ -118,14 +118,14 @@ void dir_setFirstCluster(FileSystem *fs,FileLocation *loc,euint32 cluster_addr)
|
||||
void dir_setFileSize(FileSystem *fs, FileLocation *loc,euint32 numbytes)
|
||||
{
|
||||
euint8 *buf;
|
||||
|
||||
|
||||
buf = part_getSect(fs->part,loc->Sector,IOM_MODE_READWRITE);
|
||||
(((FileRecord*)buf)+loc->Offset)->FileSize=numbytes;
|
||||
part_relSect(fs->part,buf);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint8 dir_updateDirectoryEntry(FileSystem *fs,FileRecord *entry,FileLocation *loc))
|
||||
* This function changes the entire entity stores at loc to the data recorded
|
||||
* in entry. This is for custom updates to the directoryentry.
|
||||
@@ -134,14 +134,14 @@ void dir_setFileSize(FileSystem *fs, FileLocation *loc,euint32 numbytes)
|
||||
esint8 dir_updateDirectoryEntry(FileSystem *fs,FileRecord *entry,FileLocation *loc)
|
||||
{
|
||||
euint8 *buf;
|
||||
|
||||
|
||||
buf = part_getSect(fs->part,loc->Sector,IOM_MODE_READWRITE);
|
||||
memCpy(entry,buf+(loc->Offset*sizeof(*entry)),sizeof(*entry));
|
||||
part_relSect(fs->part,buf);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 dir_findFileinBuf(euint8 *buf, eint8 *fatname, FileLocation *loc)
|
||||
* This function searches for a given fatfilename in the buffer provided.
|
||||
* It will iterate through the 16 direntry's in the buffer and searches
|
||||
@@ -155,7 +155,7 @@ euint32 dir_findFileinBuf(euint8 *buf, eint8 *fatname, FileLocation *loc)
|
||||
{
|
||||
FileRecord fileEntry;
|
||||
euint8 c;
|
||||
|
||||
|
||||
for(c=0; c<16; c++)
|
||||
{
|
||||
fileEntry = *(((FileRecord*)buf) + c);
|
||||
@@ -182,7 +182,7 @@ euint32 dir_findFileinBuf(euint8 *buf, eint8 *fatname, FileLocation *loc)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 dir_findFreeEntryinBuf(euint8* buf, FileLocation *loc)
|
||||
* This function searches for a free entry in a given sector 'buf'.
|
||||
* It will put the offset into the loc->Offset field, given that loc is not 0.
|
||||
@@ -192,7 +192,7 @@ euint32 dir_findFreeEntryinBuf(euint8* buf, FileLocation *loc)
|
||||
{
|
||||
FileRecord fileEntry;
|
||||
euint8 c;
|
||||
|
||||
|
||||
for(c=0;c<16;c++){
|
||||
fileEntry = *(((FileRecord*)buf) + c);
|
||||
if( !( (fileEntry.Attribute & 0x0F) == 0x0F ) ){
|
||||
@@ -206,7 +206,7 @@ euint32 dir_findFreeEntryinBuf(euint8* buf, FileLocation *loc)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 dir_findinBuf(euint8 *buf, eint8 *fatname, FileLocation *loc)
|
||||
* Description: This function searches for a given fatfilename in a buffer.
|
||||
* Return value: Returns 0 on not found, and the firstcluster when the name is found.
|
||||
@@ -228,7 +228,7 @@ euint32 dir_findinBuf(euint8 *buf, eint8 *fatname, FileLocation *loc, euint8 mo
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 dir_findinCluster(FileSystem *fs,euint32 cluster,eint8 *fatname, FileLocation *loc, euint8 mode)
|
||||
* This function will search for an existing (fatname) or free directory entry
|
||||
* in a full cluster.
|
||||
@@ -238,7 +238,7 @@ euint32 dir_findinCluster(FileSystem *fs,euint32 cluster,eint8 *fatname, FileLoc
|
||||
{
|
||||
euint8 c,*buf=0;
|
||||
euint32 fclus;
|
||||
|
||||
|
||||
for(c=0;c<fs->volumeId.SectorsPerCluster;c++){
|
||||
buf = part_getSect(fs->part,fs_clusterToSector(fs,cluster)+c,IOM_MODE_READONLY);
|
||||
if((fclus=dir_findinBuf(buf,fatname,loc,mode))){
|
||||
@@ -251,7 +251,7 @@ euint32 dir_findinCluster(FileSystem *fs,euint32 cluster,eint8 *fatname, FileLoc
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 dir_findinDir(FileSystem *fs, eint8* fatname,euint32 firstcluster, FileLocation *loc, euint8 mode)
|
||||
* This function will search for an existing (fatname) or free directory entry
|
||||
* in a directory, following the clusterchains.
|
||||
@@ -261,14 +261,14 @@ euint32 dir_findinDir(FileSystem *fs, eint8* fatname,euint32 firstcluster, FileL
|
||||
{
|
||||
euint32 c=0,cluster;
|
||||
ClusterChain Cache;
|
||||
|
||||
|
||||
Cache.DiscCluster = Cache.FirstCluster = firstcluster;
|
||||
Cache.LogicCluster = Cache.LastCluster = Cache.Linear = 0;
|
||||
|
||||
|
||||
if(firstcluster <= 1){
|
||||
return(dir_findinRootArea(fs,fatname,loc,mode));
|
||||
return(dir_findinRootArea(fs,fatname,loc,mode));
|
||||
}
|
||||
|
||||
|
||||
while(!fat_LogicToDiscCluster(fs,&Cache,c++)){
|
||||
if((cluster=dir_findinCluster(fs,Cache.DiscCluster,fatname,loc,mode))){
|
||||
return(cluster);
|
||||
@@ -277,7 +277,7 @@ euint32 dir_findinDir(FileSystem *fs, eint8* fatname,euint32 firstcluster, FileL
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 dir_findinDir(FileSystem *fs, eint8* fatname,euint32 firstcluster, FileLocation *loc, euint8 mode)
|
||||
* This function will search for an existing (fatname) or free directory entry
|
||||
* in the rootdirectory-area of a FAT12/FAT16 filesystem.
|
||||
@@ -287,23 +287,23 @@ euint32 dir_findinRootArea(FileSystem *fs,eint8* fatname, FileLocation *loc, eui
|
||||
{
|
||||
euint32 c,fclus;
|
||||
euint8 *buf=0;
|
||||
|
||||
|
||||
if((fs->type != FAT12) && (fs->type != FAT16))return(0);
|
||||
|
||||
|
||||
for(c=fs->FirstSectorRootDir;c<(fs->FirstSectorRootDir+fs->volumeId.RootEntryCount/32);c++){
|
||||
buf = part_getSect(fs->part,c,IOM_MODE_READONLY);
|
||||
if((fclus=dir_findinBuf(buf,fatname,loc,mode))){
|
||||
if(loc)loc->Sector=c;
|
||||
part_relSect(fs->part,buf);
|
||||
return(fclus);
|
||||
}
|
||||
part_relSect(fs->part,buf);
|
||||
}
|
||||
part_relSect(fs->part,buf);
|
||||
}
|
||||
part_relSect(fs->part,buf);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint8 dir_getFatFileName(eint8* filename, eint8* fatfilename)
|
||||
* This function will take a full directory path, and strip off all leading
|
||||
* dirs and characters, leaving you with the MS-DOS notation of the actual filename.
|
||||
@@ -312,21 +312,21 @@ euint32 dir_findinRootArea(FileSystem *fs,eint8* fatname, FileLocation *loc, eui
|
||||
esint8 dir_getFatFileName(eint8* filename, eint8* fatfilename)
|
||||
{
|
||||
eint8 ffnamec[11],*next,nn=0;
|
||||
|
||||
|
||||
memClr(ffnamec,11); memClr(fatfilename,11);
|
||||
next = filename;
|
||||
|
||||
|
||||
if(*filename=='/')next++;
|
||||
|
||||
|
||||
while((next=file_normalToFatName(next,ffnamec))){
|
||||
memCpy(ffnamec,fatfilename,11);
|
||||
memCpy(ffnamec,fatfilename,11);
|
||||
nn++;
|
||||
}
|
||||
if(nn)return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint8 dir_addCluster(FileSystem *fs,euint32 firstCluster)
|
||||
* This function extends a directory by 1 cluster + optional the number of
|
||||
* clusters you want pre-allocated. It will also delete the contents of that
|
||||
@@ -337,7 +337,7 @@ esint8 dir_addCluster(FileSystem *fs,euint32 firstCluster)
|
||||
{
|
||||
euint32 lastc,logicalc;
|
||||
ClusterChain cache;
|
||||
|
||||
|
||||
fs_initClusterChain(fs,&cache,firstCluster);
|
||||
if(fat_allocClusterChain(fs,&cache,1)){
|
||||
return(-1);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "disc.h"
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void disc_initDisc(Disc *disc,hcInterface* source)
|
||||
* Description: This initialises the disc by loading the MBR and setting the
|
||||
* pointer to the hardware object.
|
||||
@@ -46,9 +46,9 @@ void disc_initDisc(Disc *disc,IOManager* ioman)
|
||||
disc_setError(disc,DISC_NOERROR);
|
||||
disc_loadMBR(disc);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void disc_loadMBR(Disc *disc)
|
||||
* Description: This functions copies the partitiontable to the partitions field.
|
||||
*/
|
||||
@@ -56,13 +56,13 @@ void disc_loadMBR(Disc *disc)
|
||||
{
|
||||
euint8 x;
|
||||
euint8 *buf;
|
||||
|
||||
|
||||
buf=ioman_getSector(disc->ioman,LBA_ADDR_MBR,IOM_MODE_READONLY|IOM_MODE_EXP_REQ);
|
||||
for(x=0;x<4;x++){
|
||||
ex_getPartitionField(buf,&(disc->partitions[x]),PARTITION_TABLE_OFFSET+(x*SIZE_PARTITION_FIELD));
|
||||
}
|
||||
ioman_releaseSector(disc->ioman,buf);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "efs.h"
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint8 efs_init(EmbeddedFileSystem * efs,eint8* opts)
|
||||
* Description: This function initialises all subelements of a filesystem.
|
||||
* It sets the pointerchain and verifies each step.
|
||||
@@ -51,7 +51,7 @@ esint8 efs_init(EmbeddedFileSystem * efs,eint8* opts)
|
||||
if(efs->myPart.activePartition==-1){
|
||||
efs->myDisc.partitions[0].type=0x0B;
|
||||
efs->myDisc.partitions[0].LBA_begin=0;
|
||||
efs->myDisc.partitions[0].numSectors=efs->myCard.sectorCount;
|
||||
efs->myDisc.partitions[0].numSectors=efs->myCard.sectorCount;
|
||||
/*efs->myPart.activePartition = 0;*/
|
||||
/*efs->myPart.disc = &(efs->myDisc);*/
|
||||
part_initPartition(&efs->myPart, &efs->myDisc);
|
||||
|
||||
@@ -35,16 +35,16 @@
|
||||
#include "fs.h"
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* unsigned long fat_getSectorAddressFatEntry(FileSystem *fs,unsigned long cluster_addr)
|
||||
* Description: Returns the sectornumber that holds the fat entry for cluster cluster_addr.
|
||||
* This works for all FAT types.
|
||||
* Return value: Sectornumber, or 0. Warning, no boundary check.
|
||||
*/
|
||||
euint32 fat_getSectorAddressFatEntry(FileSystem *fs,euint32 cluster_addr)
|
||||
{
|
||||
{
|
||||
euint32 base = fs->volumeId.ReservedSectorCount,res;
|
||||
|
||||
|
||||
switch(fs->type){
|
||||
case FAT12:
|
||||
res=(cluster_addr*3/1024);
|
||||
@@ -69,14 +69,14 @@ euint32 fat_getSectorAddressFatEntry(FileSystem *fs,euint32 cluster_addr)
|
||||
}else{
|
||||
return(base+res);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* unsigned long fat_getNextClusterAddress(FileSystem *fs,unsigned long cluster_addr
|
||||
* Description: This function loads the sector of the fat which contains the entry
|
||||
* for cluster_addr. It then fetches and (if required) calculates it's value.
|
||||
@@ -85,20 +85,20 @@ euint32 fat_getSectorAddressFatEntry(FileSystem *fs,euint32 cluster_addr)
|
||||
*/
|
||||
euint32 fat_getNextClusterAddress(FileSystem *fs,euint32 cluster_addr,euint16 *linear)
|
||||
{
|
||||
euint8 *buf;
|
||||
euint8 *buf;
|
||||
euint8 hb,lb;
|
||||
euint16 offset;
|
||||
euint32 sector;
|
||||
euint32 nextcluster=0;
|
||||
|
||||
|
||||
sector=fat_getSectorAddressFatEntry(fs,cluster_addr);
|
||||
if( (fs->FatSectorCount <= (sector-fs->volumeId.ReservedSectorCount)) || sector==0 )
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
buf=part_getSect(fs->part,sector,IOM_MODE_READONLY);
|
||||
|
||||
|
||||
switch(fs->type)
|
||||
{
|
||||
case FAT12:
|
||||
@@ -126,34 +126,34 @@ euint32 fat_getNextClusterAddress(FileSystem *fs,euint32 cluster_addr,euint16 *l
|
||||
nextcluster = *((euint32 *)buf + offset);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
part_relSect(fs->part,buf);
|
||||
|
||||
|
||||
return(nextcluster);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void fat_setNextClusterAddress(FileSystem *fs,unsigned long cluster_addr,unsigned long next_cluster_addr)
|
||||
* Description: This function makes an entry in the fattable for cluster_addr. The value it puts there
|
||||
* is next_cluster_addr.
|
||||
* is next_cluster_addr.
|
||||
*/
|
||||
void fat_setNextClusterAddress(FileSystem *fs,euint32 cluster_addr,euint32 next_cluster_addr)
|
||||
{
|
||||
euint8 *buf,*buf2;
|
||||
euint8 *buf,*buf2;
|
||||
euint16 offset;
|
||||
euint32 sector;
|
||||
|
||||
|
||||
sector=fat_getSectorAddressFatEntry(fs,cluster_addr);
|
||||
|
||||
|
||||
if(( fs->FatSectorCount <= (sector - fs->volumeId.ReservedSectorCount )||(sector==0))){
|
||||
DBG((TXT("HARDERROR:::fat_getNextClusterAddress READ PAST FAT BOUNDARY\n")));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
buf=part_getSect(fs->part,sector,IOM_MODE_READWRITE);
|
||||
|
||||
|
||||
switch(fs->type){
|
||||
case FAT12:
|
||||
offset = ((cluster_addr%1024)*3/2)%512;
|
||||
@@ -192,12 +192,12 @@ void fat_setNextClusterAddress(FileSystem *fs,euint32 cluster_addr,euint32 next_
|
||||
part_relSect(fs->part,buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* short fat_isEocMarker(FileSystem *fs,unsigned long fat_entry)
|
||||
* Description: Checks if a certain value is the EoC marker for the filesystem
|
||||
* noted in fs->type.
|
||||
@@ -224,10 +224,10 @@ eint16 fat_isEocMarker(FileSystem *fs,euint32 fat_entry)
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* unsigned long fat_giveEocMarker(FileSystem *fs)
|
||||
* Description: Returns an EoC markernumber valid for the filesystem noted in
|
||||
* fs->type.
|
||||
@@ -251,9 +251,9 @@ euint32 fat_giveEocMarker(FileSystem *fs)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 fat_getNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr, euint8* buf)
|
||||
* Description: This function retrieves the contents of a FAT field. It does not fetch
|
||||
* it's own buffer, it is given as a parameter. (ioman makes this function rather obsolete)
|
||||
@@ -266,7 +266,7 @@ euint32 fat_getNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr, euint
|
||||
euint8 hb,lb;
|
||||
euint16 offset;
|
||||
euint32 nextcluster=0;
|
||||
|
||||
|
||||
switch(fs->type)
|
||||
{
|
||||
case FAT12:
|
||||
@@ -296,9 +296,9 @@ euint32 fat_getNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr, euint
|
||||
}
|
||||
return(nextcluster);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void fat_setNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr,euint32 next_cluster_addr,euint8* buf)
|
||||
* Description: This function fills in a fat entry. The entry is cluster_addr and the
|
||||
* data entered is next_cluster_addr. This function is also given a *buf, so it does
|
||||
@@ -310,7 +310,7 @@ void fat_setNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr,euint32 n
|
||||
{
|
||||
euint16 offset;
|
||||
euint8 *buf2;
|
||||
|
||||
|
||||
switch(fs->type)
|
||||
{
|
||||
case FAT12:
|
||||
@@ -350,10 +350,10 @@ void fat_setNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr,euint32 n
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint16 fat_getNextClusterChain(FileSystem *fs, ClusterChain *Cache)
|
||||
* Description: This function is to advance the clusterchain of a Cache.
|
||||
* First, the function verifies if the Cache is valid. It could correct it if it
|
||||
* First, the function verifies if the Cache is valid. It could correct it if it
|
||||
* is not, but this is not done at the time. If the cachen is valid, the next step is
|
||||
* to see what the next cluster is, if this is the End of Clustermark, the cache is
|
||||
* updated to know the lastcluster but will remain untouched otherwise. -1 is returned.
|
||||
@@ -384,29 +384,29 @@ esint16 fat_getNextClusterChain(FileSystem *fs, ClusterChain *Cache)
|
||||
part_relSect(fs->part,buf);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
Cache->DiscCluster=dc;
|
||||
Cache->LogicCluster++;
|
||||
|
||||
|
||||
lr=Cache->DiscCluster-1;
|
||||
nlr=lr+1;
|
||||
|
||||
|
||||
while(nlr-1==lr && fat_getSectorAddressFatEntry(fs,nlr)==sect)
|
||||
{
|
||||
lr=nlr;
|
||||
nlr=fat_getNextClusterAddressWBuf(fs,lr,buf);
|
||||
lin++;
|
||||
lin++;
|
||||
}
|
||||
|
||||
|
||||
Cache->Linear=lin-1<0?0:lin-1;
|
||||
|
||||
|
||||
part_relSect(fs->part,buf);
|
||||
return(0);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint16 fat_LogicToDiscCluster(FileSystem *fs, ClusterChain *Cache,euint32 logiccluster)
|
||||
* Description: This function is used to follow clusterchains. When called it will convert
|
||||
* a logical cluster, to a disc cluster, using a Cache object. All it does is call
|
||||
@@ -422,11 +422,11 @@ esint16 fat_LogicToDiscCluster(FileSystem *fs, ClusterChain *Cache,euint32 logic
|
||||
Cache->DiscCluster=Cache->FirstCluster;
|
||||
Cache->Linear=0;
|
||||
}
|
||||
|
||||
|
||||
if(Cache->LogicCluster==logiccluster){
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
while(Cache->LogicCluster!=logiccluster)
|
||||
{
|
||||
if(Cache->Linear!=0)
|
||||
@@ -446,10 +446,10 @@ esint16 fat_LogicToDiscCluster(FileSystem *fs, ClusterChain *Cache,euint32 logic
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* eint16 fat_allocClusterChain(FileSystem *fs,ClusterChain *Cache,euint32 num_clusters)
|
||||
* Description: This function extends a clusterchain by num_clusters. It returns the
|
||||
* number of clusters it *failed* to allocate.
|
||||
* number of clusters it *failed* to allocate.
|
||||
* Return value: 0 on success, all other values are the number of clusters it could
|
||||
* not allocate.
|
||||
*/
|
||||
@@ -460,10 +460,10 @@ eint16 fat_allocClusterChain(FileSystem *fs,ClusterChain *Cache,euint32 num_clus
|
||||
euint8 overflow=0;
|
||||
|
||||
if(Cache->FirstCluster<=1)return(num_clusters);
|
||||
|
||||
|
||||
lc=fs_getLastCluster(fs,Cache);
|
||||
cc=lc;
|
||||
|
||||
|
||||
while(ncl > 0){
|
||||
cc++;
|
||||
if(cc>=fs->DataClusterCount+1){
|
||||
@@ -498,7 +498,7 @@ eint16 fat_allocClusterChain(FileSystem *fs,ClusterChain *Cache,euint32 num_clus
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* eint16 fat_unlinkClusterChain(FileSystem *fs,ClusterChain *Cache)
|
||||
* Description: This function removes a clusterchain. Starting at FirstCluster
|
||||
* it follows the chain until the end, resetting all values to 0.
|
||||
@@ -507,12 +507,12 @@ eint16 fat_allocClusterChain(FileSystem *fs,ClusterChain *Cache,euint32 num_clus
|
||||
eint16 fat_unlinkClusterChain(FileSystem *fs,ClusterChain *Cache)
|
||||
{
|
||||
euint32 c,tbd=0;
|
||||
|
||||
|
||||
Cache->LogicCluster=0;
|
||||
Cache->DiscCluster=Cache->FirstCluster;
|
||||
|
||||
|
||||
c=0;
|
||||
|
||||
|
||||
while(!fat_LogicToDiscCluster(fs,Cache,c++)){
|
||||
if(tbd!=0){
|
||||
fat_setNextClusterAddress(fs,tbd,0);
|
||||
@@ -520,7 +520,7 @@ eint16 fat_unlinkClusterChain(FileSystem *fs,ClusterChain *Cache)
|
||||
tbd=Cache->DiscCluster;
|
||||
}
|
||||
fat_setNextClusterAddress(fs,Cache->DiscCluster,0);
|
||||
fs->FreeClusterCount+=c;
|
||||
fs->FreeClusterCount+=c;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -528,14 +528,14 @@ euint32 fat_countClustersInChain(FileSystem *fs,euint32 firstcluster)
|
||||
{
|
||||
ClusterChain cache;
|
||||
euint32 c=0;
|
||||
|
||||
|
||||
if(firstcluster<=1)return(0);
|
||||
|
||||
|
||||
cache.DiscCluster = cache.LogicCluster = cache.LastCluster = cache.Linear = 0;
|
||||
cache.FirstCluster = firstcluster;
|
||||
|
||||
|
||||
while(!(fat_LogicToDiscCluster(fs,&cache,c++)));
|
||||
|
||||
|
||||
return(c-1);
|
||||
}
|
||||
|
||||
@@ -543,10 +543,10 @@ euint32 fat_DiscToLogicCluster(FileSystem *fs,euint32 firstcluster,euint32 discc
|
||||
{
|
||||
ClusterChain cache;
|
||||
euint32 c=0,r=0;
|
||||
|
||||
|
||||
cache.DiscCluster = cache.LogicCluster = cache.LastCluster = cache.Linear = 0;
|
||||
cache.FirstCluster = firstcluster;
|
||||
|
||||
|
||||
while(!(fat_LogicToDiscCluster(fs,&cache,c++)) && !r){
|
||||
if(cache.DiscCluster == disccluster){
|
||||
r = cache.LogicCluster;
|
||||
@@ -558,7 +558,7 @@ euint32 fat_DiscToLogicCluster(FileSystem *fs,euint32 firstcluster,euint32 discc
|
||||
euint32 fat_countFreeClusters(FileSystem *fs)
|
||||
{
|
||||
euint32 c=2,fc=0;
|
||||
|
||||
|
||||
while(c<=fs->DataClusterCount+1){
|
||||
if(fat_getNextClusterAddress(fs,c,0)==0)fc++;
|
||||
c++;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "file.h"
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 file_fread(File *file,euint32 offset, euint32 size,euint8 *buf)
|
||||
* Description: This function reads 'size' bytes from 'file' starting at
|
||||
* 'offset' and puts the result in '*buf'.
|
||||
@@ -49,21 +49,21 @@ euint32 file_fread(File *file,euint32 offset, euint32 size,euint8 *buf)
|
||||
euint32 rclus,rsec;
|
||||
euint32 btr;
|
||||
euint8 *tbuf;
|
||||
|
||||
|
||||
if(!file_getAttr(file,FILE_STATUS_OPEN))return(0);
|
||||
|
||||
|
||||
if(offset>=file->FileSize)
|
||||
size_left=0; /* Offset check */
|
||||
|
||||
|
||||
if( (offset+size > file->FileSize) && size_left!=0)
|
||||
size_left=file->FileSize-offset;
|
||||
|
||||
|
||||
while(size_left>0){
|
||||
|
||||
|
||||
cclus = coffset/(512*file->fs->volumeId.SectorsPerCluster);
|
||||
csec = (coffset/(512))%file->fs->volumeId.SectorsPerCluster;
|
||||
cbyte = coffset%512;
|
||||
|
||||
|
||||
if(cbyte!=0 || size_left<512){
|
||||
btr = 512-(coffset%512)>=size_left?size_left:512-(coffset%512);
|
||||
}else{
|
||||
@@ -75,8 +75,8 @@ euint32 file_fread(File *file,euint32 offset, euint32 size,euint8 *buf)
|
||||
}
|
||||
rclus=file->Cache.DiscCluster;
|
||||
rsec=fs_clusterToSector(file->fs,rclus);
|
||||
|
||||
|
||||
|
||||
|
||||
if(btr==512){
|
||||
/*part_readBuf(file->fs->part,rsec+csec,buf+bytes_read);*/
|
||||
part_directSectorRead(file->fs->part,rsec+csec,buf+bytes_read);
|
||||
@@ -86,17 +86,17 @@ euint32 file_fread(File *file,euint32 offset, euint32 size,euint8 *buf)
|
||||
memCpy(tbuf+(coffset%512),buf+bytes_read,btr);
|
||||
part_relSect(file->fs->part,tbuf);
|
||||
}
|
||||
|
||||
|
||||
coffset+=btr;
|
||||
bytes_read+=btr;
|
||||
size_left-=btr;
|
||||
}
|
||||
|
||||
|
||||
return(bytes_read);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 file_read (File *file,euint32 size,euint8 *buf)
|
||||
* Description: This function reads from a file, taking the FilePtr into account
|
||||
* and advancing it according to the freadcall.
|
||||
@@ -105,14 +105,14 @@ euint32 file_fread(File *file,euint32 offset, euint32 size,euint8 *buf)
|
||||
euint32 file_read(File *file,euint32 size,euint8 *buf)
|
||||
{
|
||||
euint32 r;
|
||||
|
||||
|
||||
r=file_fread(file,file->FilePtr,size,buf);
|
||||
file->FilePtr+=r;
|
||||
return(r);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 file_write(File *file, euint32 size,euint8 *buf)
|
||||
* Description: This function writes to a file, taking FilePtr into account
|
||||
* and advancing it according to the fwritecall.
|
||||
@@ -121,14 +121,14 @@ euint32 file_read(File *file,euint32 size,euint8 *buf)
|
||||
euint32 file_write(File *file, euint32 size,euint8 *buf)
|
||||
{
|
||||
euint32 r;
|
||||
|
||||
|
||||
r=file_fwrite(file,file->FilePtr,size,buf);
|
||||
file->FilePtr+=r;
|
||||
return(r);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint16 file_setpos(File *file,euint32 pos)
|
||||
* Description: This function does a sanity check on the requested position
|
||||
* and changes the fileptr accordingly.
|
||||
@@ -144,7 +144,7 @@ esint16 file_setpos(File *file,euint32 pos)
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint32 file_fwrite(File* file,euint32 offset,euint32 size,euint8* buf)
|
||||
* Description: This function writes to a file, at offset 'offset' and size 'size'.
|
||||
* It also updates the FileSize in the object, and discstructure.
|
||||
@@ -161,25 +161,25 @@ euint32 file_fwrite(File* file,euint32 offset,euint32 size,euint8* buf)
|
||||
euint8 *tbuf;
|
||||
|
||||
if(!file_getAttr(file,FILE_STATUS_OPEN) || !file_getAttr(file,FILE_STATUS_WRITE))return(0);
|
||||
|
||||
|
||||
if(offset>file->FileSize){
|
||||
offset=file->FileSize;
|
||||
}
|
||||
|
||||
|
||||
need_cluster = file_requiredCluster(file,offset,size);
|
||||
|
||||
|
||||
if(need_cluster){
|
||||
if(fat_allocClusterChain(file->fs,&(file->Cache),need_cluster+CLUSTER_PREALLOC_FILE)!=0){
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while(size_left>0){
|
||||
|
||||
|
||||
cclus = coffset/(512*file->fs->volumeId.SectorsPerCluster);
|
||||
csec = (coffset/(512))%file->fs->volumeId.SectorsPerCluster;
|
||||
cbyte = coffset%512;
|
||||
|
||||
|
||||
if(cbyte!=0 || size_left<512){
|
||||
btr = 512-(coffset%512)>=size_left?size_left:512-(coffset%512);
|
||||
}else{
|
||||
@@ -193,7 +193,7 @@ euint32 file_fwrite(File* file,euint32 offset,euint32 size,euint8* buf)
|
||||
}
|
||||
rclus=file->Cache.DiscCluster;
|
||||
rsec=fs_clusterToSector(file->fs,rclus);
|
||||
|
||||
|
||||
if(btr==512){
|
||||
/*part_writeBuf(file->fs->part,rsec+csec,buf+bytes_written);*/
|
||||
part_directSectorWrite(file->fs->part,rsec+csec,buf+bytes_written);
|
||||
@@ -204,23 +204,23 @@ euint32 file_fwrite(File* file,euint32 offset,euint32 size,euint8* buf)
|
||||
/*part_writeBuf(file->fs->part,rsec+csec,tbuf);*/
|
||||
part_relSect(file->fs->part,tbuf);
|
||||
}
|
||||
|
||||
|
||||
coffset+=btr;
|
||||
bytes_written+=btr;
|
||||
size_left-=btr;
|
||||
}
|
||||
|
||||
|
||||
if(bytes_written>file->FileSize-offset){
|
||||
file->FileSize+=bytes_written-(file->FileSize-offset);
|
||||
}
|
||||
|
||||
return(bytes_written);
|
||||
|
||||
return(bytes_written);
|
||||
}
|
||||
|
||||
/* ***************************************************************************\
|
||||
* signed eint8 file_fopen(FileSystem *fs,File* file,eint8* filename)
|
||||
* Description: This functions opens a file.
|
||||
* This function is about to be redesigned. No Docs.
|
||||
* signed eint8 file_fopen(FileSystem *fs,File* file,eint8* filename)
|
||||
* Description: This functions opens a file.
|
||||
* This function is about to be redesigned. No Docs.
|
||||
* Return value:
|
||||
*/
|
||||
esint8 file_fopen(File* file,FileSystem *fs,eint8* filename,eint8 mode)
|
||||
@@ -231,7 +231,7 @@ esint8 file_fopen(File* file,FileSystem *fs,eint8* filename,eint8 mode)
|
||||
euint32 sec;
|
||||
|
||||
dir_getFatFileName(filename,fatfilename);
|
||||
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case MODE_READ:
|
||||
@@ -320,7 +320,7 @@ esint8 file_fopen(File* file,FileSystem *fs,eint8* filename,eint8 mode)
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* esint8 file_fclose(File *file)
|
||||
* Description: This function closes a file, by clearing the object.
|
||||
* Return value: 0 on success.
|
||||
@@ -340,7 +340,7 @@ esint8 file_fclose(File *file)
|
||||
dir_setFileSize(file->fs,&(file->Location),file->FileSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
memClr(file,sizeof(*file));
|
||||
file_setAttr(file,FILE_STATUS_OPEN,0);
|
||||
file_setAttr(file,FILE_STATUS_WRITE,0);
|
||||
@@ -348,7 +348,7 @@ esint8 file_fclose(File *file)
|
||||
}
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void file_initFile(File *file, FileSystem *fs, FileLocation *loc)
|
||||
* Description: This function initialises a new file object, by filling in
|
||||
* the fs pointer, filesize (note, that DirEntry must already be filled in)
|
||||
@@ -363,18 +363,18 @@ void file_initFile(File *file, FileSystem *fs, FileLocation *loc)
|
||||
file->Location.Sector=loc->Sector;
|
||||
file->Location.Offset=loc->Offset;
|
||||
file->Cache.Linear=0;
|
||||
file->Cache.FirstCluster=(((euint32)file->DirEntry.FirstClusterHigh)<<16)+
|
||||
file->Cache.FirstCluster=(((euint32)file->DirEntry.FirstClusterHigh)<<16)+
|
||||
file->DirEntry.FirstClusterLow;
|
||||
file->Cache.LastCluster=0;
|
||||
file->Cache.LastCluster=0;
|
||||
file->Cache.LogicCluster=0;
|
||||
file->Cache.DiscCluster=file->Cache.FirstCluster;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint8* file_normalToFatName(eint8* filename,eint8* fatfilename)
|
||||
* Description: This function converts a human readable filename (limited to
|
||||
* 8.3 eint8 character) to a valid FAT (not VFAT) filename. Invalid characters are
|
||||
* Description: This function converts a human readable filename (limited to
|
||||
* 8.3 eint8 character) to a valid FAT (not VFAT) filename. Invalid characters are
|
||||
* changed to capital X and only the first 11 characters are used.
|
||||
* Furthermore all letters are capitalised.
|
||||
* Return value: pointer after the filename
|
||||
@@ -382,14 +382,14 @@ void file_initFile(File *file, FileSystem *fs, FileLocation *loc)
|
||||
eint8* file_normalToFatName(eint8* filename,eint8* fatfilename)
|
||||
{
|
||||
euint8 c,dot=0,vc=0;
|
||||
|
||||
|
||||
for(c=0;c<11;c++)fatfilename[c]=' ';
|
||||
|
||||
|
||||
c=0;
|
||||
|
||||
|
||||
if(*filename == '.'){
|
||||
fatfilename[0]='.';
|
||||
vc++;
|
||||
vc++;
|
||||
if(*(filename+1) == '.'){
|
||||
fatfilename[1]='.';
|
||||
filename+=2;
|
||||
@@ -405,7 +405,7 @@ eint8* file_normalToFatName(eint8* filename,eint8* fatfilename)
|
||||
if(dot){
|
||||
if(c<=10){
|
||||
fatfilename[c]=file_validateChar(*filename);
|
||||
c++;
|
||||
c++;
|
||||
}
|
||||
}else{
|
||||
if(c<=7){
|
||||
@@ -417,7 +417,7 @@ eint8* file_normalToFatName(eint8* filename,eint8* fatfilename)
|
||||
filename++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(vc>0){
|
||||
if(*filename=='\0'){
|
||||
return(filename);
|
||||
@@ -430,12 +430,12 @@ eint8* file_normalToFatName(eint8* filename,eint8* fatfilename)
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
*
|
||||
* Description: This function takes the character c, and if it is not a *
|
||||
* valid FAT Filename character returns X. If it is a lowercase letter the *
|
||||
* uppercase equivalent is returned. The remaining characters are returned *
|
||||
* as they are.
|
||||
* as they are.
|
||||
* Return value: The validated char
|
||||
*/
|
||||
euint8 file_validateChar(euint8 c)
|
||||
@@ -449,7 +449,7 @@ euint8 file_validateChar(euint8 c)
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* void ioman_setAttr(IOManager *ioman,euint16 bufplace,euint8 attribute,euint8 val)
|
||||
* Description: This sets the attribute of 'bufplace' to the given value (binary).
|
||||
*
|
||||
@@ -465,7 +465,7 @@ void file_setAttr(File* file,euint8 attribute,euint8 val)
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/* ****************************************************************************
|
||||
/* ****************************************************************************
|
||||
* euint8 ioman_getAttr(IOManager *ioman,euint16 bufplace,euint8 attribute)
|
||||
* Description: This function retrieves an attribute from the bufstat array.
|
||||
* It returns nonzero when it attribute is true and 0 when it is false.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user