Satellite Observers Workbench. NOT yet complete, just published for forum posters to \"cherry pick\" pieces of code as requiered as an example.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nexstar.h Source File

nexstar.h

00001 /****************************************************************************
00002  *    Copyright 2010 Andy Kirkham, Stellar Technologies Ltd
00003  *    
00004  *    This file is part of the Satellite Observers Workbench (SOWB).
00005  *
00006  *    SOWB is free software: you can redistribute it and/or modify
00007  *    it under the terms of the GNU General Public License as published by
00008  *    the Free Software Foundation, either version 3 of the License, or
00009  *    (at your option) any later version.
00010  *
00011  *    SOWB is distributed in the hope that it will be useful,
00012  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *    GNU General Public License for more details.
00015  *
00016  *    You should have received a copy of the GNU General Public License
00017  *    along with SOWB.  If not, see <http://www.gnu.org/licenses/>.
00018  *
00019  *    $Id: main.cpp 5 2010-07-12 20:51:11Z ajk $
00020  *    
00021  ***************************************************************************/
00022 
00023 #ifndef NEXSTAR_H
00024 #define NEXSTAR_H
00025 
00026 #ifndef NEXSTAR_C
00027 extern bool nexstar_aligned;
00028 #endif
00029 
00030 #define IS_NEXSTAR_ALIGNED nexstar_aligned
00031 
00032 #define NEXSTAR_INIT    0
00033 #define NEXSTAR_IDLE    1
00034 #define NEXSTAR_CMD     2
00035 
00036 /* Nexstar statuses. */
00037 #define NEXSTAR_STATE_NOT_CONN  -1
00038 #define NEXSTAR_STATE_IDLE      1
00039 #define NEXSTAR_STATE_BUSY      2
00040 
00041 /* Statuses for command packets. */
00042 #define NEXSTAR_SET_TRACKING        1
00043 #define NEXSTAR_GET_AZMALT          2
00044 #define NEXSTAR_GET_RADEC           3
00045 #define NEXSTAR_SET_ELEVATION_RATE  4
00046 #define NEXSTAR_SET_AZMITH_RATE     5
00047 #define NEXSTAR_GOTO                6
00048 #define NEXSTAR_SET_APPROACH        7
00049 #define NEXSTAR_GOTO_AZM_FAST       8
00050 #define NEXSTAR_GOTO_ELE_FAST       9
00051 #define NEXSTAR_IS_ALIGNED          10
00052 #define NEXSTAR_SET_TIME            11
00053 #define NEXSTAR_SET_LOCATION        12
00054 #define NEXSTAR_SYNC                13
00055 
00056 #define NEXSTAR_BUFFER_SIZE  16
00057 #define NEXSTAR_SERIAL_TIMEOUT  350
00058 
00059 /* API functions. */
00060 void nexstar_get_elazm(double *el, double *azm);
00061 
00062 /* Function prototypes. */
00063 int _nexstar_set_tracking_mode(int mode);
00064 int _nexstar_get_altazm(void);
00065 int _nexstar_get_radec(void);
00066 void _nexstar_set_elevation_rate_coarse(double rate);
00067 void _nexstar_set_elevation_rate_fine(double rate);
00068 void _nexstar_set_elevation_rate_auto(double rate);
00069 void _nexstar_set_azmith_rate_coarse(double rate);
00070 void _nexstar_set_azmith_rate_fine(double rate);
00071 void _nexstar_set_azmith_rate_auto(double rate);
00072 
00073 int _nexstar_set_elevation_rate(void);
00074 int _nexstar_set_azmith_rate(void);
00075 void _nexstar_set_azm_approach(int approach);
00076 
00077 int _nexstar_goto(uint32_t, uint32_t);
00078 int _nexstar_goto_azm_fast(uint32_t azmith);
00079 
00080 #include "gps.h"
00081 void _nexstar_set_time(GPS_TIME *t);
00082 void _nexstar_set_location(GPS_LOCATION_AVERAGE *l);
00083 
00084 #include "satapi.h"
00085 void _nexstar_sync(RaDec *);
00086 
00087 double nexstar_get_rate_azm(void);
00088 double nexstar_get_rate_alt(void);
00089 
00090 bool _nexstar_is_aligned(void);
00091 
00092 /* Defined in nexstar_align.c */
00093 void nexstar_force_align(void);
00094 
00095 /* Macros */
00096             
00097 /* Used to test the IIR register. Common across UARTs. */
00098 #define UART_ISSET_THRE              0x0002
00099 #define UART_ISSET_RDA               0x0004
00100 #define UART_ISSET_CTI               0x000C
00101 #define UART_ISSET_RLS               0x0006
00102 #define UART_ISSET_FIFOLVL_RXFULL    0x0000000F
00103 #define UART_ISSET_FIFOLVL_TXFULL    0x00000F00
00104 
00105 /* UART2 peripheral control masks. */
00106 #define UART2_ORMASK_PCONP      0x01000000
00107 #define UART2_ORMASK_PCLKSEL1   0x00010000
00108 #define UART2_ORMASK_PINMODE0   0x00A00000
00109 #define UART2_ORMASK_PINSEL0    0x00500000
00110 
00111 /* UART2 register configuration values. */
00112 #define UART2_SET_LCR           0x00000003
00113 #define UART2_SET_LCR_DLAB      0x00000083
00114 #define UART2_SET_DLLSB         0x71
00115 #define UART2_SET_DLMSB         0x02
00116 #define UART2_SET_FCR           0x01
00117 #define UART2_SET_FCR_CLEAR     0x07
00118 #define UART2_SET_IER           0x01
00119 
00120 /* Standard API functions. */
00121 void nexstar_init(void);
00122 void nexstar_process(void);
00123 
00124 /* endif NEXSTAR_H */
00125 #endif
00126