Satellite Observers Workbench. NOT yet complete, just published for forum posters to \"cherry pick\" pieces of code as requiered as an example.
nexstar/nexstar.h@0:0a841b89d614, 2010-10-11 (annotated)
- Committer:
- AjK
- Date:
- Mon Oct 11 10:34:55 2010 +0000
- Revision:
- 0:0a841b89d614
Totally Alpha quality as this project isn\t completed. Just publishing it as it answers many questions asked in the forums
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AjK | 0:0a841b89d614 | 1 | /**************************************************************************** |
AjK | 0:0a841b89d614 | 2 | * Copyright 2010 Andy Kirkham, Stellar Technologies Ltd |
AjK | 0:0a841b89d614 | 3 | * |
AjK | 0:0a841b89d614 | 4 | * This file is part of the Satellite Observers Workbench (SOWB). |
AjK | 0:0a841b89d614 | 5 | * |
AjK | 0:0a841b89d614 | 6 | * SOWB is free software: you can redistribute it and/or modify |
AjK | 0:0a841b89d614 | 7 | * it under the terms of the GNU General Public License as published by |
AjK | 0:0a841b89d614 | 8 | * the Free Software Foundation, either version 3 of the License, or |
AjK | 0:0a841b89d614 | 9 | * (at your option) any later version. |
AjK | 0:0a841b89d614 | 10 | * |
AjK | 0:0a841b89d614 | 11 | * SOWB is distributed in the hope that it will be useful, |
AjK | 0:0a841b89d614 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
AjK | 0:0a841b89d614 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
AjK | 0:0a841b89d614 | 14 | * GNU General Public License for more details. |
AjK | 0:0a841b89d614 | 15 | * |
AjK | 0:0a841b89d614 | 16 | * You should have received a copy of the GNU General Public License |
AjK | 0:0a841b89d614 | 17 | * along with SOWB. If not, see <http://www.gnu.org/licenses/>. |
AjK | 0:0a841b89d614 | 18 | * |
AjK | 0:0a841b89d614 | 19 | * $Id: main.cpp 5 2010-07-12 20:51:11Z ajk $ |
AjK | 0:0a841b89d614 | 20 | * |
AjK | 0:0a841b89d614 | 21 | ***************************************************************************/ |
AjK | 0:0a841b89d614 | 22 | |
AjK | 0:0a841b89d614 | 23 | #ifndef NEXSTAR_H |
AjK | 0:0a841b89d614 | 24 | #define NEXSTAR_H |
AjK | 0:0a841b89d614 | 25 | |
AjK | 0:0a841b89d614 | 26 | #ifndef NEXSTAR_C |
AjK | 0:0a841b89d614 | 27 | extern bool nexstar_aligned; |
AjK | 0:0a841b89d614 | 28 | #endif |
AjK | 0:0a841b89d614 | 29 | |
AjK | 0:0a841b89d614 | 30 | #define IS_NEXSTAR_ALIGNED nexstar_aligned |
AjK | 0:0a841b89d614 | 31 | |
AjK | 0:0a841b89d614 | 32 | #define NEXSTAR_INIT 0 |
AjK | 0:0a841b89d614 | 33 | #define NEXSTAR_IDLE 1 |
AjK | 0:0a841b89d614 | 34 | #define NEXSTAR_CMD 2 |
AjK | 0:0a841b89d614 | 35 | |
AjK | 0:0a841b89d614 | 36 | /* Nexstar statuses. */ |
AjK | 0:0a841b89d614 | 37 | #define NEXSTAR_STATE_NOT_CONN -1 |
AjK | 0:0a841b89d614 | 38 | #define NEXSTAR_STATE_IDLE 1 |
AjK | 0:0a841b89d614 | 39 | #define NEXSTAR_STATE_BUSY 2 |
AjK | 0:0a841b89d614 | 40 | |
AjK | 0:0a841b89d614 | 41 | /* Statuses for command packets. */ |
AjK | 0:0a841b89d614 | 42 | #define NEXSTAR_SET_TRACKING 1 |
AjK | 0:0a841b89d614 | 43 | #define NEXSTAR_GET_AZMALT 2 |
AjK | 0:0a841b89d614 | 44 | #define NEXSTAR_GET_RADEC 3 |
AjK | 0:0a841b89d614 | 45 | #define NEXSTAR_SET_ELEVATION_RATE 4 |
AjK | 0:0a841b89d614 | 46 | #define NEXSTAR_SET_AZMITH_RATE 5 |
AjK | 0:0a841b89d614 | 47 | #define NEXSTAR_GOTO 6 |
AjK | 0:0a841b89d614 | 48 | #define NEXSTAR_SET_APPROACH 7 |
AjK | 0:0a841b89d614 | 49 | #define NEXSTAR_GOTO_AZM_FAST 8 |
AjK | 0:0a841b89d614 | 50 | #define NEXSTAR_GOTO_ELE_FAST 9 |
AjK | 0:0a841b89d614 | 51 | #define NEXSTAR_IS_ALIGNED 10 |
AjK | 0:0a841b89d614 | 52 | #define NEXSTAR_SET_TIME 11 |
AjK | 0:0a841b89d614 | 53 | #define NEXSTAR_SET_LOCATION 12 |
AjK | 0:0a841b89d614 | 54 | #define NEXSTAR_SYNC 13 |
AjK | 0:0a841b89d614 | 55 | |
AjK | 0:0a841b89d614 | 56 | #define NEXSTAR_BUFFER_SIZE 16 |
AjK | 0:0a841b89d614 | 57 | #define NEXSTAR_SERIAL_TIMEOUT 350 |
AjK | 0:0a841b89d614 | 58 | |
AjK | 0:0a841b89d614 | 59 | /* API functions. */ |
AjK | 0:0a841b89d614 | 60 | void nexstar_get_elazm(double *el, double *azm); |
AjK | 0:0a841b89d614 | 61 | |
AjK | 0:0a841b89d614 | 62 | /* Function prototypes. */ |
AjK | 0:0a841b89d614 | 63 | int _nexstar_set_tracking_mode(int mode); |
AjK | 0:0a841b89d614 | 64 | int _nexstar_get_altazm(void); |
AjK | 0:0a841b89d614 | 65 | int _nexstar_get_radec(void); |
AjK | 0:0a841b89d614 | 66 | void _nexstar_set_elevation_rate_coarse(double rate); |
AjK | 0:0a841b89d614 | 67 | void _nexstar_set_elevation_rate_fine(double rate); |
AjK | 0:0a841b89d614 | 68 | void _nexstar_set_elevation_rate_auto(double rate); |
AjK | 0:0a841b89d614 | 69 | void _nexstar_set_azmith_rate_coarse(double rate); |
AjK | 0:0a841b89d614 | 70 | void _nexstar_set_azmith_rate_fine(double rate); |
AjK | 0:0a841b89d614 | 71 | void _nexstar_set_azmith_rate_auto(double rate); |
AjK | 0:0a841b89d614 | 72 | |
AjK | 0:0a841b89d614 | 73 | int _nexstar_set_elevation_rate(void); |
AjK | 0:0a841b89d614 | 74 | int _nexstar_set_azmith_rate(void); |
AjK | 0:0a841b89d614 | 75 | void _nexstar_set_azm_approach(int approach); |
AjK | 0:0a841b89d614 | 76 | |
AjK | 0:0a841b89d614 | 77 | int _nexstar_goto(uint32_t, uint32_t); |
AjK | 0:0a841b89d614 | 78 | int _nexstar_goto_azm_fast(uint32_t azmith); |
AjK | 0:0a841b89d614 | 79 | |
AjK | 0:0a841b89d614 | 80 | #include "gps.h" |
AjK | 0:0a841b89d614 | 81 | void _nexstar_set_time(GPS_TIME *t); |
AjK | 0:0a841b89d614 | 82 | void _nexstar_set_location(GPS_LOCATION_AVERAGE *l); |
AjK | 0:0a841b89d614 | 83 | |
AjK | 0:0a841b89d614 | 84 | #include "satapi.h" |
AjK | 0:0a841b89d614 | 85 | void _nexstar_sync(RaDec *); |
AjK | 0:0a841b89d614 | 86 | |
AjK | 0:0a841b89d614 | 87 | double nexstar_get_rate_azm(void); |
AjK | 0:0a841b89d614 | 88 | double nexstar_get_rate_alt(void); |
AjK | 0:0a841b89d614 | 89 | |
AjK | 0:0a841b89d614 | 90 | bool _nexstar_is_aligned(void); |
AjK | 0:0a841b89d614 | 91 | |
AjK | 0:0a841b89d614 | 92 | /* Defined in nexstar_align.c */ |
AjK | 0:0a841b89d614 | 93 | void nexstar_force_align(void); |
AjK | 0:0a841b89d614 | 94 | |
AjK | 0:0a841b89d614 | 95 | /* Macros */ |
AjK | 0:0a841b89d614 | 96 | |
AjK | 0:0a841b89d614 | 97 | /* Used to test the IIR register. Common across UARTs. */ |
AjK | 0:0a841b89d614 | 98 | #define UART_ISSET_THRE 0x0002 |
AjK | 0:0a841b89d614 | 99 | #define UART_ISSET_RDA 0x0004 |
AjK | 0:0a841b89d614 | 100 | #define UART_ISSET_CTI 0x000C |
AjK | 0:0a841b89d614 | 101 | #define UART_ISSET_RLS 0x0006 |
AjK | 0:0a841b89d614 | 102 | #define UART_ISSET_FIFOLVL_RXFULL 0x0000000F |
AjK | 0:0a841b89d614 | 103 | #define UART_ISSET_FIFOLVL_TXFULL 0x00000F00 |
AjK | 0:0a841b89d614 | 104 | |
AjK | 0:0a841b89d614 | 105 | /* UART2 peripheral control masks. */ |
AjK | 0:0a841b89d614 | 106 | #define UART2_ORMASK_PCONP 0x01000000 |
AjK | 0:0a841b89d614 | 107 | #define UART2_ORMASK_PCLKSEL1 0x00010000 |
AjK | 0:0a841b89d614 | 108 | #define UART2_ORMASK_PINMODE0 0x00A00000 |
AjK | 0:0a841b89d614 | 109 | #define UART2_ORMASK_PINSEL0 0x00500000 |
AjK | 0:0a841b89d614 | 110 | |
AjK | 0:0a841b89d614 | 111 | /* UART2 register configuration values. */ |
AjK | 0:0a841b89d614 | 112 | #define UART2_SET_LCR 0x00000003 |
AjK | 0:0a841b89d614 | 113 | #define UART2_SET_LCR_DLAB 0x00000083 |
AjK | 0:0a841b89d614 | 114 | #define UART2_SET_DLLSB 0x71 |
AjK | 0:0a841b89d614 | 115 | #define UART2_SET_DLMSB 0x02 |
AjK | 0:0a841b89d614 | 116 | #define UART2_SET_FCR 0x01 |
AjK | 0:0a841b89d614 | 117 | #define UART2_SET_FCR_CLEAR 0x07 |
AjK | 0:0a841b89d614 | 118 | #define UART2_SET_IER 0x01 |
AjK | 0:0a841b89d614 | 119 | |
AjK | 0:0a841b89d614 | 120 | /* Standard API functions. */ |
AjK | 0:0a841b89d614 | 121 | void nexstar_init(void); |
AjK | 0:0a841b89d614 | 122 | void nexstar_process(void); |
AjK | 0:0a841b89d614 | 123 | |
AjK | 0:0a841b89d614 | 124 | /* endif NEXSTAR_H */ |
AjK | 0:0a841b89d614 | 125 | #endif |
AjK | 0:0a841b89d614 | 126 |