From 9f3ee94f881e6b8fb0cf642c49f213955a187fc0 Mon Sep 17 00:00:00 2001 From: Spitzbube Date: Sat, 26 Dec 2020 17:00:35 +0100 Subject: [PATCH] add freertos_app --- FreeRTOS/Makefile | 115 + FreeRTOS/include/FreeRTOS.h | 1345 ++++ FreeRTOS/include/deprecated_definitions.h | 279 + FreeRTOS/include/list.h | 417 ++ FreeRTOS/include/mpu_wrappers.h | 187 + FreeRTOS/include/portable.h | 216 + FreeRTOS/include/projdefs.h | 120 + FreeRTOS/include/queue.h | 1716 +++++ FreeRTOS/include/stack_macros.h | 127 + FreeRTOS/include/task.h | 3053 +++++++++ FreeRTOS/include/timers.h | 1351 ++++ FreeRTOS/list.c | 210 + FreeRTOS/portable/Makefile | 88 + FreeRTOS/portable/MemMang/ReadMe.url | 5 + FreeRTOS/portable/MemMang/heap_1.c | 144 + FreeRTOS/portable/MemMang/heap_2.c | 274 + FreeRTOS/portable/MemMang/heap_3.c | 94 + FreeRTOS/portable/MemMang/heap_4.c | 494 ++ FreeRTOS/portable/MemMang/heap_5.c | 550 ++ FreeRTOS/portable/RVDS/ARM7_LPC21xx/Makefile | 52 + FreeRTOS/portable/RVDS/ARM7_LPC21xx/port.c | 291 + FreeRTOS/portable/RVDS/ARM7_LPC21xx/portASM.s | 124 + .../portable/RVDS/ARM7_LPC21xx/portmacro.h | 149 + .../portable/RVDS/ARM7_LPC21xx/portmacro.inc | 91 + FreeRTOS/portable/RVDS/Makefile | 88 + FreeRTOS/queue.c | 3013 +++++++++ FreeRTOS/tasks.c | 5395 +++++++++++++++ Makefile | 1 + applications/Makefile | 1 + applications/freertos_app/Handle0Key.c | 432 ++ applications/freertos_app/Handle1Key.c | 278 + applications/freertos_app/Handle2Key.c | 319 + applications/freertos_app/Handle3Key.c | 322 + applications/freertos_app/Handle4Key.c | 322 + applications/freertos_app/Handle5Key.c | 322 + applications/freertos_app/Handle6Key.c | 322 + applications/freertos_app/Handle7Key.c | 335 + applications/freertos_app/Handle8Key.c | 324 + applications/freertos_app/Handle9Key.c | 359 + applications/freertos_app/HandleDownKey.c | 1144 ++++ applications/freertos_app/HandleEnterKey.c | 1656 +++++ applications/freertos_app/HandleHelpKey.c | 779 +++ applications/freertos_app/HandleLeftKey.c | 1210 ++++ applications/freertos_app/HandleMinusKey.c | 1065 +++ applications/freertos_app/HandleRightKey.c | 1276 ++++ applications/freertos_app/HandleUpKey.c | 1452 ++++ applications/freertos_app/HelpScreen.c | 489 ++ applications/freertos_app/Makefile | 71 + applications/freertos_app/Startup.s | 429 ++ applications/freertos_app/align_stars.c | 235 + applications/freertos_app/alignment.c | 519 ++ applications/freertos_app/ascom.c | 291 + applications/freertos_app/data.c | 687 ++ applications/freertos_app/data.h | 807 +++ applications/freertos_app/earth.c | 89 + applications/freertos_app/file_1f30.c | 5987 +++++++++++++++++ applications/freertos_app/file_5099c.c | 61 + applications/freertos_app/file_79080.c | 1018 +++ applications/freertos_app/func_23130.c | 935 +++ applications/freertos_app/func_27844.c | 5871 ++++++++++++++++ applications/freertos_app/func_3d72c.c | 3177 +++++++++ applications/freertos_app/jupiter.c | 112 + applications/freertos_app/language.c | 966 +++ applications/freertos_app/macros.h | 10 + applications/freertos_app/main.c | 5678 ++++++++++++++++ applications/freertos_app/mars.c | 90 + applications/freertos_app/menu.h | 194 + applications/freertos_app/mercury.c | 108 + applications/freertos_app/my_types.h | 232 + applications/freertos_app/neptun.c | 81 + applications/freertos_app/object_database.c | 429 ++ applications/freertos_app/pluto.c | 77 + applications/freertos_app/saturn.c | 114 + applications/freertos_app/slew1.c | 311 + applications/freertos_app/slew2.c | 677 ++ applications/freertos_app/uart.c | 431 ++ applications/freertos_app/uranus.c | 98 + applications/freertos_app/venus.c | 81 + applications/v2.3/Makefile | 2 +- env/FreeRTOSConfig.h | 77 + env/LPC214x.h | 364 + env/Makefile | 5 +- env/make/Makefile.common | 5 + env/make/Makefile.rules | 43 +- env/make/Makefile.target.arm7-realview | 6 + 85 files changed, 62760 insertions(+), 4 deletions(-) create mode 100644 FreeRTOS/Makefile create mode 100644 FreeRTOS/include/FreeRTOS.h create mode 100644 FreeRTOS/include/deprecated_definitions.h create mode 100644 FreeRTOS/include/list.h create mode 100644 FreeRTOS/include/mpu_wrappers.h create mode 100644 FreeRTOS/include/portable.h create mode 100644 FreeRTOS/include/projdefs.h create mode 100644 FreeRTOS/include/queue.h create mode 100644 FreeRTOS/include/stack_macros.h create mode 100644 FreeRTOS/include/task.h create mode 100644 FreeRTOS/include/timers.h create mode 100644 FreeRTOS/list.c create mode 100644 FreeRTOS/portable/Makefile create mode 100644 FreeRTOS/portable/MemMang/ReadMe.url create mode 100644 FreeRTOS/portable/MemMang/heap_1.c create mode 100644 FreeRTOS/portable/MemMang/heap_2.c create mode 100644 FreeRTOS/portable/MemMang/heap_3.c create mode 100644 FreeRTOS/portable/MemMang/heap_4.c create mode 100644 FreeRTOS/portable/MemMang/heap_5.c create mode 100644 FreeRTOS/portable/RVDS/ARM7_LPC21xx/Makefile create mode 100644 FreeRTOS/portable/RVDS/ARM7_LPC21xx/port.c create mode 100644 FreeRTOS/portable/RVDS/ARM7_LPC21xx/portASM.s create mode 100644 FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.h create mode 100644 FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.inc create mode 100644 FreeRTOS/portable/RVDS/Makefile create mode 100644 FreeRTOS/queue.c create mode 100644 FreeRTOS/tasks.c create mode 100644 applications/freertos_app/Handle0Key.c create mode 100644 applications/freertos_app/Handle1Key.c create mode 100644 applications/freertos_app/Handle2Key.c create mode 100644 applications/freertos_app/Handle3Key.c create mode 100644 applications/freertos_app/Handle4Key.c create mode 100644 applications/freertos_app/Handle5Key.c create mode 100644 applications/freertos_app/Handle6Key.c create mode 100644 applications/freertos_app/Handle7Key.c create mode 100644 applications/freertos_app/Handle8Key.c create mode 100644 applications/freertos_app/Handle9Key.c create mode 100644 applications/freertos_app/HandleDownKey.c create mode 100644 applications/freertos_app/HandleEnterKey.c create mode 100644 applications/freertos_app/HandleHelpKey.c create mode 100644 applications/freertos_app/HandleLeftKey.c create mode 100644 applications/freertos_app/HandleMinusKey.c create mode 100644 applications/freertos_app/HandleRightKey.c create mode 100644 applications/freertos_app/HandleUpKey.c create mode 100644 applications/freertos_app/HelpScreen.c create mode 100644 applications/freertos_app/Makefile create mode 100644 applications/freertos_app/Startup.s create mode 100644 applications/freertos_app/align_stars.c create mode 100644 applications/freertos_app/alignment.c create mode 100644 applications/freertos_app/ascom.c create mode 100644 applications/freertos_app/data.c create mode 100644 applications/freertos_app/data.h create mode 100644 applications/freertos_app/earth.c create mode 100644 applications/freertos_app/file_1f30.c create mode 100644 applications/freertos_app/file_5099c.c create mode 100644 applications/freertos_app/file_79080.c create mode 100644 applications/freertos_app/func_23130.c create mode 100644 applications/freertos_app/func_27844.c create mode 100644 applications/freertos_app/func_3d72c.c create mode 100644 applications/freertos_app/jupiter.c create mode 100644 applications/freertos_app/language.c create mode 100644 applications/freertos_app/macros.h create mode 100644 applications/freertos_app/main.c create mode 100644 applications/freertos_app/mars.c create mode 100644 applications/freertos_app/menu.h create mode 100644 applications/freertos_app/mercury.c create mode 100644 applications/freertos_app/my_types.h create mode 100644 applications/freertos_app/neptun.c create mode 100644 applications/freertos_app/object_database.c create mode 100644 applications/freertos_app/pluto.c create mode 100644 applications/freertos_app/saturn.c create mode 100644 applications/freertos_app/slew1.c create mode 100644 applications/freertos_app/slew2.c create mode 100644 applications/freertos_app/uart.c create mode 100644 applications/freertos_app/uranus.c create mode 100644 applications/freertos_app/venus.c create mode 100644 env/FreeRTOSConfig.h create mode 100644 env/LPC214x.h diff --git a/FreeRTOS/Makefile b/FreeRTOS/Makefile new file mode 100644 index 0000000..a331200 --- /dev/null +++ b/FreeRTOS/Makefile @@ -0,0 +1,115 @@ +################################################################################ +################################################################################ +## +## Makefile -- makefile for FreeRTOS modules. +## +## Mandatory settings: +## +## o TOPDIR = the toplevel directory (using slashes as path separator) +## o TARGET = the machine qualifier to generate code for +## o DIRECTORIES = the list of sub directories to build +## +################################################################################ +################################################################################ + + TOPDIR = .. + SUBDIR = FreeRTOS + +include $(TOPDIR)/env/make/Makefile.config + +################################################################################ +# project specific settings +################################################################################ + + DIRECTORIES += portable + + LIBRARY = libFreeRTOS + +################################################################################ +# source files +################################################################################ + +HEADERS += include/FreeRTOS.h +HEADERS += include/deprecated_definitions.h +HEADERS += include/list.h +HEADERS += include/mpu_wrappers.h +HEADERS += include/portable.h +HEADERS += include/projdefs.h +HEADERS += include/stack_macros.h +HEADERS += include/task.h +HEADERS += include/timers.h +HEADERS += include/queue.h + +SOURCES += portable/MemMang/heap_1.c +SOURCES += portable/MemMang/heap_2.c +SOURCES += portable/MemMang/heap_3.c +SOURCES += portable/MemMang/heap_4.c +SOURCES += portable/MemMang/heap_5.c + +SOURCES += list.c +SOURCES += queue.c +SOURCES += tasks.c + +################################################################################ +# define user targets +################################################################################ + +default: all + +clean: clean-objects clean-library $(DIRECTORIES:%=subdir-clean-%) + +build: build-objects build-library $(DIRECTORIES:%=subdir-build-%) + +headers: install-headers $(DIRECTORIES:%=subdir-headers-%) + +install: build install-library $(DIRECTORIES:%=subdir-install-%) + +depend: $(DIRECTORIES:%=subdir-depend-%) + +all: clean build install + +################################################################################ +# include internal definitions and rules +################################################################################ + +include $(TOPDIR)/env/make/Makefile.rules + +################################################################################ +# local directory specific rules +################################################################################ + +subdir-clean-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking clean [$(SUBDIR)/$(@:subdir-clean-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-clean-%=%) clean TARGET=$(TARGET) + +subdir-depend-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking depend [$(SUBDIR)/$(@:subdir-depend-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-depend-%=%) depend TARGET=$(TARGET) + +subdir-headers-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking headers [$(SUBDIR)/$(@:subdir-headers-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-headers-%=%) headers TARGET=$(TARGET) + +subdir-build-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking build [$(SUBDIR)/$(@:subdir-build-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-build-%=%) build TARGET=$(TARGET) + +subdir-install-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking install [$(SUBDIR)/$(@:subdir-install-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-install-%=%) install TARGET=$(TARGET) + +subdir-release-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking release [$(SUBDIR)/$(@:subdir-release-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-release-%=%) release TARGET=$(TARGET) + +subdir-doc-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking doc [$(SUBDIR)/$(@:subdir-doc-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-doc-%=%) doc TARGET=$(TARGET) + diff --git a/FreeRTOS/include/FreeRTOS.h b/FreeRTOS/include/FreeRTOS.h new file mode 100644 index 0000000..093e0b5 --- /dev/null +++ b/FreeRTOS/include/FreeRTOS.h @@ -0,0 +1,1345 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef INC_FREERTOS_H +#define INC_FREERTOS_H + +/* + * Include the generic headers required for the FreeRTOS port being used. + */ +#include + +/* + * If stdint.h cannot be located then: + * + If using GCC ensure the -nostdint options is *not* being used. + * + Ensure the project's include path includes the directory in which your + * compiler stores stdint.h. + * + Set any compiler options necessary for it to support C99, as technically + * stdint.h is only mandatory with C99 (FreeRTOS does not require C99 in any + * other way). + * + The FreeRTOS download includes a simple stdint.h definition that can be + * used in cases where none is provided by the compiler. The files only + * contains the typedefs required to build FreeRTOS. Read the instructions + * in FreeRTOS/source/stdint.readme for more information. + */ +#include /* READ COMMENT ABOVE. */ + +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +/* Application specific configuration options. */ +#include "FreeRTOSConfig.h" + +/* Basic FreeRTOS definitions. */ +#include "projdefs.h" + +/* Definitions specific to the port being used. */ +#include "portable.h" + +/* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */ +#ifndef configUSE_NEWLIB_REENTRANT + #define configUSE_NEWLIB_REENTRANT 0 +#endif + +/* Required if struct _reent is used. */ +#if ( configUSE_NEWLIB_REENTRANT == 1 ) + #include +#endif + +/* + * Check all the required application specific macros have been defined. + * These macros are application specific and (as downloaded) are defined + * within FreeRTOSConfig.h. + */ + +#ifndef configMINIMAL_STACK_SIZE + #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. +#endif + +#ifndef configMAX_PRIORITIES + #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#if configMAX_PRIORITIES < 1 + #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. +#endif + +#ifndef configUSE_PREEMPTION + #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_IDLE_HOOK + #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_TICK_HOOK + #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_16_BIT_TICKS + #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_CO_ROUTINES + #define configUSE_CO_ROUTINES 0 +#endif + +#ifndef INCLUDE_vTaskPrioritySet + #define INCLUDE_vTaskPrioritySet 0 +#endif + +#ifndef INCLUDE_uxTaskPriorityGet + #define INCLUDE_uxTaskPriorityGet 0 +#endif + +#ifndef INCLUDE_vTaskDelete + #define INCLUDE_vTaskDelete 0 +#endif + +#ifndef INCLUDE_vTaskSuspend + #define INCLUDE_vTaskSuspend 0 +#endif + +#ifdef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil. Backward + * compatibility is maintained if only one or the other is defined, but + * there is a conflict if both are defined. */ + #error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined. INCLUDE_vTaskDelayUntil is no longer required and should be removed + #endif +#endif + +#ifndef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then + * the project's FreeRTOSConfig.h probably pre-dates the introduction of + * xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever + * INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility. + */ + #define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil + #endif +#endif + +#ifndef INCLUDE_xTaskDelayUntil + #define INCLUDE_xTaskDelayUntil 0 +#endif + +#ifndef INCLUDE_vTaskDelay + #define INCLUDE_vTaskDelay 0 +#endif + +#ifndef INCLUDE_xTaskGetIdleTaskHandle + #define INCLUDE_xTaskGetIdleTaskHandle 0 +#endif + +#ifndef INCLUDE_xTaskAbortDelay + #define INCLUDE_xTaskAbortDelay 0 +#endif + +#ifndef INCLUDE_xQueueGetMutexHolder + #define INCLUDE_xQueueGetMutexHolder 0 +#endif + +#ifndef INCLUDE_xSemaphoreGetMutexHolder + #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder +#endif + +#ifndef INCLUDE_xTaskGetHandle + #define INCLUDE_xTaskGetHandle 0 +#endif + +#ifndef INCLUDE_uxTaskGetStackHighWaterMark + #define INCLUDE_uxTaskGetStackHighWaterMark 0 +#endif + +#ifndef INCLUDE_uxTaskGetStackHighWaterMark2 + #define INCLUDE_uxTaskGetStackHighWaterMark2 0 +#endif + +#ifndef INCLUDE_eTaskGetState + #define INCLUDE_eTaskGetState 0 +#endif + +#ifndef INCLUDE_xTaskResumeFromISR + #define INCLUDE_xTaskResumeFromISR 1 +#endif + +#ifndef INCLUDE_xTimerPendFunctionCall + #define INCLUDE_xTimerPendFunctionCall 0 +#endif + +#ifndef INCLUDE_xTaskGetSchedulerState + #define INCLUDE_xTaskGetSchedulerState 0 +#endif + +#ifndef INCLUDE_xTaskGetCurrentTaskHandle + #define INCLUDE_xTaskGetCurrentTaskHandle 0 +#endif + +#if configUSE_CO_ROUTINES != 0 + #ifndef configMAX_CO_ROUTINE_PRIORITIES + #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. + #endif +#endif + +#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK + #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 +#endif + +#ifndef configUSE_APPLICATION_TASK_TAG + #define configUSE_APPLICATION_TASK_TAG 0 +#endif + +#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS + #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 +#endif + +#ifndef configUSE_RECURSIVE_MUTEXES + #define configUSE_RECURSIVE_MUTEXES 0 +#endif + +#ifndef configUSE_MUTEXES + #define configUSE_MUTEXES 0 +#endif + +#ifndef configUSE_TIMERS + #define configUSE_TIMERS 0 +#endif + +#ifndef configUSE_COUNTING_SEMAPHORES + #define configUSE_COUNTING_SEMAPHORES 0 +#endif + +#ifndef configUSE_ALTERNATIVE_API + #define configUSE_ALTERNATIVE_API 0 +#endif + +#ifndef portCRITICAL_NESTING_IN_TCB + #define portCRITICAL_NESTING_IN_TCB 0 +#endif + +#ifndef configMAX_TASK_NAME_LEN + #define configMAX_TASK_NAME_LEN 16 +#endif + +#ifndef configIDLE_SHOULD_YIELD + #define configIDLE_SHOULD_YIELD 1 +#endif + +#if configMAX_TASK_NAME_LEN < 1 + #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h +#endif + +#ifndef configASSERT + #define configASSERT( x ) + #define configASSERT_DEFINED 0 +#else + #define configASSERT_DEFINED 1 +#endif + +/* configPRECONDITION should be defined as configASSERT. + * The CBMC proofs need a way to track assumptions and assertions. + * A configPRECONDITION statement should express an implicit invariant or + * assumption made. A configASSERT statement should express an invariant that must + * hold explicit before calling the code. */ +#ifndef configPRECONDITION + #define configPRECONDITION( X ) configASSERT( X ) + #define configPRECONDITION_DEFINED 0 +#else + #define configPRECONDITION_DEFINED 1 +#endif + +#ifndef portMEMORY_BARRIER + #define portMEMORY_BARRIER() +#endif + +#ifndef portSOFTWARE_BARRIER + #define portSOFTWARE_BARRIER() +#endif + +/* The timers module relies on xTaskGetSchedulerState(). */ +#if configUSE_TIMERS == 1 + + #ifndef configTIMER_TASK_PRIORITY + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. + #endif /* configTIMER_TASK_PRIORITY */ + + #ifndef configTIMER_QUEUE_LENGTH + #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. + #endif /* configTIMER_QUEUE_LENGTH */ + + #ifndef configTIMER_TASK_STACK_DEPTH + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. + #endif /* configTIMER_TASK_STACK_DEPTH */ + +#endif /* configUSE_TIMERS */ + +#ifndef portSET_INTERRUPT_MASK_FROM_ISR + #define portSET_INTERRUPT_MASK_FROM_ISR() 0 +#endif + +#ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR + #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue +#endif + +#ifndef portCLEAN_UP_TCB + #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB +#endif + +#ifndef portPRE_TASK_DELETE_HOOK + #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) +#endif + +#ifndef portSETUP_TCB + #define portSETUP_TCB( pxTCB ) ( void ) pxTCB +#endif + +#ifndef configQUEUE_REGISTRY_SIZE + #define configQUEUE_REGISTRY_SIZE 0U +#endif + +#if ( configQUEUE_REGISTRY_SIZE < 1 ) + #define vQueueAddToRegistry( xQueue, pcName ) + #define vQueueUnregisterQueue( xQueue ) + #define pcQueueGetName( xQueue ) +#endif + +#ifndef portPOINTER_SIZE_TYPE + #define portPOINTER_SIZE_TYPE uint32_t +#endif + +/* Remove any unused trace macros. */ +#ifndef traceSTART + +/* Used to perform any necessary initialisation - for example, open a file + * into which trace is to be written. */ + #define traceSTART() +#endif + +#ifndef traceEND + +/* Use to close a trace, for example close a file into which trace has been + * written. */ + #define traceEND() +#endif + +#ifndef traceTASK_SWITCHED_IN + +/* Called after a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the selected task. */ + #define traceTASK_SWITCHED_IN() +#endif + +#ifndef traceINCREASE_TICK_COUNT + +/* Called before stepping the tick count after waking from tickless idle + * sleep. */ + #define traceINCREASE_TICK_COUNT( x ) +#endif + +#ifndef traceLOW_POWER_IDLE_BEGIN + /* Called immediately before entering tickless idle. */ + #define traceLOW_POWER_IDLE_BEGIN() +#endif + +#ifndef traceLOW_POWER_IDLE_END + /* Called when returning to the Idle task after a tickless idle. */ + #define traceLOW_POWER_IDLE_END() +#endif + +#ifndef traceTASK_SWITCHED_OUT + +/* Called before a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the task being switched out. */ + #define traceTASK_SWITCHED_OUT() +#endif + +#ifndef traceTASK_PRIORITY_INHERIT + +/* Called when a task attempts to take a mutex that is already held by a + * lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task + * that holds the mutex. uxInheritedPriority is the priority the mutex holder + * will inherit (the priority of the task that is attempting to obtain the + * muted. */ + #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) +#endif + +#ifndef traceTASK_PRIORITY_DISINHERIT + +/* Called when a task releases a mutex, the holding of which had resulted in + * the task inheriting the priority of a higher priority task. + * pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the + * mutex. uxOriginalPriority is the task's configured (base) priority. */ + #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) +#endif + +#ifndef traceBLOCKING_ON_QUEUE_RECEIVE + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) +#endif + +#ifndef traceBLOCKING_ON_QUEUE_PEEK + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) +#endif + +#ifndef traceBLOCKING_ON_QUEUE_SEND + +/* Task is about to block because it cannot write to a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the write was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the write. */ + #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) +#endif + +#ifndef configCHECK_FOR_STACK_OVERFLOW + #define configCHECK_FOR_STACK_OVERFLOW 0 +#endif + +#ifndef configRECORD_STACK_HIGH_ADDRESS + #define configRECORD_STACK_HIGH_ADDRESS 0 +#endif + +#ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H + #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 +#endif + +/* The following event macros are embedded in the kernel API calls. */ + +#ifndef traceMOVED_TASK_TO_READY_STATE + #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) +#endif + +#ifndef tracePOST_MOVED_TASK_TO_READY_STATE + #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) +#endif + +#ifndef traceQUEUE_CREATE + #define traceQUEUE_CREATE( pxNewQueue ) +#endif + +#ifndef traceQUEUE_CREATE_FAILED + #define traceQUEUE_CREATE_FAILED( ucQueueType ) +#endif + +#ifndef traceCREATE_MUTEX + #define traceCREATE_MUTEX( pxNewQueue ) +#endif + +#ifndef traceCREATE_MUTEX_FAILED + #define traceCREATE_MUTEX_FAILED() +#endif + +#ifndef traceGIVE_MUTEX_RECURSIVE + #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) +#endif + +#ifndef traceGIVE_MUTEX_RECURSIVE_FAILED + #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) +#endif + +#ifndef traceTAKE_MUTEX_RECURSIVE + #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) +#endif + +#ifndef traceTAKE_MUTEX_RECURSIVE_FAILED + #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) +#endif + +#ifndef traceCREATE_COUNTING_SEMAPHORE + #define traceCREATE_COUNTING_SEMAPHORE() +#endif + +#ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED + #define traceCREATE_COUNTING_SEMAPHORE_FAILED() +#endif + +#ifndef traceQUEUE_SET_SEND + #define traceQUEUE_SET_SEND traceQUEUE_SEND +#endif + +#ifndef traceQUEUE_SEND + #define traceQUEUE_SEND( pxQueue ) +#endif + +#ifndef traceQUEUE_SEND_FAILED + #define traceQUEUE_SEND_FAILED( pxQueue ) +#endif + +#ifndef traceQUEUE_RECEIVE + #define traceQUEUE_RECEIVE( pxQueue ) +#endif + +#ifndef traceQUEUE_PEEK + #define traceQUEUE_PEEK( pxQueue ) +#endif + +#ifndef traceQUEUE_PEEK_FAILED + #define traceQUEUE_PEEK_FAILED( pxQueue ) +#endif + +#ifndef traceQUEUE_PEEK_FROM_ISR + #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) +#endif + +#ifndef traceQUEUE_RECEIVE_FAILED + #define traceQUEUE_RECEIVE_FAILED( pxQueue ) +#endif + +#ifndef traceQUEUE_SEND_FROM_ISR + #define traceQUEUE_SEND_FROM_ISR( pxQueue ) +#endif + +#ifndef traceQUEUE_SEND_FROM_ISR_FAILED + #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) +#endif + +#ifndef traceQUEUE_RECEIVE_FROM_ISR + #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) +#endif + +#ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED + #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) +#endif + +#ifndef traceQUEUE_PEEK_FROM_ISR_FAILED + #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) +#endif + +#ifndef traceQUEUE_DELETE + #define traceQUEUE_DELETE( pxQueue ) +#endif + +#ifndef traceTASK_CREATE + #define traceTASK_CREATE( pxNewTCB ) +#endif + +#ifndef traceTASK_CREATE_FAILED + #define traceTASK_CREATE_FAILED() +#endif + +#ifndef traceTASK_DELETE + #define traceTASK_DELETE( pxTaskToDelete ) +#endif + +#ifndef traceTASK_DELAY_UNTIL + #define traceTASK_DELAY_UNTIL( x ) +#endif + +#ifndef traceTASK_DELAY + #define traceTASK_DELAY() +#endif + +#ifndef traceTASK_PRIORITY_SET + #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) +#endif + +#ifndef traceTASK_SUSPEND + #define traceTASK_SUSPEND( pxTaskToSuspend ) +#endif + +#ifndef traceTASK_RESUME + #define traceTASK_RESUME( pxTaskToResume ) +#endif + +#ifndef traceTASK_RESUME_FROM_ISR + #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) +#endif + +#ifndef traceTASK_INCREMENT_TICK + #define traceTASK_INCREMENT_TICK( xTickCount ) +#endif + +#ifndef traceTIMER_CREATE + #define traceTIMER_CREATE( pxNewTimer ) +#endif + +#ifndef traceTIMER_CREATE_FAILED + #define traceTIMER_CREATE_FAILED() +#endif + +#ifndef traceTIMER_COMMAND_SEND + #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) +#endif + +#ifndef traceTIMER_EXPIRED + #define traceTIMER_EXPIRED( pxTimer ) +#endif + +#ifndef traceTIMER_COMMAND_RECEIVED + #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) +#endif + +#ifndef traceMALLOC + #define traceMALLOC( pvAddress, uiSize ) +#endif + +#ifndef traceFREE + #define traceFREE( pvAddress, uiSize ) +#endif + +#ifndef traceEVENT_GROUP_CREATE + #define traceEVENT_GROUP_CREATE( xEventGroup ) +#endif + +#ifndef traceEVENT_GROUP_CREATE_FAILED + #define traceEVENT_GROUP_CREATE_FAILED() +#endif + +#ifndef traceEVENT_GROUP_SYNC_BLOCK + #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) +#endif + +#ifndef traceEVENT_GROUP_SYNC_END + #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred +#endif + +#ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK + #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) +#endif + +#ifndef traceEVENT_GROUP_WAIT_BITS_END + #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred +#endif + +#ifndef traceEVENT_GROUP_CLEAR_BITS + #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) +#endif + +#ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR + #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) +#endif + +#ifndef traceEVENT_GROUP_SET_BITS + #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) +#endif + +#ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR + #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) +#endif + +#ifndef traceEVENT_GROUP_DELETE + #define traceEVENT_GROUP_DELETE( xEventGroup ) +#endif + +#ifndef tracePEND_FUNC_CALL + #define tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, ret ) +#endif + +#ifndef tracePEND_FUNC_CALL_FROM_ISR + #define tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, ret ) +#endif + +#ifndef traceQUEUE_REGISTRY_ADD + #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ) +#endif + +#ifndef traceTASK_NOTIFY_TAKE_BLOCK + #define traceTASK_NOTIFY_TAKE_BLOCK( uxIndexToWait ) +#endif + +#ifndef traceTASK_NOTIFY_TAKE + #define traceTASK_NOTIFY_TAKE( uxIndexToWait ) +#endif + +#ifndef traceTASK_NOTIFY_WAIT_BLOCK + #define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait ) +#endif + +#ifndef traceTASK_NOTIFY_WAIT + #define traceTASK_NOTIFY_WAIT( uxIndexToWait ) +#endif + +#ifndef traceTASK_NOTIFY + #define traceTASK_NOTIFY( uxIndexToNotify ) +#endif + +#ifndef traceTASK_NOTIFY_FROM_ISR + #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ) +#endif + +#ifndef traceTASK_NOTIFY_GIVE_FROM_ISR + #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify ) +#endif + +#ifndef traceSTREAM_BUFFER_CREATE_FAILED + #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED + #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_CREATE + #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_DELETE + #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_RESET + #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) +#endif + +#ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND + #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_SEND + #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) +#endif + +#ifndef traceSTREAM_BUFFER_SEND_FAILED + #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_SEND_FROM_ISR + #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) +#endif + +#ifndef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE + #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_RECEIVE + #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) +#endif + +#ifndef traceSTREAM_BUFFER_RECEIVE_FAILED + #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_RECEIVE_FROM_ISR + #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) +#endif + +#ifndef configGENERATE_RUN_TIME_STATS + #define configGENERATE_RUN_TIME_STATS 0 +#endif + +#if ( configGENERATE_RUN_TIME_STATS == 1 ) + + #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS + #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. + #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ + + #ifndef portGET_RUN_TIME_COUNTER_VALUE + #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE + #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. + #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ + #endif /* portGET_RUN_TIME_COUNTER_VALUE */ + +#endif /* configGENERATE_RUN_TIME_STATS */ + +#ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS + #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() +#endif + +#ifndef configUSE_MALLOC_FAILED_HOOK + #define configUSE_MALLOC_FAILED_HOOK 0 +#endif + +#ifndef portPRIVILEGE_BIT + #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) +#endif + +#ifndef portYIELD_WITHIN_API + #define portYIELD_WITHIN_API portYIELD +#endif + +#ifndef portSUPPRESS_TICKS_AND_SLEEP + #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) +#endif + +#ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP + #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 +#endif + +#if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2 + #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 +#endif + +#ifndef configUSE_TICKLESS_IDLE + #define configUSE_TICKLESS_IDLE 0 +#endif + +#ifndef configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING + #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) +#endif + +#ifndef configPRE_SLEEP_PROCESSING + #define configPRE_SLEEP_PROCESSING( x ) +#endif + +#ifndef configPOST_SLEEP_PROCESSING + #define configPOST_SLEEP_PROCESSING( x ) +#endif + +#ifndef configUSE_QUEUE_SETS + #define configUSE_QUEUE_SETS 0 +#endif + +#ifndef portTASK_USES_FLOATING_POINT + #define portTASK_USES_FLOATING_POINT() +#endif + +#ifndef portALLOCATE_SECURE_CONTEXT + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) +#endif + +#ifndef portDONT_DISCARD + #define portDONT_DISCARD +#endif + +#ifndef configUSE_TIME_SLICING + #define configUSE_TIME_SLICING 1 +#endif + +#ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS + #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 +#endif + +#ifndef configUSE_STATS_FORMATTING_FUNCTIONS + #define configUSE_STATS_FORMATTING_FUNCTIONS 0 +#endif + +#ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() +#endif + +#ifndef configUSE_TRACE_FACILITY + #define configUSE_TRACE_FACILITY 0 +#endif + +#ifndef mtCOVERAGE_TEST_MARKER + #define mtCOVERAGE_TEST_MARKER() +#endif + +#ifndef mtCOVERAGE_TEST_DELAY + #define mtCOVERAGE_TEST_DELAY() +#endif + +#ifndef portASSERT_IF_IN_ISR + #define portASSERT_IF_IN_ISR() +#endif + +#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION + #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#endif + +#ifndef configAPPLICATION_ALLOCATED_HEAP + #define configAPPLICATION_ALLOCATED_HEAP 0 +#endif + +#ifndef configUSE_TASK_NOTIFICATIONS + #define configUSE_TASK_NOTIFICATIONS 1 +#endif + +#ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES + #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 +#endif + +#if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1 + #error configTASK_NOTIFICATION_ARRAY_ENTRIES must be at least 1 +#endif + +#ifndef configUSE_POSIX_ERRNO + #define configUSE_POSIX_ERRNO 0 +#endif + +#ifndef portTICK_TYPE_IS_ATOMIC + #define portTICK_TYPE_IS_ATOMIC 0 +#endif + +#ifndef configSUPPORT_STATIC_ALLOCATION + /* Defaults to 0 for backward compatibility. */ + #define configSUPPORT_STATIC_ALLOCATION 0 +#endif + +#ifndef configSUPPORT_DYNAMIC_ALLOCATION + /* Defaults to 1 for backward compatibility. */ + #define configSUPPORT_DYNAMIC_ALLOCATION 1 +#endif + +#ifndef configSTACK_DEPTH_TYPE + +/* Defaults to uint16_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if uint16_t is too restrictive. */ + #define configSTACK_DEPTH_TYPE uint16_t +#endif + +#ifndef configMESSAGE_BUFFER_LENGTH_TYPE + +/* Defaults to size_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if lengths will always be less than the number of bytes + * in a size_t. */ + #define configMESSAGE_BUFFER_LENGTH_TYPE size_t +#endif + +/* Sanity check the configuration. */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + #if ( INCLUDE_vTaskSuspend != 1 ) + #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 + #endif /* INCLUDE_vTaskSuspend */ +#endif /* configUSE_TICKLESS_IDLE */ + +#if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) + #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. +#endif + +#if ( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) + #error configUSE_MUTEXES must be set to 1 to use recursive mutexes +#endif + +#ifndef configINITIAL_TICK_COUNT + #define configINITIAL_TICK_COUNT 0 +#endif + +#if ( portTICK_TYPE_IS_ATOMIC == 0 ) + +/* Either variables of tick type cannot be read atomically, or + * portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when + * the tick count is returned to the standard critical section macros. */ + #define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL() + #define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL() + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) +#else + +/* The tick type can be read atomically, so critical sections used when the + * tick count is returned can be defined away. */ + #define portTICK_TYPE_ENTER_CRITICAL() + #define portTICK_TYPE_EXIT_CRITICAL() + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x +#endif /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */ + +/* Definitions to allow backward compatibility with FreeRTOS versions prior to + * V8 if desired. */ +#ifndef configENABLE_BACKWARD_COMPATIBILITY + #define configENABLE_BACKWARD_COMPATIBILITY 1 +#endif + +#ifndef configPRINTF + +/* configPRINTF() was not defined, so define it away to nothing. To use + * configPRINTF() then define it as follows (where MyPrintFunction() is + * provided by the application writer): + * + * void MyPrintFunction(const char *pcFormat, ... ); + #define configPRINTF( X ) MyPrintFunction X + * + * Then call like a standard printf() function, but placing brackets around + * all parameters so they are passed as a single parameter. For example: + * configPRINTF( ("Value = %d", MyVariable) ); */ + #define configPRINTF( X ) +#endif + +#ifndef configMAX + +/* The application writer has not provided their own MAX macro, so define + * the following generic implementation. */ + #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) +#endif + +#ifndef configMIN + +/* The application writer has not provided their own MAX macro, so define + * the following generic implementation. */ + #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) +#endif + +#if configENABLE_BACKWARD_COMPATIBILITY == 1 + #define eTaskStateGet eTaskGetState + #define portTickType TickType_t + #define xTaskHandle TaskHandle_t + #define xQueueHandle QueueHandle_t + #define xSemaphoreHandle SemaphoreHandle_t + #define xQueueSetHandle QueueSetHandle_t + #define xQueueSetMemberHandle QueueSetMemberHandle_t + #define xTimeOutType TimeOut_t + #define xMemoryRegion MemoryRegion_t + #define xTaskParameters TaskParameters_t + #define xTaskStatusType TaskStatus_t + #define xTimerHandle TimerHandle_t + #define xCoRoutineHandle CoRoutineHandle_t + #define pdTASK_HOOK_CODE TaskHookFunction_t + #define portTICK_RATE_MS portTICK_PERIOD_MS + #define pcTaskGetTaskName pcTaskGetName + #define pcTimerGetTimerName pcTimerGetName + #define pcQueueGetQueueName pcQueueGetName + #define vTaskGetTaskInfo vTaskGetInfo + #define xTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + +/* Backward compatibility within the scheduler code only - these definitions + * are not really required but are included for completeness. */ + #define tmrTIMER_CALLBACK TimerCallbackFunction_t + #define pdTASK_CODE TaskFunction_t + #define xListItem ListItem_t + #define xList List_t + +/* For libraries that break the list data hiding, and access list structure + * members directly (which is not supposed to be done). */ + #define pxContainer pvContainer +#endif /* configENABLE_BACKWARD_COMPATIBILITY */ + +#if ( configUSE_ALTERNATIVE_API != 0 ) + #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 +#endif + +/* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even + * if floating point hardware is otherwise supported by the FreeRTOS port in use. + * This constant is not supported by all FreeRTOS ports that include floating + * point support. */ +#ifndef configUSE_TASK_FPU_SUPPORT + #define configUSE_TASK_FPU_SUPPORT 1 +#endif + +/* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is + * currently used in ARMv8M ports. */ +#ifndef configENABLE_MPU + #define configENABLE_MPU 0 +#endif + +/* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is + * currently used in ARMv8M ports. */ +#ifndef configENABLE_FPU + #define configENABLE_FPU 1 +#endif + +/* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it. + * This is currently used in ARMv8M ports. */ +#ifndef configENABLE_TRUSTZONE + #define configENABLE_TRUSTZONE 1 +#endif + +/* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on + * the Secure Side only. */ +#ifndef configRUN_FREERTOS_SECURE_ONLY + #define configRUN_FREERTOS_SECURE_ONLY 0 +#endif + +/* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using + * dynamically allocated RAM, in which case when any task is deleted it is known + * that both the task's stack and TCB need to be freed. Sometimes the + * FreeRTOSConfig.h settings only allow a task to be created using statically + * allocated RAM, in which case when any task is deleted it is known that neither + * the task's stack or TCB should be freed. Sometimes the FreeRTOSConfig.h + * settings allow a task to be created using either statically or dynamically + * allocated RAM, in which case a member of the TCB is used to record whether the + * stack and/or TCB were allocated statically or dynamically, so when a task is + * deleted the RAM that was allocated dynamically is freed again and no attempt is + * made to free the RAM that was allocated statically. + * tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is only true if it is possible for a + * task to be created using either statically or dynamically allocated RAM. Note + * that if portUSING_MPU_WRAPPERS is 1 then a protected task can be created with + * a statically allocated stack and a dynamically allocated TCB. + * + * The following table lists various combinations of portUSING_MPU_WRAPPERS, + * configSUPPORT_DYNAMIC_ALLOCATION and configSUPPORT_STATIC_ALLOCATION and + * when it is possible to have both static and dynamic allocation: + * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+ + * | MPU | Dynamic | Static | Available Functions | Possible Allocations | Both Dynamic and | Need Free | + * | | | | | | Static Possible | | + * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+ + * | 0 | 0 | 1 | xTaskCreateStatic | TCB - Static, Stack - Static | No | No | + * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------| + * | 0 | 1 | 0 | xTaskCreate | TCB - Dynamic, Stack - Dynamic | No | Yes | + * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------| + * | 0 | 1 | 1 | xTaskCreate, | 1. TCB - Dynamic, Stack - Dynamic | Yes | Yes | + * | | | | xTaskCreateStatic | 2. TCB - Static, Stack - Static | | | + * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------| + * | 1 | 0 | 1 | xTaskCreateStatic, | TCB - Static, Stack - Static | No | No | + * | | | | xTaskCreateRestrictedStatic | | | | + * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------| + * | 1 | 1 | 0 | xTaskCreate, | 1. TCB - Dynamic, Stack - Dynamic | Yes | Yes | + * | | | | xTaskCreateRestricted | 2. TCB - Dynamic, Stack - Static | | | + * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------| + * | 1 | 1 | 1 | xTaskCreate, | 1. TCB - Dynamic, Stack - Dynamic | Yes | Yes | + * | | | | xTaskCreateStatic, | 2. TCB - Dynamic, Stack - Static | | | + * | | | | xTaskCreateRestricted, | 3. TCB - Static, Stack - Static | | | + * | | | | xTaskCreateRestrictedStatic | | | | + * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+ + */ +#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE \ + ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ + ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) + +/* + * In line with software engineering best practice, FreeRTOS implements a strict + * data hiding policy, so the real structures used by FreeRTOS to maintain the + * state of tasks, queues, semaphores, etc. are not accessible to the application + * code. However, if the application writer wants to statically allocate such + * an object then the size of the object needs to be know. Dummy structures + * that are guaranteed to have the same size and alignment requirements of the + * real objects are used for this purpose. The dummy list and list item + * structures below are used for inclusion in such a dummy structure. + */ +struct xSTATIC_LIST_ITEM +{ + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 4 ]; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy4; + #endif +}; +typedef struct xSTATIC_LIST_ITEM StaticListItem_t; + +/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ +struct xSTATIC_MINI_LIST_ITEM +{ + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 2 ]; +}; +typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; + +/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ +typedef struct xSTATIC_LIST +{ + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + UBaseType_t uxDummy2; + void * pvDummy3; + StaticMiniListItem_t xDummy4; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy5; + #endif +} StaticList_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the Task structure used internally by + * FreeRTOS is not accessible to application code. However, if the application + * writer wants to statically allocate the memory required to create a task then + * the size of the task object needs to be know. The StaticTask_t structure + * below is provided for this purpose. Its sizes and alignment requirements are + * guaranteed to match those of the genuine structure, no matter which + * architecture is being used, and no matter how the values in FreeRTOSConfig.h + * are set. Its contents are somewhat obfuscated in the hope users will + * recognise that it would be unwise to make direct use of the structure members. + */ +typedef struct xSTATIC_TCB +{ + void * pxDummy1; + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xDummy2; + #endif + StaticListItem_t xDummy3[ 2 ]; + UBaseType_t uxDummy5; + void * pxDummy6; + uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; + #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + void * pxDummy8; + #endif + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + UBaseType_t uxDummy9; + #endif + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy10[ 2 ]; + #endif + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxDummy12[ 2 ]; + #endif + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + void * pxDummy14; + #endif + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #endif + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t ulDummy16; + #endif + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + struct _reent xDummy17; + #endif + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + #endif + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) + uint8_t uxDummy20; + #endif + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + uint8_t ucDummy21; + #endif + #if ( configUSE_POSIX_ERRNO == 1 ) + int iDummy22; + #endif +} StaticTask_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the Queue structure used internally by + * FreeRTOS is not accessible to application code. However, if the application + * writer wants to statically allocate the memory required to create a queue + * then the size of the queue object needs to be know. The StaticQueue_t + * structure below is provided for this purpose. Its sizes and alignment + * requirements are guaranteed to match those of the genuine structure, no + * matter which architecture is being used, and no matter how the values in + * FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in the hope + * users will recognise that it would be unwise to make direct use of the + * structure members. + */ +typedef struct xSTATIC_QUEUE +{ + void * pvDummy1[ 3 ]; + + union + { + void * pvDummy2; + UBaseType_t uxDummy2; + } u; + + StaticList_t xDummy3[ 2 ]; + UBaseType_t uxDummy4[ 3 ]; + uint8_t ucDummy5[ 2 ]; + + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy6; + #endif + + #if ( configUSE_QUEUE_SETS == 1 ) + void * pvDummy7; + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy8; + uint8_t ucDummy9; + #endif +} StaticQueue_t; +typedef StaticQueue_t StaticSemaphore_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the event group structure used + * internally by FreeRTOS is not accessible to application code. However, if + * the application writer wants to statically allocate the memory required to + * create an event group then the size of the event group object needs to be + * know. The StaticEventGroup_t structure below is provided for this purpose. + * Its sizes and alignment requirements are guaranteed to match those of the + * genuine structure, no matter which architecture is being used, and no matter + * how the values in FreeRTOSConfig.h are set. Its contents are somewhat + * obfuscated in the hope users will recognise that it would be unwise to make + * direct use of the structure members. + */ +typedef struct xSTATIC_EVENT_GROUP +{ + TickType_t xDummy1; + StaticList_t xDummy2; + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy3; + #endif + + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy4; + #endif +} StaticEventGroup_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the software timer structure used + * internally by FreeRTOS is not accessible to application code. However, if + * the application writer wants to statically allocate the memory required to + * create a software timer then the size of the queue object needs to be know. + * The StaticTimer_t structure below is provided for this purpose. Its sizes + * and alignment requirements are guaranteed to match those of the genuine + * structure, no matter which architecture is being used, and no matter how the + * values in FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in + * the hope users will recognise that it would be unwise to make direct use of + * the structure members. + */ +typedef struct xSTATIC_TIMER +{ + void * pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + void * pvDummy5; + TaskFunction_t pvDummy6; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy7; + #endif + uint8_t ucDummy8; +} StaticTimer_t; + +/* + * In line with software engineering best practice, especially when supplying a + * library that is likely to change in future versions, FreeRTOS implements a + * strict data hiding policy. This means the stream buffer structure used + * internally by FreeRTOS is not accessible to application code. However, if + * the application writer wants to statically allocate the memory required to + * create a stream buffer then the size of the stream buffer object needs to be + * know. The StaticStreamBuffer_t structure below is provided for this purpose. + * Its size and alignment requirements are guaranteed to match those of the + * genuine structure, no matter which architecture is being used, and no matter + * how the values in FreeRTOSConfig.h are set. Its contents are somewhat + * obfuscated in the hope users will recognise that it would be unwise to make + * direct use of the structure members. + */ +typedef struct xSTATIC_STREAM_BUFFER +{ + size_t uxDummy1[ 4 ]; + void * pvDummy2[ 3 ]; + uint8_t ucDummy3; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy4; + #endif +} StaticStreamBuffer_t; + +/* Message buffers are built on stream buffers. */ +typedef StaticStreamBuffer_t StaticMessageBuffer_t; + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ + +#endif /* INC_FREERTOS_H */ diff --git a/FreeRTOS/include/deprecated_definitions.h b/FreeRTOS/include/deprecated_definitions.h new file mode 100644 index 0000000..9792d50 --- /dev/null +++ b/FreeRTOS/include/deprecated_definitions.h @@ -0,0 +1,279 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef DEPRECATED_DEFINITIONS_H +#define DEPRECATED_DEFINITIONS_H + + +/* Each FreeRTOS port has a unique portmacro.h header file. Originally a + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. The + * definitions below remain in the code for backward compatibility only. New + * projects should not use them. */ + +#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT + #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); +#endif + +#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT + #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); +#endif + +#ifdef GCC_MEGA_AVR + #include "../portable/GCC/ATMega323/portmacro.h" +#endif + +#ifdef IAR_MEGA_AVR + #include "../portable/IAR/ATMega323/portmacro.h" +#endif + +#ifdef MPLAB_PIC24_PORT + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" +#endif + +#ifdef MPLAB_DSPIC_PORT + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" +#endif + +#ifdef MPLAB_PIC18F_PORT + #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" +#endif + +#ifdef MPLAB_PIC32MX_PORT + #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" +#endif + +#ifdef _FEDPICC + #include "libFreeRTOS/Include/portmacro.h" +#endif + +#ifdef SDCC_CYGNAL + #include "../../Source/portable/SDCC/Cygnal/portmacro.h" +#endif + +#ifdef GCC_ARM7 + #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" +#endif + +#ifdef GCC_ARM7_ECLIPSE + #include "portmacro.h" +#endif + +#ifdef ROWLEY_LPC23xx + #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" +#endif + +#ifdef IAR_MSP430 + #include "..\..\Source\portable\IAR\MSP430\portmacro.h" +#endif + +#ifdef GCC_MSP430 + #include "../../Source/portable/GCC/MSP430F449/portmacro.h" +#endif + +#ifdef ROWLEY_MSP430 + #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" +#endif + +#ifdef ARM7_LPC21xx_KEIL_RVDS + #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" +#endif + +#ifdef SAM7_GCC + #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" +#endif + +#ifdef SAM7_IAR + #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" +#endif + +#ifdef SAM9XE_IAR + #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" +#endif + +#ifdef LPC2000_IAR + #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" +#endif + +#ifdef STR71X_IAR + #include "..\..\Source\portable\IAR\STR71x\portmacro.h" +#endif + +#ifdef STR75X_IAR + #include "..\..\Source\portable\IAR\STR75x\portmacro.h" +#endif + +#ifdef STR75X_GCC + #include "..\..\Source\portable\GCC\STR75x\portmacro.h" +#endif + +#ifdef STR91X_IAR + #include "..\..\Source\portable\IAR\STR91x\portmacro.h" +#endif + +#ifdef GCC_H8S + #include "../../Source/portable/GCC/H8S2329/portmacro.h" +#endif + +#ifdef GCC_AT91FR40008 + #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" +#endif + +#ifdef RVDS_ARMCM3_LM3S102 + #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" +#endif + +#ifdef GCC_ARMCM3_LM3S102 + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" +#endif + +#ifdef GCC_ARMCM3 + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" +#endif + +#ifdef IAR_ARM_CM3 + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" +#endif + +#ifdef IAR_ARMCM3_LM + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" +#endif + +#ifdef HCS12_CODE_WARRIOR + #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" +#endif + +#ifdef MICROBLAZE_GCC + #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" +#endif + +#ifdef TERN_EE + #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" +#endif + +#ifdef GCC_HCS12 + #include "../../Source/portable/GCC/HCS12/portmacro.h" +#endif + +#ifdef GCC_MCF5235 + #include "../../Source/portable/GCC/MCF5235/portmacro.h" +#endif + +#ifdef COLDFIRE_V2_GCC + #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" +#endif + +#ifdef COLDFIRE_V2_CODEWARRIOR + #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" +#endif + +#ifdef GCC_PPC405 + #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" +#endif + +#ifdef GCC_PPC440 + #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" +#endif + +#ifdef _16FX_SOFTUNE + #include "..\..\Source\portable\Softune\MB96340\portmacro.h" +#endif + +#ifdef BCC_INDUSTRIAL_PC_PORT + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); +#endif + +#ifdef BCC_FLASH_LITE_186_PORT + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); +#endif + +#ifdef __GNUC__ + #ifdef __AVR32_AVR32A__ + #include "portmacro.h" + #endif +#endif + +#ifdef __ICCAVR32__ + #ifdef __CORE__ + #if __CORE__ == __AVR32A__ + #include "portmacro.h" + #endif + #endif +#endif + +#ifdef __91467D + #include "portmacro.h" +#endif + +#ifdef __96340 + #include "portmacro.h" +#endif + + +#ifdef __IAR_V850ES_Fx3__ + #include "../../Source/portable/IAR/V850ES/portmacro.h" +#endif + +#ifdef __IAR_V850ES_Jx3__ + #include "../../Source/portable/IAR/V850ES/portmacro.h" +#endif + +#ifdef __IAR_V850ES_Jx3_L__ + #include "../../Source/portable/IAR/V850ES/portmacro.h" +#endif + +#ifdef __IAR_V850ES_Jx2__ + #include "../../Source/portable/IAR/V850ES/portmacro.h" +#endif + +#ifdef __IAR_V850ES_Hx2__ + #include "../../Source/portable/IAR/V850ES/portmacro.h" +#endif + +#ifdef __IAR_78K0R_Kx3__ + #include "../../Source/portable/IAR/78K0R/portmacro.h" +#endif + +#ifdef __IAR_78K0R_Kx3L__ + #include "../../Source/portable/IAR/78K0R/portmacro.h" +#endif + +#endif /* DEPRECATED_DEFINITIONS_H */ diff --git a/FreeRTOS/include/list.h b/FreeRTOS/include/list.h new file mode 100644 index 0000000..3aa0602 --- /dev/null +++ b/FreeRTOS/include/list.h @@ -0,0 +1,417 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* + * This is the list implementation used by the scheduler. While it is tailored + * heavily for the schedulers needs, it is also available for use by + * application code. + * + * list_ts can only store pointers to list_item_ts. Each ListItem_t contains a + * numeric value (xItemValue). Most of the time the lists are sorted in + * descending item value order. + * + * Lists are created already containing one list item. The value of this + * item is the maximum possible that can be stored, it is therefore always at + * the end of the list and acts as a marker. The list member pxHead always + * points to this marker - even though it is at the tail of the list. This + * is because the tail contains a wrap back pointer to the true head of + * the list. + * + * In addition to it's value, each list item contains a pointer to the next + * item in the list (pxNext), a pointer to the list it is in (pxContainer) + * and a pointer to back to the object that contains it. These later two + * pointers are included for efficiency of list manipulation. There is + * effectively a two way link between the object containing the list item and + * the list item itself. + * + * + * \page ListIntroduction List Implementation + * \ingroup FreeRTOSIntro + */ + + +#ifndef LIST_H +#define LIST_H + +#ifndef INC_FREERTOS_H + #error "FreeRTOS.h must be included before list.h" +#endif + +/* + * The list structure members are modified from within interrupts, and therefore + * by rights should be declared volatile. However, they are only modified in a + * functionally atomic way (within critical sections of with the scheduler + * suspended) and are either passed by reference into a function or indexed via + * a volatile variable. Therefore, in all use cases tested so far, the volatile + * qualifier can be omitted in order to provide a moderate performance + * improvement without adversely affecting functional behaviour. The assembly + * instructions generated by the IAR, ARM and GCC compilers when the respective + * compiler's options were set for maximum optimisation has been inspected and + * deemed to be as intended. That said, as compiler technology advances, and + * especially if aggressive cross module optimisation is used (a use case that + * has not been exercised to any great extend) then it is feasible that the + * volatile qualifier will be needed for correct optimisation. It is expected + * that a compiler removing essential code because, without the volatile + * qualifier on the list structure members and with aggressive cross module + * optimisation, the compiler deemed the code unnecessary will result in + * complete and obvious failure of the scheduler. If this is ever experienced + * then the volatile qualifier can be inserted in the relevant places within the + * list structures by simply defining configLIST_VOLATILE to volatile in + * FreeRTOSConfig.h (as per the example at the bottom of this comment block). + * If configLIST_VOLATILE is not defined then the preprocessor directives below + * will simply #define configLIST_VOLATILE away completely. + * + * To use volatile list structure members then add the following line to + * FreeRTOSConfig.h (without the quotes): + * "#define configLIST_VOLATILE volatile" + */ +#ifndef configLIST_VOLATILE + #define configLIST_VOLATILE +#endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */ + +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +/* Macros that can be used to place known values within the list structures, + * then check that the known values do not get corrupted during the execution of + * the application. These may catch the list data structures being overwritten in + * memory. They will not catch data errors caused by incorrect configuration or + * use of FreeRTOS.*/ +#if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) + /* Define the macros to do nothing. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) + #define listTEST_LIST_INTEGRITY( pxList ) +#else /* if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) */ + /* Define macros that add new members into the list structures. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; + +/* Define macros that set the new structure members to known values. */ + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + +/* Define macros that will assert if one of the structure members does not + * contain its expected value. */ + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) +#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */ + + +/* + * Definition of the only type of object that a list can contain. + */ +struct xLIST; +struct xLIST_ITEM +{ + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ + struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ + void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ + struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */ + listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ +}; +typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ + +struct xMINI_LIST_ITEM +{ + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; + struct xLIST_ITEM * configLIST_VOLATILE pxNext; + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; +}; +typedef struct xMINI_LIST_ITEM MiniListItem_t; + +/* + * Definition of the type of queue used by the scheduler. + */ +typedef struct xLIST +{ + listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + volatile UBaseType_t uxNumberOfItems; + ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ + MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ + listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ +} List_t; + +/* + * Access macro to set the owner of a list item. The owner of a list item + * is the object (usually a TCB) that contains the list item. + * + * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER + * \ingroup LinkedList + */ +#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) + +/* + * Access macro to get the owner of a list item. The owner of a list item + * is the object (usually a TCB) that contains the list item. + * + * \page listGET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER + * \ingroup LinkedList + */ +#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) + +/* + * Access macro to set the value of the list item. In most cases the value is + * used to sort the list in descending order. + * + * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE + * \ingroup LinkedList + */ +#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) + +/* + * Access macro to retrieve the value of the list item. The value can + * represent anything - for example the priority of a task, or the time at + * which a task should be unblocked. + * + * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE + * \ingroup LinkedList + */ +#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) + +/* + * Access macro to retrieve the value of the list item at the head of a given + * list. + * + * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE + * \ingroup LinkedList + */ +#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) + +/* + * Return the list item at the head of the list. + * + * \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY + * \ingroup LinkedList + */ +#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) + +/* + * Return the next list item. + * + * \page listGET_NEXT listGET_NEXT + * \ingroup LinkedList + */ +#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) + +/* + * Return the list item that marks the end of the list + * + * \page listGET_END_MARKER listGET_END_MARKER + * \ingroup LinkedList + */ +#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) + +/* + * Access macro to determine if a list contains any items. The macro will + * only have the value true if the list is empty. + * + * \page listLIST_IS_EMPTY listLIST_IS_EMPTY + * \ingroup LinkedList + */ +#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE ) + +/* + * Access macro to return the number of items in the list. + */ +#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) + +/* + * Access function to obtain the owner of the next entry in a list. + * + * The list member pxIndex is used to walk through a list. Calling + * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list + * and returns that entry's pxOwner parameter. Using multiple calls to this + * function it is therefore possible to move through every item contained in + * a list. + * + * The pxOwner parameter of a list item is a pointer to the object that owns + * the list item. In the scheduler this is normally a task control block. + * The pxOwner parameter effectively creates a two way link between the list + * item and its owner. + * + * @param pxTCB pxTCB is set to the address of the owner of the next list item. + * @param pxList The list from which the next item owner is to be returned. + * + * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY + * \ingroup LinkedList + */ +#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ + { \ + List_t * const pxConstList = ( pxList ); \ + /* Increment the index to the next item and return the item, ensuring */ \ + /* we don't return the marker used at the end of the list. */ \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ + { \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + } \ + ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ + } + + +/* + * Access function to obtain the owner of the first entry in a list. Lists + * are normally sorted in ascending item value order. + * + * This function returns the pxOwner member of the first item in the list. + * The pxOwner parameter of a list item is a pointer to the object that owns + * the list item. In the scheduler this is normally a task control block. + * The pxOwner parameter effectively creates a two way link between the list + * item and its owner. + * + * @param pxList The list from which the owner of the head item is to be + * returned. + * + * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY + * \ingroup LinkedList + */ +#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( &( ( pxList )->xListEnd ) )->pxNext->pvOwner ) + +/* + * Check to see if a list item is within a list. The list item maintains a + * "container" pointer that points to the list it is in. All this macro does + * is check to see if the container and the list match. + * + * @param pxList The list we want to know if the list item is within. + * @param pxListItem The list item we want to know if is in the list. + * @return pdTRUE if the list item is in the list, otherwise pdFALSE. + */ +#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) ) + +/* + * Return the list a list item is contained within (referenced from). + * + * @param pxListItem The list item being queried. + * @return A pointer to the List_t object that references the pxListItem + */ +#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer ) + +/* + * This provides a crude means of knowing if a list has been initialised, as + * pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise() + * function. + */ +#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) + +/* + * Must be called before a list is used! This initialises all the members + * of the list structure and inserts the xListEnd item into the list as a + * marker to the back of the list. + * + * @param pxList Pointer to the list being initialised. + * + * \page vListInitialise vListInitialise + * \ingroup LinkedList + */ +void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION; + +/* + * Must be called before a list item is used. This sets the list container to + * null so the item does not think that it is already contained in a list. + * + * @param pxItem Pointer to the list item being initialised. + * + * \page vListInitialiseItem vListInitialiseItem + * \ingroup LinkedList + */ +void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION; + +/* + * Insert a list item into a list. The item will be inserted into the list in + * a position determined by its item value (descending item value order). + * + * @param pxList The list into which the item is to be inserted. + * + * @param pxNewListItem The item that is to be placed in the list. + * + * \page vListInsert vListInsert + * \ingroup LinkedList + */ +void vListInsert( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; + +/* + * Insert a list item into a list. The item will be inserted in a position + * such that it will be the last item within the list returned by multiple + * calls to listGET_OWNER_OF_NEXT_ENTRY. + * + * The list member pxIndex is used to walk through a list. Calling + * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list. + * Placing an item in a list using vListInsertEnd effectively places the item + * in the list position pointed to by pxIndex. This means that every other + * item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before + * the pxIndex parameter again points to the item being inserted. + * + * @param pxList The list into which the item is to be inserted. + * + * @param pxNewListItem The list item to be inserted into the list. + * + * \page vListInsertEnd vListInsertEnd + * \ingroup LinkedList + */ +void vListInsertEnd( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; + +/* + * Remove an item from a list. The list item has a pointer to the list that + * it is in, so only the list item need be passed into the function. + * + * @param uxListRemove The item to be removed. The item will remove itself from + * the list pointed to by it's pxContainer parameter. + * + * @return The number of items that remain in the list after the list item has + * been removed. + * + * \page uxListRemove uxListRemove + * \ingroup LinkedList + */ +UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION; + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ + +#endif /* ifndef LIST_H */ diff --git a/FreeRTOS/include/mpu_wrappers.h b/FreeRTOS/include/mpu_wrappers.h new file mode 100644 index 0000000..a1a3d02 --- /dev/null +++ b/FreeRTOS/include/mpu_wrappers.h @@ -0,0 +1,187 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef MPU_WRAPPERS_H +#define MPU_WRAPPERS_H + +/* This file redefines API functions to be called through a wrapper macro, but + * only for ports that are using the MPU. */ +#ifdef portUSING_MPU_WRAPPERS + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is + * included from queue.c or task.c to prevent it from having an effect within + * those files. */ + #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* + * Map standard (non MPU) API functions to equivalents that start + * "MPU_". This will cause the application code to call the MPU_ + * version, which wraps the non-MPU version with privilege promoting + * then demoting code, so the kernel code always runs will full + * privileges. + */ + +/* Map standard tasks.h API functions to the MPU equivalents. */ + #define xTaskCreate MPU_xTaskCreate + #define xTaskCreateStatic MPU_xTaskCreateStatic + #define xTaskCreateRestricted MPU_xTaskCreateRestricted + #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions + #define vTaskDelete MPU_vTaskDelete + #define vTaskDelay MPU_vTaskDelay + #define xTaskDelayUntil MPU_xTaskDelayUntil + #define xTaskAbortDelay MPU_xTaskAbortDelay + #define uxTaskPriorityGet MPU_uxTaskPriorityGet + #define eTaskGetState MPU_eTaskGetState + #define vTaskGetInfo MPU_vTaskGetInfo + #define vTaskPrioritySet MPU_vTaskPrioritySet + #define vTaskSuspend MPU_vTaskSuspend + #define vTaskResume MPU_vTaskResume + #define vTaskSuspendAll MPU_vTaskSuspendAll + #define xTaskResumeAll MPU_xTaskResumeAll + #define xTaskGetTickCount MPU_xTaskGetTickCount + #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks + #define pcTaskGetName MPU_pcTaskGetName + #define xTaskGetHandle MPU_xTaskGetHandle + #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark + #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 + #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag + #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag + #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer + #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer + #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook + #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle + #define uxTaskGetSystemState MPU_uxTaskGetSystemState + #define vTaskList MPU_vTaskList + #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats + #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter + #define xTaskGenericNotify MPU_xTaskGenericNotify + #define xTaskGenericNotifyWait MPU_xTaskGenericNotifyWait + #define ulTaskGenericNotifyTake MPU_ulTaskGenericNotifyTake + #define xTaskGenericNotifyStateClear MPU_xTaskGenericNotifyStateClear + #define ulTaskGenericNotifyValueClear MPU_ulTaskGenericNotifyValueClear + #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks + + #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle + #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState + #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut + #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState + +/* Map standard queue.h API functions to the MPU equivalents. */ + #define xQueueGenericSend MPU_xQueueGenericSend + #define xQueueReceive MPU_xQueueReceive + #define xQueuePeek MPU_xQueuePeek + #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake + #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting + #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable + #define vQueueDelete MPU_vQueueDelete + #define xQueueCreateMutex MPU_xQueueCreateMutex + #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic + #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore + #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic + #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder + #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive + #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive + #define xQueueGenericCreate MPU_xQueueGenericCreate + #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic + #define xQueueCreateSet MPU_xQueueCreateSet + #define xQueueAddToSet MPU_xQueueAddToSet + #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet + #define xQueueSelectFromSet MPU_xQueueSelectFromSet + #define xQueueGenericReset MPU_xQueueGenericReset + + #if ( configQUEUE_REGISTRY_SIZE > 0 ) + #define vQueueAddToRegistry MPU_vQueueAddToRegistry + #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue + #define pcQueueGetName MPU_pcQueueGetName + #endif + +/* Map standard timer.h API functions to the MPU equivalents. */ + #define xTimerCreate MPU_xTimerCreate + #define xTimerCreateStatic MPU_xTimerCreateStatic + #define pvTimerGetTimerID MPU_pvTimerGetTimerID + #define vTimerSetTimerID MPU_vTimerSetTimerID + #define xTimerIsTimerActive MPU_xTimerIsTimerActive + #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle + #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall + #define pcTimerGetName MPU_pcTimerGetName + #define vTimerSetReloadMode MPU_vTimerSetReloadMode + #define uxTimerGetReloadMode MPU_uxTimerGetReloadMode + #define xTimerGetPeriod MPU_xTimerGetPeriod + #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime + #define xTimerGenericCommand MPU_xTimerGenericCommand + +/* Map standard event_group.h API functions to the MPU equivalents. */ + #define xEventGroupCreate MPU_xEventGroupCreate + #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic + #define xEventGroupWaitBits MPU_xEventGroupWaitBits + #define xEventGroupClearBits MPU_xEventGroupClearBits + #define xEventGroupSetBits MPU_xEventGroupSetBits + #define xEventGroupSync MPU_xEventGroupSync + #define vEventGroupDelete MPU_vEventGroupDelete + +/* Map standard message/stream_buffer.h API functions to the MPU + * equivalents. */ + #define xStreamBufferSend MPU_xStreamBufferSend + #define xStreamBufferReceive MPU_xStreamBufferReceive + #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes + #define vStreamBufferDelete MPU_vStreamBufferDelete + #define xStreamBufferIsFull MPU_xStreamBufferIsFull + #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty + #define xStreamBufferReset MPU_xStreamBufferReset + #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable + #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable + #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel + #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate + #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic + + +/* Remove the privileged function macro, but keep the PRIVILEGED_DATA + * macro so applications can place data in privileged access sections + * (useful when using statically allocated objects). */ + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL + + #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ + +/* Ensure API functions go in the privileged execution section. */ + #define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) ) + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) ) + + #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ + +#else /* portUSING_MPU_WRAPPERS */ + + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA + #define FREERTOS_SYSTEM_CALL + #define portUSING_MPU_WRAPPERS 0 + +#endif /* portUSING_MPU_WRAPPERS */ + + +#endif /* MPU_WRAPPERS_H */ diff --git a/FreeRTOS/include/portable.h b/FreeRTOS/include/portable.h new file mode 100644 index 0000000..f92c7c4 --- /dev/null +++ b/FreeRTOS/include/portable.h @@ -0,0 +1,216 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/*----------------------------------------------------------- +* Portable layer API. Each function must be defined for each port. +*----------------------------------------------------------*/ + +#ifndef PORTABLE_H +#define PORTABLE_H + +/* Each FreeRTOS port has a unique portmacro.h header file. Originally a + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. + * Purely for reasons of backward compatibility the old method is still valid, but + * to make it clear that new projects should not use it, support for the port + * specific constants has been moved into the deprecated_definitions.h header + * file. */ +#include "deprecated_definitions.h" + +/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h + * did not result in a portmacro.h header file being included - and it should be + * included here. In this case the path to the correct portmacro.h header file + * must be set in the compiler's include path. */ +#ifndef portENTER_CRITICAL + #include "portmacro.h" +#endif + +#if portBYTE_ALIGNMENT == 32 + #define portBYTE_ALIGNMENT_MASK ( 0x001f ) +#endif + +#if portBYTE_ALIGNMENT == 16 + #define portBYTE_ALIGNMENT_MASK ( 0x000f ) +#endif + +#if portBYTE_ALIGNMENT == 8 + #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) +#endif + +#if portBYTE_ALIGNMENT == 4 + #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) +#endif + +#if portBYTE_ALIGNMENT == 2 + #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) +#endif + +#if portBYTE_ALIGNMENT == 1 + #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) +#endif + +#ifndef portBYTE_ALIGNMENT_MASK + #error "Invalid portBYTE_ALIGNMENT definition" +#endif + +#ifndef portNUM_CONFIGURABLE_REGIONS + #define portNUM_CONFIGURABLE_REGIONS 1 +#endif + +#ifndef portHAS_STACK_OVERFLOW_CHECKING + #define portHAS_STACK_OVERFLOW_CHECKING 0 +#endif + +#ifndef portARCH_NAME + #define portARCH_NAME NULL +#endif + +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +#include "mpu_wrappers.h" + +/* + * Setup the stack of a new task so it is ready to be placed under the + * scheduler control. The registers have to be placed on the stack in + * the order that the port expects to find them. + * + */ +#if ( portUSING_MPU_WRAPPERS == 1 ) + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #endif +#else /* if ( portUSING_MPU_WRAPPERS == 1 ) */ + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #endif +#endif /* if ( portUSING_MPU_WRAPPERS == 1 ) */ + +/* Used by heap_5.c to define the start address and size of each memory region + * that together comprise the total FreeRTOS heap space. */ +typedef struct HeapRegion +{ + uint8_t * pucStartAddress; + size_t xSizeInBytes; +} HeapRegion_t; + +/* Used to pass information about the heap out of vPortGetHeapStats(). */ +typedef struct xHeapStats +{ + size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ + size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ + size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ + size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ +} HeapStats_t; + +/* + * Used to define multiple heap regions for use by heap_5.c. This function + * must be called before any calls to pvPortMalloc() - not creating a task, + * queue, semaphore, mutex, software timer, event group, etc. will result in + * pvPortMalloc being called. + * + * pxHeapRegions passes in an array of HeapRegion_t structures - each of which + * defines a region of memory that can be used as the heap. The array is + * terminated by a HeapRegions_t structure that has a size of 0. The region + * with the lowest start address must appear first in the array. + */ +void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; + +/* + * Returns a HeapStats_t structure filled with information about the current + * heap state. + */ +void vPortGetHeapStats( HeapStats_t * pxHeapStats ); + +/* + * Map to the memory management routines required for the port. + */ +void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; +void vPortFree( void * pv ) PRIVILEGED_FUNCTION; +void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; +size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; +size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; + +/* + * Setup the hardware ready for the scheduler to take control. This generally + * sets up a tick interrupt and sets timers for the correct tick frequency. + */ +BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; + +/* + * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so + * the hardware is left in its original condition after the scheduler stops + * executing. + */ +void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; + +/* + * The structures and methods of manipulating the MPU are contained within the + * port layer. + * + * Fills the xMPUSettings structure with the memory region information + * contained in xRegions. + */ +#if ( portUSING_MPU_WRAPPERS == 1 ) + struct xMEMORY_REGION; + void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings, + const struct xMEMORY_REGION * const xRegions, + StackType_t * pxBottomOfStack, + uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; +#endif + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ + +#endif /* PORTABLE_H */ diff --git a/FreeRTOS/include/projdefs.h b/FreeRTOS/include/projdefs.h new file mode 100644 index 0000000..d327c67 --- /dev/null +++ b/FreeRTOS/include/projdefs.h @@ -0,0 +1,120 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef PROJDEFS_H +#define PROJDEFS_H + +/* + * Defines the prototype to which task functions must conform. Defined in this + * file to ensure the type is known before portable.h is included. + */ +typedef void (* TaskFunction_t)( void * ); + +/* Converts a time in milliseconds to a time in ticks. This macro can be + * overridden by a macro of the same name defined in FreeRTOSConfig.h in case the + * definition here is not suitable for your application. */ +#ifndef pdMS_TO_TICKS + #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) ) +#endif + +#define pdFALSE ( ( BaseType_t ) 0 ) +#define pdTRUE ( ( BaseType_t ) 1 ) + +#define pdPASS ( pdTRUE ) +#define pdFAIL ( pdFALSE ) +#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) +#define errQUEUE_FULL ( ( BaseType_t ) 0 ) + +/* FreeRTOS error definitions. */ +#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) +#define errQUEUE_BLOCKED ( -4 ) +#define errQUEUE_YIELD ( -5 ) + +/* Macros used for basic data corruption checks. */ +#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES + #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 +#endif + +#if ( configUSE_16_BIT_TICKS == 1 ) + #define pdINTEGRITY_CHECK_VALUE 0x5a5a +#else + #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL +#endif + +/* The following errno values are used by FreeRTOS+ components, not FreeRTOS + * itself. */ +#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ +#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ +#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ +#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ +#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ +#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ +#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ +#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ +#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ +#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ +#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ +#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ +#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ +#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ +#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ +#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ +#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ +#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ +#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ +#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ +#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ +#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ +#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ +#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ +#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ +#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ +#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ +#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ +#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ +#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ +#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ +#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ +#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ +#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ +#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ +#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ +#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ +#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ +#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ + +/* The following endian values are used by FreeRTOS+ components, not FreeRTOS + * itself. */ +#define pdFREERTOS_LITTLE_ENDIAN 0 +#define pdFREERTOS_BIG_ENDIAN 1 + +/* Re-defining endian values for generic naming. */ +#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN +#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN + + +#endif /* PROJDEFS_H */ diff --git a/FreeRTOS/include/queue.h b/FreeRTOS/include/queue.h new file mode 100644 index 0000000..62f320a --- /dev/null +++ b/FreeRTOS/include/queue.h @@ -0,0 +1,1716 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#ifndef QUEUE_H +#define QUEUE_H + +#ifndef INC_FREERTOS_H + #error "include FreeRTOS.h" must appear in source files before "include queue.h" +#endif + +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +#include "task.h" + +/** + * Type by which queues are referenced. For example, a call to xQueueCreate() + * returns an QueueHandle_t variable that can then be used as a parameter to + * xQueueSend(), xQueueReceive(), etc. + */ +struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */ +typedef struct QueueDefinition * QueueHandle_t; + +/** + * Type by which queue sets are referenced. For example, a call to + * xQueueCreateSet() returns an xQueueSet variable that can then be used as a + * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc. + */ +typedef struct QueueDefinition * QueueSetHandle_t; + +/** + * Queue sets can contain both queues and semaphores, so the + * QueueSetMemberHandle_t is defined as a type to be used where a parameter or + * return value can be either an QueueHandle_t or an SemaphoreHandle_t. + */ +typedef struct QueueDefinition * QueueSetMemberHandle_t; + +/* For internal use only. */ +#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) +#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) +#define queueOVERWRITE ( ( BaseType_t ) 2 ) + +/* For internal use only. These definitions *must* match those in queue.c. */ +#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) +#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) +#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) +#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) + +/** + * queue. h + *
+ * QueueHandle_t xQueueCreate(
+ *                            UBaseType_t uxQueueLength,
+ *                            UBaseType_t uxItemSize
+ *                        );
+ * 
+ * + * Creates a new queue instance, and returns a handle by which the new queue + * can be referenced. + * + * Internally, within the FreeRTOS implementation, queues use two blocks of + * memory. The first block is used to hold the queue's data structures. The + * second block is used to hold items placed into the queue. If a queue is + * created using xQueueCreate() then both blocks of memory are automatically + * dynamically allocated inside the xQueueCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a queue is created using + * xQueueCreateStatic() then the application writer must provide the memory that + * will get used by the queue. xQueueCreateStatic() therefore allows a queue to + * be created without using any dynamic memory allocation. + * + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html + * + * @param uxQueueLength The maximum number of items that the queue can contain. + * + * @param uxItemSize The number of bytes each item in the queue will require. + * Items are queued by copy, not by reference, so this is the number of bytes + * that will be copied for each posted item. Each item on the queue must be + * the same size. + * + * @return If the queue is successfully create then a handle to the newly + * created queue is returned. If the queue cannot be created then 0 is + * returned. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * };
+ *
+ * void vATask( void *pvParameters )
+ * {
+ * QueueHandle_t xQueue1, xQueue2;
+ *
+ *  // Create a queue capable of containing 10 uint32_t values.
+ *  xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
+ *  if( xQueue1 == 0 )
+ *  {
+ *      // Queue was not created and must not be used.
+ *  }
+ *
+ *  // Create a queue capable of containing 10 pointers to AMessage structures.
+ *  // These should be passed by pointer as they contain a lot of data.
+ *  xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+ *  if( xQueue2 == 0 )
+ *  {
+ *      // Queue was not created and must not be used.
+ *  }
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueueCreate xQueueCreate + * \ingroup QueueManagement + */ +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) +#endif + +/** + * queue. h + *
+ * QueueHandle_t xQueueCreateStatic(
+ *                            UBaseType_t uxQueueLength,
+ *                            UBaseType_t uxItemSize,
+ *                            uint8_t *pucQueueStorageBuffer,
+ *                            StaticQueue_t *pxQueueBuffer
+ *                        );
+ * 
+ * + * Creates a new queue instance, and returns a handle by which the new queue + * can be referenced. + * + * Internally, within the FreeRTOS implementation, queues use two blocks of + * memory. The first block is used to hold the queue's data structures. The + * second block is used to hold items placed into the queue. If a queue is + * created using xQueueCreate() then both blocks of memory are automatically + * dynamically allocated inside the xQueueCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a queue is created using + * xQueueCreateStatic() then the application writer must provide the memory that + * will get used by the queue. xQueueCreateStatic() therefore allows a queue to + * be created without using any dynamic memory allocation. + * + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html + * + * @param uxQueueLength The maximum number of items that the queue can contain. + * + * @param uxItemSize The number of bytes each item in the queue will require. + * Items are queued by copy, not by reference, so this is the number of bytes + * that will be copied for each posted item. Each item on the queue must be + * the same size. + * + * @param pucQueueStorageBuffer If uxItemSize is not zero then + * pucQueueStorageBuffer must point to a uint8_t array that is at least large + * enough to hold the maximum number of items that can be in the queue at any + * one time - which is ( uxQueueLength * uxItemsSize ) bytes. If uxItemSize is + * zero then pucQueueStorageBuffer can be NULL. + * + * @param pxQueueBuffer Must point to a variable of type StaticQueue_t, which + * will be used to hold the queue's data structure. + * + * @return If the queue is created then a handle to the created queue is + * returned. If pxQueueBuffer is NULL then NULL is returned. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * };
+ *
+ #define QUEUE_LENGTH 10
+ #define ITEM_SIZE sizeof( uint32_t )
+ *
+ * // xQueueBuffer will hold the queue structure.
+ * StaticQueue_t xQueueBuffer;
+ *
+ * // ucQueueStorage will hold the items posted to the queue.  Must be at least
+ * // [(queue length) * ( queue item size)] bytes long.
+ * uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ];
+ *
+ * void vATask( void *pvParameters )
+ * {
+ * QueueHandle_t xQueue1;
+ *
+ *  // Create a queue capable of containing 10 uint32_t values.
+ *  xQueue1 = xQueueCreate( QUEUE_LENGTH, // The number of items the queue can hold.
+ *                          ITEM_SIZE     // The size of each item in the queue
+ *                          &( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue.
+ *                          &xQueueBuffer ); // The buffer that will hold the queue structure.
+ *
+ *  // The queue is guaranteed to be created successfully as no dynamic memory
+ *  // allocation is used.  Therefore xQueue1 is now a handle to a valid queue.
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueueCreateStatic xQueueCreateStatic + * \ingroup QueueManagement + */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +/** + * queue. h + *
+ * BaseType_t xQueueSendToToFront(
+ *                                 QueueHandle_t    xQueue,
+ *                                 const void       *pvItemToQueue,
+ *                                 TickType_t       xTicksToWait
+ *                             );
+ * 
+ * + * Post an item to the front of a queue. The item is queued by copy, not by + * reference. This function must not be called from an interrupt service + * routine. See xQueueSendFromISR () for an alternative which may be used + * in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0 and the + * queue is full. The time is defined in tick periods so the constant + * portTICK_PERIOD_MS should be used to convert to real time if this is required. + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * } xMessage;
+ *
+ * uint32_t ulVar = 10UL;
+ *
+ * void vATask( void *pvParameters )
+ * {
+ * QueueHandle_t xQueue1, xQueue2;
+ * struct AMessage *pxMessage;
+ *
+ *  // Create a queue capable of containing 10 uint32_t values.
+ *  xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
+ *
+ *  // Create a queue capable of containing 10 pointers to AMessage structures.
+ *  // These should be passed by pointer as they contain a lot of data.
+ *  xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+ *
+ *  // ...
+ *
+ *  if( xQueue1 != 0 )
+ *  {
+ *      // Send an uint32_t.  Wait for 10 ticks for space to become
+ *      // available if necessary.
+ *      if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
+ *      {
+ *          // Failed to post the message, even after 10 ticks.
+ *      }
+ *  }
+ *
+ *  if( xQueue2 != 0 )
+ *  {
+ *      // Send a pointer to a struct AMessage object.  Don't block if the
+ *      // queue is already full.
+ *      pxMessage = & xMessage;
+ *      xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
+ *  }
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) + +/** + * queue. h + *
+ * BaseType_t xQueueSendToBack(
+ *                                 QueueHandle_t    xQueue,
+ *                                 const void       *pvItemToQueue,
+ *                                 TickType_t       xTicksToWait
+ *                             );
+ * 
+ * + * This is a macro that calls xQueueGenericSend(). + * + * Post an item to the back of a queue. The item is queued by copy, not by + * reference. This function must not be called from an interrupt service + * routine. See xQueueSendFromISR () for an alternative which may be used + * in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0 and the queue + * is full. The time is defined in tick periods so the constant + * portTICK_PERIOD_MS should be used to convert to real time if this is required. + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * } xMessage;
+ *
+ * uint32_t ulVar = 10UL;
+ *
+ * void vATask( void *pvParameters )
+ * {
+ * QueueHandle_t xQueue1, xQueue2;
+ * struct AMessage *pxMessage;
+ *
+ *  // Create a queue capable of containing 10 uint32_t values.
+ *  xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
+ *
+ *  // Create a queue capable of containing 10 pointers to AMessage structures.
+ *  // These should be passed by pointer as they contain a lot of data.
+ *  xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+ *
+ *  // ...
+ *
+ *  if( xQueue1 != 0 )
+ *  {
+ *      // Send an uint32_t.  Wait for 10 ticks for space to become
+ *      // available if necessary.
+ *      if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
+ *      {
+ *          // Failed to post the message, even after 10 ticks.
+ *      }
+ *  }
+ *
+ *  if( xQueue2 != 0 )
+ *  {
+ *      // Send a pointer to a struct AMessage object.  Don't block if the
+ *      // queue is already full.
+ *      pxMessage = & xMessage;
+ *      xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
+ *  }
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) + +/** + * queue. h + *
+ * BaseType_t xQueueSend(
+ *                            QueueHandle_t xQueue,
+ *                            const void * pvItemToQueue,
+ *                            TickType_t xTicksToWait
+ *                       );
+ * 
+ * + * This is a macro that calls xQueueGenericSend(). It is included for + * backward compatibility with versions of FreeRTOS.org that did not + * include the xQueueSendToFront() and xQueueSendToBack() macros. It is + * equivalent to xQueueSendToBack(). + * + * Post an item on a queue. The item is queued by copy, not by reference. + * This function must not be called from an interrupt service routine. + * See xQueueSendFromISR () for an alternative which may be used in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0 and the + * queue is full. The time is defined in tick periods so the constant + * portTICK_PERIOD_MS should be used to convert to real time if this is required. + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * } xMessage;
+ *
+ * uint32_t ulVar = 10UL;
+ *
+ * void vATask( void *pvParameters )
+ * {
+ * QueueHandle_t xQueue1, xQueue2;
+ * struct AMessage *pxMessage;
+ *
+ *  // Create a queue capable of containing 10 uint32_t values.
+ *  xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
+ *
+ *  // Create a queue capable of containing 10 pointers to AMessage structures.
+ *  // These should be passed by pointer as they contain a lot of data.
+ *  xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+ *
+ *  // ...
+ *
+ *  if( xQueue1 != 0 )
+ *  {
+ *      // Send an uint32_t.  Wait for 10 ticks for space to become
+ *      // available if necessary.
+ *      if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
+ *      {
+ *          // Failed to post the message, even after 10 ticks.
+ *      }
+ *  }
+ *
+ *  if( xQueue2 != 0 )
+ *  {
+ *      // Send a pointer to a struct AMessage object.  Don't block if the
+ *      // queue is already full.
+ *      pxMessage = & xMessage;
+ *      xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
+ *  }
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) + +/** + * queue. h + *
+ * BaseType_t xQueueOverwrite(
+ *                            QueueHandle_t xQueue,
+ *                            const void * pvItemToQueue
+ *                       );
+ * 
+ * + * Only for use with queues that have a length of one - so the queue is either + * empty or full. + * + * Post an item on a queue. If the queue is already full then overwrite the + * value held in the queue. The item is queued by copy, not by reference. + * + * This function must not be called from an interrupt service routine. + * See xQueueOverwriteFromISR () for an alternative which may be used in an ISR. + * + * @param xQueue The handle of the queue to which the data is being sent. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @return xQueueOverwrite() is a macro that calls xQueueGenericSend(), and + * therefore has the same return values as xQueueSendToFront(). However, pdPASS + * is the only value that can be returned because xQueueOverwrite() will write + * to the queue even when the queue is already full. + * + * Example usage: + *
+ *
+ * void vFunction( void *pvParameters )
+ * {
+ * QueueHandle_t xQueue;
+ * uint32_t ulVarToSend, ulValReceived;
+ *
+ *  // Create a queue to hold one uint32_t value.  It is strongly
+ *  // recommended *not* to use xQueueOverwrite() on queues that can
+ *  // contain more than one value, and doing so will trigger an assertion
+ *  // if configASSERT() is defined.
+ *  xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
+ *
+ *  // Write the value 10 to the queue using xQueueOverwrite().
+ *  ulVarToSend = 10;
+ *  xQueueOverwrite( xQueue, &ulVarToSend );
+ *
+ *  // Peeking the queue should now return 10, but leave the value 10 in
+ *  // the queue.  A block time of zero is used as it is known that the
+ *  // queue holds a value.
+ *  ulValReceived = 0;
+ *  xQueuePeek( xQueue, &ulValReceived, 0 );
+ *
+ *  if( ulValReceived != 10 )
+ *  {
+ *      // Error unless the item was removed by a different task.
+ *  }
+ *
+ *  // The queue is still full.  Use xQueueOverwrite() to overwrite the
+ *  // value held in the queue with 100.
+ *  ulVarToSend = 100;
+ *  xQueueOverwrite( xQueue, &ulVarToSend );
+ *
+ *  // This time read from the queue, leaving the queue empty once more.
+ *  // A block time of 0 is used again.
+ *  xQueueReceive( xQueue, &ulValReceived, 0 );
+ *
+ *  // The value read should be the last value written, even though the
+ *  // queue was already full when the value was written.
+ *  if( ulValReceived != 100 )
+ *  {
+ *      // Error!
+ *  }
+ *
+ *  // ...
+ * }
+ * 
+ * \defgroup xQueueOverwrite xQueueOverwrite + * \ingroup QueueManagement + */ +#define xQueueOverwrite( xQueue, pvItemToQueue ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) + + +/** + * queue. h + *
+ * BaseType_t xQueueGenericSend(
+ *                                  QueueHandle_t xQueue,
+ *                                  const void * pvItemToQueue,
+ *                                  TickType_t xTicksToWait
+ *                                  BaseType_t xCopyPosition
+ *                              );
+ * 
+ * + * It is preferred that the macros xQueueSend(), xQueueSendToFront() and + * xQueueSendToBack() are used in place of calling this function directly. + * + * Post an item on a queue. The item is queued by copy, not by reference. + * This function must not be called from an interrupt service routine. + * See xQueueSendFromISR () for an alternative which may be used in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0 and the + * queue is full. The time is defined in tick periods so the constant + * portTICK_PERIOD_MS should be used to convert to real time if this is required. + * + * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the + * item at the back of the queue, or queueSEND_TO_FRONT to place the item + * at the front of the queue (for high priority messages). + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * } xMessage;
+ *
+ * uint32_t ulVar = 10UL;
+ *
+ * void vATask( void *pvParameters )
+ * {
+ * QueueHandle_t xQueue1, xQueue2;
+ * struct AMessage *pxMessage;
+ *
+ *  // Create a queue capable of containing 10 uint32_t values.
+ *  xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
+ *
+ *  // Create a queue capable of containing 10 pointers to AMessage structures.
+ *  // These should be passed by pointer as they contain a lot of data.
+ *  xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+ *
+ *  // ...
+ *
+ *  if( xQueue1 != 0 )
+ *  {
+ *      // Send an uint32_t.  Wait for 10 ticks for space to become
+ *      // available if necessary.
+ *      if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )
+ *      {
+ *          // Failed to post the message, even after 10 ticks.
+ *      }
+ *  }
+ *
+ *  if( xQueue2 != 0 )
+ *  {
+ *      // Send a pointer to a struct AMessage object.  Don't block if the
+ *      // queue is already full.
+ *      pxMessage = & xMessage;
+ *      xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );
+ *  }
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +BaseType_t xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * BaseType_t xQueuePeek(
+ *                           QueueHandle_t xQueue,
+ *                           void * const pvBuffer,
+ *                           TickType_t xTicksToWait
+ *                       );
+ * 
+ * + * Receive an item from a queue without removing the item from the queue. + * The item is received by copy so a buffer of adequate size must be + * provided. The number of bytes copied into the buffer was defined when + * the queue was created. + * + * Successfully received items remain on the queue so will be returned again + * by the next call, or a call to xQueueReceive(). + * + * This macro must not be used in an interrupt service routine. See + * xQueuePeekFromISR() for an alternative that can be called from an interrupt + * service routine. + * + * @param xQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for an item to receive should the queue be empty at the time + * of the call. The time is defined in tick periods so the constant + * portTICK_PERIOD_MS should be used to convert to real time if this is required. + * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue + * is empty. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * } xMessage;
+ *
+ * QueueHandle_t xQueue;
+ *
+ * // Task to create a queue and post a value.
+ * void vATask( void *pvParameters )
+ * {
+ * struct AMessage *pxMessage;
+ *
+ *  // Create a queue capable of containing 10 pointers to AMessage structures.
+ *  // These should be passed by pointer as they contain a lot of data.
+ *  xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
+ *  if( xQueue == 0 )
+ *  {
+ *      // Failed to create the queue.
+ *  }
+ *
+ *  // ...
+ *
+ *  // Send a pointer to a struct AMessage object.  Don't block if the
+ *  // queue is already full.
+ *  pxMessage = & xMessage;
+ *  xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
+ *
+ *  // ... Rest of task code.
+ * }
+ *
+ * // Task to peek the data from the queue.
+ * void vADifferentTask( void *pvParameters )
+ * {
+ * struct AMessage *pxRxedMessage;
+ *
+ *  if( xQueue != 0 )
+ *  {
+ *      // Peek a message on the created queue.  Block for 10 ticks if a
+ *      // message is not immediately available.
+ *      if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
+ *      {
+ *          // pcRxedMessage now points to the struct AMessage variable posted
+ *          // by vATask, but the item still remains on the queue.
+ *      }
+ *  }
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueuePeek xQueuePeek + * \ingroup QueueManagement + */ +BaseType_t xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * BaseType_t xQueuePeekFromISR(
+ *                                  QueueHandle_t xQueue,
+ *                                  void *pvBuffer,
+ *                              );
+ * 
+ * + * A version of xQueuePeek() that can be called from an interrupt service + * routine (ISR). + * + * Receive an item from a queue without removing the item from the queue. + * The item is received by copy so a buffer of adequate size must be + * provided. The number of bytes copied into the buffer was defined when + * the queue was created. + * + * Successfully received items remain on the queue so will be returned again + * by the next call, or a call to xQueueReceive(). + * + * @param xQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * \defgroup xQueuePeekFromISR xQueuePeekFromISR + * \ingroup QueueManagement + */ +BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, + void * const pvBuffer ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * BaseType_t xQueueReceive(
+ *                               QueueHandle_t xQueue,
+ *                               void *pvBuffer,
+ *                               TickType_t xTicksToWait
+ *                          );
+ * 
+ * + * Receive an item from a queue. The item is received by copy so a buffer of + * adequate size must be provided. The number of bytes copied into the buffer + * was defined when the queue was created. + * + * Successfully received items are removed from the queue. + * + * This function must not be used in an interrupt service routine. See + * xQueueReceiveFromISR for an alternative that can. + * + * @param xQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for an item to receive should the queue be empty at the time + * of the call. xQueueReceive() will return immediately if xTicksToWait + * is zero and the queue is empty. The time is defined in tick periods so the + * constant portTICK_PERIOD_MS should be used to convert to real time if this is + * required. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * Example usage: + *
+ * struct AMessage
+ * {
+ *  char ucMessageID;
+ *  char ucData[ 20 ];
+ * } xMessage;
+ *
+ * QueueHandle_t xQueue;
+ *
+ * // Task to create a queue and post a value.
+ * void vATask( void *pvParameters )
+ * {
+ * struct AMessage *pxMessage;
+ *
+ *  // Create a queue capable of containing 10 pointers to AMessage structures.
+ *  // These should be passed by pointer as they contain a lot of data.
+ *  xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
+ *  if( xQueue == 0 )
+ *  {
+ *      // Failed to create the queue.
+ *  }
+ *
+ *  // ...
+ *
+ *  // Send a pointer to a struct AMessage object.  Don't block if the
+ *  // queue is already full.
+ *  pxMessage = & xMessage;
+ *  xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
+ *
+ *  // ... Rest of task code.
+ * }
+ *
+ * // Task to receive from the queue.
+ * void vADifferentTask( void *pvParameters )
+ * {
+ * struct AMessage *pxRxedMessage;
+ *
+ *  if( xQueue != 0 )
+ *  {
+ *      // Receive a message on the created queue.  Block for 10 ticks if a
+ *      // message is not immediately available.
+ *      if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
+ *      {
+ *          // pcRxedMessage now points to the struct AMessage variable posted
+ *          // by vATask.
+ *      }
+ *  }
+ *
+ *  // ... Rest of task code.
+ * }
+ * 
+ * \defgroup xQueueReceive xQueueReceive + * \ingroup QueueManagement + */ +BaseType_t xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );
+ * 
+ * + * Return the number of messages stored in a queue. + * + * @param xQueue A handle to the queue being queried. + * + * @return The number of messages available in the queue. + * + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * \ingroup QueueManagement + */ +UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );
+ * 
+ * + * Return the number of free spaces available in a queue. This is equal to the + * number of items that can be sent to the queue before the queue becomes full + * if no items are removed. + * + * @param xQueue A handle to the queue being queried. + * + * @return The number of spaces available in the queue. + * + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * \ingroup QueueManagement + */ +UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * void vQueueDelete( QueueHandle_t xQueue );
+ * 
+ * + * Delete a queue - freeing all the memory allocated for storing of items + * placed on the queue. + * + * @param xQueue A handle to the queue to be deleted. + * + * \defgroup vQueueDelete vQueueDelete + * \ingroup QueueManagement + */ +void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * BaseType_t xQueueSendToFrontFromISR(
+ *                                       QueueHandle_t xQueue,
+ *                                       const void *pvItemToQueue,
+ *                                       BaseType_t *pxHigherPriorityTaskWoken
+ *                                    );
+ * 
+ * + * This is a macro that calls xQueueGenericSendFromISR(). + * + * Post an item to the front of a queue. It is safe to use this macro from + * within an interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @return pdTRUE if the data was successfully sent to the queue, otherwise + * errQUEUE_FULL. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): + *
+ * void vBufferISR( void )
+ * {
+ * char cIn;
+ * BaseType_t xHigherPrioritTaskWoken;
+ *
+ *  // We have not woken a task at the start of the ISR.
+ *  xHigherPriorityTaskWoken = pdFALSE;
+ *
+ *  // Loop until the buffer is empty.
+ *  do
+ *  {
+ *      // Obtain a byte from the buffer.
+ *      cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
+ *
+ *      // Post the byte.
+ *      xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
+ *
+ *  } while( portINPUT_BYTE( BUFFER_COUNT ) );
+ *
+ *  // Now the buffer is empty we can switch context if necessary.
+ *  if( xHigherPriorityTaskWoken )
+ *  {
+ *      taskYIELD ();
+ *  }
+ * }
+ * 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) + + +/** + * queue. h + *
+ * BaseType_t xQueueSendToBackFromISR(
+ *                                       QueueHandle_t xQueue,
+ *                                       const void *pvItemToQueue,
+ *                                       BaseType_t *pxHigherPriorityTaskWoken
+ *                                    );
+ * 
+ * + * This is a macro that calls xQueueGenericSendFromISR(). + * + * Post an item to the back of a queue. It is safe to use this macro from + * within an interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @return pdTRUE if the data was successfully sent to the queue, otherwise + * errQUEUE_FULL. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): + *
+ * void vBufferISR( void )
+ * {
+ * char cIn;
+ * BaseType_t xHigherPriorityTaskWoken;
+ *
+ *  // We have not woken a task at the start of the ISR.
+ *  xHigherPriorityTaskWoken = pdFALSE;
+ *
+ *  // Loop until the buffer is empty.
+ *  do
+ *  {
+ *      // Obtain a byte from the buffer.
+ *      cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
+ *
+ *      // Post the byte.
+ *      xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
+ *
+ *  } while( portINPUT_BYTE( BUFFER_COUNT ) );
+ *
+ *  // Now the buffer is empty we can switch context if necessary.
+ *  if( xHigherPriorityTaskWoken )
+ *  {
+ *      taskYIELD ();
+ *  }
+ * }
+ * 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) + +/** + * queue. h + *
+ * BaseType_t xQueueOverwriteFromISR(
+ *                            QueueHandle_t xQueue,
+ *                            const void * pvItemToQueue,
+ *                            BaseType_t *pxHigherPriorityTaskWoken
+ *                       );
+ * 
+ * + * A version of xQueueOverwrite() that can be used in an interrupt service + * routine (ISR). + * + * Only for use with queues that can hold a single item - so the queue is either + * empty or full. + * + * Post an item on a queue. If the queue is already full then overwrite the + * value held in the queue. The item is queued by copy, not by reference. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xQueueOverwriteFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @return xQueueOverwriteFromISR() is a macro that calls + * xQueueGenericSendFromISR(), and therefore has the same return values as + * xQueueSendToFrontFromISR(). However, pdPASS is the only value that can be + * returned because xQueueOverwriteFromISR() will write to the queue even when + * the queue is already full. + * + * Example usage: + *
+ *
+ * QueueHandle_t xQueue;
+ *
+ * void vFunction( void *pvParameters )
+ * {
+ *  // Create a queue to hold one uint32_t value.  It is strongly
+ *  // recommended *not* to use xQueueOverwriteFromISR() on queues that can
+ *  // contain more than one value, and doing so will trigger an assertion
+ *  // if configASSERT() is defined.
+ *  xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
+ * }
+ *
+ * void vAnInterruptHandler( void )
+ * {
+ * // xHigherPriorityTaskWoken must be set to pdFALSE before it is used.
+ * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
+ * uint32_t ulVarToSend, ulValReceived;
+ *
+ *  // Write the value 10 to the queue using xQueueOverwriteFromISR().
+ *  ulVarToSend = 10;
+ *  xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
+ *
+ *  // The queue is full, but calling xQueueOverwriteFromISR() again will still
+ *  // pass because the value held in the queue will be overwritten with the
+ *  // new value.
+ *  ulVarToSend = 100;
+ *  xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
+ *
+ *  // Reading from the queue will now return 100.
+ *
+ *  // ...
+ *
+ *  if( xHigherPrioritytaskWoken == pdTRUE )
+ *  {
+ *      // Writing to the queue caused a task to unblock and the unblocked task
+ *      // has a priority higher than or equal to the priority of the currently
+ *      // executing task (the task this interrupt interrupted).  Perform a context
+ *      // switch so this interrupt returns directly to the unblocked task.
+ *      portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.
+ *  }
+ * }
+ * 
+ * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR + * \ingroup QueueManagement + */ +#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) + +/** + * queue. h + *
+ * BaseType_t xQueueSendFromISR(
+ *                                   QueueHandle_t xQueue,
+ *                                   const void *pvItemToQueue,
+ *                                   BaseType_t *pxHigherPriorityTaskWoken
+ *                              );
+ * 
+ * + * This is a macro that calls xQueueGenericSendFromISR(). It is included + * for backward compatibility with versions of FreeRTOS.org that did not + * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR() + * macros. + * + * Post an item to the back of a queue. It is safe to use this function from + * within an interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xQueueSendFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @return pdTRUE if the data was successfully sent to the queue, otherwise + * errQUEUE_FULL. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): + *
+ * void vBufferISR( void )
+ * {
+ * char cIn;
+ * BaseType_t xHigherPriorityTaskWoken;
+ *
+ *  // We have not woken a task at the start of the ISR.
+ *  xHigherPriorityTaskWoken = pdFALSE;
+ *
+ *  // Loop until the buffer is empty.
+ *  do
+ *  {
+ *      // Obtain a byte from the buffer.
+ *      cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
+ *
+ *      // Post the byte.
+ *      xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
+ *
+ *  } while( portINPUT_BYTE( BUFFER_COUNT ) );
+ *
+ *  // Now the buffer is empty we can switch context if necessary.
+ *  if( xHigherPriorityTaskWoken )
+ *  {
+ *      // Actual macro used here is port specific.
+ *      portYIELD_FROM_ISR ();
+ *  }
+ * }
+ * 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) + +/** + * queue. h + *
+ * BaseType_t xQueueGenericSendFromISR(
+ *                                         QueueHandle_t    xQueue,
+ *                                         const    void    *pvItemToQueue,
+ *                                         BaseType_t  *pxHigherPriorityTaskWoken,
+ *                                         BaseType_t  xCopyPosition
+ *                                     );
+ * 
+ * + * It is preferred that the macros xQueueSendFromISR(), + * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place + * of calling this function directly. xQueueGiveFromISR() is an + * equivalent for use by semaphores that don't actually copy any data. + * + * Post an item on a queue. It is safe to use this function from within an + * interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the + * item at the back of the queue, or queueSEND_TO_FRONT to place the item + * at the front of the queue (for high priority messages). + * + * @return pdTRUE if the data was successfully sent to the queue, otherwise + * errQUEUE_FULL. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): + *
+ * void vBufferISR( void )
+ * {
+ * char cIn;
+ * BaseType_t xHigherPriorityTaskWokenByPost;
+ *
+ *  // We have not woken a task at the start of the ISR.
+ *  xHigherPriorityTaskWokenByPost = pdFALSE;
+ *
+ *  // Loop until the buffer is empty.
+ *  do
+ *  {
+ *      // Obtain a byte from the buffer.
+ *      cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
+ *
+ *      // Post each byte.
+ *      xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
+ *
+ *  } while( portINPUT_BYTE( BUFFER_COUNT ) );
+ *
+ *  // Now the buffer is empty we can switch context if necessary.  Note that the
+ *  // name of the yield function required is port specific.
+ *  if( xHigherPriorityTaskWokenByPost )
+ *  {
+ *      portYIELD_FROM_ISR();
+ *  }
+ * }
+ * 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, + const void * const pvItemToQueue, + BaseType_t * const pxHigherPriorityTaskWoken, + const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; +BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + +/** + * queue. h + *
+ * BaseType_t xQueueReceiveFromISR(
+ *                                     QueueHandle_t    xQueue,
+ *                                     void             *pvBuffer,
+ *                                     BaseType_t       *pxTaskWoken
+ *                                 );
+ * 
+ * + * Receive an item from a queue. It is safe to use this function from within an + * interrupt service routine. + * + * @param xQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @param pxTaskWoken A task may be blocked waiting for space to become + * available on the queue. If xQueueReceiveFromISR causes such a task to + * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will + * remain unchanged. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * Example usage: + *
+ *
+ * QueueHandle_t xQueue;
+ *
+ * // Function to create a queue and post some values.
+ * void vAFunction( void *pvParameters )
+ * {
+ * char cValueToPost;
+ * const TickType_t xTicksToWait = ( TickType_t )0xff;
+ *
+ *  // Create a queue capable of containing 10 characters.
+ *  xQueue = xQueueCreate( 10, sizeof( char ) );
+ *  if( xQueue == 0 )
+ *  {
+ *      // Failed to create the queue.
+ *  }
+ *
+ *  // ...
+ *
+ *  // Post some characters that will be used within an ISR.  If the queue
+ *  // is full then this task will block for xTicksToWait ticks.
+ *  cValueToPost = 'a';
+ *  xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
+ *  cValueToPost = 'b';
+ *  xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
+ *
+ *  // ... keep posting characters ... this task may block when the queue
+ *  // becomes full.
+ *
+ *  cValueToPost = 'c';
+ *  xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
+ * }
+ *
+ * // ISR that outputs all the characters received on the queue.
+ * void vISR_Routine( void )
+ * {
+ * BaseType_t xTaskWokenByReceive = pdFALSE;
+ * char cRxedChar;
+ *
+ *  while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
+ *  {
+ *      // A character was received.  Output the character now.
+ *      vOutputCharacter( cRxedChar );
+ *
+ *      // If removing the character from the queue woke the task that was
+ *      // posting onto the queue cTaskWokenByReceive will have been set to
+ *      // pdTRUE.  No matter how many times this loop iterates only one
+ *      // task will be woken.
+ *  }
+ *
+ *  if( cTaskWokenByPost != ( char ) pdFALSE;
+ *  {
+ *      taskYIELD ();
+ *  }
+ * }
+ * 
+ * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR + * \ingroup QueueManagement + */ +BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, + void * const pvBuffer, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + +/* + * Utilities to query queues that are safe to use from an ISR. These utilities + * should be used only from witin an ISR, or within a critical section. + */ +BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; + +/* + * The functions defined above are for passing data to and from tasks. The + * functions below are the equivalents for passing data to and from + * co-routines. + * + * These functions are called from the co-routine macro implementation and + * should not be called directly from application code. Instead use the macro + * wrappers defined within croutine.h. + */ +BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, + const void * pvItemToQueue, + BaseType_t xCoRoutinePreviouslyWoken ); +BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, + void * pvBuffer, + BaseType_t * pxTaskWoken ); +BaseType_t xQueueCRSend( QueueHandle_t xQueue, + const void * pvItemToQueue, + TickType_t xTicksToWait ); +BaseType_t xQueueCRReceive( QueueHandle_t xQueue, + void * pvBuffer, + TickType_t xTicksToWait ); + +/* + * For internal use only. Use xSemaphoreCreateMutex(), + * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling + * these functions directly. + */ +QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; +TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; + +/* + * For internal use only. Use xSemaphoreTakeMutexRecursive() or + * xSemaphoreGiveMutexRecursive() instead of calling these functions directly. + */ +BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; + +/* + * Reset a queue back to its original empty state. The return value is now + * obsolete and is always set to pdPASS. + */ +#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) + +/* + * The registry is provided as a means for kernel aware debuggers to + * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add + * a queue, semaphore or mutex handle to the registry if you want the handle + * to be available to a kernel aware debugger. If you are not using a kernel + * aware debugger then this function can be ignored. + * + * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the + * registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0 + * within FreeRTOSConfig.h for the registry to be available. Its value + * does not effect the number of queues, semaphores and mutexes that can be + * created - just the number that the registry can hold. + * + * @param xQueue The handle of the queue being added to the registry. This + * is the handle returned by a call to xQueueCreate(). Semaphore and mutex + * handles can also be passed in here. + * + * @param pcName The name to be associated with the handle. This is the + * name that the kernel aware debugger will display. The queue registry only + * stores a pointer to the string - so the string must be persistent (global or + * preferably in ROM/Flash), not on the stack. + */ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcQueueName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +#endif + +/* + * The registry is provided as a means for kernel aware debuggers to + * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add + * a queue, semaphore or mutex handle to the registry if you want the handle + * to be available to a kernel aware debugger, and vQueueUnregisterQueue() to + * remove the queue, semaphore or mutex from the register. If you are not using + * a kernel aware debugger then this function can be ignored. + * + * @param xQueue The handle of the queue being removed from the registry. + */ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +#endif + +/* + * The queue registry is provided as a means for kernel aware debuggers to + * locate queues, semaphores and mutexes. Call pcQueueGetName() to look + * up and return the name of a queue in the queue registry from the queue's + * handle. + * + * @param xQueue The handle of the queue the name of which will be returned. + * @return If the queue is in the registry then a pointer to the name of the + * queue is returned. If the queue is not in the registry then NULL is + * returned. + */ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + const char * pcQueueGetName( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +#endif + +/* + * Generic version of the function used to create a queue using dynamic memory + * allocation. This is called by other functions and macros that create other + * RTOS objects that use the queue structure as their base. + */ +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#endif + +/* + * Generic version of the function used to create a queue using dynamic memory + * allocation. This is called by other functions and macros that create other + * RTOS objects that use the queue structure as their base. + */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#endif + +/* + * Queue sets provide a mechanism to allow a task to block (pend) on a read + * operation from multiple queues or semaphores simultaneously. + * + * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this + * function. + * + * A queue set must be explicitly created using a call to xQueueCreateSet() + * before it can be used. Once created, standard FreeRTOS queues and semaphores + * can be added to the set using calls to xQueueAddToSet(). + * xQueueSelectFromSet() is then used to determine which, if any, of the queues + * or semaphores contained in the set is in a state where a queue read or + * semaphore take operation would be successful. + * + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html + * for reasons why queue sets are very rarely needed in practice as there are + * simpler methods of blocking on multiple objects. + * + * Note 2: Blocking on a queue set that contains a mutex will not cause the + * mutex holder to inherit the priority of the blocked task. + * + * Note 3: An additional 4 bytes of RAM is required for each space in a every + * queue added to a queue set. Therefore counting semaphores that have a high + * maximum count value should not be added to a queue set. + * + * Note 4: A receive (in the case of a queue) or take (in the case of a + * semaphore) operation must not be performed on a member of a queue set unless + * a call to xQueueSelectFromSet() has first returned a handle to that set member. + * + * @param uxEventQueueLength Queue sets store events that occur on + * the queues and semaphores contained in the set. uxEventQueueLength specifies + * the maximum number of events that can be queued at once. To be absolutely + * certain that events are not lost uxEventQueueLength should be set to the + * total sum of the length of the queues added to the set, where binary + * semaphores and mutexes have a length of 1, and counting semaphores have a + * length set by their maximum count value. Examples: + * + If a queue set is to hold a queue of length 5, another queue of length 12, + * and a binary semaphore, then uxEventQueueLength should be set to + * (5 + 12 + 1), or 18. + * + If a queue set is to hold three binary semaphores then uxEventQueueLength + * should be set to (1 + 1 + 1 ), or 3. + * + If a queue set is to hold a counting semaphore that has a maximum count of + * 5, and a counting semaphore that has a maximum count of 3, then + * uxEventQueueLength should be set to (5 + 3), or 8. + * + * @return If the queue set is created successfully then a handle to the created + * queue set is returned. Otherwise NULL is returned. + */ +QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION; + +/* + * Adds a queue or semaphore to a queue set that was previously created by a + * call to xQueueCreateSet(). + * + * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this + * function. + * + * Note 1: A receive (in the case of a queue) or take (in the case of a + * semaphore) operation must not be performed on a member of a queue set unless + * a call to xQueueSelectFromSet() has first returned a handle to that set member. + * + * @param xQueueOrSemaphore The handle of the queue or semaphore being added to + * the queue set (cast to an QueueSetMemberHandle_t type). + * + * @param xQueueSet The handle of the queue set to which the queue or semaphore + * is being added. + * + * @return If the queue or semaphore was successfully added to the queue set + * then pdPASS is returned. If the queue could not be successfully added to the + * queue set because it is already a member of a different queue set then pdFAIL + * is returned. + */ +BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; + +/* + * Removes a queue or semaphore from a queue set. A queue or semaphore can only + * be removed from a set if the queue or semaphore is empty. + * + * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this + * function. + * + * @param xQueueOrSemaphore The handle of the queue or semaphore being removed + * from the queue set (cast to an QueueSetMemberHandle_t type). + * + * @param xQueueSet The handle of the queue set in which the queue or semaphore + * is included. + * + * @return If the queue or semaphore was successfully removed from the queue set + * then pdPASS is returned. If the queue was not in the queue set, or the + * queue (or semaphore) was not empty, then pdFAIL is returned. + */ +BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; + +/* + * xQueueSelectFromSet() selects from the members of a queue set a queue or + * semaphore that either contains data (in the case of a queue) or is available + * to take (in the case of a semaphore). xQueueSelectFromSet() effectively + * allows a task to block (pend) on a read operation on all the queues and + * semaphores in a queue set simultaneously. + * + * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this + * function. + * + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html + * for reasons why queue sets are very rarely needed in practice as there are + * simpler methods of blocking on multiple objects. + * + * Note 2: Blocking on a queue set that contains a mutex will not cause the + * mutex holder to inherit the priority of the blocked task. + * + * Note 3: A receive (in the case of a queue) or take (in the case of a + * semaphore) operation must not be performed on a member of a queue set unless + * a call to xQueueSelectFromSet() has first returned a handle to that set member. + * + * @param xQueueSet The queue set on which the task will (potentially) block. + * + * @param xTicksToWait The maximum time, in ticks, that the calling task will + * remain in the Blocked state (with other tasks executing) to wait for a member + * of the queue set to be ready for a successful queue read or semaphore take + * operation. + * + * @return xQueueSelectFromSet() will return the handle of a queue (cast to + * a QueueSetMemberHandle_t type) contained in the queue set that contains data, + * or the handle of a semaphore (cast to a QueueSetMemberHandle_t type) contained + * in the queue set that is available, or NULL if no such queue or semaphore + * exists before before the specified block time expires. + */ +QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/* + * A version of xQueueSelectFromSet() that can be used from an ISR. + */ +QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; + +/* Not public API functions. */ +void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; +BaseType_t xQueueGenericReset( QueueHandle_t xQueue, + BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; +void vQueueSetQueueNumber( QueueHandle_t xQueue, + UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; +UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; + + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ + +#endif /* QUEUE_H */ diff --git a/FreeRTOS/include/stack_macros.h b/FreeRTOS/include/stack_macros.h new file mode 100644 index 0000000..e273692 --- /dev/null +++ b/FreeRTOS/include/stack_macros.h @@ -0,0 +1,127 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef STACK_MACROS_H +#define STACK_MACROS_H + +/* + * Call the stack overflow hook function if the stack of the task being swapped + * out is currently overflowed, or looks like it might have overflowed in the + * past. + * + * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check + * the current stack state only - comparing the current top of stack value to + * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 + * will also cause the last few stack bytes to be checked to ensure the value + * to which the bytes were set when the task was created have not been + * overwritten. Note this second test does not guarantee that an overflowed + * stack will always be recognised. + */ + +/*-----------------------------------------------------------*/ + +#if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) + +/* Only the current stack state is to be checked. */ + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ +/*-----------------------------------------------------------*/ + +#if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) + +/* Only the current stack state is to be checked. */ + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ +/*-----------------------------------------------------------*/ + +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) + + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ + const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ + \ + if( ( pulStack[ 0 ] != ulCheckValue ) || \ + ( pulStack[ 1 ] != ulCheckValue ) || \ + ( pulStack[ 2 ] != ulCheckValue ) || \ + ( pulStack[ 3 ] != ulCheckValue ) ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ +/*-----------------------------------------------------------*/ + +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) + + #define taskCHECK_FOR_STACK_OVERFLOW() \ + { \ + int8_t * pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ + } + +#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ +/*-----------------------------------------------------------*/ + +/* Remove stack overflow macro if not being used. */ +#ifndef taskCHECK_FOR_STACK_OVERFLOW + #define taskCHECK_FOR_STACK_OVERFLOW() +#endif + + + +#endif /* STACK_MACROS_H */ diff --git a/FreeRTOS/include/task.h b/FreeRTOS/include/task.h new file mode 100644 index 0000000..4a8ad39 --- /dev/null +++ b/FreeRTOS/include/task.h @@ -0,0 +1,3053 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#ifndef INC_TASK_H +#define INC_TASK_H + +#ifndef INC_FREERTOS_H + #error "include FreeRTOS.h must appear in source files before include task.h" +#endif + +#include "list.h" + +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +/*----------------------------------------------------------- +* MACROS AND DEFINITIONS +*----------------------------------------------------------*/ + +#define tskKERNEL_VERSION_NUMBER "V10.4.2" +#define tskKERNEL_VERSION_MAJOR 10 +#define tskKERNEL_VERSION_MINOR 4 +#define tskKERNEL_VERSION_BUILD 2 + +/* MPU region parameters passed in ulParameters + * of MemoryRegion_t struct. */ +#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) +#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) +#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) +#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) + +/* The direct to task notification feature used to have only a single notification + * per task. Now there is an array of notifications per task that is dimensioned by + * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the + * original direct to task notification defaults to using the first index in the + * array. */ +#define tskDEFAULT_INDEX_TO_NOTIFY ( 0 ) + +/** + * task. h + * + * Type by which tasks are referenced. For example, a call to xTaskCreate + * returns (via a pointer parameter) an TaskHandle_t variable that can then + * be used as a parameter to vTaskDelete to delete the task. + * + * \defgroup TaskHandle_t TaskHandle_t + * \ingroup Tasks + */ +struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +typedef struct tskTaskControlBlock * TaskHandle_t; + +/* + * Defines the prototype to which the application task hook function must + * conform. + */ +typedef BaseType_t (* TaskHookFunction_t)( void * ); + +/* Task states returned by eTaskGetState. */ +typedef enum +{ + eRunning = 0, /* A task is querying the state of itself, so must be running. */ + eReady, /* The task being queried is in a read or pending ready list. */ + eBlocked, /* The task being queried is in the Blocked state. */ + eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ + eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */ + eInvalid /* Used as an 'invalid state' value. */ +} eTaskState; + +/* Actions that can be performed when vTaskNotify() is called. */ +typedef enum +{ + eNoAction = 0, /* Notify the task without updating its notify value. */ + eSetBits, /* Set bits in the task's notification value. */ + eIncrement, /* Increment the task's notification value. */ + eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */ + eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */ +} eNotifyAction; + +/* + * Used internally only. + */ +typedef struct xTIME_OUT +{ + BaseType_t xOverflowCount; + TickType_t xTimeOnEntering; +} TimeOut_t; + +/* + * Defines the memory ranges allocated to the task when an MPU is used. + */ +typedef struct xMEMORY_REGION +{ + void * pvBaseAddress; + uint32_t ulLengthInBytes; + uint32_t ulParameters; +} MemoryRegion_t; + +/* + * Parameters required to create an MPU protected task. + */ +typedef struct xTASK_PARAMETERS +{ + TaskFunction_t pvTaskCode; + const char * pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + configSTACK_DEPTH_TYPE usStackDepth; + void * pvParameters; + UBaseType_t uxPriority; + StackType_t * puxStackBuffer; + MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; + #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + StaticTask_t * const pxTaskBuffer; + #endif +} TaskParameters_t; + +/* Used with the uxTaskGetSystemState() function to return the state of each task + * in the system. */ +typedef struct xTASK_STATUS +{ + TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */ + const char * pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + UBaseType_t xTaskNumber; /* A number unique to the task. */ + eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */ + UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */ + UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ + uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See https://www.FreeRTOS.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ + StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */ + configSTACK_DEPTH_TYPE usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ +} TaskStatus_t; + +/* Possible return values for eTaskConfirmSleepModeStatus(). */ +typedef enum +{ + eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ + eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */ + eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ +} eSleepModeStatus; + +/** + * Defines the priority used by the idle task. This must not be modified. + * + * \ingroup TaskUtils + */ +#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) + +/** + * task. h + * + * Macro for forcing a context switch. + * + * \defgroup taskYIELD taskYIELD + * \ingroup SchedulerControl + */ +#define taskYIELD() portYIELD() + +/** + * task. h + * + * Macro to mark the start of a critical code region. Preemptive context + * switches cannot occur when in a critical region. + * + * NOTE: This may alter the stack (depending on the portable implementation) + * so must be used with care! + * + * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL + * \ingroup SchedulerControl + */ +#define taskENTER_CRITICAL() portENTER_CRITICAL() +#define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() + +/** + * task. h + * + * Macro to mark the end of a critical code region. Preemptive context + * switches cannot occur when in a critical region. + * + * NOTE: This may alter the stack (depending on the portable implementation) + * so must be used with care! + * + * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL + * \ingroup SchedulerControl + */ +#define taskEXIT_CRITICAL() portEXIT_CRITICAL() +#define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) + +/** + * task. h + * + * Macro to disable all maskable interrupts. + * + * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS + * \ingroup SchedulerControl + */ +#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() + +/** + * task. h + * + * Macro to enable microcontroller interrupts. + * + * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS + * \ingroup SchedulerControl + */ +#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() + +/* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is + * 0 to generate more optimal code when configASSERT() is defined as the constant + * is used in assert() statements. */ +#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) +#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) +#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) + + +/*----------------------------------------------------------- +* TASK CREATION API +*----------------------------------------------------------*/ + +/** + * task. h + *
+ * BaseType_t xTaskCreate(
+ *                            TaskFunction_t pvTaskCode,
+ *                            const char * const pcName,
+ *                            configSTACK_DEPTH_TYPE usStackDepth,
+ *                            void *pvParameters,
+ *                            UBaseType_t uxPriority,
+ *                            TaskHandle_t *pvCreatedTask
+ *                        );
+ * 
+ * + * Create a new task and add it to the list of tasks that are ready to run. + * + * Internally, within the FreeRTOS implementation, tasks use two blocks of + * memory. The first block is used to hold the task's data structures. The + * second block is used by the task as its stack. If a task is created using + * xTaskCreate() then both blocks of memory are automatically dynamically + * allocated inside the xTaskCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a task is created using + * xTaskCreateStatic() then the application writer must provide the required + * memory. xTaskCreateStatic() therefore allows a task to be created without + * using any dynamic memory allocation. + * + * See xTaskCreateStatic() for a version that does not use any dynamic memory + * allocation. + * + * xTaskCreate() can only be used to create a task that has unrestricted + * access to the entire microcontroller memory map. Systems that include MPU + * support can alternatively create an MPU constrained task using + * xTaskCreateRestricted(). + * + * @param pvTaskCode Pointer to the task entry function. Tasks + * must be implemented to never return (i.e. continuous loop). + * + * @param pcName A descriptive name for the task. This is mainly used to + * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default + * is 16. + * + * @param usStackDepth The size of the task stack specified as the number of + * variables the stack can hold - not the number of bytes. For example, if + * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes + * will be allocated for stack storage. + * + * @param pvParameters Pointer that will be used as the parameter for the task + * being created. + * + * @param uxPriority The priority at which the task should run. Systems that + * include MPU support can optionally create tasks in a privileged (system) + * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For + * example, to create a privileged task at priority 2 the uxPriority parameter + * should be set to ( 2 | portPRIVILEGE_BIT ). + * + * @param pvCreatedTask Used to pass back a handle by which the created task + * can be referenced. + * + * @return pdPASS if the task was successfully created and added to a ready + * list, otherwise an error code defined in the file projdefs.h + * + * Example usage: + *
+ * // Task to be created.
+ * void vTaskCode( void * pvParameters )
+ * {
+ *   for( ;; )
+ *   {
+ *       // Task code goes here.
+ *   }
+ * }
+ *
+ * // Function that creates a task.
+ * void vOtherFunction( void )
+ * {
+ * static uint8_t ucParameterToPass;
+ * TaskHandle_t xHandle = NULL;
+ *
+ *   // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass
+ *   // must exist for the lifetime of the task, so in this case is declared static.  If it was just an
+ *   // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
+ *   // the new task attempts to access it.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
+ *   configASSERT( xHandle );
+ *
+ *   // Use the handle to delete the task.
+ *   if( xHandle != NULL )
+ *   {
+ *      vTaskDelete( xHandle );
+ *   }
+ * }
+ * 
+ * \defgroup xTaskCreate xTaskCreate + * \ingroup Tasks + */ +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + BaseType_t xTaskCreate( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const configSTACK_DEPTH_TYPE usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION; +#endif + +/** + * task. h + *
+ * TaskHandle_t xTaskCreateStatic( TaskFunction_t pvTaskCode,
+ *                               const char * const pcName,
+ *                               uint32_t ulStackDepth,
+ *                               void *pvParameters,
+ *                               UBaseType_t uxPriority,
+ *                               StackType_t *pxStackBuffer,
+ *                               StaticTask_t *pxTaskBuffer );
+ * 
+ * + * Create a new task and add it to the list of tasks that are ready to run. + * + * Internally, within the FreeRTOS implementation, tasks use two blocks of + * memory. The first block is used to hold the task's data structures. The + * second block is used by the task as its stack. If a task is created using + * xTaskCreate() then both blocks of memory are automatically dynamically + * allocated inside the xTaskCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a task is created using + * xTaskCreateStatic() then the application writer must provide the required + * memory. xTaskCreateStatic() therefore allows a task to be created without + * using any dynamic memory allocation. + * + * @param pvTaskCode Pointer to the task entry function. Tasks + * must be implemented to never return (i.e. continuous loop). + * + * @param pcName A descriptive name for the task. This is mainly used to + * facilitate debugging. The maximum length of the string is defined by + * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h. + * + * @param ulStackDepth The size of the task stack specified as the number of + * variables the stack can hold - not the number of bytes. For example, if + * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes + * will be allocated for stack storage. + * + * @param pvParameters Pointer that will be used as the parameter for the task + * being created. + * + * @param uxPriority The priority at which the task will run. + * + * @param pxStackBuffer Must point to a StackType_t array that has at least + * ulStackDepth indexes - the array will then be used as the task's stack, + * removing the need for the stack to be allocated dynamically. + * + * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will + * then be used to hold the task's data structures, removing the need for the + * memory to be allocated dynamically. + * + * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will + * be created and a handle to the created task is returned. If either + * pxStackBuffer or pxTaskBuffer are NULL then the task will not be created and + * NULL is returned. + * + * Example usage: + *
+ *
+ *  // Dimensions the buffer that the task being created will use as its stack.
+ *  // NOTE:  This is the number of words the stack will hold, not the number of
+ *  // bytes.  For example, if each stack item is 32-bits, and this is set to 100,
+ *  // then 400 bytes (100 * 32-bits) will be allocated.
+ #define STACK_SIZE 200
+ *
+ *  // Structure that will hold the TCB of the task being created.
+ *  StaticTask_t xTaskBuffer;
+ *
+ *  // Buffer that the task being created will use as its stack.  Note this is
+ *  // an array of StackType_t variables.  The size of StackType_t is dependent on
+ *  // the RTOS port.
+ *  StackType_t xStack[ STACK_SIZE ];
+ *
+ *  // Function that implements the task being created.
+ *  void vTaskCode( void * pvParameters )
+ *  {
+ *      // The parameter value is expected to be 1 as 1 is passed in the
+ *      // pvParameters value in the call to xTaskCreateStatic().
+ *      configASSERT( ( uint32_t ) pvParameters == 1UL );
+ *
+ *      for( ;; )
+ *      {
+ *          // Task code goes here.
+ *      }
+ *  }
+ *
+ *  // Function that creates a task.
+ *  void vOtherFunction( void )
+ *  {
+ *      TaskHandle_t xHandle = NULL;
+ *
+ *      // Create the task without using any dynamic memory allocation.
+ *      xHandle = xTaskCreateStatic(
+ *                    vTaskCode,       // Function that implements the task.
+ *                    "NAME",          // Text name for the task.
+ *                    STACK_SIZE,      // Stack size in words, not bytes.
+ *                    ( void * ) 1,    // Parameter passed into the task.
+ *                    tskIDLE_PRIORITY,// Priority at which the task is created.
+ *                    xStack,          // Array to use as the task's stack.
+ *                    &xTaskBuffer );  // Variable to hold the task's data structure.
+ *
+ *      // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
+ *      // been created, and xHandle will be the task's handle.  Use the handle
+ *      // to suspend the task.
+ *      vTaskSuspend( xHandle );
+ *  }
+ * 
+ * \defgroup xTaskCreateStatic xTaskCreateStatic + * \ingroup Tasks + */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const puxStackBuffer, + StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION; +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +/** + * task. h + *
+ * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
+ * 
+ * + * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1. + * + * xTaskCreateRestricted() should only be used in systems that include an MPU + * implementation. + * + * Create a new task and add it to the list of tasks that are ready to run. + * The function parameters define the memory regions and associated access + * permissions allocated to the task. + * + * See xTaskCreateRestrictedStatic() for a version that does not use any + * dynamic memory allocation. + * + * @param pxTaskDefinition Pointer to a structure that contains a member + * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API + * documentation) plus an optional stack buffer and the memory region + * definitions. + * + * @param pxCreatedTask Used to pass back a handle by which the created task + * can be referenced. + * + * @return pdPASS if the task was successfully created and added to a ready + * list, otherwise an error code defined in the file projdefs.h + * + * Example usage: + *
+ * // Create an TaskParameters_t structure that defines the task to be created.
+ * static const TaskParameters_t xCheckTaskParameters =
+ * {
+ *  vATask,     // pvTaskCode - the function that implements the task.
+ *  "ATask",    // pcName - just a text name for the task to assist debugging.
+ *  100,        // usStackDepth - the stack size DEFINED IN WORDS.
+ *  NULL,       // pvParameters - passed into the task function as the function parameters.
+ *  ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
+ *  cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
+ *
+ *  // xRegions - Allocate up to three separate memory regions for access by
+ *  // the task, with appropriate access permissions.  Different processors have
+ *  // different memory alignment requirements - refer to the FreeRTOS documentation
+ *  // for full information.
+ *  {
+ *      // Base address                 Length  Parameters
+ *      { cReadWriteArray,              32,     portMPU_REGION_READ_WRITE },
+ *      { cReadOnlyArray,               32,     portMPU_REGION_READ_ONLY },
+ *      { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }
+ *  }
+ * };
+ *
+ * int main( void )
+ * {
+ * TaskHandle_t xHandle;
+ *
+ *  // Create a task from the const structure defined above.  The task handle
+ *  // is requested (the second parameter is not NULL) but in this case just for
+ *  // demonstration purposes as its not actually used.
+ *  xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
+ *
+ *  // Start the scheduler.
+ *  vTaskStartScheduler();
+ *
+ *  // Will only get here if there was insufficient memory to create the idle
+ *  // and/or timer task.
+ *  for( ;; );
+ * }
+ * 
+ * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * \ingroup Tasks + */ +#if ( portUSING_MPU_WRAPPERS == 1 ) + BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION; +#endif + +/** + * task. h + *
+ * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
+ * 
+ * + * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1. + * + * xTaskCreateRestrictedStatic() should only be used in systems that include an + * MPU implementation. + * + * Internally, within the FreeRTOS implementation, tasks use two blocks of + * memory. The first block is used to hold the task's data structures. The + * second block is used by the task as its stack. If a task is created using + * xTaskCreateRestricted() then the stack is provided by the application writer, + * and the memory used to hold the task's data structure is automatically + * dynamically allocated inside the xTaskCreateRestricted() function. If a task + * is created using xTaskCreateRestrictedStatic() then the application writer + * must provide the memory used to hold the task's data structures too. + * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be + * created without using any dynamic memory allocation. + * + * @param pxTaskDefinition Pointer to a structure that contains a member + * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API + * documentation) plus an optional stack buffer and the memory region + * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure + * contains an additional member, which is used to point to a variable of type + * StaticTask_t - which is then used to hold the task's data structure. + * + * @param pxCreatedTask Used to pass back a handle by which the created task + * can be referenced. + * + * @return pdPASS if the task was successfully created and added to a ready + * list, otherwise an error code defined in the file projdefs.h + * + * Example usage: + *
+ * // Create an TaskParameters_t structure that defines the task to be created.
+ * // The StaticTask_t variable is only included in the structure when
+ * // configSUPPORT_STATIC_ALLOCATION is set to 1.  The PRIVILEGED_DATA macro can
+ * // be used to force the variable into the RTOS kernel's privileged data area.
+ * static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
+ * static const TaskParameters_t xCheckTaskParameters =
+ * {
+ *  vATask,     // pvTaskCode - the function that implements the task.
+ *  "ATask",    // pcName - just a text name for the task to assist debugging.
+ *  100,        // usStackDepth - the stack size DEFINED IN WORDS.
+ *  NULL,       // pvParameters - passed into the task function as the function parameters.
+ *  ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
+ *  cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
+ *
+ *  // xRegions - Allocate up to three separate memory regions for access by
+ *  // the task, with appropriate access permissions.  Different processors have
+ *  // different memory alignment requirements - refer to the FreeRTOS documentation
+ *  // for full information.
+ *  {
+ *      // Base address                 Length  Parameters
+ *      { cReadWriteArray,              32,     portMPU_REGION_READ_WRITE },
+ *      { cReadOnlyArray,               32,     portMPU_REGION_READ_ONLY },
+ *      { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }
+ *  }
+ *
+ *  &xTaskBuffer; // Holds the task's data structure.
+ * };
+ *
+ * int main( void )
+ * {
+ * TaskHandle_t xHandle;
+ *
+ *  // Create a task from the const structure defined above.  The task handle
+ *  // is requested (the second parameter is not NULL) but in this case just for
+ *  // demonstration purposes as its not actually used.
+ *  xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
+ *
+ *  // Start the scheduler.
+ *  vTaskStartScheduler();
+ *
+ *  // Will only get here if there was insufficient memory to create the idle
+ *  // and/or timer task.
+ *  for( ;; );
+ * }
+ * 
+ * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic + * \ingroup Tasks + */ +#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION; +#endif + +/** + * task. h + *
+ * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
+ * 
+ * + * Memory regions are assigned to a restricted task when the task is created by + * a call to xTaskCreateRestricted(). These regions can be redefined using + * vTaskAllocateMPURegions(). + * + * @param xTask The handle of the task being updated. + * + * @param xRegions A pointer to an MemoryRegion_t structure that contains the + * new memory region definitions. + * + * Example usage: + *
+ * // Define an array of MemoryRegion_t structures that configures an MPU region
+ * // allowing read/write access for 1024 bytes starting at the beginning of the
+ * // ucOneKByte array.  The other two of the maximum 3 definable regions are
+ * // unused so set to zero.
+ * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
+ * {
+ *  // Base address     Length      Parameters
+ *  { ucOneKByte,       1024,       portMPU_REGION_READ_WRITE },
+ *  { 0,                0,          0 },
+ *  { 0,                0,          0 }
+ * };
+ *
+ * void vATask( void *pvParameters )
+ * {
+ *  // This task was created such that it has access to certain regions of
+ *  // memory as defined by the MPU configuration.  At some point it is
+ *  // desired that these MPU regions are replaced with that defined in the
+ *  // xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()
+ *  // for this purpose.  NULL is used as the task handle to indicate that this
+ *  // function should modify the MPU regions of the calling task.
+ *  vTaskAllocateMPURegions( NULL, xAltRegions );
+ *
+ *  // Now the task can continue its function, but from this point on can only
+ *  // access its stack and the ucOneKByte array (unless any other statically
+ *  // defined or shared regions have been declared elsewhere).
+ * }
+ * 
+ * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * \ingroup Tasks + */ +void vTaskAllocateMPURegions( TaskHandle_t xTask, + const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void vTaskDelete( TaskHandle_t xTask );
+ * 
+ * + * INCLUDE_vTaskDelete must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Remove a task from the RTOS real time kernel's management. The task being + * deleted will be removed from all ready, blocked, suspended and event lists. + * + * NOTE: The idle task is responsible for freeing the kernel allocated + * memory from tasks that have been deleted. It is therefore important that + * the idle task is not starved of microcontroller processing time if your + * application makes any calls to vTaskDelete (). Memory allocated by the + * task code is not automatically freed, and should be freed before the task + * is deleted. + * + * See the demo application file death.c for sample code that utilises + * vTaskDelete (). + * + * @param xTask The handle of the task to be deleted. Passing NULL will + * cause the calling task to be deleted. + * + * Example usage: + *
+ * void vOtherFunction( void )
+ * {
+ * TaskHandle_t xHandle;
+ *
+ *   // Create the task, storing the handle.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+ *
+ *   // Use the handle to delete the task.
+ *   vTaskDelete( xHandle );
+ * }
+ * 
+ * \defgroup vTaskDelete vTaskDelete + * \ingroup Tasks + */ +void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; + +/*----------------------------------------------------------- +* TASK CONTROL API +*----------------------------------------------------------*/ + +/** + * task. h + *
+ * void vTaskDelay( const TickType_t xTicksToDelay );
+ * 
+ * + * Delay a task for a given number of ticks. The actual time that the + * task remains blocked depends on the tick rate. The constant + * portTICK_PERIOD_MS can be used to calculate real time from the tick + * rate - with the resolution of one tick period. + * + * INCLUDE_vTaskDelay must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * + * vTaskDelay() specifies a time at which the task wishes to unblock relative to + * the time at which vTaskDelay() is called. For example, specifying a block + * period of 100 ticks will cause the task to unblock 100 ticks after + * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method + * of controlling the frequency of a periodic task as the path taken through the + * code, as well as other task and interrupt activity, will effect the frequency + * at which vTaskDelay() gets called and therefore the time at which the task + * next executes. See xTaskDelayUntil() for an alternative API function designed + * to facilitate fixed frequency execution. It does this by specifying an + * absolute time (rather than a relative time) at which the calling task should + * unblock. + * + * @param xTicksToDelay The amount of time, in tick periods, that + * the calling task should block. + * + * Example usage: + * + * void vTaskFunction( void * pvParameters ) + * { + * // Block for 500ms. + * const TickType_t xDelay = 500 / portTICK_PERIOD_MS; + * + * for( ;; ) + * { + * // Simply toggle the LED every 500ms, blocking between each toggle. + * vToggleLED(); + * vTaskDelay( xDelay ); + * } + * } + * + * \defgroup vTaskDelay vTaskDelay + * \ingroup TaskCtrl + */ +void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
+ * 
+ * + * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Delay a task until a specified time. This function can be used by periodic + * tasks to ensure a constant execution frequency. + * + * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will + * cause a task to block for the specified number of ticks from the time vTaskDelay () is + * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed + * execution frequency as the time between a task starting to execute and that task + * calling vTaskDelay () may not be fixed [the task may take a different path though the + * code between calls, or may get interrupted or preempted a different number of times + * each time it executes]. + * + * Whereas vTaskDelay () specifies a wake time relative to the time at which the function + * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to + * unblock. + * + * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a + * time specified in milliseconds with a resolution of one tick period. + * + * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the + * task was last unblocked. The variable must be initialised with the current time + * prior to its first use (see the example below). Following this the variable is + * automatically updated within xTaskDelayUntil (). + * + * @param xTimeIncrement The cycle time period. The task will be unblocked at + * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the + * same xTimeIncrement parameter value will cause the task to execute with + * a fixed interface period. + * + * @return Value which can be used to check whether the task was actually delayed. + * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not + * be delayed if the next expected wake time is in the past. + * + * Example usage: + *
+ * // Perform an action every 10 ticks.
+ * void vTaskFunction( void * pvParameters )
+ * {
+ * TickType_t xLastWakeTime;
+ * const TickType_t xFrequency = 10;
+ * BaseType_t xWasDelayed;
+ *
+ *     // Initialise the xLastWakeTime variable with the current time.
+ *     xLastWakeTime = xTaskGetTickCount ();
+ *     for( ;; )
+ *     {
+ *         // Wait for the next cycle.
+ *         xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
+ *
+ *         // Perform action here. xWasDelayed value can be used to determine
+ *         // whether a deadline was missed if the code here took too long.
+ *     }
+ * }
+ * 
+ * \defgroup xTaskDelayUntil xTaskDelayUntil + * \ingroup TaskCtrl + */ +BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; + +/* + * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not + * return a value. + */ +#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \ +{ \ + ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \ +} + + +/** + * task. h + *
+ * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
+ * 
+ * + * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this + * function to be available. + * + * A task will enter the Blocked state when it is waiting for an event. The + * event it is waiting for can be a temporal event (waiting for a time), such + * as when vTaskDelay() is called, or an event on an object, such as when + * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task + * that is in the Blocked state is used in a call to xTaskAbortDelay() then the + * task will leave the Blocked state, and return from whichever function call + * placed the task into the Blocked state. + * + * There is no 'FromISR' version of this function as an interrupt would need to + * know which object a task was blocked on in order to know which actions to + * take. For example, if the task was blocked on a queue the interrupt handler + * would then need to know if the queue was locked. + * + * @param xTask The handle of the task to remove from the Blocked state. + * + * @return If the task referenced by xTask was not in the Blocked state then + * pdFAIL is returned. Otherwise pdPASS is returned. + * + * \defgroup xTaskAbortDelay xTaskAbortDelay + * \ingroup TaskCtrl + */ +BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
+ * 
+ * + * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Obtain the priority of any task. + * + * @param xTask Handle of the task to be queried. Passing a NULL + * handle results in the priority of the calling task being returned. + * + * @return The priority of xTask. + * + * Example usage: + *
+ * void vAFunction( void )
+ * {
+ * TaskHandle_t xHandle;
+ *
+ *   // Create a task, storing the handle.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+ *
+ *   // ...
+ *
+ *   // Use the handle to obtain the priority of the created task.
+ *   // It was created with tskIDLE_PRIORITY, but may have changed
+ *   // it itself.
+ *   if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
+ *   {
+ *       // The task has changed it's priority.
+ *   }
+ *
+ *   // ...
+ *
+ *   // Is our priority higher than the created task?
+ *   if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
+ *   {
+ *       // Our priority (obtained using NULL handle) is higher.
+ *   }
+ * }
+ * 
+ * \defgroup uxTaskPriorityGet uxTaskPriorityGet + * \ingroup TaskCtrl + */ +UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
+ * 
+ * + * A version of uxTaskPriorityGet() that can be used from an ISR. + */ +UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * eTaskState eTaskGetState( TaskHandle_t xTask );
+ * 
+ * + * INCLUDE_eTaskGetState must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Obtain the state of any task. States are encoded by the eTaskState + * enumerated type. + * + * @param xTask Handle of the task to be queried. + * + * @return The state of xTask at the time the function was called. Note the + * state of the task might change between the function being called, and the + * functions return value being tested by the calling task. + */ +eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
+ * 
+ * + * configUSE_TRACE_FACILITY must be defined as 1 for this function to be + * available. See the configuration section for more information. + * + * Populates a TaskStatus_t structure with information about a task. + * + * @param xTask Handle of the task being queried. If xTask is NULL then + * information will be returned about the calling task. + * + * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be + * filled with information about the task referenced by the handle passed using + * the xTask parameter. + * + * @xGetFreeStackSpace The TaskStatus_t structure contains a member to report + * the stack high water mark of the task being queried. Calculating the stack + * high water mark takes a relatively long time, and can make the system + * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to + * allow the high water mark checking to be skipped. The high watermark value + * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is + * not set to pdFALSE; + * + * @param eState The TaskStatus_t structure contains a member to report the + * state of the task being queried. Obtaining the task state is not as fast as + * a simple assignment - so the eState parameter is provided to allow the state + * information to be omitted from the TaskStatus_t structure. To obtain state + * information then set eState to eInvalid - otherwise the value passed in + * eState will be reported as the task state in the TaskStatus_t structure. + * + * Example usage: + *
+ * void vAFunction( void )
+ * {
+ * TaskHandle_t xHandle;
+ * TaskStatus_t xTaskDetails;
+ *
+ *  // Obtain the handle of a task from its name.
+ *  xHandle = xTaskGetHandle( "Task_Name" );
+ *
+ *  // Check the handle is not NULL.
+ *  configASSERT( xHandle );
+ *
+ *  // Use the handle to obtain further information about the task.
+ *  vTaskGetInfo( xHandle,
+ *                &xTaskDetails,
+ *                pdTRUE, // Include the high water mark in xTaskDetails.
+ *                eInvalid ); // Include the task state in xTaskDetails.
+ * }
+ * 
+ * \defgroup vTaskGetInfo vTaskGetInfo + * \ingroup TaskCtrl + */ +void vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
+ * 
+ * + * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Set the priority of any task. + * + * A context switch will occur before the function returns if the priority + * being set is higher than the currently executing task. + * + * @param xTask Handle to the task for which the priority is being set. + * Passing a NULL handle results in the priority of the calling task being set. + * + * @param uxNewPriority The priority to which the task will be set. + * + * Example usage: + *
+ * void vAFunction( void )
+ * {
+ * TaskHandle_t xHandle;
+ *
+ *   // Create a task, storing the handle.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+ *
+ *   // ...
+ *
+ *   // Use the handle to raise the priority of the created task.
+ *   vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
+ *
+ *   // ...
+ *
+ *   // Use a NULL handle to raise our priority to the same value.
+ *   vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
+ * }
+ * 
+ * \defgroup vTaskPrioritySet vTaskPrioritySet + * \ingroup TaskCtrl + */ +void vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
+ * 
+ * + * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Suspend any task. When suspended a task will never get any microcontroller + * processing time, no matter what its priority. + * + * Calls to vTaskSuspend are not accumulative - + * i.e. calling vTaskSuspend () twice on the same task still only requires one + * call to vTaskResume () to ready the suspended task. + * + * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL + * handle will cause the calling task to be suspended. + * + * Example usage: + *
+ * void vAFunction( void )
+ * {
+ * TaskHandle_t xHandle;
+ *
+ *   // Create a task, storing the handle.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+ *
+ *   // ...
+ *
+ *   // Use the handle to suspend the created task.
+ *   vTaskSuspend( xHandle );
+ *
+ *   // ...
+ *
+ *   // The created task will not run during this period, unless
+ *   // another task calls vTaskResume( xHandle ).
+ *
+ *   //...
+ *
+ *
+ *   // Suspend ourselves.
+ *   vTaskSuspend( NULL );
+ *
+ *   // We cannot get here unless another task calls vTaskResume
+ *   // with our handle as the parameter.
+ * }
+ * 
+ * \defgroup vTaskSuspend vTaskSuspend + * \ingroup TaskCtrl + */ +void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void vTaskResume( TaskHandle_t xTaskToResume );
+ * 
+ * + * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Resumes a suspended task. + * + * A task that has been suspended by one or more calls to vTaskSuspend () + * will be made available for running again by a single call to + * vTaskResume (). + * + * @param xTaskToResume Handle to the task being readied. + * + * Example usage: + *
+ * void vAFunction( void )
+ * {
+ * TaskHandle_t xHandle;
+ *
+ *   // Create a task, storing the handle.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+ *
+ *   // ...
+ *
+ *   // Use the handle to suspend the created task.
+ *   vTaskSuspend( xHandle );
+ *
+ *   // ...
+ *
+ *   // The created task will not run during this period, unless
+ *   // another task calls vTaskResume( xHandle ).
+ *
+ *   //...
+ *
+ *
+ *   // Resume the suspended task ourselves.
+ *   vTaskResume( xHandle );
+ *
+ *   // The created task will once again get microcontroller processing
+ *   // time in accordance with its priority within the system.
+ * }
+ * 
+ * \defgroup vTaskResume vTaskResume + * \ingroup TaskCtrl + */ +void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
+ * 
+ * + * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be + * available. See the configuration section for more information. + * + * An implementation of vTaskResume() that can be called from within an ISR. + * + * A task that has been suspended by one or more calls to vTaskSuspend () + * will be made available for running again by a single call to + * xTaskResumeFromISR (). + * + * xTaskResumeFromISR() should not be used to synchronise a task with an + * interrupt if there is a chance that the interrupt could arrive prior to the + * task being suspended - as this can lead to interrupts being missed. Use of a + * semaphore as a synchronisation mechanism would avoid this eventuality. + * + * @param xTaskToResume Handle to the task being readied. + * + * @return pdTRUE if resuming the task should result in a context switch, + * otherwise pdFALSE. This is used by the ISR to determine if a context switch + * may be required following the ISR. + * + * \defgroup vTaskResumeFromISR vTaskResumeFromISR + * \ingroup TaskCtrl + */ +BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; + +/*----------------------------------------------------------- +* SCHEDULER CONTROL +*----------------------------------------------------------*/ + +/** + * task. h + *
+ * void vTaskStartScheduler( void );
+ * 
+ * + * Starts the real time kernel tick processing. After calling the kernel + * has control over which tasks are executed and when. + * + * See the demo application file main.c for an example of creating + * tasks and starting the kernel. + * + * Example usage: + *
+ * void vAFunction( void )
+ * {
+ *   // Create at least one task before starting the kernel.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
+ *
+ *   // Start the real time kernel with preemption.
+ *   vTaskStartScheduler ();
+ *
+ *   // Will not get here unless a task calls vTaskEndScheduler ()
+ * }
+ * 
+ * + * \defgroup vTaskStartScheduler vTaskStartScheduler + * \ingroup SchedulerControl + */ +void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void vTaskEndScheduler( void );
+ * 
+ * + * NOTE: At the time of writing only the x86 real mode port, which runs on a PC + * in place of DOS, implements this function. + * + * Stops the real time kernel tick. All created tasks will be automatically + * deleted and multitasking (either preemptive or cooperative) will + * stop. Execution then resumes from the point where vTaskStartScheduler () + * was called, as if vTaskStartScheduler () had just returned. + * + * See the demo application file main. c in the demo/PC directory for an + * example that uses vTaskEndScheduler (). + * + * vTaskEndScheduler () requires an exit function to be defined within the + * portable layer (see vPortEndScheduler () in port. c for the PC port). This + * performs hardware specific operations such as stopping the kernel tick. + * + * vTaskEndScheduler () will cause all of the resources allocated by the + * kernel to be freed - but will not free resources allocated by application + * tasks. + * + * Example usage: + *
+ * void vTaskCode( void * pvParameters )
+ * {
+ *   for( ;; )
+ *   {
+ *       // Task code goes here.
+ *
+ *       // At some point we want to end the real time kernel processing
+ *       // so call ...
+ *       vTaskEndScheduler ();
+ *   }
+ * }
+ *
+ * void vAFunction( void )
+ * {
+ *   // Create at least one task before starting the kernel.
+ *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
+ *
+ *   // Start the real time kernel with preemption.
+ *   vTaskStartScheduler ();
+ *
+ *   // Will only get here when the vTaskCode () task has called
+ *   // vTaskEndScheduler ().  When we get here we are back to single task
+ *   // execution.
+ * }
+ * 
+ * + * \defgroup vTaskEndScheduler vTaskEndScheduler + * \ingroup SchedulerControl + */ +void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * void vTaskSuspendAll( void );
+ * 
+ * + * Suspends the scheduler without disabling interrupts. Context switches will + * not occur while the scheduler is suspended. + * + * After calling vTaskSuspendAll () the calling task will continue to execute + * without risk of being swapped out until a call to xTaskResumeAll () has been + * made. + * + * API functions that have the potential to cause a context switch (for example, + * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler + * is suspended. + * + * Example usage: + *
+ * void vTask1( void * pvParameters )
+ * {
+ *   for( ;; )
+ *   {
+ *       // Task code goes here.
+ *
+ *       // ...
+ *
+ *       // At some point the task wants to perform a long operation during
+ *       // which it does not want to get swapped out.  It cannot use
+ *       // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
+ *       // operation may cause interrupts to be missed - including the
+ *       // ticks.
+ *
+ *       // Prevent the real time kernel swapping out the task.
+ *       vTaskSuspendAll ();
+ *
+ *       // Perform the operation here.  There is no need to use critical
+ *       // sections as we have all the microcontroller processing time.
+ *       // During this time interrupts will still operate and the kernel
+ *       // tick count will be maintained.
+ *
+ *       // ...
+ *
+ *       // The operation is complete.  Restart the kernel.
+ *       xTaskResumeAll ();
+ *   }
+ * }
+ * 
+ * \defgroup vTaskSuspendAll vTaskSuspendAll + * \ingroup SchedulerControl + */ +void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
+ * BaseType_t xTaskResumeAll( void );
+ * 
+ * + * Resumes scheduler activity after it was suspended by a call to + * vTaskSuspendAll(). + * + * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks + * that were previously suspended by a call to vTaskSuspend(). + * + * @return If resuming the scheduler caused a context switch then pdTRUE is + * returned, otherwise pdFALSE is returned. + * + * Example usage: + *
+ * void vTask1( void * pvParameters )
+ * {
+ *   for( ;; )
+ *   {
+ *       // Task code goes here.
+ *
+ *       // ...
+ *
+ *       // At some point the task wants to perform a long operation during
+ *       // which it does not want to get swapped out.  It cannot use
+ *       // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
+ *       // operation may cause interrupts to be missed - including the
+ *       // ticks.
+ *
+ *       // Prevent the real time kernel swapping out the task.
+ *       vTaskSuspendAll ();
+ *
+ *       // Perform the operation here.  There is no need to use critical
+ *       // sections as we have all the microcontroller processing time.
+ *       // During this time interrupts will still operate and the real
+ *       // time kernel tick count will be maintained.
+ *
+ *       // ...
+ *
+ *       // The operation is complete.  Restart the kernel.  We want to force
+ *       // a context switch - but there is no point if resuming the scheduler
+ *       // caused a context switch already.
+ *       if( !xTaskResumeAll () )
+ *       {
+ *            taskYIELD ();
+ *       }
+ *   }
+ * }
+ * 
+ * \defgroup xTaskResumeAll xTaskResumeAll + * \ingroup SchedulerControl + */ +BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; + +/*----------------------------------------------------------- +* TASK UTILITIES +*----------------------------------------------------------*/ + +/** + * task. h + *
TickType_t xTaskGetTickCount( void );
+ * + * @return The count of ticks since vTaskStartScheduler was called. + * + * \defgroup xTaskGetTickCount xTaskGetTickCount + * \ingroup TaskUtils + */ +TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
TickType_t xTaskGetTickCountFromISR( void );
+ * + * @return The count of ticks since vTaskStartScheduler was called. + * + * This is a version of xTaskGetTickCount() that is safe to be called from an + * ISR - provided that TickType_t is the natural word size of the + * microcontroller being used or interrupt nesting is either not supported or + * not being used. + * + * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR + * \ingroup TaskUtils + */ +TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
uint16_t uxTaskGetNumberOfTasks( void );
+ * + * @return The number of tasks that the real time kernel is currently managing. + * This includes all ready, blocked and suspended tasks. A task that + * has been deleted but not yet freed by the idle task will also be + * included in the count. + * + * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks + * \ingroup TaskUtils + */ +UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
char *pcTaskGetName( TaskHandle_t xTaskToQuery );
+ * + * @return The text (human readable) name of the task referenced by the handle + * xTaskToQuery. A task can query its own name by either passing in its own + * handle, or by setting xTaskToQuery to NULL. + * + * \defgroup pcTaskGetName pcTaskGetName + * \ingroup TaskUtils + */ +char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * task. h + *
TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );
+ * + * NOTE: This function takes a relatively long time to complete and should be + * used sparingly. + * + * @return The handle of the task that has the human readable name pcNameToQuery. + * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle + * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available. + * + * \defgroup pcTaskGetHandle pcTaskGetHandle + * \ingroup TaskUtils + */ +TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * task.h + *
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
+ * + * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for + * this function to be available. + * + * Returns the high water mark of the stack associated with xTask. That is, + * the minimum free stack space there has been (in words, so on a 32 bit machine + * a value of 1 means 4 bytes) since the task started. The smaller the returned + * number the closer the task has come to overflowing its stack. + * + * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the + * same except for their return type. Using configSTACK_DEPTH_TYPE allows the + * user to determine the return type. It gets around the problem of the value + * overflowing on 8-bit types without breaking backward compatibility for + * applications that expect an 8-bit return type. + * + * @param xTask Handle of the task associated with the stack to be checked. + * Set xTask to NULL to check the stack of the calling task. + * + * @return The smallest amount of free stack space there has been (in words, so + * actual spaces on the stack rather than bytes) since the task referenced by + * xTask was created. + */ +UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * task.h + *
configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
+ * + * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for + * this function to be available. + * + * Returns the high water mark of the stack associated with xTask. That is, + * the minimum free stack space there has been (in words, so on a 32 bit machine + * a value of 1 means 4 bytes) since the task started. The smaller the returned + * number the closer the task has come to overflowing its stack. + * + * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the + * same except for their return type. Using configSTACK_DEPTH_TYPE allows the + * user to determine the return type. It gets around the problem of the value + * overflowing on 8-bit types without breaking backward compatibility for + * applications that expect an 8-bit return type. + * + * @param xTask Handle of the task associated with the stack to be checked. + * Set xTask to NULL to check the stack of the calling task. + * + * @return The smallest amount of free stack space there has been (in words, so + * actual spaces on the stack rather than bytes) since the task referenced by + * xTask was created. + */ +configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/* When using trace macros it is sometimes necessary to include task.h before + * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, + * so the following two prototypes will cause a compilation error. This can be + * fixed by simply guarding against the inclusion of these two prototypes unless + * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration + * constant. */ +#ifdef configUSE_APPLICATION_TASK_TAG + #if configUSE_APPLICATION_TASK_TAG == 1 + +/** + * task.h + *
+ * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
+ * 
+ * + * Sets pxHookFunction to be the task hook function used by the task xTask. + * Passing xTask as NULL has the effect of setting the calling tasks hook + * function. + */ + void vTaskSetApplicationTaskTag( TaskHandle_t xTask, + TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION; + +/** + * task.h + *
+ * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
+ * 
+ * + * Returns the pxHookFunction value assigned to the task xTask. Do not + * call from an interrupt service routine - call + * xTaskGetApplicationTaskTagFromISR() instead. + */ + TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * task.h + *
+ * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
+ * 
+ * + * Returns the pxHookFunction value assigned to the task xTask. Can + * be called from an interrupt service routine. + */ + TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ +#endif /* ifdef configUSE_APPLICATION_TASK_TAG */ + +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + +/* Each task contains an array of pointers that is dimensioned by the + * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The + * kernel does not use the pointers itself, so the application writer can use + * the pointers for any purpose they wish. The following two functions are + * used to set and query a pointer respectively. */ + void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, + BaseType_t xIndex, + void * pvValue ) PRIVILEGED_FUNCTION; + void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, + BaseType_t xIndex ) PRIVILEGED_FUNCTION; + +#endif + +#if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) + + /** + * task.h + *
void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); 
+ * + * The application stack overflow hook is called when a stack overflow is detected for a task. + * + * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html + * + * @param xTask the task that just exceeded its stack boundaries. + * @param pcTaskName A character string containing the name of the offending task. + */ + void vApplicationStackOverflowHook( TaskHandle_t xTask, + char * pcTaskName ); + +#endif + +#if ( configUSE_TICK_HOOK > 0 ) + /** + * task.h + *
void vApplicationTickHook( void ); 
+ * + * This hook function is called in the system tick handler after any OS work is completed. + */ + void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ + +#endif + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + /** + * task.h + *
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) 
+ * + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, + StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */ +#endif + +/** + * task.h + *
+ * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
+ * 
+ * + * Calls the hook function associated with xTask. Passing xTask as NULL has + * the effect of calling the Running tasks (the calling task) hook function. + * + * pvParameter is passed to the hook function for the task to interpret as it + * wants. The return value is the value returned by the task hook function + * registered by the user. + */ +BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) PRIVILEGED_FUNCTION; + +/** + * xTaskGetIdleTaskHandle() is only available if + * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h. + * + * Simply returns the handle of the idle task. It is not valid to call + * xTaskGetIdleTaskHandle() before the scheduler has been started. + */ +TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; + +/** + * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for + * uxTaskGetSystemState() to be available. + * + * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in + * the system. TaskStatus_t structures contain, among other things, members + * for the task handle, task name, task priority, task state, and total amount + * of run time consumed by the task. See the TaskStatus_t structure + * definition in this file for the full member list. + * + * NOTE: This function is intended for debugging use only as its use results in + * the scheduler remaining suspended for an extended period. + * + * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures. + * The array must contain at least one TaskStatus_t structure for each task + * that is under the control of the RTOS. The number of tasks under the control + * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function. + * + * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray + * parameter. The size is specified as the number of indexes in the array, or + * the number of TaskStatus_t structures contained in the array, not by the + * number of bytes in the array. + * + * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in + * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the + * total run time (as defined by the run time stats clock, see + * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted. + * pulTotalRunTime can be set to NULL to omit the total run time information. + * + * @return The number of TaskStatus_t structures that were populated by + * uxTaskGetSystemState(). This should equal the number returned by the + * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed + * in the uxArraySize parameter was too small. + * + * Example usage: + *
+ *  // This example demonstrates how a human readable table of run time stats
+ *  // information is generated from raw data provided by uxTaskGetSystemState().
+ *  // The human readable table is written to pcWriteBuffer
+ *  void vTaskGetRunTimeStats( char *pcWriteBuffer )
+ *  {
+ *  TaskStatus_t *pxTaskStatusArray;
+ *  volatile UBaseType_t uxArraySize, x;
+ *  uint32_t ulTotalRunTime, ulStatsAsPercentage;
+ *
+ *      // Make sure the write buffer does not contain a string.
+ * pcWriteBuffer = 0x00;
+ *
+ *      // Take a snapshot of the number of tasks in case it changes while this
+ *      // function is executing.
+ *      uxArraySize = uxTaskGetNumberOfTasks();
+ *
+ *      // Allocate a TaskStatus_t structure for each task.  An array could be
+ *      // allocated statically at compile time.
+ *      pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
+ *
+ *      if( pxTaskStatusArray != NULL )
+ *      {
+ *          // Generate raw status information about each task.
+ *          uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
+ *
+ *          // For percentage calculations.
+ *          ulTotalRunTime /= 100UL;
+ *
+ *          // Avoid divide by zero errors.
+ *          if( ulTotalRunTime > 0 )
+ *          {
+ *              // For each populated position in the pxTaskStatusArray array,
+ *              // format the raw data as human readable ASCII data
+ *              for( x = 0; x < uxArraySize; x++ )
+ *              {
+ *                  // What percentage of the total run time has the task used?
+ *                  // This will always be rounded down to the nearest integer.
+ *                  // ulTotalRunTimeDiv100 has already been divided by 100.
+ *                  ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
+ *
+ *                  if( ulStatsAsPercentage > 0UL )
+ *                  {
+ *                      sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
+ *                  }
+ *                  else
+ *                  {
+ *                      // If the percentage is zero here then the task has
+ *                      // consumed less than 1% of the total run time.
+ *                      sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
+ *                  }
+ *
+ *                  pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
+ *              }
+ *          }
+ *
+ *          // The array is no longer needed, free the memory it consumes.
+ *          vPortFree( pxTaskStatusArray );
+ *      }
+ *  }
+ *  
+ */ +UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
void vTaskList( char *pcWriteBuffer );
+ * + * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must + * both be defined as 1 for this function to be available. See the + * configuration section of the FreeRTOS.org website for more information. + * + * NOTE 1: This function will disable interrupts for its duration. It is + * not intended for normal application runtime use but as a debug aid. + * + * Lists all the current tasks, along with their current state and stack + * usage high water mark. + * + * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or + * suspended ('S'). + * + * PLEASE NOTE: + * + * This function is provided for convenience only, and is used by many of the + * demo applications. Do not consider it to be part of the scheduler. + * + * vTaskList() calls uxTaskGetSystemState(), then formats part of the + * uxTaskGetSystemState() output into a human readable table that displays task + * names, states and stack usage. + * + * vTaskList() has a dependency on the sprintf() C library function that might + * bloat the code size, use a lot of stack, and provide different results on + * different platforms. An alternative, tiny, third party, and limited + * functionality implementation of sprintf() is provided in many of the + * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note + * printf-stdarg.c does not provide a full snprintf() implementation!). + * + * It is recommended that production systems call uxTaskGetSystemState() + * directly to get access to raw stats data, rather than indirectly through a + * call to vTaskList(). + * + * @param pcWriteBuffer A buffer into which the above mentioned details + * will be written, in ASCII form. This buffer is assumed to be large + * enough to contain the generated report. Approximately 40 bytes per + * task should be sufficient. + * + * \defgroup vTaskList vTaskList + * \ingroup TaskUtils + */ +void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * task. h + *
void vTaskGetRunTimeStats( char *pcWriteBuffer );
+ * + * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS + * must both be defined as 1 for this function to be available. The application + * must also then provide definitions for + * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() + * to configure a peripheral timer/counter and return the timers current count + * value respectively. The counter should be at least 10 times the frequency of + * the tick count. + * + * NOTE 1: This function will disable interrupts for its duration. It is + * not intended for normal application runtime use but as a debug aid. + * + * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total + * accumulated execution time being stored for each task. The resolution + * of the accumulated time value depends on the frequency of the timer + * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. + * Calling vTaskGetRunTimeStats() writes the total execution time of each + * task into a buffer, both as an absolute count value and as a percentage + * of the total system execution time. + * + * NOTE 2: + * + * This function is provided for convenience only, and is used by many of the + * demo applications. Do not consider it to be part of the scheduler. + * + * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the + * uxTaskGetSystemState() output into a human readable table that displays the + * amount of time each task has spent in the Running state in both absolute and + * percentage terms. + * + * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function + * that might bloat the code size, use a lot of stack, and provide different + * results on different platforms. An alternative, tiny, third party, and + * limited functionality implementation of sprintf() is provided in many of the + * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note + * printf-stdarg.c does not provide a full snprintf() implementation!). + * + * It is recommended that production systems call uxTaskGetSystemState() directly + * to get access to raw stats data, rather than indirectly through a call to + * vTaskGetRunTimeStats(). + * + * @param pcWriteBuffer A buffer into which the execution times will be + * written, in ASCII form. This buffer is assumed to be large enough to + * contain the generated report. Approximately 40 bytes per task should + * be sufficient. + * + * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats + * \ingroup TaskUtils + */ +void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * task. h + *
uint32_t ulTaskGetIdleRunTimeCounter( void );
+ * + * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS + * must both be defined as 1 for this function to be available. The application + * must also then provide definitions for + * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() + * to configure a peripheral timer/counter and return the timers current count + * value respectively. The counter should be at least 10 times the frequency of + * the tick count. + * + * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total + * accumulated execution time being stored for each task. The resolution + * of the accumulated time value depends on the frequency of the timer + * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. + * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total + * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() + * returns the total execution time of just the idle task. + * + * @return The total run time of the idle task. This is the amount of time the + * idle task has actually been executing. The unit of time is dependent on the + * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and + * portGET_RUN_TIME_COUNTER_VALUE() macros. + * + * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + * \ingroup TaskUtils + */ +uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; + +/** + * task. h + *
BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction );
+ *
BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
+ * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Sends a direct to task notification to a task, with an optional value and + * action. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * Events can be sent to a task using an intermediary object. Examples of such + * objects are queues, semaphores, mutexes and event groups. Task notifications + * are a method of sending an event directly to a task without the need for such + * an intermediary object. + * + * A notification sent to a task can optionally perform an action, such as + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. + * + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does + * not consume any CPU time while it is in the Blocked state. + * + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotify() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed() + * with the uxIndexToNotify parameter set to 0. + * + * @param xTaskToNotify The handle of the task being notified. The handle to a + * task can be returned from the xTaskCreate() API function used to create the + * task, and the handle of the currently running task can be obtained by calling + * xTaskGetCurrentTaskHandle(). + * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does + * not have this parameter and always sends notifications to index 0. + * + * @param ulValue Data that can be sent with the notification. How the data is + * used depends on the value of the eAction parameter. + * + * @param eAction Specifies how the notification updates the task's notification + * value, if at all. Valid values for eAction are as follows: + * + * eSetBits - + * The target notification value is bitwise ORed with ulValue. + * xTaskNofifyIndexed() always returns pdPASS in this case. + * + * eIncrement - + * The target notification value is incremented. ulValue is not used and + * xTaskNotifyIndexed() always returns pdPASS in this case. + * + * eSetValueWithOverwrite - + * The target notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification at the + * same array index (the task already had a notification pending at that index). + * xTaskNotifyIndexed() always returns pdPASS in this case. + * + * eSetValueWithoutOverwrite - + * If the task being notified did not already have a notification pending at the + * same array index then the target notification value is set to ulValue and + * xTaskNotifyIndexed() will return pdPASS. If the task being notified already + * had a notification pending at the same array index then no action is + * performed and pdFAIL is returned. + * + * eNoAction - + * The task receives a notification at the specified array index without the + * notification value at that index being updated. ulValue is not used and + * xTaskNotifyIndexed() always returns pdPASS in this case. + * + * pulPreviousNotificationValue - + * Can be used to pass out the subject task's notification value before any + * bits are modified by the notify function. + * + * @return Dependent on the value of eAction. See the description of the + * eAction parameter. + * + * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed + * \ingroup TaskNotifications + */ +BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; +#define xTaskNotify( xTaskToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL ) +#define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL ) + +/** + * task. h + *
BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
+ *
BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
+ * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * xTaskNotifyAndQueryIndexed() performs the same operation as + * xTaskNotifyIndexed() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than when the function returns) in the additional + * pulPreviousNotifyValue parameter. + * + * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the + * addition that it also returns the subject task's prior notification value + * (the notification value as it was at the time the function is called, rather + * than when the function returns) in the additional pulPreviousNotifyValue + * parameter. + * + * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed + * \ingroup TaskNotifications + */ +#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) +#define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) + +/** + * task. h + *
BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
+ *
BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
+ * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * A version of xTaskNotifyIndexed() that can be used from an interrupt service + * routine (ISR). + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * Events can be sent to a task using an intermediary object. Examples of such + * objects are queues, semaphores, mutexes and event groups. Task notifications + * are a method of sending an event directly to a task without the need for such + * an intermediary object. + * + * A notification sent to a task can optionally perform an action, such as + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. + * + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does + * not consume any CPU time while it is in the Blocked state. + * + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyFromISR() is equivalent to calling + * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0. + * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR() + * does not have this parameter and always sends notifications to index 0. + * + * @param xTaskToNotify The handle of the task being notified. The handle to a + * task can be returned from the xTaskCreate() API function used to create the + * task, and the handle of the currently running task can be obtained by calling + * xTaskGetCurrentTaskHandle(). + * + * @param ulValue Data that can be sent with the notification. How the data is + * used depends on the value of the eAction parameter. + * + * @param eAction Specifies how the notification updates the task's notification + * value, if at all. Valid values for eAction are as follows: + * + * eSetBits - + * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * always returns pdPASS in this case. + * + * eIncrement - + * The task's notification value is incremented. ulValue is not used and + * xTaskNotify() always returns pdPASS in this case. + * + * eSetValueWithOverwrite - + * The task's notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification (the + * task already had a notification pending). xTaskNotify() always returns + * pdPASS in this case. + * + * eSetValueWithoutOverwrite - + * If the task being notified did not already have a notification pending then + * the task's notification value is set to ulValue and xTaskNotify() will + * return pdPASS. If the task being notified already had a notification + * pending then no action is performed and pdFAIL is returned. + * + * eNoAction - + * The task receives a notification without its notification value being + * updated. ulValue is not used and xTaskNotify() always returns pdPASS in + * this case. + * + * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the + * task to which the notification was sent to leave the Blocked state, and the + * unblocked task has a priority higher than the currently running task. If + * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should + * be requested before the interrupt is exited. How a context switch is + * requested from an ISR is dependent on the port - see the documentation page + * for the port in use. + * + * @return Dependent on the value of eAction. See the description of the + * eAction parameter. + * + * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR + * \ingroup TaskNotifications + */ +BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) + +/** + * task. h + *
BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
+ *
BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
+ * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as + * xTaskNotifyIndexedFromISR() with the addition that it also returns the + * subject task's prior notification value (the notification value at the time + * the function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * xTaskNotifyAndQueryFromISR() performs the same operation as + * xTaskNotifyFromISR() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR + * \ingroup TaskNotifications + */ +#define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) + +/** + * task. h + *
+ * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
+ *
+ * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
+ * 
+ * + * Waits for a direct to task notification to be pending at a given index within + * an array of direct to task notifications. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this + * function to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * Events can be sent to a task using an intermediary object. Examples of such + * objects are queues, semaphores, mutexes and event groups. Task notifications + * are a method of sending an event directly to a task without the need for such + * an intermediary object. + * + * A notification sent to a task can optionally perform an action, such as + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. + * + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does + * not consume any CPU time while it is in the Blocked state. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyWait() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyWait() is equivalent to calling + * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be received. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does + * not have this parameter and always waits for notifications on index 0. + * + * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value + * will be cleared in the calling task's notification value before the task + * checks to see if any notifications are pending, and optionally blocks if no + * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if + * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have + * the effect of resetting the task's notification value to 0. Setting + * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged. + * + * @param ulBitsToClearOnExit If a notification is pending or received before + * the calling task exits the xTaskNotifyWait() function then the task's + * notification value (see the xTaskNotify() API function) is passed out using + * the pulNotificationValue parameter. Then any bits that are set in + * ulBitsToClearOnExit will be cleared in the task's notification value (note + * *pulNotificationValue is set before any bits are cleared). Setting + * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL + * (if limits.h is not included) will have the effect of resetting the task's + * notification value to 0 before the function exits. Setting + * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged + * when the function exits (in which case the value passed out in + * pulNotificationValue will match the task's notification value). + * + * @param pulNotificationValue Used to pass the task's notification value out + * of the function. Note the value passed out will not be effected by the + * clearing of any bits caused by ulBitsToClearOnExit being non-zero. + * + * @param xTicksToWait The maximum amount of time that the task should wait in + * the Blocked state for a notification to be received, should a notification + * not already be pending when xTaskNotifyWait() was called. The task + * will not consume any processing time while it is in the Blocked state. This + * is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be + * used to convert a time specified in milliseconds to a time specified in + * ticks. + * + * @return If a notification was received (including notifications that were + * already pending when xTaskNotifyWait was called) then pdPASS is + * returned. Otherwise pdFAIL is returned. + * + * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed + * \ingroup TaskNotifications + */ +BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) +#define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) + +/** + * task. h + *
BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify );
+ *
BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );
+ * + * Sends a direct to task notification to a particular index in the target + * task's notification array in a manner similar to giving a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * macros to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * Events can be sent to a task using an intermediary object. Examples of such + * objects are queues, semaphores, mutexes and event groups. Task notifications + * are a method of sending an event directly to a task without the need for such + * an intermediary object. + * + * A notification sent to a task can optionally perform an action, such as + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. + * + * xTaskNotifyGiveIndexed() is a helper macro intended for use when task + * notifications are used as light weight and faster binary or counting + * semaphore equivalents. Actual FreeRTOS semaphores are given using the + * xSemaphoreGive() API function, the equivalent action that instead uses a task + * notification is xTaskNotifyGiveIndexed(). + * + * When task notifications are being used as a binary or counting semaphore + * equivalent then the task being notified should wait for the notification + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyGive() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyGive() is equivalent to calling + * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0. + * + * @param xTaskToNotify The handle of the task being notified. The handle to a + * task can be returned from the xTaskCreate() API function used to create the + * task, and the handle of the currently running task can be obtained by calling + * xTaskGetCurrentTaskHandle(). + * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive() + * does not have this parameter and always sends notifications to index 0. + * + * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the + * eAction parameter set to eIncrement - so pdPASS is always returned. + * + * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed + * \ingroup TaskNotifications + */ +#define xTaskNotifyGive( xTaskToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL ) +#define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL ) + +/** + * task. h + *
void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken );
+ *
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
+ * + * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt + * service routine (ISR). + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro + * to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * Events can be sent to a task using an intermediary object. Examples of such + * objects are queues, semaphores, mutexes and event groups. Task notifications + * are a method of sending an event directly to a task without the need for such + * an intermediary object. + * + * A notification sent to a task can optionally perform an action, such as + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. + * + * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications + * are used as light weight and faster binary or counting semaphore equivalents. + * Actual FreeRTOS semaphores are given from an ISR using the + * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses + * a task notification is vTaskNotifyGiveIndexedFromISR(). + * + * When task notifications are being used as a binary or counting semaphore + * equivalent then the task being notified should wait for the notification + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling + * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0. + * + * @param xTaskToNotify The handle of the task being notified. The handle to a + * task can be returned from the xTaskCreate() API function used to create the + * task, and the handle of the currently running task can be obtained by calling + * xTaskGetCurrentTaskHandle(). + * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * xTaskNotifyGiveFromISR() does not have this parameter and always sends + * notifications to index 0. + * + * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the + * task to which the notification was sent to leave the Blocked state, and the + * unblocked task has a priority higher than the currently running task. If + * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch + * should be requested before the interrupt is exited. How a context switch is + * requested from an ISR is dependent on the port - see the documentation page + * for the port in use. + * + * \defgroup vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR + * \ingroup TaskNotifications + */ +void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) ); +#define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) ); + +/** + * task. h + *
+ * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
+ *
+ * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
+ * 
+ * + * Waits for a direct to task notification on a particular index in the calling + * task's notification array in a manner similar to taking a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this + * function to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * Events can be sent to a task using an intermediary object. Examples of such + * objects are queues, semaphores, mutexes and event groups. Task notifications + * are a method of sending an event directly to a task without the need for such + * an intermediary object. + * + * A notification sent to a task can optionally perform an action, such as + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. + * + * ulTaskNotifyTakeIndexed() is intended for use when a task notification is + * used as a faster and lighter weight binary or counting semaphore alternative. + * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function, + * the equivalent action that instead uses a task notification is + * ulTaskNotifyTakeIndexed(). + * + * When a task is using its notification value as a binary or counting semaphore + * other tasks should send notifications to it using the xTaskNotifyGiveIndexed() + * macro, or xTaskNotifyIndex() function with the eAction parameter set to + * eIncrement. + * + * ulTaskNotifyTakeIndexed() can either clear the task's notification value at + * the array index specified by the uxIndexToWaitOn parameter to zero on exit, + * in which case the notification value acts like a binary semaphore, or + * decrement the notification value on exit, in which case the notification + * value acts like a counting semaphore. + * + * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for + * the task's notification value to be non-zero. The task does not consume any + * CPU time while it is in the Blocked state. + * + * Where as xTaskNotifyWaitIndexed() will return when a notification is pending, + * ulTaskNotifyTakeIndexed() will return when the task's notification value is + * not zero. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyTake() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling ulTaskNotifyTake() is equivalent to calling + * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be non-zero. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does + * not have this parameter and always waits for notifications on index 0. + * + * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's + * notification value is decremented when the function exits. In this way the + * notification value acts like a counting semaphore. If xClearCountOnExit is + * not pdFALSE then the task's notification value is cleared to zero when the + * function exits. In this way the notification value acts like a binary + * semaphore. + * + * @param xTicksToWait The maximum amount of time that the task should wait in + * the Blocked state for the task's notification value to be greater than zero, + * should the count not already be greater than zero when + * ulTaskNotifyTake() was called. The task will not consume any processing + * time while it is in the Blocked state. This is specified in kernel ticks, + * the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time + * specified in milliseconds to a time specified in ticks. + * + * @return The task's notification count before it is either cleared to zero or + * decremented (see the xClearCountOnExit parameter). + * + * \defgroup ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed + * \ingroup TaskNotifications + */ +uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) ) +#define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) ) + +/** + * task. h + *
+ * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
+ *
+ * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
+ * 
+ * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * If a notification is sent to an index within the array of notifications then + * the notification at that index is said to be 'pending' until it is read or + * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed() + * is the function that clears a pending notification without reading the + * notification value. The notification value at the same array index is not + * altered. Set xTask to NULL to clear the notification state of the calling + * task. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyStateClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyStateClear() is equivalent to calling + * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have a notification state + * cleared. Set xTask to NULL to clear a notification state in the calling + * task. To obtain a task's handle create the task using xTaskCreate() and + * make use of the pxCreatedTask parameter, or create the task using + * xTaskCreateStatic() and store the returned value, or use the task's name in + * a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values to act upon. For example, setting uxIndexToClear to 1 + * will clear the state of the notification at index 1 within the array. + * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyStateClear() does not have this parameter and always acts on the + * notification at index 0. + * + * @return pdTRUE if the task's notification state was set to + * eNotWaitingNotification, otherwise pdFALSE. + * + * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed + * \ingroup TaskNotifications + */ +BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION; +#define xTaskNotifyStateClear( xTask ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) ) +#define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) ) + +/** + * task. h + *
+ * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
+ *
+ * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
+ * 
+ * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * ulTaskNotifyValueClearIndexed() clears the bits specified by the + * ulBitsToClear bit mask in the notification value at array index uxIndexToClear + * of the task referenced by xTask. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyValueClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling + * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have bits in one of its + * notification values cleared. Set xTask to NULL to clear bits in a + * notification value of the calling task. To obtain a task's handle create the + * task using xTaskCreate() and make use of the pxCreatedTask parameter, or + * create the task using xTaskCreateStatic() and store the returned value, or + * use the task's name in a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values in which to clear the bits. uxIndexToClear + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyValueClear() does not have this parameter and always clears bits + * in the notification value at index 0. + * + * @param ulBitsToClear Bit mask of the bits to clear in the notification value of + * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification + * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear + * the notification value to 0. Set ulBitsToClear to 0 to query the task's + * notification value without clearing any bits. + * + * + * @return The value of the target task's notification value before the bits + * specified by ulBitsToClear were cleared. + * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear + * \ingroup TaskNotifications + */ +uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) ) +#define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) ) + +/** + * task.h + *
+ * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
+ * 
+ * + * Capture the current time for future use with xTaskCheckForTimeOut(). + * + * @param pxTimeOut Pointer to a timeout object into which the current time + * is to be captured. The captured time includes the tick count and the number + * of times the tick count has overflowed since the system first booted. + * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState + * \ingroup TaskCtrl + */ +void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; + +/** + * task.h + *
+ * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
+ * 
+ * + * Determines if pxTicksToWait ticks has passed since a time was captured + * using a call to vTaskSetTimeOutState(). The captured time includes the tick + * count and the number of times the tick count has overflowed. + * + * @param pxTimeOut The time status as captured previously using + * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated + * to reflect the current time status. + * @param pxTicksToWait The number of ticks to check for timeout i.e. if + * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by + * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred. + * If the timeout has not occurred, pxTIcksToWait is updated to reflect the + * number of remaining ticks. + * + * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is + * returned and pxTicksToWait is updated to reflect the number of remaining + * ticks. + * + * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html + * + * Example Usage: + *
+ *  // Driver library function used to receive uxWantedBytes from an Rx buffer
+ *  // that is filled by a UART interrupt. If there are not enough bytes in the
+ *  // Rx buffer then the task enters the Blocked state until it is notified that
+ *  // more data has been placed into the buffer. If there is still not enough
+ *  // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
+ *  // is used to re-calculate the Block time to ensure the total amount of time
+ *  // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
+ *  // continues until either the buffer contains at least uxWantedBytes bytes,
+ *  // or the total amount of time spent in the Blocked state reaches
+ *  // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are
+ *  // available up to a maximum of uxWantedBytes.
+ *
+ *  size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
+ *  {
+ *  size_t uxReceived = 0;
+ *  TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
+ *  TimeOut_t xTimeOut;
+ *
+ *      // Initialize xTimeOut.  This records the time at which this function
+ *      // was entered.
+ *      vTaskSetTimeOutState( &xTimeOut );
+ *
+ *      // Loop until the buffer contains the wanted number of bytes, or a
+ *      // timeout occurs.
+ *      while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
+ *      {
+ *          // The buffer didn't contain enough data so this task is going to
+ *          // enter the Blocked state. Adjusting xTicksToWait to account for
+ *          // any time that has been spent in the Blocked state within this
+ *          // function so far to ensure the total amount of time spent in the
+ *          // Blocked state does not exceed MAX_TIME_TO_WAIT.
+ *          if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
+ *          {
+ *              //Timed out before the wanted number of bytes were available,
+ *              // exit the loop.
+ *              break;
+ *          }
+ *
+ *          // Wait for a maximum of xTicksToWait ticks to be notified that the
+ *          // receive interrupt has placed more data into the buffer.
+ *          ulTaskNotifyTake( pdTRUE, xTicksToWait );
+ *      }
+ *
+ *      // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
+ *      // The actual number of bytes read (which might be less than
+ *      // uxWantedBytes) is returned.
+ *      uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
+ *                                                  pucBuffer,
+ *                                                  uxWantedBytes );
+ *
+ *      return uxReceived;
+ *  }
+ * 
+ * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut + * \ingroup TaskCtrl + */ +BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * task.h + *
+ * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
+ * 
+ * + * This function corrects the tick count value after the application code has held + * interrupts disabled for an extended period resulting in tick interrupts having + * been missed. + * + * This function is similar to vTaskStepTick(), however, unlike + * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a + * time at which a task should be removed from the blocked state. That means + * tasks may have to be removed from the blocked state as the tick count is + * moved. + * + * @param xTicksToCatchUp The number of tick interrupts that have been missed due to + * interrupts being disabled. Its value is not computed automatically, so must be + * computed by the application writer. + * + * @return pdTRUE if moving the tick count forward resulted in a task leaving the + * blocked state and a context switch being performed. Otherwise pdFALSE. + * + * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks + * \ingroup TaskCtrl + */ +BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION; + + +/*----------------------------------------------------------- +* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES +*----------------------------------------------------------*/ + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY + * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS + * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * Called from the real time kernel tick (either preemptive or cooperative), + * this increments the tick count and checks if any tasks that are blocked + * for a finite period required removing from a blocked list and placing on + * a ready list. If a non-zero value is returned then a context switch is + * required because either: + * + A task was removed from a blocked list because its timeout had expired, + * or + * + Time slicing is in use and there is a task of equal priority to the + * currently running task. + */ +BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN + * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. + * + * Removes the calling task from the ready list and places it both + * on the list of tasks waiting for a particular event, and the + * list of delayed tasks. The task will be removed from both lists + * and replaced on the ready list should either the event occur (and + * there be no higher priority tasks waiting on the same event) or + * the delay period expires. + * + * The 'unordered' version replaces the event list item value with the + * xItemValue value, and inserts the list item at the end of the list. + * + * The 'ordered' version uses the existing event list item value (which is the + * owning tasks priority) to insert the list item into the event list is task + * priority order. + * + * @param pxEventList The list containing tasks that are blocked waiting + * for the event to occur. + * + * @param xItemValue The item value to use for the event list item when the + * event list is not ordered by task priority. + * + * @param xTicksToWait The maximum amount of time that the task should wait + * for the event to occur. This is specified in kernel ticks,the constant + * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time + * period. + */ +void vTaskPlaceOnEventList( List_t * const pxEventList, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, + const TickType_t xItemValue, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN + * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. + * + * This function performs nearly the same function as vTaskPlaceOnEventList(). + * The difference being that this function does not permit tasks to block + * indefinitely, whereas vTaskPlaceOnEventList() does. + * + */ +void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN + * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. + * + * Removes a task from both the specified event list and the list of blocked + * tasks, and places it on a ready queue. + * + * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called + * if either an event occurs to unblock a task, or the block timeout period + * expires. + * + * xTaskRemoveFromEventList() is used when the event list is in task priority + * order. It removes the list item from the head of the event list as that will + * have the highest priority owning task of all the tasks on the event list. + * vTaskRemoveFromUnorderedEventList() is used when the event list is not + * ordered and the event list items hold something other than the owning tasks + * priority. In this case the event list item value is updated to the value + * passed in the xItemValue parameter. + * + * @return pdTRUE if the task being removed has a higher priority than the task + * making the call, otherwise pdFALSE. + */ +BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; +void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, + const TickType_t xItemValue ) PRIVILEGED_FUNCTION; + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY + * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS + * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * Sets the pointer to the current TCB to the TCB of the highest priority task + * that is ready to run. + */ +portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; + +/* + * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY + * THE EVENT BITS MODULE. + */ +TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION; + +/* + * Return the handle of the calling task. + */ +TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION; + +/* + * Shortcut used by the queue implementation to prevent unnecessary call to + * taskYIELD(); + */ +void vTaskMissedYield( void ) PRIVILEGED_FUNCTION; + +/* + * Returns the scheduler state as taskSCHEDULER_RUNNING, + * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED. + */ +BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION; + +/* + * Raises the priority of the mutex holder to that of the calling task should + * the mutex holder have a priority less than the calling task. + */ +BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION; + +/* + * Set the priority of a task back to its proper priority in the case that it + * inherited a higher priority while it was holding a semaphore. + */ +BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION; + +/* + * If a higher priority task attempting to obtain a mutex caused a lower + * priority task to inherit the higher priority task's priority - but the higher + * priority task then timed out without obtaining the mutex, then the lower + * priority task will disinherit the priority again - but only down as far as + * the highest priority task that is still waiting for the mutex (if there were + * more than one task waiting for the mutex). + */ +void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, + UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; + +/* + * Get the uxTCBNumber assigned to the task referenced by the xTask parameter. + */ +UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/* + * Set the uxTaskNumber of the task referenced by the xTask parameter to + * uxHandle. + */ +void vTaskSetTaskNumber( TaskHandle_t xTask, + const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; + +/* + * Only available when configUSE_TICKLESS_IDLE is set to 1. + * If tickless mode is being used, or a low power mode is implemented, then + * the tick interrupt will not execute during idle periods. When this is the + * case, the tick count value maintained by the scheduler needs to be kept up + * to date with the actual execution time by being skipped forward by a time + * equal to the idle period. + */ +void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION; + +/* + * Only available when configUSE_TICKLESS_IDLE is set to 1. + * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port + * specific sleep function to determine if it is ok to proceed with the sleep, + * and if it is ok to proceed, if it is ok to sleep indefinitely. + * + * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only + * called with the scheduler suspended, not from within a critical section. It + * is therefore possible for an interrupt to request a context switch between + * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being + * entered. eTaskConfirmSleepModeStatus() should be called from a short + * critical section between the timer being stopped and the sleep mode being + * entered to ensure it is ok to proceed into the sleep mode. + */ +eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION; + +/* + * For internal use only. Increment the mutex held count when a mutex is + * taken and return the handle of the task that has taken the mutex. + */ +TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; + +/* + * For internal use only. Same as vTaskSetTimeOutState(), but without a critical + * section. + */ +void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; + + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ +#endif /* INC_TASK_H */ diff --git a/FreeRTOS/include/timers.h b/FreeRTOS/include/timers.h new file mode 100644 index 0000000..c6baff3 --- /dev/null +++ b/FreeRTOS/include/timers.h @@ -0,0 +1,1351 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#ifndef TIMERS_H +#define TIMERS_H + +#ifndef INC_FREERTOS_H + #error "include FreeRTOS.h must appear in source files before include timers.h" +#endif + +/*lint -save -e537 This headers are only multiply included if the application code + * happens to also be including task.h. */ +#include "task.h" +/*lint -restore */ + +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +/*----------------------------------------------------------- +* MACROS AND DEFINITIONS +*----------------------------------------------------------*/ + +/* IDs for commands that can be sent/received on the timer queue. These are to + * be used solely through the macros that make up the public software timer API, + * as defined below. The commands that are sent from interrupts must use the + * highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task + * or interrupt version of the queue send function should be used. */ +#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) +#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) +#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) +#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) +#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) +#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) +#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) +#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) + +#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) +#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) +#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) + + +/** + * Type by which software timers are referenced. For example, a call to + * xTimerCreate() returns an TimerHandle_t variable that can then be used to + * reference the subject timer in calls to other software timer API functions + * (for example, xTimerStart(), xTimerReset(), etc.). + */ +struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +typedef struct tmrTimerControl * TimerHandle_t; + +/* + * Defines the prototype to which timer callback functions must conform. + */ +typedef void (* TimerCallbackFunction_t)( TimerHandle_t xTimer ); + +/* + * Defines the prototype to which functions used with the + * xTimerPendFunctionCallFromISR() function must conform. + */ +typedef void (* PendedFunction_t)( void *, + uint32_t ); + +/** + * TimerHandle_t xTimerCreate( const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction ); + * + * Creates a new software timer instance, and returns a handle by which the + * created software timer can be referenced. + * + * Internally, within the FreeRTOS implementation, software timers use a block + * of memory, in which the timer data structure is stored. If a software timer + * is created using xTimerCreate() then the required memory is automatically + * dynamically allocated inside the xTimerCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a software timer is created using + * xTimerCreateStatic() then the application writer must provide the memory that + * will get used by the software timer. xTimerCreateStatic() therefore allows a + * software timer to be created without using any dynamic memory allocation. + * + * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), + * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and + * xTimerChangePeriodFromISR() API functions can all be used to transition a + * timer into the active state. + * + * @param pcTimerName A text name that is assigned to the timer. This is done + * purely to assist debugging. The kernel itself only ever references a timer + * by its handle, and never by its name. + * + * @param xTimerPeriodInTicks The timer period. The time is defined in tick + * periods so the constant portTICK_PERIOD_MS can be used to convert a time that + * has been specified in milliseconds. For example, if the timer must expire + * after 100 ticks, then xTimerPeriodInTicks should be set to 100. + * Alternatively, if the timer must expire after 500ms, then xPeriod can be set + * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or + * equal to 1000. Time timer period must be greater than 0. + * + * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will + * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. + * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and + * enter the dormant state after it expires. + * + * @param pvTimerID An identifier that is assigned to the timer being created. + * Typically this would be used in the timer callback function to identify which + * timer expired when the same callback function is assigned to more than one + * timer. + * + * @param pxCallbackFunction The function to call when the timer expires. + * Callback functions must have the prototype defined by TimerCallbackFunction_t, + * which is "void vCallbackFunction( TimerHandle_t xTimer );". + * + * @return If the timer is successfully created then a handle to the newly + * created timer is returned. If the timer cannot be created because there is + * insufficient FreeRTOS heap remaining to allocate the timer + * structures then NULL is returned. + * + * Example usage: + * @verbatim + * #define NUM_TIMERS 5 + * + * // An array to hold handles to the created timers. + * TimerHandle_t xTimers[ NUM_TIMERS ]; + * + * // An array to hold a count of the number of times each timer expires. + * int32_t lExpireCounters[ NUM_TIMERS ] = { 0 }; + * + * // Define a callback function that will be used by multiple timer instances. + * // The callback function does nothing but count the number of times the + * // associated timer expires, and stop the timer once the timer has expired + * // 10 times. + * void vTimerCallback( TimerHandle_t pxTimer ) + * { + * int32_t lArrayIndex; + * const int32_t xMaxExpiryCountBeforeStopping = 10; + * + * // Optionally do something if the pxTimer parameter is NULL. + * configASSERT( pxTimer ); + * + * // Which timer expired? + * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer ); + * + * // Increment the number of times that pxTimer has expired. + * lExpireCounters[ lArrayIndex ] += 1; + * + * // If the timer has expired 10 times then stop it from running. + * if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping ) + * { + * // Do not use a block time if calling a timer API function from a + * // timer callback function, as doing so could cause a deadlock! + * xTimerStop( pxTimer, 0 ); + * } + * } + * + * void main( void ) + * { + * int32_t x; + * + * // Create then start some timers. Starting the timers before the scheduler + * // has been started means the timers will start running immediately that + * // the scheduler starts. + * for( x = 0; x < NUM_TIMERS; x++ ) + * { + * xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel. + * ( 100 * x ), // The timer period in ticks. + * pdTRUE, // The timers will auto-reload themselves when they expire. + * ( void * ) x, // Assign each timer a unique id equal to its array index. + * vTimerCallback // Each timer calls the same callback when it expires. + * ); + * + * if( xTimers[ x ] == NULL ) + * { + * // The timer was not created. + * } + * else + * { + * // Start the timer. No block time is specified, and even if one was + * // it would be ignored because the scheduler has not yet been + * // started. + * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) + * { + * // The timer could not be set into the Active state. + * } + * } + * } + * + * // ... + * // Create tasks here. + * // ... + * + * // Starting the scheduler will start the timers running as they have already + * // been set into the active state. + * vTaskStartScheduler(); + * + * // Should not reach here. + * for( ;; ); + * } + * @endverbatim + */ +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; +#endif + +/** + * TimerHandle_t xTimerCreateStatic(const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction, + * StaticTimer_t *pxTimerBuffer ); + * + * Creates a new software timer instance, and returns a handle by which the + * created software timer can be referenced. + * + * Internally, within the FreeRTOS implementation, software timers use a block + * of memory, in which the timer data structure is stored. If a software timer + * is created using xTimerCreate() then the required memory is automatically + * dynamically allocated inside the xTimerCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a software timer is created using + * xTimerCreateStatic() then the application writer must provide the memory that + * will get used by the software timer. xTimerCreateStatic() therefore allows a + * software timer to be created without using any dynamic memory allocation. + * + * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), + * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and + * xTimerChangePeriodFromISR() API functions can all be used to transition a + * timer into the active state. + * + * @param pcTimerName A text name that is assigned to the timer. This is done + * purely to assist debugging. The kernel itself only ever references a timer + * by its handle, and never by its name. + * + * @param xTimerPeriodInTicks The timer period. The time is defined in tick + * periods so the constant portTICK_PERIOD_MS can be used to convert a time that + * has been specified in milliseconds. For example, if the timer must expire + * after 100 ticks, then xTimerPeriodInTicks should be set to 100. + * Alternatively, if the timer must expire after 500ms, then xPeriod can be set + * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or + * equal to 1000. The timer period must be greater than 0. + * + * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will + * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. + * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and + * enter the dormant state after it expires. + * + * @param pvTimerID An identifier that is assigned to the timer being created. + * Typically this would be used in the timer callback function to identify which + * timer expired when the same callback function is assigned to more than one + * timer. + * + * @param pxCallbackFunction The function to call when the timer expires. + * Callback functions must have the prototype defined by TimerCallbackFunction_t, + * which is "void vCallbackFunction( TimerHandle_t xTimer );". + * + * @param pxTimerBuffer Must point to a variable of type StaticTimer_t, which + * will be then be used to hold the software timer's data structures, removing + * the need for the memory to be allocated dynamically. + * + * @return If the timer is created then a handle to the created timer is + * returned. If pxTimerBuffer was NULL then NULL is returned. + * + * Example usage: + * @verbatim + * + * // The buffer used to hold the software timer's data structure. + * static StaticTimer_t xTimerBuffer; + * + * // A variable that will be incremented by the software timer's callback + * // function. + * UBaseType_t uxVariableToIncrement = 0; + * + * // A software timer callback function that increments a variable passed to + * // it when the software timer was created. After the 5th increment the + * // callback function stops the software timer. + * static void prvTimerCallback( TimerHandle_t xExpiredTimer ) + * { + * UBaseType_t *puxVariableToIncrement; + * BaseType_t xReturned; + * + * // Obtain the address of the variable to increment from the timer ID. + * puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer ); + * + * // Increment the variable to show the timer callback has executed. + * ( *puxVariableToIncrement )++; + * + * // If this callback has executed the required number of times, stop the + * // timer. + * if( *puxVariableToIncrement == 5 ) + * { + * // This is called from a timer callback so must not block. + * xTimerStop( xExpiredTimer, staticDONT_BLOCK ); + * } + * } + * + * + * void main( void ) + * { + * // Create the software time. xTimerCreateStatic() has an extra parameter + * // than the normal xTimerCreate() API function. The parameter is a pointer + * // to the StaticTimer_t structure that will hold the software timer + * // structure. If the parameter is passed as NULL then the structure will be + * // allocated dynamically, just as if xTimerCreate() had been called. + * xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS. + * xTimerPeriod, // The period of the timer in ticks. + * pdTRUE, // This is an auto-reload timer. + * ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function + * prvTimerCallback, // The function to execute when the timer expires. + * &xTimerBuffer ); // The buffer that will hold the software timer structure. + * + * // The scheduler has not started yet so a block time is not used. + * xReturned = xTimerStart( xTimer, 0 ); + * + * // ... + * // Create tasks here. + * // ... + * + * // Starting the scheduler will start the timers running as they have already + * // been set into the active state. + * vTaskStartScheduler(); + * + * // Should not reach here. + * for( ;; ); + * } + * @endverbatim + */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION; +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +/** + * void *pvTimerGetTimerID( TimerHandle_t xTimer ); + * + * Returns the ID assigned to the timer. + * + * IDs are assigned to timers using the pvTimerID parameter of the call to + * xTimerCreated() that was used to create the timer, and by calling the + * vTimerSetTimerID() API function. + * + * If the same callback function is assigned to multiple timers then the timer + * ID can be used as time specific (timer local) storage. + * + * @param xTimer The timer being queried. + * + * @return The ID assigned to the timer being queried. + * + * Example usage: + * + * See the xTimerCreate() API function example usage scenario. + */ +void * pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; + +/** + * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); + * + * Sets the ID assigned to the timer. + * + * IDs are assigned to timers using the pvTimerID parameter of the call to + * xTimerCreated() that was used to create the timer. + * + * If the same callback function is assigned to multiple timers then the timer + * ID can be used as time specific (timer local) storage. + * + * @param xTimer The timer being updated. + * + * @param pvNewID The ID to assign to the timer. + * + * Example usage: + * + * See the xTimerCreate() API function example usage scenario. + */ +void vTimerSetTimerID( TimerHandle_t xTimer, + void * pvNewID ) PRIVILEGED_FUNCTION; + +/** + * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); + * + * Queries a timer to see if it is active or dormant. + * + * A timer will be dormant if: + * 1) It has been created but not started, or + * 2) It is an expired one-shot timer that has not been restarted. + * + * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), + * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and + * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the + * active state. + * + * @param xTimer The timer being queried. + * + * @return pdFALSE will be returned if the timer is dormant. A value other than + * pdFALSE will be returned if the timer is active. + * + * Example usage: + * @verbatim + * // This function assumes xTimer has already been created. + * void vAFunction( TimerHandle_t xTimer ) + * { + * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" + * { + * // xTimer is active, do something. + * } + * else + * { + * // xTimer is not active, do something else. + * } + * } + * @endverbatim + */ +BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; + +/** + * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); + * + * Simply returns the handle of the timer service/daemon task. It it not valid + * to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started. + */ +TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; + +/** + * BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait ); + * + * Timer functionality is provided by a timer service/daemon task. Many of the + * public FreeRTOS timer API functions send commands to the timer service task + * through a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the + * configTIMER_QUEUE_LENGTH configuration constant. + * + * xTimerStart() starts a timer that was previously created using the + * xTimerCreate() API function. If the timer had already been started and was + * already in the active state, then xTimerStart() has equivalent functionality + * to the xTimerReset() API function. + * + * Starting a timer ensures the timer is in the active state. If the timer + * is not stopped, deleted, or reset in the mean time, the callback function + * associated with the timer will get called 'n' ticks after xTimerStart() was + * called, where 'n' is the timers defined period. + * + * It is valid to call xTimerStart() before the scheduler has been started, but + * when this is done the timer will not actually start until the scheduler is + * started, and the timers expiry time will be relative to when the scheduler is + * started, not relative to when xTimerStart() was called. + * + * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStart() + * to be available. + * + * @param xTimer The handle of the timer being started/restarted. + * + * @param xTicksToWait Specifies the time, in ticks, that the calling task should + * be held in the Blocked state to wait for the start command to be successfully + * sent to the timer command queue, should the queue already be full when + * xTimerStart() was called. xTicksToWait is ignored if xTimerStart() is called + * before the scheduler is started. + * + * @return pdFAIL will be returned if the start command could not be sent to + * the timer command queue even after xTicksToWait ticks had passed. pdPASS will + * be returned if the command was successfully sent to the timer command queue. + * When the command is actually processed will depend on the priority of the + * timer service/daemon task relative to other tasks in the system, although the + * timers expiry time is relative to when xTimerStart() is actually called. The + * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * configuration constant. + * + * Example usage: + * + * See the xTimerCreate() API function example usage scenario. + * + */ +#define xTimerStart( xTimer, xTicksToWait ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) + +/** + * BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait ); + * + * Timer functionality is provided by a timer service/daemon task. Many of the + * public FreeRTOS timer API functions send commands to the timer service task + * through a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the + * configTIMER_QUEUE_LENGTH configuration constant. + * + * xTimerStop() stops a timer that was previously started using either of the + * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), + * xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions. + * + * Stopping a timer ensures the timer is not in the active state. + * + * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStop() + * to be available. + * + * @param xTimer The handle of the timer being stopped. + * + * @param xTicksToWait Specifies the time, in ticks, that the calling task should + * be held in the Blocked state to wait for the stop command to be successfully + * sent to the timer command queue, should the queue already be full when + * xTimerStop() was called. xTicksToWait is ignored if xTimerStop() is called + * before the scheduler is started. + * + * @return pdFAIL will be returned if the stop command could not be sent to + * the timer command queue even after xTicksToWait ticks had passed. pdPASS will + * be returned if the command was successfully sent to the timer command queue. + * When the command is actually processed will depend on the priority of the + * timer service/daemon task relative to other tasks in the system. The timer + * service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * configuration constant. + * + * Example usage: + * + * See the xTimerCreate() API function example usage scenario. + * + */ +#define xTimerStop( xTimer, xTicksToWait ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) ) + +/** + * BaseType_t xTimerChangePeriod( TimerHandle_t xTimer, + * TickType_t xNewPeriod, + * TickType_t xTicksToWait ); + * + * Timer functionality is provided by a timer service/daemon task. Many of the + * public FreeRTOS timer API functions send commands to the timer service task + * through a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the + * configTIMER_QUEUE_LENGTH configuration constant. + * + * xTimerChangePeriod() changes the period of a timer that was previously + * created using the xTimerCreate() API function. + * + * xTimerChangePeriod() can be called to change the period of an active or + * dormant state timer. + * + * The configUSE_TIMERS configuration constant must be set to 1 for + * xTimerChangePeriod() to be available. + * + * @param xTimer The handle of the timer that is having its period changed. + * + * @param xNewPeriod The new period for xTimer. Timer periods are specified in + * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time + * that has been specified in milliseconds. For example, if the timer must + * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, + * if the timer must expire after 500ms, then xNewPeriod can be set to + * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than + * or equal to 1000. + * + * @param xTicksToWait Specifies the time, in ticks, that the calling task should + * be held in the Blocked state to wait for the change period command to be + * successfully sent to the timer command queue, should the queue already be + * full when xTimerChangePeriod() was called. xTicksToWait is ignored if + * xTimerChangePeriod() is called before the scheduler is started. + * + * @return pdFAIL will be returned if the change period command could not be + * sent to the timer command queue even after xTicksToWait ticks had passed. + * pdPASS will be returned if the command was successfully sent to the timer + * command queue. When the command is actually processed will depend on the + * priority of the timer service/daemon task relative to other tasks in the + * system. The timer service/daemon task priority is set by the + * configTIMER_TASK_PRIORITY configuration constant. + * + * Example usage: + * @verbatim + * // This function assumes xTimer has already been created. If the timer + * // referenced by xTimer is already active when it is called, then the timer + * // is deleted. If the timer referenced by xTimer is not active when it is + * // called, then the period of the timer is set to 500ms and the timer is + * // started. + * void vAFunction( TimerHandle_t xTimer ) + * { + * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" + * { + * // xTimer is already active - delete it. + * xTimerDelete( xTimer ); + * } + * else + * { + * // xTimer is not active, change its period to 500ms. This will also + * // cause the timer to start. Block for a maximum of 100 ticks if the + * // change period command cannot immediately be sent to the timer + * // command queue. + * if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS ) + * { + * // The command was successfully sent. + * } + * else + * { + * // The command could not be sent, even after waiting for 100 ticks + * // to pass. Take appropriate action here. + * } + * } + * } + * @endverbatim + */ +#define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) ) + +/** + * BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait ); + * + * Timer functionality is provided by a timer service/daemon task. Many of the + * public FreeRTOS timer API functions send commands to the timer service task + * through a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the + * configTIMER_QUEUE_LENGTH configuration constant. + * + * xTimerDelete() deletes a timer that was previously created using the + * xTimerCreate() API function. + * + * The configUSE_TIMERS configuration constant must be set to 1 for + * xTimerDelete() to be available. + * + * @param xTimer The handle of the timer being deleted. + * + * @param xTicksToWait Specifies the time, in ticks, that the calling task should + * be held in the Blocked state to wait for the delete command to be + * successfully sent to the timer command queue, should the queue already be + * full when xTimerDelete() was called. xTicksToWait is ignored if xTimerDelete() + * is called before the scheduler is started. + * + * @return pdFAIL will be returned if the delete command could not be sent to + * the timer command queue even after xTicksToWait ticks had passed. pdPASS will + * be returned if the command was successfully sent to the timer command queue. + * When the command is actually processed will depend on the priority of the + * timer service/daemon task relative to other tasks in the system. The timer + * service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * configuration constant. + * + * Example usage: + * + * See the xTimerChangePeriod() API function example usage scenario. + */ +#define xTimerDelete( xTimer, xTicksToWait ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) ) + +/** + * BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait ); + * + * Timer functionality is provided by a timer service/daemon task. Many of the + * public FreeRTOS timer API functions send commands to the timer service task + * through a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the + * configTIMER_QUEUE_LENGTH configuration constant. + * + * xTimerReset() re-starts a timer that was previously created using the + * xTimerCreate() API function. If the timer had already been started and was + * already in the active state, then xTimerReset() will cause the timer to + * re-evaluate its expiry time so that it is relative to when xTimerReset() was + * called. If the timer was in the dormant state then xTimerReset() has + * equivalent functionality to the xTimerStart() API function. + * + * Resetting a timer ensures the timer is in the active state. If the timer + * is not stopped, deleted, or reset in the mean time, the callback function + * associated with the timer will get called 'n' ticks after xTimerReset() was + * called, where 'n' is the timers defined period. + * + * It is valid to call xTimerReset() before the scheduler has been started, but + * when this is done the timer will not actually start until the scheduler is + * started, and the timers expiry time will be relative to when the scheduler is + * started, not relative to when xTimerReset() was called. + * + * The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset() + * to be available. + * + * @param xTimer The handle of the timer being reset/started/restarted. + * + * @param xTicksToWait Specifies the time, in ticks, that the calling task should + * be held in the Blocked state to wait for the reset command to be successfully + * sent to the timer command queue, should the queue already be full when + * xTimerReset() was called. xTicksToWait is ignored if xTimerReset() is called + * before the scheduler is started. + * + * @return pdFAIL will be returned if the reset command could not be sent to + * the timer command queue even after xTicksToWait ticks had passed. pdPASS will + * be returned if the command was successfully sent to the timer command queue. + * When the command is actually processed will depend on the priority of the + * timer service/daemon task relative to other tasks in the system, although the + * timers expiry time is relative to when xTimerStart() is actually called. The + * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * configuration constant. + * + * Example usage: + * @verbatim + * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass + * // without a key being pressed, then the LCD back-light is switched off. In + * // this case, the timer is a one-shot timer. + * + * TimerHandle_t xBacklightTimer = NULL; + * + * // The callback function assigned to the one-shot timer. In this case the + * // parameter is not used. + * void vBacklightTimerCallback( TimerHandle_t pxTimer ) + * { + * // The timer expired, therefore 5 seconds must have passed since a key + * // was pressed. Switch off the LCD back-light. + * vSetBacklightState( BACKLIGHT_OFF ); + * } + * + * // The key press event handler. + * void vKeyPressEventHandler( char cKey ) + * { + * // Ensure the LCD back-light is on, then reset the timer that is + * // responsible for turning the back-light off after 5 seconds of + * // key inactivity. Wait 10 ticks for the command to be successfully sent + * // if it cannot be sent immediately. + * vSetBacklightState( BACKLIGHT_ON ); + * if( xTimerReset( xBacklightTimer, 100 ) != pdPASS ) + * { + * // The reset command was not executed successfully. Take appropriate + * // action here. + * } + * + * // Perform the rest of the key processing here. + * } + * + * void main( void ) + * { + * int32_t x; + * + * // Create then start the one-shot timer that is responsible for turning + * // the back-light off if no keys are pressed within a 5 second period. + * xBacklightTimer = xTimerCreate( "BacklightTimer", // Just a text name, not used by the kernel. + * ( 5000 / portTICK_PERIOD_MS), // The timer period in ticks. + * pdFALSE, // The timer is a one-shot timer. + * 0, // The id is not used by the callback so can take any value. + * vBacklightTimerCallback // The callback function that switches the LCD back-light off. + * ); + * + * if( xBacklightTimer == NULL ) + * { + * // The timer was not created. + * } + * else + * { + * // Start the timer. No block time is specified, and even if one was + * // it would be ignored because the scheduler has not yet been + * // started. + * if( xTimerStart( xBacklightTimer, 0 ) != pdPASS ) + * { + * // The timer could not be set into the Active state. + * } + * } + * + * // ... + * // Create tasks here. + * // ... + * + * // Starting the scheduler will start the timer running as it has already + * // been set into the active state. + * vTaskStartScheduler(); + * + * // Should not reach here. + * for( ;; ); + * } + * @endverbatim + */ +#define xTimerReset( xTimer, xTicksToWait ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) + +/** + * BaseType_t xTimerStartFromISR( TimerHandle_t xTimer, + * BaseType_t *pxHigherPriorityTaskWoken ); + * + * A version of xTimerStart() that can be called from an interrupt service + * routine. + * + * @param xTimer The handle of the timer being started/restarted. + * + * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most + * of its time in the Blocked state, waiting for messages to arrive on the timer + * command queue. Calling xTimerStartFromISR() writes a message to the timer + * command queue, so has the potential to transition the timer service/daemon + * task out of the Blocked state. If calling xTimerStartFromISR() causes the + * timer service/daemon task to leave the Blocked state, and the timer service/ + * daemon task has a priority equal to or greater than the currently executing + * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will + * get set to pdTRUE internally within the xTimerStartFromISR() function. If + * xTimerStartFromISR() sets this value to pdTRUE then a context switch should + * be performed before the interrupt exits. + * + * @return pdFAIL will be returned if the start command could not be sent to + * the timer command queue. pdPASS will be returned if the command was + * successfully sent to the timer command queue. When the command is actually + * processed will depend on the priority of the timer service/daemon task + * relative to other tasks in the system, although the timers expiry time is + * relative to when xTimerStartFromISR() is actually called. The timer + * service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * configuration constant. + * + * Example usage: + * @verbatim + * // This scenario assumes xBacklightTimer has already been created. When a + * // key is pressed, an LCD back-light is switched on. If 5 seconds pass + * // without a key being pressed, then the LCD back-light is switched off. In + * // this case, the timer is a one-shot timer, and unlike the example given for + * // the xTimerReset() function, the key press event handler is an interrupt + * // service routine. + * + * // The callback function assigned to the one-shot timer. In this case the + * // parameter is not used. + * void vBacklightTimerCallback( TimerHandle_t pxTimer ) + * { + * // The timer expired, therefore 5 seconds must have passed since a key + * // was pressed. Switch off the LCD back-light. + * vSetBacklightState( BACKLIGHT_OFF ); + * } + * + * // The key press interrupt service routine. + * void vKeyPressEventInterruptHandler( void ) + * { + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; + * + * // Ensure the LCD back-light is on, then restart the timer that is + * // responsible for turning the back-light off after 5 seconds of + * // key inactivity. This is an interrupt service routine so can only + * // call FreeRTOS API functions that end in "FromISR". + * vSetBacklightState( BACKLIGHT_ON ); + * + * // xTimerStartFromISR() or xTimerResetFromISR() could be called here + * // as both cause the timer to re-calculate its expiry time. + * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was + * // declared (in this function). + * if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * { + * // The start command was not executed successfully. Take appropriate + * // action here. + * } + * + * // Perform the rest of the key processing here. + * + * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch + * // should be performed. The syntax required to perform a context switch + * // from inside an ISR varies from port to port, and from compiler to + * // compiler. Inspect the demos for the port you are using to find the + * // actual syntax required. + * if( xHigherPriorityTaskWoken != pdFALSE ) + * { + * // Call the interrupt safe yield function here (actual function + * // depends on the FreeRTOS port being used). + * } + * } + * @endverbatim + */ +#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) + +/** + * BaseType_t xTimerStopFromISR( TimerHandle_t xTimer, + * BaseType_t *pxHigherPriorityTaskWoken ); + * + * A version of xTimerStop() that can be called from an interrupt service + * routine. + * + * @param xTimer The handle of the timer being stopped. + * + * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most + * of its time in the Blocked state, waiting for messages to arrive on the timer + * command queue. Calling xTimerStopFromISR() writes a message to the timer + * command queue, so has the potential to transition the timer service/daemon + * task out of the Blocked state. If calling xTimerStopFromISR() causes the + * timer service/daemon task to leave the Blocked state, and the timer service/ + * daemon task has a priority equal to or greater than the currently executing + * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will + * get set to pdTRUE internally within the xTimerStopFromISR() function. If + * xTimerStopFromISR() sets this value to pdTRUE then a context switch should + * be performed before the interrupt exits. + * + * @return pdFAIL will be returned if the stop command could not be sent to + * the timer command queue. pdPASS will be returned if the command was + * successfully sent to the timer command queue. When the command is actually + * processed will depend on the priority of the timer service/daemon task + * relative to other tasks in the system. The timer service/daemon task + * priority is set by the configTIMER_TASK_PRIORITY configuration constant. + * + * Example usage: + * @verbatim + * // This scenario assumes xTimer has already been created and started. When + * // an interrupt occurs, the timer should be simply stopped. + * + * // The interrupt service routine that stops the timer. + * void vAnExampleInterruptServiceRoutine( void ) + * { + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; + * + * // The interrupt has occurred - simply stop the timer. + * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined + * // (within this function). As this is an interrupt service routine, only + * // FreeRTOS API functions that end in "FromISR" can be used. + * if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * { + * // The stop command was not executed successfully. Take appropriate + * // action here. + * } + * + * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch + * // should be performed. The syntax required to perform a context switch + * // from inside an ISR varies from port to port, and from compiler to + * // compiler. Inspect the demos for the port you are using to find the + * // actual syntax required. + * if( xHigherPriorityTaskWoken != pdFALSE ) + * { + * // Call the interrupt safe yield function here (actual function + * // depends on the FreeRTOS port being used). + * } + * } + * @endverbatim + */ +#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U ) + +/** + * BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer, + * TickType_t xNewPeriod, + * BaseType_t *pxHigherPriorityTaskWoken ); + * + * A version of xTimerChangePeriod() that can be called from an interrupt + * service routine. + * + * @param xTimer The handle of the timer that is having its period changed. + * + * @param xNewPeriod The new period for xTimer. Timer periods are specified in + * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time + * that has been specified in milliseconds. For example, if the timer must + * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, + * if the timer must expire after 500ms, then xNewPeriod can be set to + * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than + * or equal to 1000. + * + * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most + * of its time in the Blocked state, waiting for messages to arrive on the timer + * command queue. Calling xTimerChangePeriodFromISR() writes a message to the + * timer command queue, so has the potential to transition the timer service/ + * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR() + * causes the timer service/daemon task to leave the Blocked state, and the + * timer service/daemon task has a priority equal to or greater than the + * currently executing task (the task that was interrupted), then + * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the + * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets + * this value to pdTRUE then a context switch should be performed before the + * interrupt exits. + * + * @return pdFAIL will be returned if the command to change the timers period + * could not be sent to the timer command queue. pdPASS will be returned if the + * command was successfully sent to the timer command queue. When the command + * is actually processed will depend on the priority of the timer service/daemon + * task relative to other tasks in the system. The timer service/daemon task + * priority is set by the configTIMER_TASK_PRIORITY configuration constant. + * + * Example usage: + * @verbatim + * // This scenario assumes xTimer has already been created and started. When + * // an interrupt occurs, the period of xTimer should be changed to 500ms. + * + * // The interrupt service routine that changes the period of xTimer. + * void vAnExampleInterruptServiceRoutine( void ) + * { + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; + * + * // The interrupt has occurred - change the period of xTimer to 500ms. + * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined + * // (within this function). As this is an interrupt service routine, only + * // FreeRTOS API functions that end in "FromISR" can be used. + * if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * { + * // The command to change the timers period was not executed + * // successfully. Take appropriate action here. + * } + * + * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch + * // should be performed. The syntax required to perform a context switch + * // from inside an ISR varies from port to port, and from compiler to + * // compiler. Inspect the demos for the port you are using to find the + * // actual syntax required. + * if( xHigherPriorityTaskWoken != pdFALSE ) + * { + * // Call the interrupt safe yield function here (actual function + * // depends on the FreeRTOS port being used). + * } + * } + * @endverbatim + */ +#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) + +/** + * BaseType_t xTimerResetFromISR( TimerHandle_t xTimer, + * BaseType_t *pxHigherPriorityTaskWoken ); + * + * A version of xTimerReset() that can be called from an interrupt service + * routine. + * + * @param xTimer The handle of the timer that is to be started, reset, or + * restarted. + * + * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most + * of its time in the Blocked state, waiting for messages to arrive on the timer + * command queue. Calling xTimerResetFromISR() writes a message to the timer + * command queue, so has the potential to transition the timer service/daemon + * task out of the Blocked state. If calling xTimerResetFromISR() causes the + * timer service/daemon task to leave the Blocked state, and the timer service/ + * daemon task has a priority equal to or greater than the currently executing + * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will + * get set to pdTRUE internally within the xTimerResetFromISR() function. If + * xTimerResetFromISR() sets this value to pdTRUE then a context switch should + * be performed before the interrupt exits. + * + * @return pdFAIL will be returned if the reset command could not be sent to + * the timer command queue. pdPASS will be returned if the command was + * successfully sent to the timer command queue. When the command is actually + * processed will depend on the priority of the timer service/daemon task + * relative to other tasks in the system, although the timers expiry time is + * relative to when xTimerResetFromISR() is actually called. The timer service/daemon + * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. + * + * Example usage: + * @verbatim + * // This scenario assumes xBacklightTimer has already been created. When a + * // key is pressed, an LCD back-light is switched on. If 5 seconds pass + * // without a key being pressed, then the LCD back-light is switched off. In + * // this case, the timer is a one-shot timer, and unlike the example given for + * // the xTimerReset() function, the key press event handler is an interrupt + * // service routine. + * + * // The callback function assigned to the one-shot timer. In this case the + * // parameter is not used. + * void vBacklightTimerCallback( TimerHandle_t pxTimer ) + * { + * // The timer expired, therefore 5 seconds must have passed since a key + * // was pressed. Switch off the LCD back-light. + * vSetBacklightState( BACKLIGHT_OFF ); + * } + * + * // The key press interrupt service routine. + * void vKeyPressEventInterruptHandler( void ) + * { + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; + * + * // Ensure the LCD back-light is on, then reset the timer that is + * // responsible for turning the back-light off after 5 seconds of + * // key inactivity. This is an interrupt service routine so can only + * // call FreeRTOS API functions that end in "FromISR". + * vSetBacklightState( BACKLIGHT_ON ); + * + * // xTimerStartFromISR() or xTimerResetFromISR() could be called here + * // as both cause the timer to re-calculate its expiry time. + * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was + * // declared (in this function). + * if( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) + * { + * // The reset command was not executed successfully. Take appropriate + * // action here. + * } + * + * // Perform the rest of the key processing here. + * + * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch + * // should be performed. The syntax required to perform a context switch + * // from inside an ISR varies from port to port, and from compiler to + * // compiler. Inspect the demos for the port you are using to find the + * // actual syntax required. + * if( xHigherPriorityTaskWoken != pdFALSE ) + * { + * // Call the interrupt safe yield function here (actual function + * // depends on the FreeRTOS port being used). + * } + * } + * @endverbatim + */ +#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) \ + xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) + + +/** + * BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, + * void *pvParameter1, + * uint32_t ulParameter2, + * BaseType_t *pxHigherPriorityTaskWoken ); + * + * + * Used from application interrupt service routines to defer the execution of a + * function to the RTOS daemon task (the timer service task, hence this function + * is implemented in timers.c and is prefixed with 'Timer'). + * + * Ideally an interrupt service routine (ISR) is kept as short as possible, but + * sometimes an ISR either has a lot of processing to do, or needs to perform + * processing that is not deterministic. In these cases + * xTimerPendFunctionCallFromISR() can be used to defer processing of a function + * to the RTOS daemon task. + * + * A mechanism is provided that allows the interrupt to return directly to the + * task that will subsequently execute the pended callback function. This + * allows the callback function to execute contiguously in time with the + * interrupt - just as if the callback had executed in the interrupt itself. + * + * @param xFunctionToPend The function to execute from the timer service/ + * daemon task. The function must conform to the PendedFunction_t + * prototype. + * + * @param pvParameter1 The value of the callback function's first parameter. + * The parameter has a void * type to allow it to be used to pass any type. + * For example, unsigned longs can be cast to a void *, or the void * can be + * used to point to a structure. + * + * @param ulParameter2 The value of the callback function's second parameter. + * + * @param pxHigherPriorityTaskWoken As mentioned above, calling this function + * will result in a message being sent to the timer daemon task. If the + * priority of the timer daemon task (which is set using + * configTIMER_TASK_PRIORITY in FreeRTOSConfig.h) is higher than the priority of + * the currently running task (the task the interrupt interrupted) then + * *pxHigherPriorityTaskWoken will be set to pdTRUE within + * xTimerPendFunctionCallFromISR(), indicating that a context switch should be + * requested before the interrupt exits. For that reason + * *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the + * example code below. + * + * @return pdPASS is returned if the message was successfully sent to the + * timer daemon task, otherwise pdFALSE is returned. + * + * Example usage: + * @verbatim + * + * // The callback function that will execute in the context of the daemon task. + * // Note callback functions must all use this same prototype. + * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 ) + * { + * BaseType_t xInterfaceToService; + * + * // The interface that requires servicing is passed in the second + * // parameter. The first parameter is not used in this case. + * xInterfaceToService = ( BaseType_t ) ulParameter2; + * + * // ...Perform the processing here... + * } + * + * // An ISR that receives data packets from multiple interfaces + * void vAnISR( void ) + * { + * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; + * + * // Query the hardware to determine which interface needs processing. + * xInterfaceToService = prvCheckInterfaces(); + * + * // The actual processing is to be deferred to a task. Request the + * // vProcessInterface() callback function is executed, passing in the + * // number of the interface that needs processing. The interface to + * // service is passed in the second parameter. The first parameter is + * // not used in this case. + * xHigherPriorityTaskWoken = pdFALSE; + * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); + * + * // If xHigherPriorityTaskWoken is now set to pdTRUE then a context + * // switch should be requested. The macro used is port specific and will + * // be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to + * // the documentation page for the port being used. + * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * + * } + * @endverbatim + */ +BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + +/** + * BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + * void *pvParameter1, + * uint32_t ulParameter2, + * TickType_t xTicksToWait ); + * + * + * Used to defer the execution of a function to the RTOS daemon task (the timer + * service task, hence this function is implemented in timers.c and is prefixed + * with 'Timer'). + * + * @param xFunctionToPend The function to execute from the timer service/ + * daemon task. The function must conform to the PendedFunction_t + * prototype. + * + * @param pvParameter1 The value of the callback function's first parameter. + * The parameter has a void * type to allow it to be used to pass any type. + * For example, unsigned longs can be cast to a void *, or the void * can be + * used to point to a structure. + * + * @param ulParameter2 The value of the callback function's second parameter. + * + * @param xTicksToWait Calling this function will result in a message being + * sent to the timer daemon task on a queue. xTicksToWait is the amount of + * time the calling task should remain in the Blocked state (so not using any + * processing time) for space to become available on the timer queue if the + * queue is found to be full. + * + * @return pdPASS is returned if the message was successfully sent to the + * timer daemon task, otherwise pdFALSE is returned. + * + */ +BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * const char * const pcTimerGetName( TimerHandle_t xTimer ); + * + * Returns the name that was assigned to a timer when the timer was created. + * + * @param xTimer The handle of the timer being queried. + * + * @return The name assigned to the timer specified by the xTimer parameter. + */ +const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ); + * + * Updates a timer to be either an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in + * which case the timer will only expire once unless it is manually restarted. + * + * @param xTimer The handle of the timer being updated. + * + * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will + * expire repeatedly with a frequency set by the timer's period (see the + * xTimerPeriodInTicks parameter of the xTimerCreate() API function). If + * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and + * enter the dormant state after it expires. + */ +void vTimerSetReloadMode( TimerHandle_t xTimer, + const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; + +/** + * UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ); + * + * Queries a timer to determine if it is an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in + * which case the timer will only expire once unless it is manually restarted. + * + * @param xTimer The handle of the timer being queried. + * + * @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise + * pdFALSE is returned. + */ +UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; + +/** + * TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); + * + * Returns the period of a timer. + * + * @param xTimer The handle of the timer being queried. + * + * @return The period of the timer in ticks. + */ +TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; + +/** + * TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ); + * + * Returns the time in ticks at which the timer will expire. If this is less + * than the current tick count then the expiry time has overflowed from the + * current time. + * + * @param xTimer The handle of the timer being queried. + * + * @return If the timer is running then the time in ticks at which the timer + * will next expire is returned. If the timer is not running then the return + * value is undefined. + */ +TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; + +/* + * Functions beyond this part are not part of the public API and are intended + * for use by the kernel only. + */ +BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION; +BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, + const BaseType_t xCommandID, + const TickType_t xOptionalValue, + BaseType_t * const pxHigherPriorityTaskWoken, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + +#if ( configUSE_TRACE_FACILITY == 1 ) + void vTimerSetTimerNumber( TimerHandle_t xTimer, + UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +#endif + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + + /** + * task.h + *
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) 
+ * + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Timer Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxTimerTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxTimerTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulTimerTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ); + +#endif + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ +#endif /* TIMERS_H */ diff --git a/FreeRTOS/list.c b/FreeRTOS/list.c new file mode 100644 index 0000000..89d0470 --- /dev/null +++ b/FreeRTOS/list.c @@ -0,0 +1,210 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "list.h" + +/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified + * because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be + * defined for the header files above, but not in this file, in order to + * generate the correct privileged Vs unprivileged linkage and placement. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */ + +/*----------------------------------------------------------- +* PUBLIC LIST API documented in list.h +*----------------------------------------------------------*/ + +void vListInitialise( List_t * const pxList ) +{ + /* The list structure contains a list item which is used to mark the + * end of the list. To initialise the list the list end is inserted + * as the only list entry. */ + pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ + + /* The list end value is the highest possible value in the list to + * ensure it remains at the end of the list. */ + pxList->xListEnd.xItemValue = portMAX_DELAY; + + /* The list end next and previous pointers point to itself so we know + * when the list is empty. */ + pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ + pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ + + pxList->uxNumberOfItems = ( UBaseType_t ) 0U; + + /* Write known values into the list if + * configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ); + listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ); +} +/*-----------------------------------------------------------*/ + +void vListInitialiseItem( ListItem_t * const pxItem ) +{ + /* Make sure the list item is not recorded as being on a list. */ + pxItem->pxContainer = NULL; + + /* Write known values into the list item if + * configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ); + listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ); +} +/*-----------------------------------------------------------*/ + +void vListInsertEnd( List_t * const pxList, + ListItem_t * const pxNewListItem ) +{ + ListItem_t * const pxIndex = pxList->pxIndex; + + /* Only effective when configASSERT() is also defined, these tests may catch + * the list data structures being overwritten in memory. They will not catch + * data errors caused by incorrect configuration or use of FreeRTOS. */ + listTEST_LIST_INTEGRITY( pxList ); + listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); + + /* Insert a new list item into pxList, but rather than sort the list, + * makes the new list item the last item to be removed by a call to + * listGET_OWNER_OF_NEXT_ENTRY(). */ + pxNewListItem->pxNext = pxIndex; + pxNewListItem->pxPrevious = pxIndex->pxPrevious; + + /* Only used during decision coverage testing. */ + mtCOVERAGE_TEST_DELAY(); + + pxIndex->pxPrevious->pxNext = pxNewListItem; + pxIndex->pxPrevious = pxNewListItem; + + /* Remember which list the item is in. */ + pxNewListItem->pxContainer = pxList; + + ( pxList->uxNumberOfItems )++; +} +/*-----------------------------------------------------------*/ + +void vListInsert( List_t * const pxList, + ListItem_t * const pxNewListItem ) +{ + ListItem_t * pxIterator; + const TickType_t xValueOfInsertion = pxNewListItem->xItemValue; + + /* Only effective when configASSERT() is also defined, these tests may catch + * the list data structures being overwritten in memory. They will not catch + * data errors caused by incorrect configuration or use of FreeRTOS. */ + listTEST_LIST_INTEGRITY( pxList ); + listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); + + /* Insert the new list item into the list, sorted in xItemValue order. + * + * If the list already contains a list item with the same item value then the + * new list item should be placed after it. This ensures that TCBs which are + * stored in ready lists (all of which have the same xItemValue value) get a + * share of the CPU. However, if the xItemValue is the same as the back marker + * the iteration loop below will not end. Therefore the value is checked + * first, and the algorithm slightly modified if necessary. */ + if( xValueOfInsertion == portMAX_DELAY ) + { + pxIterator = pxList->xListEnd.pxPrevious; + } + else + { + /* *** NOTE *********************************************************** + * If you find your application is crashing here then likely causes are + * listed below. In addition see https://www.FreeRTOS.org/FAQHelp.html for + * more tips, and ensure configASSERT() is defined! + * https://www.FreeRTOS.org/a00110.html#configASSERT + * + * 1) Stack overflow - + * see https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html + * 2) Incorrect interrupt priority assignment, especially on Cortex-M + * parts where numerically high priority values denote low actual + * interrupt priorities, which can seem counter intuitive. See + * https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html and the definition + * of configMAX_SYSCALL_INTERRUPT_PRIORITY on + * https://www.FreeRTOS.org/a00110.html + * 3) Calling an API function from within a critical section or when + * the scheduler is suspended, or calling an API function that does + * not end in "FromISR" from an interrupt. + * 4) Using a queue or semaphore before it has been initialised or + * before the scheduler has been started (are interrupts firing + * before vTaskStartScheduler() has been called?). + **********************************************************************/ + + for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */ + { + /* There is nothing to do here, just iterating to the wanted + * insertion position. */ + } + } + + pxNewListItem->pxNext = pxIterator->pxNext; + pxNewListItem->pxNext->pxPrevious = pxNewListItem; + pxNewListItem->pxPrevious = pxIterator; + pxIterator->pxNext = pxNewListItem; + + /* Remember which list the item is in. This allows fast removal of the + * item later. */ + pxNewListItem->pxContainer = pxList; + + ( pxList->uxNumberOfItems )++; +} +/*-----------------------------------------------------------*/ + +UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) +{ +/* The list item knows which list it is in. Obtain the list from the list + * item. */ + List_t * const pxList = pxItemToRemove->pxContainer; + + pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious; + pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext; + + /* Only used during decision coverage testing. */ + mtCOVERAGE_TEST_DELAY(); + + /* Make sure the index is left pointing to a valid item. */ + if( pxList->pxIndex == pxItemToRemove ) + { + pxList->pxIndex = pxItemToRemove->pxPrevious; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + pxItemToRemove->pxContainer = NULL; + ( pxList->uxNumberOfItems )--; + + return pxList->uxNumberOfItems; +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/portable/Makefile b/FreeRTOS/portable/Makefile new file mode 100644 index 0000000..e302093 --- /dev/null +++ b/FreeRTOS/portable/Makefile @@ -0,0 +1,88 @@ +################################################################################ +################################################################################ +## +## Makefile -- makefile for FreeRTOS modules. +## +## Mandatory settings: +## +## o TOPDIR = the toplevel directory (using slashes as path separator) +## o TARGET = the machine qualifier to generate code for +## o DIRECTORIES = the list of sub directories to build +## +################################################################################ +################################################################################ + + TOPDIR = ../.. + SUBDIR = FreeRTOS/portable + +include $(TOPDIR)/env/make/Makefile.config + +################################################################################ +# project specific settings +################################################################################ + + DIRECTORIES += RVDS + +################################################################################ +# define user targets +################################################################################ + +default: all + +clean: $(DIRECTORIES:%=subdir-clean-%) + +build: $(DIRECTORIES:%=subdir-build-%) + +headers: $(DIRECTORIES:%=subdir-headers-%) + +install: $(DIRECTORIES:%=subdir-install-%) + +depend: $(DIRECTORIES:%=subdir-depend-%) + +all: clean build install + +################################################################################ +# include internal definitions and rules +################################################################################ + +include $(TOPDIR)/env/make/Makefile.rules + +################################################################################ +# local directory specific rules +################################################################################ + +subdir-clean-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking clean [$(SUBDIR)/$(@:subdir-clean-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-clean-%=%) clean TARGET=$(TARGET) + +subdir-depend-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking depend [$(SUBDIR)/$(@:subdir-depend-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-depend-%=%) depend TARGET=$(TARGET) + +subdir-headers-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking headers [$(SUBDIR)/$(@:subdir-headers-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-headers-%=%) headers TARGET=$(TARGET) + +subdir-build-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking build [$(SUBDIR)/$(@:subdir-build-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-build-%=%) build TARGET=$(TARGET) + +subdir-install-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking install [$(SUBDIR)/$(@:subdir-install-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-install-%=%) install TARGET=$(TARGET) + +subdir-release-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking release [$(SUBDIR)/$(@:subdir-release-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-release-%=%) release TARGET=$(TARGET) + +subdir-doc-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking doc [$(SUBDIR)/$(@:subdir-doc-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-doc-%=%) doc TARGET=$(TARGET) + diff --git a/FreeRTOS/portable/MemMang/ReadMe.url b/FreeRTOS/portable/MemMang/ReadMe.url new file mode 100644 index 0000000..28c9937 --- /dev/null +++ b/FreeRTOS/portable/MemMang/ReadMe.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,2 +[InternetShortcut] +URL=https://www.FreeRTOS.org/a00111.html +IDList= diff --git a/FreeRTOS/portable/MemMang/heap_1.c b/FreeRTOS/portable/MemMang/heap_1.c new file mode 100644 index 0000000..41b757a --- /dev/null +++ b/FreeRTOS/portable/MemMang/heap_1.c @@ -0,0 +1,144 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + * 1 tab == 4 spaces! + */ + + +/* + * The simplest possible implementation of pvPortMalloc(). Note that this + * implementation does NOT allow allocated memory to be freed again. + * + * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the + * memory management pages of https://www.FreeRTOS.org for more information. + */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + +/* A few bytes might be lost to byte aligning the heap start address. */ +#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) + +/* Allocate the memory for the heap. */ +#if ( configAPPLICATION_ALLOCATED_HEAP == 1 ) + +/* The application writer has already defined the array used for the RTOS +* heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#else + static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/* Index into the ucHeap array. */ +static size_t xNextFreeByte = ( size_t ) 0; + +/*-----------------------------------------------------------*/ + +void * pvPortMalloc( size_t xWantedSize ) +{ + void * pvReturn = NULL; + static uint8_t * pucAlignedHeap = NULL; + + /* Ensure that blocks are always aligned to the required number of bytes. */ + #if ( portBYTE_ALIGNMENT != 1 ) + { + if( xWantedSize & portBYTE_ALIGNMENT_MASK ) + { + /* Byte alignment required. */ + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); + } + } + #endif + + vTaskSuspendAll(); + { + if( pucAlignedHeap == NULL ) + { + /* Ensure the heap starts on a correctly aligned boundary. */ + pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + } + + /* Check there is enough room left for the allocation. */ + if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && + ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */ + { + /* Return the next free byte then increment the index past this + * block. */ + pvReturn = pucAlignedHeap + xNextFreeByte; + xNextFreeByte += xWantedSize; + } + + traceMALLOC( pvReturn, xWantedSize ); + } + ( void ) xTaskResumeAll(); + + #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + } + #endif + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void * pv ) +{ + /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and + * heap_4.c for alternative implementations, and the memory management pages of + * https://www.FreeRTOS.org for more information. */ + ( void ) pv; + + /* Force an assert as it is invalid to call this function. */ + configASSERT( pv == NULL ); +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* Only required when static memory is not cleared. */ + xNextFreeByte = ( size_t ) 0; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return( configADJUSTED_HEAP_SIZE - xNextFreeByte ); +} diff --git a/FreeRTOS/portable/MemMang/heap_2.c b/FreeRTOS/portable/MemMang/heap_2.c new file mode 100644 index 0000000..c5e8d71 --- /dev/null +++ b/FreeRTOS/portable/MemMang/heap_2.c @@ -0,0 +1,274 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + * 1 tab == 4 spaces! + */ + +/* + * A sample implementation of pvPortMalloc() and vPortFree() that permits + * allocated blocks to be freed, but does not combine adjacent free blocks + * into a single larger block (and so will fragment memory). See heap_4.c for + * an equivalent that does combine adjacent blocks into single larger blocks. + * + * See heap_1.c, heap_3.c and heap_4.c for alternative implementations, and the + * memory management pages of https://www.FreeRTOS.org for more information. + */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + +/* A few bytes might be lost to byte aligning the heap start address. */ +#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) + +/* + * Initialises the heap structures before their first use. + */ +static void prvHeapInit( void ); + +/* Allocate the memory for the heap. */ +#if ( configAPPLICATION_ALLOCATED_HEAP == 1 ) + +/* The application writer has already defined the array used for the RTOS +* heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#else + static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + + +/* Define the linked list structure. This is used to link free blocks in order + * of their size. */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK * pxNextFreeBlock; /*<< The next free block in the list. */ + size_t xBlockSize; /*<< The size of the free block. */ +} BlockLink_t; + + +static const uint16_t heapSTRUCT_SIZE = ( ( sizeof( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK ); +#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) ) + +/* Create a couple of list links to mark the start and end of the list. */ +static BlockLink_t xStart, xEnd; + +/* Keeps track of the number of free bytes remaining, but says nothing about + * fragmentation. */ +static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE; + +/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */ + +/* + * Insert a block into the list of free blocks - which is ordered by size of + * the block. Small blocks at the start of the list and large blocks at the end + * of the list. + */ +#define prvInsertBlockIntoFreeList( pxBlockToInsert ) \ + { \ + BlockLink_t * pxIterator; \ + size_t xBlockSize; \ + \ + xBlockSize = pxBlockToInsert->xBlockSize; \ + \ + /* Iterate through the list until a block is found that has a larger size */ \ + /* than the block we are inserting. */ \ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \ + { \ + /* There is nothing to do here - just iterate to the correct position. */ \ + } \ + \ + /* Update the list to include the block being inserted in the correct */ \ + /* position. */ \ + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \ + pxIterator->pxNextFreeBlock = pxBlockToInsert; \ + } +/*-----------------------------------------------------------*/ + +void * pvPortMalloc( size_t xWantedSize ) +{ + BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink; + static BaseType_t xHeapHasBeenInitialised = pdFALSE; + void * pvReturn = NULL; + + vTaskSuspendAll(); + { + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( xHeapHasBeenInitialised == pdFALSE ) + { + prvHeapInit(); + xHeapHasBeenInitialised = pdTRUE; + } + + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += heapSTRUCT_SIZE; + + /* Ensure that blocks are always aligned to the required number of bytes. */ + if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 ) + { + /* Byte alignment required. */ + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); + } + } + + if( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) ) + { + /* Blocks are stored in byte order - traverse the list from the start + * (smallest) block until one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If we found the end marker then a block of adequate size was not found. */ + if( pxBlock != &xEnd ) + { + /* Return the memory space - jumping over the BlockLink_t structure + * at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE ); + + /* This block is being returned for use so must be taken out of the + * list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new block + * following the number of bytes requested. The void cast is + * used to prevent byte alignment warnings from the compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + + /* Calculate the sizes of two blocks split from the single + * block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + } + } + + traceMALLOC( pvReturn, xWantedSize ); + } + ( void ) xTaskResumeAll(); + + #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + } + #endif + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void * pv ) +{ + uint8_t * puc = ( uint8_t * ) pv; + BlockLink_t * pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= heapSTRUCT_SIZE; + + /* This unexpected casting is to keep some compilers from issuing + * byte alignment warnings. */ + pxLink = ( void * ) puc; + + vTaskSuspendAll(); + { + /* Add this block to the list of free blocks. */ + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + } + ( void ) xTaskResumeAll(); + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) +{ + BlockLink_t * pxFirstFreeBlock; + uint8_t * pucAlignedHeap; + + /* Ensure the heap starts on a correctly aligned boundary. */ + pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + + /* xStart is used to hold a pointer to the first item in the list of free + * blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + + /* xEnd is used to mark the end of the list of free blocks. */ + xEnd.xBlockSize = configADJUSTED_HEAP_SIZE; + xEnd.pxNextFreeBlock = NULL; + + /* To start with there is a single free block that is sized to take up the + * entire heap space. */ + pxFirstFreeBlock = ( void * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = configADJUSTED_HEAP_SIZE; + pxFirstFreeBlock->pxNextFreeBlock = &xEnd; +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/portable/MemMang/heap_3.c b/FreeRTOS/portable/MemMang/heap_3.c new file mode 100644 index 0000000..b37dd2a --- /dev/null +++ b/FreeRTOS/portable/MemMang/heap_3.c @@ -0,0 +1,94 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + * 1 tab == 4 spaces! + */ + + +/* + * Implementation of pvPortMalloc() and vPortFree() that relies on the + * compilers own malloc() and free() implementations. + * + * This file can only be used if the linker is configured to to generate + * a heap memory area. + * + * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the + * memory management pages of https://www.FreeRTOS.org for more information. + */ + +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + +/*-----------------------------------------------------------*/ + +void * pvPortMalloc( size_t xWantedSize ) +{ + void * pvReturn; + + vTaskSuspendAll(); + { + pvReturn = malloc( xWantedSize ); + traceMALLOC( pvReturn, xWantedSize ); + } + ( void ) xTaskResumeAll(); + + #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + } + #endif + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void * pv ) +{ + if( pv ) + { + vTaskSuspendAll(); + { + free( pv ); + traceFREE( pv, 0 ); + } + ( void ) xTaskResumeAll(); + } +} diff --git a/FreeRTOS/portable/MemMang/heap_4.c b/FreeRTOS/portable/MemMang/heap_4.c new file mode 100644 index 0000000..da8dd54 --- /dev/null +++ b/FreeRTOS/portable/MemMang/heap_4.c @@ -0,0 +1,494 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* + * A sample implementation of pvPortMalloc() and vPortFree() that combines + * (coalescences) adjacent memory blocks as they are freed, and in so doing + * limits memory fragmentation. + * + * See heap_1.c, heap_2.c and heap_3.c for alternative implementations, and the + * memory management pages of https://www.FreeRTOS.org for more information. + */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + +/* Block sizes must not get too small. */ +#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) + +/* Assumes 8bit bytes! */ +#define heapBITS_PER_BYTE ( ( size_t ) 8 ) + +/* Allocate the memory for the heap. */ +#if ( configAPPLICATION_ALLOCATED_HEAP == 1 ) + +/* The application writer has already defined the array used for the RTOS +* heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#else + PRIVILEGED_DATA static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/* Define the linked list structure. This is used to link free blocks in order + * of their memory address. */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK * pxNextFreeBlock; /*<< The next free block in the list. */ + size_t xBlockSize; /*<< The size of the free block. */ +} BlockLink_t; + +/*-----------------------------------------------------------*/ + +/* + * Inserts a block of memory that is being freed into the correct position in + * the list of free memory blocks. The block being freed will be merged with + * the block in front it and/or the block behind it if the memory blocks are + * adjacent to each other. + */ +static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ) PRIVILEGED_FUNCTION; + +/* + * Called automatically to setup the required heap structures the first time + * pvPortMalloc() is called. + */ +static void prvHeapInit( void ) PRIVILEGED_FUNCTION; + +/*-----------------------------------------------------------*/ + +/* The size of the structure placed at the beginning of each allocated memory + * block must by correctly byte aligned. */ +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); + +/* Create a couple of list links to mark the start and end of the list. */ +PRIVILEGED_DATA static BlockLink_t xStart, * pxEnd = NULL; + +/* Keeps track of the number of calls to allocate and free memory as well as the + * number of free bytes remaining, but says nothing about fragmentation. */ +PRIVILEGED_DATA static size_t xFreeBytesRemaining = 0U; +PRIVILEGED_DATA static size_t xMinimumEverFreeBytesRemaining = 0U; +PRIVILEGED_DATA static size_t xNumberOfSuccessfulAllocations = 0; +PRIVILEGED_DATA static size_t xNumberOfSuccessfulFrees = 0; + +/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize + * member of an BlockLink_t structure is set then the block belongs to the + * application. When the bit is free the block is still part of the free heap + * space. */ +PRIVILEGED_DATA static size_t xBlockAllocatedBit = 0; + +/*-----------------------------------------------------------*/ + +void * pvPortMalloc( size_t xWantedSize ) +{ + BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink; + void * pvReturn = NULL; + + vTaskSuspendAll(); + { + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( pxEnd == NULL ) + { + prvHeapInit(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Check the requested block size is not so large that the top bit is + * set. The top bit of the block size member of the BlockLink_t structure + * is used to determine who owns the block - the application or the + * kernel, so it must be free. */ + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + { + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += xHeapStructSize; + + /* Ensure that blocks are always aligned to the required number + * of bytes. */ + if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) + { + /* Byte alignment required. */ + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); + configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size + * was not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 ); + + /* Calculate the sizes of two blocks split from the + * single block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( pxNewBlockLink ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned + * by the application and has no "next" block. */ + pxBlock->xBlockSize |= xBlockAllocatedBit; + pxBlock->pxNextFreeBlock = NULL; + xNumberOfSuccessfulAllocations++; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + } + ( void ) xTaskResumeAll(); + + #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* if ( configUSE_MALLOC_FAILED_HOOK == 1 ) */ + + configASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) portBYTE_ALIGNMENT_MASK ) == 0 ); + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void * pv ) +{ + uint8_t * puc = ( uint8_t * ) pv; + BlockLink_t * pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= xHeapStructSize; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + /* Check the block is actually allocated. */ + configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); + configASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + pxLink->xBlockSize &= ~xBlockAllocatedBit; + + vTaskSuspendAll(); + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + xNumberOfSuccessfulFrees++; + } + ( void ) xTaskResumeAll(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */ +{ + BlockLink_t * pxFirstFreeBlock; + uint8_t * pucAlignedHeap; + size_t uxAddress; + size_t xTotalHeapSize = configTOTAL_HEAP_SIZE; + + /* Ensure the heap starts on a correctly aligned boundary. */ + uxAddress = ( size_t ) ucHeap; + + if( ( uxAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) + { + uxAddress += ( portBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( size_t ) ucHeap; + } + + pucAlignedHeap = ( uint8_t * ) uxAddress; + + /* xStart is used to hold a pointer to the first item in the list of free + * blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + + /* pxEnd is used to mark the end of the list of free blocks and is inserted + * at the end of the heap space. */ + uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); + pxEnd = ( void * ) uxAddress; + pxEnd->xBlockSize = 0; + pxEnd->pxNextFreeBlock = NULL; + + /* To start with there is a single free block that is sized to take up the + * entire heap space, minus the space taken by pxEnd. */ + pxFirstFreeBlock = ( void * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock; + pxFirstFreeBlock->pxNextFreeBlock = pxEnd; + + /* Only one block exists - and it covers the entire usable heap space. */ + xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + + /* Work out the position of the top bit in a size_t variable. */ + xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ); +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ) /* PRIVILEGED_FUNCTION */ +{ + BlockLink_t * pxIterator; + uint8_t * puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void vPortGetHeapStats( HeapStats_t * pxHeapStats ) +{ + BlockLink_t * pxBlock; + size_t xBlocks = 0, xMaxSize = 0, xMinSize = portMAX_DELAY; /* portMAX_DELAY used as a portable way of getting the maximum value. */ + + vTaskSuspendAll(); + { + pxBlock = xStart.pxNextFreeBlock; + + /* pxBlock will be NULL if the heap has not been initialised. The heap + * is initialised automatically when the first allocation is made. */ + if( pxBlock != NULL ) + { + do + { + /* Increment the number of blocks and record the largest block seen + * so far. */ + xBlocks++; + + if( pxBlock->xBlockSize > xMaxSize ) + { + xMaxSize = pxBlock->xBlockSize; + } + + if( pxBlock->xBlockSize < xMinSize ) + { + xMinSize = pxBlock->xBlockSize; + } + + /* Move to the next block in the chain until the last block is + * reached. */ + pxBlock = pxBlock->pxNextFreeBlock; + } while( pxBlock != pxEnd ); + } + } + ( void ) xTaskResumeAll(); + + pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize; + pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize; + pxHeapStats->xNumberOfFreeBlocks = xBlocks; + + taskENTER_CRITICAL(); + { + pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining; + pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations; + pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees; + pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining; + } + taskEXIT_CRITICAL(); +} diff --git a/FreeRTOS/portable/MemMang/heap_5.c b/FreeRTOS/portable/MemMang/heap_5.c new file mode 100644 index 0000000..7d742e1 --- /dev/null +++ b/FreeRTOS/portable/MemMang/heap_5.c @@ -0,0 +1,550 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + * 1 tab == 4 spaces! + */ + +/* + * A sample implementation of pvPortMalloc() that allows the heap to be defined + * across multiple non-contigous blocks and combines (coalescences) adjacent + * memory blocks as they are freed. + * + * See heap_1.c, heap_2.c, heap_3.c and heap_4.c for alternative + * implementations, and the memory management pages of https://www.FreeRTOS.org + * for more information. + * + * Usage notes: + * + * vPortDefineHeapRegions() ***must*** be called before pvPortMalloc(). + * pvPortMalloc() will be called if any task objects (tasks, queues, event + * groups, etc.) are created, therefore vPortDefineHeapRegions() ***must*** be + * called before any other objects are defined. + * + * vPortDefineHeapRegions() takes a single parameter. The parameter is an array + * of HeapRegion_t structures. HeapRegion_t is defined in portable.h as + * + * typedef struct HeapRegion + * { + * uint8_t *pucStartAddress; << Start address of a block of memory that will be part of the heap. + * size_t xSizeInBytes; << Size of the block of memory. + * } HeapRegion_t; + * + * The array is terminated using a NULL zero sized region definition, and the + * memory regions defined in the array ***must*** appear in address order from + * low address to high address. So the following is a valid example of how + * to use the function. + * + * HeapRegion_t xHeapRegions[] = + * { + * { ( uint8_t * ) 0x80000000UL, 0x10000 }, << Defines a block of 0x10000 bytes starting at address 0x80000000 + * { ( uint8_t * ) 0x90000000UL, 0xa0000 }, << Defines a block of 0xa0000 bytes starting at address of 0x90000000 + * { NULL, 0 } << Terminates the array. + * }; + * + * vPortDefineHeapRegions( xHeapRegions ); << Pass the array into vPortDefineHeapRegions(). + * + * Note 0x80000000 is the lower address so appears in the array first. + * + */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) + #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 +#endif + +/* Block sizes must not get too small. */ +#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) + +/* Assumes 8bit bytes! */ +#define heapBITS_PER_BYTE ( ( size_t ) 8 ) + +/* Define the linked list structure. This is used to link free blocks in order + * of their memory address. */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK * pxNextFreeBlock; /*<< The next free block in the list. */ + size_t xBlockSize; /*<< The size of the free block. */ +} BlockLink_t; + +/*-----------------------------------------------------------*/ + +/* + * Inserts a block of memory that is being freed into the correct position in + * the list of free memory blocks. The block being freed will be merged with + * the block in front it and/or the block behind it if the memory blocks are + * adjacent to each other. + */ +static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ); + +/*-----------------------------------------------------------*/ + +/* The size of the structure placed at the beginning of each allocated memory + * block must by correctly byte aligned. */ +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); + +/* Create a couple of list links to mark the start and end of the list. */ +static BlockLink_t xStart, * pxEnd = NULL; + +/* Keeps track of the number of calls to allocate and free memory as well as the + * number of free bytes remaining, but says nothing about fragmentation. */ +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; +static size_t xNumberOfSuccessfulAllocations = 0; +static size_t xNumberOfSuccessfulFrees = 0; + +/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize + * member of an BlockLink_t structure is set then the block belongs to the + * application. When the bit is free the block is still part of the free heap + * space. */ +static size_t xBlockAllocatedBit = 0; + +/*-----------------------------------------------------------*/ + +void * pvPortMalloc( size_t xWantedSize ) +{ + BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink; + void * pvReturn = NULL; + + /* The heap must be initialised before the first call to + * prvPortMalloc(). */ + configASSERT( pxEnd ); + + vTaskSuspendAll(); + { + /* Check the requested block size is not so large that the top bit is + * set. The top bit of the block size member of the BlockLink_t structure + * is used to determine who owns the block - the application or the + * kernel, so it must be free. */ + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + { + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += xHeapStructSize; + + /* Ensure that blocks are always aligned to the required number + * of bytes. */ + if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) + { + /* Byte alignment required. */ + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size + * was not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + + /* Calculate the sizes of two blocks split from the + * single block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned + * by the application and has no "next" block. */ + pxBlock->xBlockSize |= xBlockAllocatedBit; + pxBlock->pxNextFreeBlock = NULL; + xNumberOfSuccessfulAllocations++; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + } + ( void ) xTaskResumeAll(); + + #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* if ( configUSE_MALLOC_FAILED_HOOK == 1 ) */ + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void * pv ) +{ + uint8_t * puc = ( uint8_t * ) pv; + BlockLink_t * pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= xHeapStructSize; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + /* Check the block is actually allocated. */ + configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); + configASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + pxLink->xBlockSize &= ~xBlockAllocatedBit; + + vTaskSuspendAll(); + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + xNumberOfSuccessfulFrees++; + } + ( void ) xTaskResumeAll(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ) +{ + BlockLink_t * pxIterator; + uint8_t * puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) +{ + BlockLink_t * pxFirstFreeBlockInRegion = NULL, * pxPreviousFreeBlock; + size_t xAlignedHeap; + size_t xTotalRegionSize, xTotalHeapSize = 0; + BaseType_t xDefinedRegions = 0; + size_t xAddress; + const HeapRegion_t * pxHeapRegion; + + /* Can only call once! */ + configASSERT( pxEnd == NULL ); + + pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] ); + + while( pxHeapRegion->xSizeInBytes > 0 ) + { + xTotalRegionSize = pxHeapRegion->xSizeInBytes; + + /* Ensure the heap region starts on a correctly aligned boundary. */ + xAddress = ( size_t ) pxHeapRegion->pucStartAddress; + + if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) + { + xAddress += ( portBYTE_ALIGNMENT - 1 ); + xAddress &= ~portBYTE_ALIGNMENT_MASK; + + /* Adjust the size for the bytes lost to alignment. */ + xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress; + } + + xAlignedHeap = xAddress; + + /* Set xStart if it has not already been set. */ + if( xDefinedRegions == 0 ) + { + /* xStart is used to hold a pointer to the first item in the list of + * free blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( BlockLink_t * ) xAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + } + else + { + /* Should only get here if one region has already been added to the + * heap. */ + configASSERT( pxEnd != NULL ); + + /* Check blocks are passed in with increasing start addresses. */ + configASSERT( xAddress > ( size_t ) pxEnd ); + } + + /* Remember the location of the end marker in the previous region, if + * any. */ + pxPreviousFreeBlock = pxEnd; + + /* pxEnd is used to mark the end of the list of free blocks and is + * inserted at the end of the region space. */ + xAddress = xAlignedHeap + xTotalRegionSize; + xAddress -= xHeapStructSize; + xAddress &= ~portBYTE_ALIGNMENT_MASK; + pxEnd = ( BlockLink_t * ) xAddress; + pxEnd->xBlockSize = 0; + pxEnd->pxNextFreeBlock = NULL; + + /* To start with there is a single free block in this region that is + * sized to take up the entire heap region minus the space taken by the + * free block structure. */ + pxFirstFreeBlockInRegion = ( BlockLink_t * ) xAlignedHeap; + pxFirstFreeBlockInRegion->xBlockSize = xAddress - ( size_t ) pxFirstFreeBlockInRegion; + pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd; + + /* If this is not the first region that makes up the entire heap space + * then link the previous region to this region. */ + if( pxPreviousFreeBlock != NULL ) + { + pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion; + } + + xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize; + + /* Move onto the next HeapRegion_t structure. */ + xDefinedRegions++; + pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] ); + } + + xMinimumEverFreeBytesRemaining = xTotalHeapSize; + xFreeBytesRemaining = xTotalHeapSize; + + /* Check something was actually defined before it is accessed. */ + configASSERT( xTotalHeapSize ); + + /* Work out the position of the top bit in a size_t variable. */ + xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ); +} +/*-----------------------------------------------------------*/ + +void vPortGetHeapStats( HeapStats_t * pxHeapStats ) +{ + BlockLink_t * pxBlock; + size_t xBlocks = 0, xMaxSize = 0, xMinSize = portMAX_DELAY; /* portMAX_DELAY used as a portable way of getting the maximum value. */ + + vTaskSuspendAll(); + { + pxBlock = xStart.pxNextFreeBlock; + + /* pxBlock will be NULL if the heap has not been initialised. The heap + * is initialised automatically when the first allocation is made. */ + if( pxBlock != NULL ) + { + do + { + /* Increment the number of blocks and record the largest block seen + * so far. */ + xBlocks++; + + if( pxBlock->xBlockSize > xMaxSize ) + { + xMaxSize = pxBlock->xBlockSize; + } + + /* Heap five will have a zero sized block at the end of each + * each region - the block is only used to link to the next + * heap region so it not a real block. */ + if( pxBlock->xBlockSize != 0 ) + { + if( pxBlock->xBlockSize < xMinSize ) + { + xMinSize = pxBlock->xBlockSize; + } + } + + /* Move to the next block in the chain until the last block is + * reached. */ + pxBlock = pxBlock->pxNextFreeBlock; + } while( pxBlock != pxEnd ); + } + } + ( void ) xTaskResumeAll(); + + pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize; + pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize; + pxHeapStats->xNumberOfFreeBlocks = xBlocks; + + taskENTER_CRITICAL(); + { + pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining; + pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations; + pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees; + pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining; + } + taskEXIT_CRITICAL(); +} diff --git a/FreeRTOS/portable/RVDS/ARM7_LPC21xx/Makefile b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/Makefile new file mode 100644 index 0000000..6f2a134 --- /dev/null +++ b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/Makefile @@ -0,0 +1,52 @@ +################################################################################ +################################################################################ +## +## Makefile -- makefile for v2.3 +## +## Mandatory settings: +## +## o TOPDIR = the toplevel directory (using slashes as path separator) +## o TARGET = the machine qualifier to generate code for +## +################################################################################ +################################################################################ + +TOPDIR = ../../../.. +SUBDIR = FreeRTOS/portable/RVDS/ARM7_LPC21xx + +include $(TOPDIR)/env/make/Makefile.config + +################################################################################ +# project specific settings +################################################################################ + +LIBRARY = libFreeRTOS_portable + +################################################################################ +# source files +################################################################################ + +HEADERS += portmacro.h +SOURCES += portASM.s +SOURCES += port.c + +################################################################################ +# define user targets +################################################################################ + +default: build + +clean: clean-objects clean-library + +build: build-objects build-library + +headers: install-headers + +install: build install-library + +all: clean build install + + +include $(TOPDIR)/env/make/Makefile.rules + + diff --git a/FreeRTOS/portable/RVDS/ARM7_LPC21xx/port.c b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/port.c new file mode 100644 index 0000000..7308997 --- /dev/null +++ b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/port.c @@ -0,0 +1,291 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + * 1 tab == 4 spaces! + */ + + +/* Standard includes. */ +#include + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Constants required to setup the initial task context. */ +#define portINITIAL_SPSR ( ( StackType_t ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */ +#define portTHUMB_MODE_BIT ( ( StackType_t ) 0x20 ) +#define portINSTRUCTION_SIZE ( ( StackType_t ) 4 ) +#define portNO_CRITICAL_SECTION_NESTING ( ( StackType_t ) 0 ) + +/* Constants required to setup the tick ISR. */ +#define portENABLE_TIMER ( ( uint8_t ) 0x01 ) +#define portPRESCALE_VALUE 0x00 +#define portINTERRUPT_ON_MATCH ( ( uint32_t ) 0x01 ) +#define portRESET_COUNT_ON_MATCH ( ( uint32_t ) 0x02 ) + +/* Constants required to setup the VIC for the tick ISR. */ +#define portTIMER_VIC_CHANNEL ( ( uint32_t ) 0x0004 ) +#define portTIMER_VIC_CHANNEL_BIT ( ( uint32_t ) 0x0010 ) +#define portTIMER_VIC_ENABLE ( ( uint32_t ) 0x0020 ) + +/* Constants required to handle interrupts. */ +#define portTIMER_MATCH_ISR_BIT ( ( uint8_t ) 0x01 ) +#define portCLEAR_VIC_INTERRUPT ( ( uint32_t ) 0 ) + +/*-----------------------------------------------------------*/ + +/* The code generated by the Keil compiler does not maintain separate +stack and frame pointers. The portENTER_CRITICAL macro cannot therefore +use the stack as per other ports. Instead a variable is used to keep +track of the critical section nesting. This variable has to be stored +as part of the task context and must be initialised to a non zero value. */ + +#define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 ) +volatile uint32_t ulCriticalNesting = 9999UL; + +/*-----------------------------------------------------------*/ + +/* Setup the timer to generate the tick interrupts. */ +static void prvSetupTimerInterrupt( void ); + +/* + * The scheduler can only be started from ARM mode, so + * vPortStartFirstSTask() is defined in portISR.c. + */ +extern __asm void vPortStartFirstTask( void ); + +/*-----------------------------------------------------------*/ + +/* + * See header file for description. + */ +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) +{ +StackType_t *pxOriginalTOS; + + /* Setup the initial stack of the task. The stack is set exactly as + expected by the portRESTORE_CONTEXT() macro. + + Remember where the top of the (simulated) stack is before we place + anything on it. */ + pxOriginalTOS = pxTopOfStack; + + /* To ensure asserts in tasks.c don't fail, although in this case the assert + is not really required. */ + pxTopOfStack--; + + /* First on the stack is the return address - which in this case is the + start of the task. The offset is added to make the return address appear + as it would within an IRQ ISR. */ + *pxTopOfStack = ( StackType_t ) pxCode + portINSTRUCTION_SIZE; + pxTopOfStack--; + + *pxTopOfStack = ( StackType_t ) 0xaaaaaaaa; /* R14 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxOriginalTOS; /* Stack used when task starts goes in R13. */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909; /* R9 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808; /* R8 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707; /* R7 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606; /* R6 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505; /* R5 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404; /* R4 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + + /* The last thing onto the stack is the status register, which is set for + system mode, with interrupts enabled. */ + *pxTopOfStack = ( StackType_t ) portINITIAL_SPSR; + + if( ( ( uint32_t ) pxCode & 0x01UL ) != 0x00UL ) + { + /* We want the task to start in thumb mode. */ + *pxTopOfStack |= portTHUMB_MODE_BIT; + } + + pxTopOfStack--; + + /* The code generated by the Keil compiler does not maintain separate + stack and frame pointers. The portENTER_CRITICAL macro cannot therefore + use the stack as per other ports. Instead a variable is used to keep + track of the critical section nesting. This variable has to be stored + as part of the task context and is initially set to zero. */ + *pxTopOfStack = portNO_CRITICAL_SECTION_NESTING; + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) +{ + /* Start the timer that generates the tick ISR. */ + prvSetupTimerInterrupt(); + + /* Start the first task. This is done from portISR.c as ARM mode must be + used. */ + vPortStartFirstTask(); + + /* Should not get here! */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* It is unlikely that the ARM port will require this function as there + is nothing to return to. If this is required - stop the tick ISR then + return back to main. */ +} +/*-----------------------------------------------------------*/ + +#if configUSE_PREEMPTION == 0 + + /* + * The cooperative scheduler requires a normal IRQ service routine to + * simply increment the system tick. + */ + void vNonPreemptiveTick( void ) __irq; + void vNonPreemptiveTick( void ) __irq + { + /* Increment the tick count - this may make a delaying task ready + to run - but a context switch is not performed. */ + xTaskIncrementTick(); + + T0IR = portTIMER_MATCH_ISR_BIT; /* Clear the timer event */ + VICVectAddr = portCLEAR_VIC_INTERRUPT; /* Acknowledge the Interrupt */ + } + + #else + + /* + ************************************************************************** + * The preemptive scheduler ISR is written in assembler and can be found + * in the portASM.s file. This will only get used if portUSE_PREEMPTION + * is set to 1 in portmacro.h + ************************************************************************** + */ + + void vPreemptiveTick( void ); + +#endif +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) +{ +uint32_t ulCompareMatch; + + /* A 1ms tick does not require the use of the timer prescale. This is + defaulted to zero but can be used if necessary. */ + T0PR = portPRESCALE_VALUE; + + /* Calculate the match value required for our wanted tick rate. */ + ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ; + + /* Protect against divide by zero. Using an if() statement still results + in a warning - hence the #if. */ + #if portPRESCALE_VALUE != 0 + { + ulCompareMatch /= ( portPRESCALE_VALUE + 1 ); + } + #endif + + T0MR0 = ulCompareMatch; + + /* Generate tick with timer 0 compare match. */ + T0MCR = portRESET_COUNT_ON_MATCH | portINTERRUPT_ON_MATCH; + + /* Setup the VIC for the timer. */ + VICIntSelect &= ~( portTIMER_VIC_CHANNEL_BIT ); + VICIntEnable |= portTIMER_VIC_CHANNEL_BIT; + + /* The ISR installed depends on whether the preemptive or cooperative + scheduler is being used. */ + #if configUSE_PREEMPTION == 1 + { + VICVectAddr0 = ( uint32_t ) vPreemptiveTick; + } + #else + { + VICVectAddr0 = ( uint32_t ) vNonPreemptiveTick; + } + #endif + + VICVectCntl0 = portTIMER_VIC_CHANNEL | portTIMER_VIC_ENABLE; + + /* Start the timer - interrupts are disabled when this function is called + so it is okay to do this here. */ + T0TCR = portENABLE_TIMER; +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) +{ + /* Disable interrupts as per portDISABLE_INTERRUPTS(); */ + __disable_irq(); + + /* Now interrupts are disabled ulCriticalNesting can be accessed + directly. Increment ulCriticalNesting to keep a count of how many times + portENTER_CRITICAL() has been called. */ + ulCriticalNesting++; +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) +{ + if( ulCriticalNesting > portNO_CRITICAL_NESTING ) + { + /* Decrement the nesting count as we are leaving a critical section. */ + ulCriticalNesting--; + + /* If the nesting level has reached zero then interrupts should be + re-enabled. */ + if( ulCriticalNesting == portNO_CRITICAL_NESTING ) + { + /* Enable interrupts as per portEXIT_CRITICAL(). */ + __enable_irq(); + } + } +} +/*-----------------------------------------------------------*/ + + diff --git a/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portASM.s b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portASM.s new file mode 100644 index 0000000..090d705 --- /dev/null +++ b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portASM.s @@ -0,0 +1,124 @@ +;/* +; * FreeRTOS Kernel V10.4.2 +; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * +; * Permission is hereby granted, free of charge, to any person obtaining a copy of +; * this software and associated documentation files (the "Software"), to deal in +; * the Software without restriction, including without limitation the rights to +; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +; * the Software, and to permit persons to whom the Software is furnished to do so, +; * subject to the following conditions: +; * +; * The above copyright notice and this permission notice shall be included in all +; * copies or substantial portions of the Software. +; * +; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +; * +; * https://www.FreeRTOS.org +; * https://github.com/FreeRTOS +; * +; * 1 tab == 4 spaces! +; */ + + INCLUDE portmacro.inc + + IMPORT vTaskSwitchContext + IMPORT xTaskIncrementTick + + EXPORT vPortYieldProcessor + EXPORT vPortStartFirstTask + EXPORT vPreemptiveTick + EXPORT vPortYield + + +VICVECTADDR EQU 0xFFFFF030 +T0IR EQU 0xE0004000 +T0MATCHBIT EQU 0x00000001 + + ARM + AREA PORT_ASM, CODE, READONLY + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Starting the first task is done by just restoring the context +; setup by pxPortInitialiseStack +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +vPortStartFirstTask + + PRESERVE8 + + portRESTORE_CONTEXT + +vPortYield + + PRESERVE8 + + SVC 0 + bx lr + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Interrupt service routine for the SWI interrupt. The vector table is +; configured in the startup.s file. +; +; vPortYieldProcessor() is used to manually force a context switch. The +; SWI interrupt is generated by a call to taskYIELD() or portYIELD(). +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +vPortYieldProcessor + + PRESERVE8 + + ; Within an IRQ ISR the link register has an offset from the true return + ; address, but an SWI ISR does not. Add the offset manually so the same + ; ISR return code can be used in both cases. + ADD LR, LR, #4 + + ; Perform the context switch. + portSAVE_CONTEXT ; Save current task context + LDR R0, =vTaskSwitchContext ; Get the address of the context switch function + MOV LR, PC ; Store the return address + BX R0 ; Call the contedxt switch function + portRESTORE_CONTEXT ; restore the context of the selected task + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Interrupt service routine for preemptive scheduler tick timer +; Only used if portUSE_PREEMPTION is set to 1 in portmacro.h +; +; Uses timer 0 of LPC21XX Family +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +vPreemptiveTick + + PRESERVE8 + + portSAVE_CONTEXT ; Save the context of the current task. + + LDR R0, =xTaskIncrementTick ; Increment the tick count. + MOV LR, PC ; This may make a delayed task ready + BX R0 ; to run. + + CMP R0, #0 + BEQ SkipContextSwitch + LDR R0, =vTaskSwitchContext ; Find the highest priority task that + MOV LR, PC ; is ready to run. + BX R0 +SkipContextSwitch + MOV R0, #T0MATCHBIT ; Clear the timer event + LDR R1, =T0IR + STR R0, [R1] + + LDR R0, =VICVECTADDR ; Acknowledge the interrupt + STR R0,[R0] + + portRESTORE_CONTEXT ; Restore the context of the highest + ; priority task that is ready to run. + END + diff --git a/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.h b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.h new file mode 100644 index 0000000..acd091f --- /dev/null +++ b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.h @@ -0,0 +1,149 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +/*----------------------------------------------------------- + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the + * given hardware and compiler. + * + * These settings should not be altered. + *----------------------------------------------------------- + */ + +/* Type definitions. */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL +#endif +/*-----------------------------------------------------------*/ + +/* Hardware specifics. */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +/*-----------------------------------------------------------*/ + +/* Task utilities. */ + +/*----------------------------------------------------------- + * ISR entry and exit macros. These are only required if a task switch + * is required from an ISR. + *----------------------------------------------------------*/ + +/* If a switch is required then we just need to call */ +/* vTaskSwitchContext() as the context has already been */ +/* saved. */ + +#define portEXIT_SWITCHING_ISR(SwitchRequired) \ +{ \ +extern void vTaskSwitchContext(void); \ + \ + if(SwitchRequired) \ + { \ + vTaskSwitchContext(); \ + } \ +} \ + +extern void vPortYield( void ); +#define portYIELD() vPortYield() + + +/* Critical section management. */ + +/* + ****************************************************************** + * We don't need to worry about whether we're in ARM or + * THUMB mode with the Keil Real View compiler when enabling + * or disabling interrupts as the compiler's intrinsic functions + * take care of that for us. + ******************************************************************* + */ +#define portDISABLE_INTERRUPTS() __disable_irq() +#define portENABLE_INTERRUPTS() __enable_irq() + + +/*----------------------------------------------------------- + * Critical section control + * + * The code generated by the Keil compiler does not maintain separate + * stack and frame pointers. The portENTER_CRITICAL macro cannot therefore + * use the stack as per other ports. Instead a variable is used to keep + * track of the critical section nesting. This necessitates the use of a + * function in place of the macro. + *----------------------------------------------------------*/ + +extern void vPortEnterCritical( void ); +extern void vPortExitCritical( void ); + +#define portENTER_CRITICAL() vPortEnterCritical(); +#define portEXIT_CRITICAL() vPortExitCritical(); +/*-----------------------------------------------------------*/ + +/* Compiler specifics. */ +#define inline +#define register +#define portNOP() __asm{ NOP } +/*-----------------------------------------------------------*/ + +/* Task function macros as described on the FreeRTOS.org WEB site. */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ + +#endif /* PORTMACRO_H */ + diff --git a/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.inc b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.inc new file mode 100644 index 0000000..da6fdf9 --- /dev/null +++ b/FreeRTOS/portable/RVDS/ARM7_LPC21xx/portmacro.inc @@ -0,0 +1,91 @@ +;/* +; * FreeRTOS Kernel V10.4.2 +; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * +; * Permission is hereby granted, free of charge, to any person obtaining a copy of +; * this software and associated documentation files (the "Software"), to deal in +; * the Software without restriction, including without limitation the rights to +; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +; * the Software, and to permit persons to whom the Software is furnished to do so, +; * subject to the following conditions: +; * +; * The above copyright notice and this permission notice shall be included in all +; * copies or substantial portions of the Software. +; * +; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +; * +; * https://www.FreeRTOS.org +; * https://github.com/FreeRTOS +; * +; * 1 tab == 4 spaces! +; */ + + IMPORT ulCriticalNesting ; + IMPORT pxCurrentTCB ; + + + MACRO + portRESTORE_CONTEXT + + + LDR R0, =pxCurrentTCB ; Set the LR to the task stack. The location was... + LDR R0, [R0] ; ... stored in pxCurrentTCB + LDR LR, [R0] + + LDR R0, =ulCriticalNesting ; The critical nesting depth is the first item on... + LDMFD LR!, {R1} ; ...the stack. Load it into the ulCriticalNesting var. + STR R1, [R0] ; + + LDMFD LR!, {R0} ; Get the SPSR from the stack. + MSR SPSR_cxsf, R0 ; + + LDMFD LR, {R0-R14}^ ; Restore all system mode registers for the task. + NOP ; + + LDR LR, [LR, #+60] ; Restore the return address + + ; And return - correcting the offset in the LR to obtain ... + SUBS PC, LR, #4 ; ...the correct address. + + MEND + +; /**********************************************************************/ + + MACRO + portSAVE_CONTEXT + + + STMDB SP!, {R0} ; Store R0 first as we need to use it. + + STMDB SP,{SP}^ ; Set R0 to point to the task stack pointer. + NOP ; + SUB SP, SP, #4 ; + LDMIA SP!,{R0} ; + + STMDB R0!, {LR} ; Push the return address onto the stack. + MOV LR, R0 ; Now we have saved LR we can use it instead of R0. + LDMIA SP!, {R0} ; Pop R0 so we can save it onto the system mode stack. + + STMDB LR,{R0-LR}^ ; Push all the system mode registers onto the task stack. + NOP ; + SUB LR, LR, #60 ; + + MRS R0, SPSR ; Push the SPSR onto the task stack. + STMDB LR!, {R0} ; + + LDR R0, =ulCriticalNesting ; + LDR R0, [R0] ; + STMDB LR!, {R0} ; + + LDR R0, =pxCurrentTCB ; Store the new top of stack for the task. + LDR R1, [R0] ; + STR LR, [R1] ; + + MEND + + END diff --git a/FreeRTOS/portable/RVDS/Makefile b/FreeRTOS/portable/RVDS/Makefile new file mode 100644 index 0000000..b5e051b --- /dev/null +++ b/FreeRTOS/portable/RVDS/Makefile @@ -0,0 +1,88 @@ +################################################################################ +################################################################################ +## +## Makefile -- makefile for FreeRTOS modules. +## +## Mandatory settings: +## +## o TOPDIR = the toplevel directory (using slashes as path separator) +## o TARGET = the machine qualifier to generate code for +## o DIRECTORIES = the list of sub directories to build +## +################################################################################ +################################################################################ + + TOPDIR = ../../.. + SUBDIR = FreeRTOS/portable/RVDS + +include $(TOPDIR)/env/make/Makefile.config + +################################################################################ +# project specific settings +################################################################################ + + DIRECTORIES += ARM7_LPC21xx + +################################################################################ +# define user targets +################################################################################ + +default: all + +clean: $(DIRECTORIES:%=subdir-clean-%) + +build: $(DIRECTORIES:%=subdir-build-%) + +headers: $(DIRECTORIES:%=subdir-headers-%) + +install: $(DIRECTORIES:%=subdir-install-%) + +depend: $(DIRECTORIES:%=subdir-depend-%) + +all: clean build install + +################################################################################ +# include internal definitions and rules +################################################################################ + +include $(TOPDIR)/env/make/Makefile.rules + +################################################################################ +# local directory specific rules +################################################################################ + +subdir-clean-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking clean [$(SUBDIR)/$(@:subdir-clean-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-clean-%=%) clean TARGET=$(TARGET) + +subdir-depend-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking depend [$(SUBDIR)/$(@:subdir-depend-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-depend-%=%) depend TARGET=$(TARGET) + +subdir-headers-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking headers [$(SUBDIR)/$(@:subdir-headers-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-headers-%=%) headers TARGET=$(TARGET) + +subdir-build-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking build [$(SUBDIR)/$(@:subdir-build-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-build-%=%) build TARGET=$(TARGET) + +subdir-install-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking install [$(SUBDIR)/$(@:subdir-install-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-install-%=%) install TARGET=$(TARGET) + +subdir-release-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking release [$(SUBDIR)/$(@:subdir-release-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-release-%=%) release TARGET=$(TARGET) + +subdir-doc-%: + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Submaking doc [$(SUBDIR)/$(@:subdir-doc-%=%)] for target [$(TARGET)] + @$(SUBMAKE) -C $(@:subdir-doc-%=%) doc TARGET=$(TARGET) + diff --git a/FreeRTOS/queue.c b/FreeRTOS/queue.c new file mode 100644 index 0000000..0e58671 --- /dev/null +++ b/FreeRTOS/queue.c @@ -0,0 +1,3013 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#include +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" + +#if ( configUSE_CO_ROUTINES == 1 ) + #include "croutine.h" +#endif + +/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified + * because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined + * for the header files above, but not in this file, in order to generate the + * correct privileged Vs unprivileged linkage and placement. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */ + + +/* Constants used with the cRxLock and cTxLock structure members. */ +#define queueUNLOCKED ( ( int8_t ) -1 ) +#define queueLOCKED_UNMODIFIED ( ( int8_t ) 0 ) +#define queueINT8_MAX ( ( int8_t ) 127 ) + +/* When the Queue_t structure is used to represent a base queue its pcHead and + * pcTail members are used as pointers into the queue storage area. When the + * Queue_t structure is used to represent a mutex pcHead and pcTail pointers are + * not necessary, and the pcHead pointer is set to NULL to indicate that the + * structure instead holds a pointer to the mutex holder (if any). Map alternative + * names to the pcHead and structure member to ensure the readability of the code + * is maintained. The QueuePointers_t and SemaphoreData_t types are used to form + * a union as their usage is mutually exclusive dependent on what the queue is + * being used for. */ +#define uxQueueType pcHead +#define queueQUEUE_IS_MUTEX NULL + +typedef struct QueuePointers +{ + int8_t * pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */ + int8_t * pcReadFrom; /*< Points to the last place that a queued item was read from when the structure is used as a queue. */ +} QueuePointers_t; + +typedef struct SemaphoreData +{ + TaskHandle_t xMutexHolder; /*< The handle of the task that holds the mutex. */ + UBaseType_t uxRecursiveCallCount; /*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */ +} SemaphoreData_t; + +/* Semaphores do not actually store or copy data, so have an item size of + * zero. */ +#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 ) +#define queueMUTEX_GIVE_BLOCK_TIME ( ( TickType_t ) 0U ) + +#if ( configUSE_PREEMPTION == 0 ) + +/* If the cooperative scheduler is being used then a yield should not be + * performed just because a higher priority task has been woken. */ + #define queueYIELD_IF_USING_PREEMPTION() +#else + #define queueYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API() +#endif + +/* + * Definition of the queue used by the scheduler. + * Items are queued by copy, not reference. See the following link for the + * rationale: https://www.FreeRTOS.org/Embedded-RTOS-Queues.html + */ +typedef struct QueueDefinition /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +{ + int8_t * pcHead; /*< Points to the beginning of the queue storage area. */ + int8_t * pcWriteTo; /*< Points to the free next place in the storage area. */ + + union + { + QueuePointers_t xQueue; /*< Data required exclusively when this structure is used as a queue. */ + SemaphoreData_t xSemaphore; /*< Data required exclusively when this structure is used as a semaphore. */ + } u; + + List_t xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */ + List_t xTasksWaitingToReceive; /*< List of tasks that are blocked waiting to read from this queue. Stored in priority order. */ + + volatile UBaseType_t uxMessagesWaiting; /*< The number of items currently in the queue. */ + UBaseType_t uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */ + UBaseType_t uxItemSize; /*< The size of each items that the queue will hold. */ + + volatile int8_t cRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + volatile int8_t cTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the memory used by the queue was statically allocated to ensure no attempt is made to free the memory. */ + #endif + + #if ( configUSE_QUEUE_SETS == 1 ) + struct QueueDefinition * pxQueueSetContainer; + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxQueueNumber; + uint8_t ucQueueType; + #endif +} xQUEUE; + +/* The old xQUEUE name is maintained above then typedefed to the new Queue_t + * name below to enable the use of older kernel aware debuggers. */ +typedef xQUEUE Queue_t; + +/*-----------------------------------------------------------*/ + +/* + * The queue registry is just a means for kernel aware debuggers to locate + * queue structures. It has no other purpose so is an optional component. + */ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + +/* The type stored within the queue registry array. This allows a name + * to be assigned to each queue making kernel aware debugging a little + * more user friendly. */ + typedef struct QUEUE_REGISTRY_ITEM + { + const char * pcQueueName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + QueueHandle_t xHandle; + } xQueueRegistryItem; + +/* The old xQueueRegistryItem name is maintained above then typedefed to the + * new xQueueRegistryItem name below to enable the use of older kernel aware + * debuggers. */ + typedef xQueueRegistryItem QueueRegistryItem_t; + +/* The queue registry is simply an array of QueueRegistryItem_t structures. + * The pcQueueName member of a structure being NULL is indicative of the + * array position being vacant. */ + PRIVILEGED_DATA QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ]; + +#endif /* configQUEUE_REGISTRY_SIZE */ + +/* + * Unlocks a queue locked by a call to prvLockQueue. Locking a queue does not + * prevent an ISR from adding or removing items to the queue, but does prevent + * an ISR from removing tasks from the queue event lists. If an ISR finds a + * queue is locked it will instead increment the appropriate queue lock count + * to indicate that a task may require unblocking. When the queue in unlocked + * these lock counts are inspected, and the appropriate action taken. + */ +static void prvUnlockQueue( Queue_t * const pxQueue ) PRIVILEGED_FUNCTION; + +/* + * Uses a critical section to determine if there is any data in a queue. + * + * @return pdTRUE if the queue contains no items, otherwise pdFALSE. + */ +static BaseType_t prvIsQueueEmpty( const Queue_t * pxQueue ) PRIVILEGED_FUNCTION; + +/* + * Uses a critical section to determine if there is any space in a queue. + * + * @return pdTRUE if there is no space, otherwise pdFALSE; + */ +static BaseType_t prvIsQueueFull( const Queue_t * pxQueue ) PRIVILEGED_FUNCTION; + +/* + * Copies an item into the queue, either at the front of the queue or the + * back of the queue. + */ +static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, + const void * pvItemToQueue, + const BaseType_t xPosition ) PRIVILEGED_FUNCTION; + +/* + * Copies an item out of a queue. + */ +static void prvCopyDataFromQueue( Queue_t * const pxQueue, + void * const pvBuffer ) PRIVILEGED_FUNCTION; + +#if ( configUSE_QUEUE_SETS == 1 ) + +/* + * Checks to see if a queue is a member of a queue set, and if so, notifies + * the queue set that the queue contains data. + */ + static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue ) PRIVILEGED_FUNCTION; +#endif + +/* + * Called after a Queue_t structure has been allocated either statically or + * dynamically to fill in the structure's members. + */ +static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + const uint8_t ucQueueType, + Queue_t * pxNewQueue ) PRIVILEGED_FUNCTION; + +/* + * Mutexes are a special type of queue. When a mutex is created, first the + * queue is created, then prvInitialiseMutex() is called to configure the queue + * as a mutex. + */ +#if ( configUSE_MUTEXES == 1 ) + static void prvInitialiseMutex( Queue_t * pxNewQueue ) PRIVILEGED_FUNCTION; +#endif + +#if ( configUSE_MUTEXES == 1 ) + +/* + * If a task waiting for a mutex causes the mutex holder to inherit a + * priority, but the waiting task times out, then the holder should + * disinherit the priority - but only down to the highest priority of any + * other tasks that are waiting for the same mutex. This function returns + * that priority. + */ + static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue ) PRIVILEGED_FUNCTION; +#endif +/*-----------------------------------------------------------*/ + +/* + * Macro to mark a queue as locked. Locking a queue prevents an ISR from + * accessing the queue event lists. + */ +#define prvLockQueue( pxQueue ) \ + taskENTER_CRITICAL(); \ + { \ + if( ( pxQueue )->cRxLock == queueUNLOCKED ) \ + { \ + ( pxQueue )->cRxLock = queueLOCKED_UNMODIFIED; \ + } \ + if( ( pxQueue )->cTxLock == queueUNLOCKED ) \ + { \ + ( pxQueue )->cTxLock = queueLOCKED_UNMODIFIED; \ + } \ + } \ + taskEXIT_CRITICAL() +/*-----------------------------------------------------------*/ + +BaseType_t xQueueGenericReset( QueueHandle_t xQueue, + BaseType_t xNewQueue ) +{ + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + + taskENTER_CRITICAL(); + { + pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; + pxQueue->pcWriteTo = pxQueue->pcHead; + pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + pxQueue->cRxLock = queueUNLOCKED; + pxQueue->cTxLock = queueUNLOCKED; + + if( xNewQueue == pdFALSE ) + { + /* If there are tasks blocked waiting to read from the queue, then + * the tasks will remain blocked as after this function exits the queue + * will still be empty. If there are tasks blocked waiting to write to + * the queue, then one should be unblocked as after this function exits + * it will be possible to write to it. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* Ensure the event queues start in the correct state. */ + vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); + vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); + } + } + taskEXIT_CRITICAL(); + + /* A value is returned for calling semantic consistency with previous + * versions. */ + return pdPASS; +} +/*-----------------------------------------------------------*/ + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + + QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) + { + Queue_t * pxNewQueue; + + configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); + + /* The StaticQueue_t structure and the queue storage area must be + * supplied. */ + configASSERT( pxStaticQueue != NULL ); + + /* A queue storage area should be provided if the item size is not 0, and + * should not be provided if the item size is 0. */ + configASSERT( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ); + configASSERT( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ); + + #if ( configASSERT_DEFINED == 1 ) + { + /* Sanity check that the size of the structure used to declare a + * variable of type StaticQueue_t or StaticSemaphore_t equals the size of + * the real queue and semaphore structures. */ + volatile size_t xSize = sizeof( StaticQueue_t ); + configASSERT( xSize == sizeof( Queue_t ) ); + ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ + } + #endif /* configASSERT_DEFINED */ + + /* The address of a statically allocated queue was passed in, use it. + * The address of a statically allocated storage area was also passed in + * but is already set. */ + pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ + + if( pxNewQueue != NULL ) + { + #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + { + /* Queues can be allocated wither statically or dynamically, so + * note this queue was allocated statically in case the queue is + * later deleted. */ + pxNewQueue->ucStaticallyAllocated = pdTRUE; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + + prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); + } + else + { + traceQUEUE_CREATE_FAILED( ucQueueType ); + mtCOVERAGE_TEST_MARKER(); + } + + return pxNewQueue; + } + +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + + QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + const uint8_t ucQueueType ) + { + Queue_t * pxNewQueue; + size_t xQueueSizeInBytes; + uint8_t * pucQueueStorage; + + configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); + + /* Allocate enough space to hold the maximum number of items that + * can be in the queue at any time. It is valid for uxItemSize to be + * zero in the case the queue is used as a semaphore. */ + xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + /* Check for multiplication overflow. */ + configASSERT( ( uxItemSize == 0 ) || ( uxQueueLength == ( xQueueSizeInBytes / uxItemSize ) ) ); + + /* Allocate the queue and storage area. Justification for MISRA + * deviation as follows: pvPortMalloc() always ensures returned memory + * blocks are aligned per the requirements of the MCU stack. In this case + * pvPortMalloc() must return a pointer that is guaranteed to meet the + * alignment requirements of the Queue_t structure - which in this case + * is an int8_t *. Therefore, whenever the stack alignment requirements + * are greater than or equal to the pointer to char requirements the cast + * is safe. In other cases alignment requirements are not strict (one or + * two bytes). */ + pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); /*lint !e9087 !e9079 see comment above. */ + + if( pxNewQueue != NULL ) + { + /* Jump past the queue structure to find the location of the queue + * storage area. */ + pucQueueStorage = ( uint8_t * ) pxNewQueue; + pucQueueStorage += sizeof( Queue_t ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + + #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + /* Queues can be created either statically or dynamically, so + * note this task was created dynamically in case it is later + * deleted. */ + pxNewQueue->ucStaticallyAllocated = pdFALSE; + } + #endif /* configSUPPORT_STATIC_ALLOCATION */ + + prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); + } + else + { + traceQUEUE_CREATE_FAILED( ucQueueType ); + mtCOVERAGE_TEST_MARKER(); + } + + return pxNewQueue; + } + +#endif /* configSUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + const uint8_t ucQueueType, + Queue_t * pxNewQueue ) +{ + /* Remove compiler warnings about unused parameters should + * configUSE_TRACE_FACILITY not be set to 1. */ + ( void ) ucQueueType; + + if( uxItemSize == ( UBaseType_t ) 0 ) + { + /* No RAM was allocated for the queue storage area, but PC head cannot + * be set to NULL because NULL is used as a key to say the queue is used as + * a mutex. Therefore just set pcHead to point to the queue as a benign + * value that is known to be within the memory map. */ + pxNewQueue->pcHead = ( int8_t * ) pxNewQueue; + } + else + { + /* Set the head to the start of the queue storage area. */ + pxNewQueue->pcHead = ( int8_t * ) pucQueueStorage; + } + + /* Initialise the queue members as described where the queue type is + * defined. */ + pxNewQueue->uxLength = uxQueueLength; + pxNewQueue->uxItemSize = uxItemSize; + ( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); + + #if ( configUSE_TRACE_FACILITY == 1 ) + { + pxNewQueue->ucQueueType = ucQueueType; + } + #endif /* configUSE_TRACE_FACILITY */ + + #if ( configUSE_QUEUE_SETS == 1 ) + { + pxNewQueue->pxQueueSetContainer = NULL; + } + #endif /* configUSE_QUEUE_SETS */ + + traceQUEUE_CREATE( pxNewQueue ); +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + + static void prvInitialiseMutex( Queue_t * pxNewQueue ) + { + if( pxNewQueue != NULL ) + { + /* The queue create function will set all the queue structure members + * correctly for a generic queue, but this function is creating a + * mutex. Overwrite those members that need to be set differently - + * in particular the information required for priority inheritance. */ + pxNewQueue->u.xSemaphore.xMutexHolder = NULL; + pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX; + + /* In case this is a recursive mutex. */ + pxNewQueue->u.xSemaphore.uxRecursiveCallCount = 0; + + traceCREATE_MUTEX( pxNewQueue ); + + /* Start with the semaphore in the expected state. */ + ( void ) xQueueGenericSend( pxNewQueue, NULL, ( TickType_t ) 0U, queueSEND_TO_BACK ); + } + else + { + traceCREATE_MUTEX_FAILED(); + } + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) + { + QueueHandle_t xNewQueue; + const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0; + + xNewQueue = xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType ); + prvInitialiseMutex( ( Queue_t * ) xNewQueue ); + + return xNewQueue; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + + QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) + { + QueueHandle_t xNewQueue; + const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0; + + /* Prevent compiler warnings about unused parameters if + * configUSE_TRACE_FACILITY does not equal 1. */ + ( void ) ucQueueType; + + xNewQueue = xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType ); + prvInitialiseMutex( ( Queue_t * ) xNewQueue ); + + return xNewQueue; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) + + TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) + { + TaskHandle_t pxReturn; + Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore; + + /* This function is called by xSemaphoreGetMutexHolder(), and should not + * be called directly. Note: This is a good way of determining if the + * calling task is the mutex holder, but not a good way of determining the + * identity of the mutex holder, as the holder may change between the + * following critical section exiting and the function returning. */ + taskENTER_CRITICAL(); + { + if( pxSemaphore->uxQueueType == queueQUEUE_IS_MUTEX ) + { + pxReturn = pxSemaphore->u.xSemaphore.xMutexHolder; + } + else + { + pxReturn = NULL; + } + } + taskEXIT_CRITICAL(); + + return pxReturn; + } /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */ + +#endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) + + TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) + { + TaskHandle_t pxReturn; + + configASSERT( xSemaphore ); + + /* Mutexes cannot be used in interrupt service routines, so the mutex + * holder should not change in an ISR, and therefore a critical section is + * not required here. */ + if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX ) + { + pxReturn = ( ( Queue_t * ) xSemaphore )->u.xSemaphore.xMutexHolder; + } + else + { + pxReturn = NULL; + } + + return pxReturn; + } /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */ + +#endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_RECURSIVE_MUTEXES == 1 ) + + BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) + { + BaseType_t xReturn; + Queue_t * const pxMutex = ( Queue_t * ) xMutex; + + configASSERT( pxMutex ); + + /* If this is the task that holds the mutex then xMutexHolder will not + * change outside of this task. If this task does not hold the mutex then + * pxMutexHolder can never coincidentally equal the tasks handle, and as + * this is the only condition we are interested in it does not matter if + * pxMutexHolder is accessed simultaneously by another task. Therefore no + * mutual exclusion is required to test the pxMutexHolder variable. */ + if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() ) + { + traceGIVE_MUTEX_RECURSIVE( pxMutex ); + + /* uxRecursiveCallCount cannot be zero if xMutexHolder is equal to + * the task handle, therefore no underflow check is required. Also, + * uxRecursiveCallCount is only modified by the mutex holder, and as + * there can only be one, no mutual exclusion is required to modify the + * uxRecursiveCallCount member. */ + ( pxMutex->u.xSemaphore.uxRecursiveCallCount )--; + + /* Has the recursive call count unwound to 0? */ + if( pxMutex->u.xSemaphore.uxRecursiveCallCount == ( UBaseType_t ) 0 ) + { + /* Return the mutex. This will automatically unblock any other + * task that might be waiting to access the mutex. */ + ( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xReturn = pdPASS; + } + else + { + /* The mutex cannot be given because the calling task is not the + * holder. */ + xReturn = pdFAIL; + + traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ); + } + + return xReturn; + } + +#endif /* configUSE_RECURSIVE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_RECURSIVE_MUTEXES == 1 ) + + BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) + { + BaseType_t xReturn; + Queue_t * const pxMutex = ( Queue_t * ) xMutex; + + configASSERT( pxMutex ); + + /* Comments regarding mutual exclusion as per those within + * xQueueGiveMutexRecursive(). */ + + traceTAKE_MUTEX_RECURSIVE( pxMutex ); + + if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() ) + { + ( pxMutex->u.xSemaphore.uxRecursiveCallCount )++; + xReturn = pdPASS; + } + else + { + xReturn = xQueueSemaphoreTake( pxMutex, xTicksToWait ); + + /* pdPASS will only be returned if the mutex was successfully + * obtained. The calling task may have entered the Blocked state + * before reaching here. */ + if( xReturn != pdFAIL ) + { + ( pxMutex->u.xSemaphore.uxRecursiveCallCount )++; + } + else + { + traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ); + } + } + + return xReturn; + } + +#endif /* configUSE_RECURSIVE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + + QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) + { + QueueHandle_t xHandle; + + configASSERT( uxMaxCount != 0 ); + configASSERT( uxInitialCount <= uxMaxCount ); + + xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); + + if( xHandle != NULL ) + { + ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; + + traceCREATE_COUNTING_SEMAPHORE(); + } + else + { + traceCREATE_COUNTING_SEMAPHORE_FAILED(); + } + + return xHandle; + } + +#endif /* ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) + { + QueueHandle_t xHandle; + + configASSERT( uxMaxCount != 0 ); + configASSERT( uxInitialCount <= uxMaxCount ); + + xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); + + if( xHandle != NULL ) + { + ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; + + traceCREATE_COUNTING_SEMAPHORE(); + } + else + { + traceCREATE_COUNTING_SEMAPHORE_FAILED(); + } + + return xHandle; + } + +#endif /* ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ +/*-----------------------------------------------------------*/ + +BaseType_t xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) +{ + BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired; + TimeOut_t xTimeOut; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); + configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) ); + #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) + { + configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); + } + #endif + + /*lint -save -e904 This function relaxes the coding standard somewhat to + * allow return statements within the function itself. This is done in the + * interest of execution time efficiency. */ + for( ; ; ) + { + taskENTER_CRITICAL(); + { + /* Is there room on the queue now? The running task must be the + * highest priority task wanting to access the queue. If the head item + * in the queue is to be overwritten then it does not matter if the + * queue is full. */ + if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) + { + traceQUEUE_SEND( pxQueue ); + + #if ( configUSE_QUEUE_SETS == 1 ) + { + const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting; + + xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); + + if( pxQueue->pxQueueSetContainer != NULL ) + { + if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) ) + { + /* Do not notify the queue set as an existing item + * was overwritten in the queue so the number of items + * in the queue has not changed. */ + mtCOVERAGE_TEST_MARKER(); + } + else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE ) + { + /* The queue is a member of a queue set, and posting + * to the queue set caused a higher priority task to + * unblock. A context switch is required. */ + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* If there was a task waiting for data to arrive on the + * queue then unblock it now. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The unblocked task has a priority higher than + * our own so yield immediately. Yes it is ok to + * do this from within the critical section - the + * kernel takes care of that. */ + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else if( xYieldRequired != pdFALSE ) + { + /* This path is a special case that will only get + * executed if the task was holding multiple mutexes + * and the mutexes were given back in an order that is + * different to that in which they were taken. */ + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + #else /* configUSE_QUEUE_SETS */ + { + xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); + + /* If there was a task waiting for data to arrive on the + * queue then unblock it now. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The unblocked task has a priority higher than + * our own so yield immediately. Yes it is ok to do + * this from within the critical section - the kernel + * takes care of that. */ + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else if( xYieldRequired != pdFALSE ) + { + /* This path is a special case that will only get + * executed if the task was holding multiple mutexes and + * the mutexes were given back in an order that is + * different to that in which they were taken. */ + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_QUEUE_SETS */ + + taskEXIT_CRITICAL(); + return pdPASS; + } + else + { + if( xTicksToWait == ( TickType_t ) 0 ) + { + /* The queue was full and no block time is specified (or + * the block time has expired) so leave now. */ + taskEXIT_CRITICAL(); + + /* Return to the original privilege level before exiting + * the function. */ + traceQUEUE_SEND_FAILED( pxQueue ); + return errQUEUE_FULL; + } + else if( xEntryTimeSet == pdFALSE ) + { + /* The queue was full and a block time was specified so + * configure the timeout structure. */ + vTaskInternalSetTimeOutState( &xTimeOut ); + xEntryTimeSet = pdTRUE; + } + else + { + /* Entry time was already set. */ + mtCOVERAGE_TEST_MARKER(); + } + } + } + taskEXIT_CRITICAL(); + + /* Interrupts and other tasks can send to and receive from the queue + * now the critical section has been exited. */ + + vTaskSuspendAll(); + prvLockQueue( pxQueue ); + + /* Update the timeout state to see if it has expired yet. */ + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + if( prvIsQueueFull( pxQueue ) != pdFALSE ) + { + traceBLOCKING_ON_QUEUE_SEND( pxQueue ); + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); + + /* Unlocking the queue means queue events can effect the + * event list. It is possible that interrupts occurring now + * remove this task from the event list again - but as the + * scheduler is suspended the task will go onto the pending + * ready last instead of the actual ready list. */ + prvUnlockQueue( pxQueue ); + + /* Resuming the scheduler will move tasks from the pending + * ready list into the ready list - so it is feasible that this + * task is already in a ready list before it yields - in which + * case the yield will not cause a context switch unless there + * is also a higher priority task in the pending ready list. */ + if( xTaskResumeAll() == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + } + else + { + /* Try again. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + } + } + else + { + /* The timeout has expired. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + + traceQUEUE_SEND_FAILED( pxQueue ); + return errQUEUE_FULL; + } + } /*lint -restore */ +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, + const void * const pvItemToQueue, + BaseType_t * const pxHigherPriorityTaskWoken, + const BaseType_t xCopyPosition ) +{ + BaseType_t xReturn; + UBaseType_t uxSavedInterruptStatus; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); + configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) ); + + /* RTOS ports that support interrupt nesting have the concept of a maximum + * system call (or maximum API call) interrupt priority. Interrupts that are + * above the maximum system call priority are kept permanently enabled, even + * when the RTOS kernel is in a critical section, but cannot make any calls to + * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h + * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has been + * assigned a priority above the configured maximum system call priority. + * Only FreeRTOS functions that end in FromISR can be called from interrupts + * that have been assigned a priority at or (logically) below the maximum + * system call interrupt priority. FreeRTOS maintains a separate interrupt + * safe API to ensure interrupt entry is as fast and as simple as possible. + * More information (albeit Cortex-M specific) is provided on the following + * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + /* Similar to xQueueGenericSend, except without blocking if there is no room + * in the queue. Also don't directly wake a task that was blocked on a queue + * read, instead return a flag to say whether a context switch is required or + * not (i.e. has a task with a higher priority than us been woken by this + * post). */ + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) + { + const int8_t cTxLock = pxQueue->cTxLock; + const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting; + + traceQUEUE_SEND_FROM_ISR( pxQueue ); + + /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a + * semaphore or mutex. That means prvCopyDataToQueue() cannot result + * in a task disinheriting a priority and prvCopyDataToQueue() can be + * called here even though the disinherit function does not check if + * the scheduler is suspended before accessing the ready lists. */ + ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); + + /* The event list is not altered if the queue is locked. This will + * be done when the queue is unlocked later. */ + if( cTxLock == queueUNLOCKED ) + { + #if ( configUSE_QUEUE_SETS == 1 ) + { + if( pxQueue->pxQueueSetContainer != NULL ) + { + if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) ) + { + /* Do not notify the queue set as an existing item + * was overwritten in the queue so the number of items + * in the queue has not changed. */ + mtCOVERAGE_TEST_MARKER(); + } + else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE ) + { + /* The queue is a member of a queue set, and posting + * to the queue set caused a higher priority task to + * unblock. A context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so + * record that a context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + #else /* configUSE_QUEUE_SETS */ + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so record that a + * context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Not used in this path. */ + ( void ) uxPreviousMessagesWaiting; + } + #endif /* configUSE_QUEUE_SETS */ + } + else + { + /* Increment the lock count so the task that unlocks the queue + * knows that data was posted while it was locked. */ + configASSERT( cTxLock != queueINT8_MAX ); + + pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 ); + } + + xReturn = pdPASS; + } + else + { + traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); + xReturn = errQUEUE_FULL; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, + BaseType_t * const pxHigherPriorityTaskWoken ) +{ + BaseType_t xReturn; + UBaseType_t uxSavedInterruptStatus; + Queue_t * const pxQueue = xQueue; + + /* Similar to xQueueGenericSendFromISR() but used with semaphores where the + * item size is 0. Don't directly wake a task that was blocked on a queue + * read, instead return a flag to say whether a context switch is required or + * not (i.e. has a task with a higher priority than us been woken by this + * post). */ + + configASSERT( pxQueue ); + + /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR() + * if the item size is not 0. */ + configASSERT( pxQueue->uxItemSize == 0 ); + + /* Normally a mutex would not be given from an interrupt, especially if + * there is a mutex holder, as priority inheritance makes no sense for an + * interrupts, only tasks. */ + configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->u.xSemaphore.xMutexHolder != NULL ) ) ); + + /* RTOS ports that support interrupt nesting have the concept of a maximum + * system call (or maximum API call) interrupt priority. Interrupts that are + * above the maximum system call priority are kept permanently enabled, even + * when the RTOS kernel is in a critical section, but cannot make any calls to + * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h + * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has been + * assigned a priority above the configured maximum system call priority. + * Only FreeRTOS functions that end in FromISR can be called from interrupts + * that have been assigned a priority at or (logically) below the maximum + * system call interrupt priority. FreeRTOS maintains a separate interrupt + * safe API to ensure interrupt entry is as fast and as simple as possible. + * More information (albeit Cortex-M specific) is provided on the following + * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + /* When the queue is used to implement a semaphore no data is ever + * moved through the queue but it is still valid to see if the queue 'has + * space'. */ + if( uxMessagesWaiting < pxQueue->uxLength ) + { + const int8_t cTxLock = pxQueue->cTxLock; + + traceQUEUE_SEND_FROM_ISR( pxQueue ); + + /* A task can only have an inherited priority if it is a mutex + * holder - and if there is a mutex holder then the mutex cannot be + * given from an ISR. As this is the ISR version of the function it + * can be assumed there is no mutex holder and no need to determine if + * priority disinheritance is needed. Simply increase the count of + * messages (semaphores) available. */ + pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1; + + /* The event list is not altered if the queue is locked. This will + * be done when the queue is unlocked later. */ + if( cTxLock == queueUNLOCKED ) + { + #if ( configUSE_QUEUE_SETS == 1 ) + { + if( pxQueue->pxQueueSetContainer != NULL ) + { + if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE ) + { + /* The semaphore is a member of a queue set, and + * posting to the queue set caused a higher priority + * task to unblock. A context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so + * record that a context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + #else /* configUSE_QUEUE_SETS */ + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so record that a + * context switch is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_QUEUE_SETS */ + } + else + { + /* Increment the lock count so the task that unlocks the queue + * knows that data was posted while it was locked. */ + configASSERT( cTxLock != queueINT8_MAX ); + + pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 ); + } + + xReturn = pdPASS; + } + else + { + traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); + xReturn = errQUEUE_FULL; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) +{ + BaseType_t xEntryTimeSet = pdFALSE; + TimeOut_t xTimeOut; + Queue_t * const pxQueue = xQueue; + + /* Check the pointer is not NULL. */ + configASSERT( ( pxQueue ) ); + + /* The buffer into which data is received can only be NULL if the data size + * is zero (so no data is copied into the buffer). */ + configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) ); + + /* Cannot block if the scheduler is suspended. */ + #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) + { + configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); + } + #endif + + /*lint -save -e904 This function relaxes the coding standard somewhat to + * allow return statements within the function itself. This is done in the + * interest of execution time efficiency. */ + for( ; ; ) + { + taskENTER_CRITICAL(); + { + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + /* Is there data in the queue now? To be running the calling task + * must be the highest priority task wanting to access the queue. */ + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + /* Data available, remove one item. */ + prvCopyDataFromQueue( pxQueue, pvBuffer ); + traceQUEUE_RECEIVE( pxQueue ); + pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1; + + /* There is now space in the queue, were any tasks waiting to + * post to the queue? If so, unblock the highest priority waiting + * task. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + taskEXIT_CRITICAL(); + return pdPASS; + } + else + { + if( xTicksToWait == ( TickType_t ) 0 ) + { + /* The queue was empty and no block time is specified (or + * the block time has expired) so leave now. */ + taskEXIT_CRITICAL(); + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else if( xEntryTimeSet == pdFALSE ) + { + /* The queue was empty and a block time was specified so + * configure the timeout structure. */ + vTaskInternalSetTimeOutState( &xTimeOut ); + xEntryTimeSet = pdTRUE; + } + else + { + /* Entry time was already set. */ + mtCOVERAGE_TEST_MARKER(); + } + } + } + taskEXIT_CRITICAL(); + + /* Interrupts and other tasks can send to and receive from the queue + * now the critical section has been exited. */ + + vTaskSuspendAll(); + prvLockQueue( pxQueue ); + + /* Update the timeout state to see if it has expired yet. */ + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + /* The timeout has not expired. If the queue is still empty place + * the task on the list of tasks waiting to receive from the queue. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + prvUnlockQueue( pxQueue ); + + if( xTaskResumeAll() == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* The queue contains data again. Loop back to try and read the + * data. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + } + } + else + { + /* Timed out. If there is no data in the queue exit, otherwise loop + * back and attempt to read the data. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } /*lint -restore */ +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) +{ + BaseType_t xEntryTimeSet = pdFALSE; + TimeOut_t xTimeOut; + Queue_t * const pxQueue = xQueue; + + #if ( configUSE_MUTEXES == 1 ) + BaseType_t xInheritanceOccurred = pdFALSE; + #endif + + /* Check the queue pointer is not NULL. */ + configASSERT( ( pxQueue ) ); + + /* Check this really is a semaphore, in which case the item size will be + * 0. */ + configASSERT( pxQueue->uxItemSize == 0 ); + + /* Cannot block if the scheduler is suspended. */ + #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) + { + configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); + } + #endif + + /*lint -save -e904 This function relaxes the coding standard somewhat to allow return + * statements within the function itself. This is done in the interest + * of execution time efficiency. */ + for( ; ; ) + { + taskENTER_CRITICAL(); + { + /* Semaphores are queues with an item size of 0, and where the + * number of messages in the queue is the semaphore's count value. */ + const UBaseType_t uxSemaphoreCount = pxQueue->uxMessagesWaiting; + + /* Is there data in the queue now? To be running the calling task + * must be the highest priority task wanting to access the queue. */ + if( uxSemaphoreCount > ( UBaseType_t ) 0 ) + { + traceQUEUE_RECEIVE( pxQueue ); + + /* Semaphores are queues with a data size of zero and where the + * messages waiting is the semaphore's count. Reduce the count. */ + pxQueue->uxMessagesWaiting = uxSemaphoreCount - ( UBaseType_t ) 1; + + #if ( configUSE_MUTEXES == 1 ) + { + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + { + /* Record the information required to implement + * priority inheritance should it become necessary. */ + pxQueue->u.xSemaphore.xMutexHolder = pvTaskIncrementMutexHeldCount(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_MUTEXES */ + + /* Check to see if other tasks are blocked waiting to give the + * semaphore, and if so, unblock the highest priority such task. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + taskEXIT_CRITICAL(); + return pdPASS; + } + else + { + if( xTicksToWait == ( TickType_t ) 0 ) + { + /* For inheritance to have occurred there must have been an + * initial timeout, and an adjusted timeout cannot become 0, as + * if it were 0 the function would have exited. */ + #if ( configUSE_MUTEXES == 1 ) + { + configASSERT( xInheritanceOccurred == pdFALSE ); + } + #endif /* configUSE_MUTEXES */ + + /* The semaphore count was 0 and no block time is specified + * (or the block time has expired) so exit now. */ + taskEXIT_CRITICAL(); + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else if( xEntryTimeSet == pdFALSE ) + { + /* The semaphore count was 0 and a block time was specified + * so configure the timeout structure ready to block. */ + vTaskInternalSetTimeOutState( &xTimeOut ); + xEntryTimeSet = pdTRUE; + } + else + { + /* Entry time was already set. */ + mtCOVERAGE_TEST_MARKER(); + } + } + } + taskEXIT_CRITICAL(); + + /* Interrupts and other tasks can give to and take from the semaphore + * now the critical section has been exited. */ + + vTaskSuspendAll(); + prvLockQueue( pxQueue ); + + /* Update the timeout state to see if it has expired yet. */ + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + /* A block time is specified and not expired. If the semaphore + * count is 0 then enter the Blocked state to wait for a semaphore to + * become available. As semaphores are implemented with queues the + * queue being empty is equivalent to the semaphore count being 0. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); + + #if ( configUSE_MUTEXES == 1 ) + { + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + { + taskENTER_CRITICAL(); + { + xInheritanceOccurred = xTaskPriorityInherit( pxQueue->u.xSemaphore.xMutexHolder ); + } + taskEXIT_CRITICAL(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* if ( configUSE_MUTEXES == 1 ) */ + + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + prvUnlockQueue( pxQueue ); + + if( xTaskResumeAll() == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* There was no timeout and the semaphore count was not 0, so + * attempt to take the semaphore again. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + } + } + else + { + /* Timed out. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + + /* If the semaphore count is 0 exit now as the timeout has + * expired. Otherwise return to attempt to take the semaphore that is + * known to be available. As semaphores are implemented by queues the + * queue being empty is equivalent to the semaphore count being 0. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + #if ( configUSE_MUTEXES == 1 ) + { + /* xInheritanceOccurred could only have be set if + * pxQueue->uxQueueType == queueQUEUE_IS_MUTEX so no need to + * test the mutex type again to check it is actually a mutex. */ + if( xInheritanceOccurred != pdFALSE ) + { + taskENTER_CRITICAL(); + { + UBaseType_t uxHighestWaitingPriority; + + /* This task blocking on the mutex caused another + * task to inherit this task's priority. Now this task + * has timed out the priority should be disinherited + * again, but only as low as the next highest priority + * task that is waiting for the same mutex. */ + uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue ); + vTaskPriorityDisinheritAfterTimeout( pxQueue->u.xSemaphore.xMutexHolder, uxHighestWaitingPriority ); + } + taskEXIT_CRITICAL(); + } + } + #endif /* configUSE_MUTEXES */ + + traceQUEUE_RECEIVE_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } /*lint -restore */ +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) +{ + BaseType_t xEntryTimeSet = pdFALSE; + TimeOut_t xTimeOut; + int8_t * pcOriginalReadPosition; + Queue_t * const pxQueue = xQueue; + + /* Check the pointer is not NULL. */ + configASSERT( ( pxQueue ) ); + + /* The buffer into which data is received can only be NULL if the data size + * is zero (so no data is copied into the buffer. */ + configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) ); + + /* Cannot block if the scheduler is suspended. */ + #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) + { + configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); + } + #endif + + /*lint -save -e904 This function relaxes the coding standard somewhat to + * allow return statements within the function itself. This is done in the + * interest of execution time efficiency. */ + for( ; ; ) + { + taskENTER_CRITICAL(); + { + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + /* Is there data in the queue now? To be running the calling task + * must be the highest priority task wanting to access the queue. */ + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + /* Remember the read position so it can be reset after the data + * is read from the queue as this function is only peeking the + * data, not removing it. */ + pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom; + + prvCopyDataFromQueue( pxQueue, pvBuffer ); + traceQUEUE_PEEK( pxQueue ); + + /* The data is not being removed, so reset the read pointer. */ + pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition; + + /* The data is being left in the queue, so see if there are + * any other tasks waiting for the data. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority than this task. */ + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + taskEXIT_CRITICAL(); + return pdPASS; + } + else + { + if( xTicksToWait == ( TickType_t ) 0 ) + { + /* The queue was empty and no block time is specified (or + * the block time has expired) so leave now. */ + taskEXIT_CRITICAL(); + traceQUEUE_PEEK_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else if( xEntryTimeSet == pdFALSE ) + { + /* The queue was empty and a block time was specified so + * configure the timeout structure ready to enter the blocked + * state. */ + vTaskInternalSetTimeOutState( &xTimeOut ); + xEntryTimeSet = pdTRUE; + } + else + { + /* Entry time was already set. */ + mtCOVERAGE_TEST_MARKER(); + } + } + } + taskEXIT_CRITICAL(); + + /* Interrupts and other tasks can send to and receive from the queue + * now the critical section has been exited. */ + + vTaskSuspendAll(); + prvLockQueue( pxQueue ); + + /* Update the timeout state to see if it has expired yet. */ + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + /* Timeout has not expired yet, check to see if there is data in the + * queue now, and if not enter the Blocked state to wait for data. */ + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceBLOCKING_ON_QUEUE_PEEK( pxQueue ); + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + prvUnlockQueue( pxQueue ); + + if( xTaskResumeAll() == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* There is data in the queue now, so don't enter the blocked + * state, instead return to try and obtain the data. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + } + } + else + { + /* The timeout has expired. If there is still no data in the queue + * exit, otherwise go back and try to read the data again. */ + prvUnlockQueue( pxQueue ); + ( void ) xTaskResumeAll(); + + if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) + { + traceQUEUE_PEEK_FAILED( pxQueue ); + return errQUEUE_EMPTY; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } /*lint -restore */ +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, + void * const pvBuffer, + BaseType_t * const pxHigherPriorityTaskWoken ) +{ + BaseType_t xReturn; + UBaseType_t uxSavedInterruptStatus; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); + + /* RTOS ports that support interrupt nesting have the concept of a maximum + * system call (or maximum API call) interrupt priority. Interrupts that are + * above the maximum system call priority are kept permanently enabled, even + * when the RTOS kernel is in a critical section, but cannot make any calls to + * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h + * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has been + * assigned a priority above the configured maximum system call priority. + * Only FreeRTOS functions that end in FromISR can be called from interrupts + * that have been assigned a priority at or (logically) below the maximum + * system call interrupt priority. FreeRTOS maintains a separate interrupt + * safe API to ensure interrupt entry is as fast and as simple as possible. + * More information (albeit Cortex-M specific) is provided on the following + * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + /* Cannot block in an ISR, so check there is data available. */ + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + const int8_t cRxLock = pxQueue->cRxLock; + + traceQUEUE_RECEIVE_FROM_ISR( pxQueue ); + + prvCopyDataFromQueue( pxQueue, pvBuffer ); + pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1; + + /* If the queue is locked the event list will not be modified. + * Instead update the lock count so the task that unlocks the queue + * will know that an ISR has removed data while the queue was + * locked. */ + if( cRxLock == queueUNLOCKED ) + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + /* The task waiting has a higher priority than us so + * force a context switch. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* Increment the lock count so the task that unlocks the queue + * knows that data was removed while it was locked. */ + configASSERT( cRxLock != queueINT8_MAX ); + + pxQueue->cRxLock = ( int8_t ) ( cRxLock + 1 ); + } + + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ); + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, + void * const pvBuffer ) +{ + BaseType_t xReturn; + UBaseType_t uxSavedInterruptStatus; + int8_t * pcOriginalReadPosition; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); + configASSERT( pxQueue->uxItemSize != 0 ); /* Can't peek a semaphore. */ + + /* RTOS ports that support interrupt nesting have the concept of a maximum + * system call (or maximum API call) interrupt priority. Interrupts that are + * above the maximum system call priority are kept permanently enabled, even + * when the RTOS kernel is in a critical section, but cannot make any calls to + * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h + * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has been + * assigned a priority above the configured maximum system call priority. + * Only FreeRTOS functions that end in FromISR can be called from interrupts + * that have been assigned a priority at or (logically) below the maximum + * system call interrupt priority. FreeRTOS maintains a separate interrupt + * safe API to ensure interrupt entry is as fast and as simple as possible. + * More information (albeit Cortex-M specific) is provided on the following + * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Cannot block in an ISR, so check there is data available. */ + if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + traceQUEUE_PEEK_FROM_ISR( pxQueue ); + + /* Remember the read position so it can be reset as nothing is + * actually being removed from the queue. */ + pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom; + prvCopyDataFromQueue( pxQueue, pvBuffer ); + pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition; + + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ); + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) +{ + UBaseType_t uxReturn; + + configASSERT( xQueue ); + + taskENTER_CRITICAL(); + { + uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting; + } + taskEXIT_CRITICAL(); + + return uxReturn; +} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */ +/*-----------------------------------------------------------*/ + +UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) +{ + UBaseType_t uxReturn; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + + taskENTER_CRITICAL(); + { + uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting; + } + taskEXIT_CRITICAL(); + + return uxReturn; +} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */ +/*-----------------------------------------------------------*/ + +UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) +{ + UBaseType_t uxReturn; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + uxReturn = pxQueue->uxMessagesWaiting; + + return uxReturn; +} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */ +/*-----------------------------------------------------------*/ + +void vQueueDelete( QueueHandle_t xQueue ) +{ + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + traceQUEUE_DELETE( pxQueue ); + + #if ( configQUEUE_REGISTRY_SIZE > 0 ) + { + vQueueUnregisterQueue( pxQueue ); + } + #endif + + #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) + { + /* The queue can only have been allocated dynamically - free it + * again. */ + vPortFree( pxQueue ); + } + #elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + { + /* The queue could have been allocated statically or dynamically, so + * check before attempting to free the memory. */ + if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdFALSE ) + { + vPortFree( pxQueue ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #else /* if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) */ + { + /* The queue must have been statically allocated, so is not going to be + * deleted. Avoid compiler warnings about the unused parameter. */ + ( void ) pxQueue; + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) + { + return ( ( Queue_t * ) xQueue )->uxQueueNumber; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + void vQueueSetQueueNumber( QueueHandle_t xQueue, + UBaseType_t uxQueueNumber ) + { + ( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) + { + return ( ( Queue_t * ) xQueue )->ucQueueType; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + + static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue ) + { + UBaseType_t uxHighestPriorityOfWaitingTasks; + + /* If a task waiting for a mutex causes the mutex holder to inherit a + * priority, but the waiting task times out, then the holder should + * disinherit the priority - but only down to the highest priority of any + * other tasks that are waiting for the same mutex. For this purpose, + * return the priority of the highest priority task that is waiting for the + * mutex. */ + if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U ) + { + uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) ); + } + else + { + uxHighestPriorityOfWaitingTasks = tskIDLE_PRIORITY; + } + + return uxHighestPriorityOfWaitingTasks; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, + const void * pvItemToQueue, + const BaseType_t xPosition ) +{ + BaseType_t xReturn = pdFALSE; + UBaseType_t uxMessagesWaiting; + + /* This function is called from a critical section. */ + + uxMessagesWaiting = pxQueue->uxMessagesWaiting; + + if( pxQueue->uxItemSize == ( UBaseType_t ) 0 ) + { + #if ( configUSE_MUTEXES == 1 ) + { + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + { + /* The mutex is no longer being held. */ + xReturn = xTaskPriorityDisinherit( pxQueue->u.xSemaphore.xMutexHolder ); + pxQueue->u.xSemaphore.xMutexHolder = NULL; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_MUTEXES */ + } + else if( xPosition == queueSEND_TO_BACK ) + { + ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */ + pxQueue->pcWriteTo += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */ + + if( pxQueue->pcWriteTo >= pxQueue->u.xQueue.pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ + { + pxQueue->pcWriteTo = pxQueue->pcHead; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + ( void ) memcpy( ( void * ) pxQueue->u.xQueue.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e9087 !e418 MISRA exception as the casts are only redundant for some ports. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. Assert checks null pointer only used when length is 0. */ + pxQueue->u.xQueue.pcReadFrom -= pxQueue->uxItemSize; + + if( pxQueue->u.xQueue.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ + { + pxQueue->u.xQueue.pcReadFrom = ( pxQueue->u.xQueue.pcTail - pxQueue->uxItemSize ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( xPosition == queueOVERWRITE ) + { + if( uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + /* An item is not being added but overwritten, so subtract + * one from the recorded number of items in the queue so when + * one is added again below the number of recorded items remains + * correct. */ + --uxMessagesWaiting; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1; + + return xReturn; +} +/*-----------------------------------------------------------*/ + +static void prvCopyDataFromQueue( Queue_t * const pxQueue, + void * const pvBuffer ) +{ + if( pxQueue->uxItemSize != ( UBaseType_t ) 0 ) + { + pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */ + + if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */ + { + pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 MISRA exception as the casts are only redundant for some ports. Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */ + } +} +/*-----------------------------------------------------------*/ + +static void prvUnlockQueue( Queue_t * const pxQueue ) +{ + /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */ + + /* The lock counts contains the number of extra data items placed or + * removed from the queue while the queue was locked. When a queue is + * locked items can be added or removed, but the event lists cannot be + * updated. */ + taskENTER_CRITICAL(); + { + int8_t cTxLock = pxQueue->cTxLock; + + /* See if data was added to the queue while it was locked. */ + while( cTxLock > queueLOCKED_UNMODIFIED ) + { + /* Data was posted while the queue was locked. Are any tasks + * blocked waiting for data to become available? */ + #if ( configUSE_QUEUE_SETS == 1 ) + { + if( pxQueue->pxQueueSetContainer != NULL ) + { + if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE ) + { + /* The queue is a member of a queue set, and posting to + * the queue set caused a higher priority task to unblock. + * A context switch is required. */ + vTaskMissedYield(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* Tasks that are removed from the event list will get + * added to the pending ready list as the scheduler is still + * suspended. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so record that a + * context switch is required. */ + vTaskMissedYield(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + break; + } + } + } + #else /* configUSE_QUEUE_SETS */ + { + /* Tasks that are removed from the event list will get added to + * the pending ready list as the scheduler is still suspended. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so record that + * a context switch is required. */ + vTaskMissedYield(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + break; + } + } + #endif /* configUSE_QUEUE_SETS */ + + --cTxLock; + } + + pxQueue->cTxLock = queueUNLOCKED; + } + taskEXIT_CRITICAL(); + + /* Do the same for the Rx lock. */ + taskENTER_CRITICAL(); + { + int8_t cRxLock = pxQueue->cRxLock; + + while( cRxLock > queueLOCKED_UNMODIFIED ) + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + vTaskMissedYield(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + --cRxLock; + } + else + { + break; + } + } + + pxQueue->cRxLock = queueUNLOCKED; + } + taskEXIT_CRITICAL(); +} +/*-----------------------------------------------------------*/ + +static BaseType_t prvIsQueueEmpty( const Queue_t * pxQueue ) +{ + BaseType_t xReturn; + + taskENTER_CRITICAL(); + { + if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) + { + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + } + taskEXIT_CRITICAL(); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) +{ + BaseType_t xReturn; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + + if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) + { + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */ +/*-----------------------------------------------------------*/ + +static BaseType_t prvIsQueueFull( const Queue_t * pxQueue ) +{ + BaseType_t xReturn; + + taskENTER_CRITICAL(); + { + if( pxQueue->uxMessagesWaiting == pxQueue->uxLength ) + { + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + } + taskEXIT_CRITICAL(); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) +{ + BaseType_t xReturn; + Queue_t * const pxQueue = xQueue; + + configASSERT( pxQueue ); + + if( pxQueue->uxMessagesWaiting == pxQueue->uxLength ) + { + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_CO_ROUTINES == 1 ) + + BaseType_t xQueueCRSend( QueueHandle_t xQueue, + const void * pvItemToQueue, + TickType_t xTicksToWait ) + { + BaseType_t xReturn; + Queue_t * const pxQueue = xQueue; + + /* If the queue is already full we may have to block. A critical section + * is required to prevent an interrupt removing something from the queue + * between the check to see if the queue is full and blocking on the queue. */ + portDISABLE_INTERRUPTS(); + { + if( prvIsQueueFull( pxQueue ) != pdFALSE ) + { + /* The queue is full - do we want to block or just leave without + * posting? */ + if( xTicksToWait > ( TickType_t ) 0 ) + { + /* As this is called from a coroutine we cannot block directly, but + * return indicating that we need to block. */ + vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) ); + portENABLE_INTERRUPTS(); + return errQUEUE_BLOCKED; + } + else + { + portENABLE_INTERRUPTS(); + return errQUEUE_FULL; + } + } + } + portENABLE_INTERRUPTS(); + + portDISABLE_INTERRUPTS(); + { + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + { + /* There is room in the queue, copy the data into the queue. */ + prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); + xReturn = pdPASS; + + /* Were any co-routines waiting for data to become available? */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + /* In this instance the co-routine could be placed directly + * into the ready list as we are within a critical section. + * Instead the same pending ready list mechanism is used as if + * the event were caused from within an interrupt. */ + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The co-routine waiting has a higher priority so record + * that a yield might be appropriate. */ + xReturn = errQUEUE_YIELD; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + xReturn = errQUEUE_FULL; + } + } + portENABLE_INTERRUPTS(); + + return xReturn; + } + +#endif /* configUSE_CO_ROUTINES */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_CO_ROUTINES == 1 ) + + BaseType_t xQueueCRReceive( QueueHandle_t xQueue, + void * pvBuffer, + TickType_t xTicksToWait ) + { + BaseType_t xReturn; + Queue_t * const pxQueue = xQueue; + + /* If the queue is already empty we may have to block. A critical section + * is required to prevent an interrupt adding something to the queue + * between the check to see if the queue is empty and blocking on the queue. */ + portDISABLE_INTERRUPTS(); + { + if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) + { + /* There are no messages in the queue, do we want to block or just + * leave with nothing? */ + if( xTicksToWait > ( TickType_t ) 0 ) + { + /* As this is a co-routine we cannot block directly, but return + * indicating that we need to block. */ + vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) ); + portENABLE_INTERRUPTS(); + return errQUEUE_BLOCKED; + } + else + { + portENABLE_INTERRUPTS(); + return errQUEUE_FULL; + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + portENABLE_INTERRUPTS(); + + portDISABLE_INTERRUPTS(); + { + if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + /* Data is available from the queue. */ + pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize; + + if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail ) + { + pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + --( pxQueue->uxMessagesWaiting ); + ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); + + xReturn = pdPASS; + + /* Were any co-routines waiting for space to become available? */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + /* In this instance the co-routine could be placed directly + * into the ready list as we are within a critical section. + * Instead the same pending ready list mechanism is used as if + * the event were caused from within an interrupt. */ + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + xReturn = errQUEUE_YIELD; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + xReturn = pdFAIL; + } + } + portENABLE_INTERRUPTS(); + + return xReturn; + } + +#endif /* configUSE_CO_ROUTINES */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_CO_ROUTINES == 1 ) + + BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, + const void * pvItemToQueue, + BaseType_t xCoRoutinePreviouslyWoken ) + { + Queue_t * const pxQueue = xQueue; + + /* Cannot block within an ISR so if there is no space on the queue then + * exit without doing anything. */ + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + { + prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); + + /* We only want to wake one co-routine per ISR, so check that a + * co-routine has not already been woken. */ + if( xCoRoutinePreviouslyWoken == pdFALSE ) + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + return pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xCoRoutinePreviouslyWoken; + } + +#endif /* configUSE_CO_ROUTINES */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_CO_ROUTINES == 1 ) + + BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, + void * pvBuffer, + BaseType_t * pxCoRoutineWoken ) + { + BaseType_t xReturn; + Queue_t * const pxQueue = xQueue; + + /* We cannot block from an ISR, so check there is data available. If + * not then just leave without doing anything. */ + if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) + { + /* Copy the data from the queue. */ + pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize; + + if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail ) + { + pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + --( pxQueue->uxMessagesWaiting ); + ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); + + if( ( *pxCoRoutineWoken ) == pdFALSE ) + { + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + *pxCoRoutineWoken = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + } + + return xReturn; + } + +#endif /* configUSE_CO_ROUTINES */ +/*-----------------------------------------------------------*/ + +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + + void vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcQueueName ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + { + UBaseType_t ux; + + /* See if there is an empty space in the registry. A NULL name denotes + * a free slot. */ + for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) + { + if( xQueueRegistry[ ux ].pcQueueName == NULL ) + { + /* Store the information on this queue. */ + xQueueRegistry[ ux ].pcQueueName = pcQueueName; + xQueueRegistry[ ux ].xHandle = xQueue; + + traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ); + break; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + +#endif /* configQUEUE_REGISTRY_SIZE */ +/*-----------------------------------------------------------*/ + +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + + const char * pcQueueGetName( QueueHandle_t xQueue ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + { + UBaseType_t ux; + const char * pcReturn = NULL; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + + /* Note there is nothing here to protect against another task adding or + * removing entries from the registry while it is being searched. */ + + for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) + { + if( xQueueRegistry[ ux ].xHandle == xQueue ) + { + pcReturn = xQueueRegistry[ ux ].pcQueueName; + break; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + return pcReturn; + } /*lint !e818 xQueue cannot be a pointer to const because it is a typedef. */ + +#endif /* configQUEUE_REGISTRY_SIZE */ +/*-----------------------------------------------------------*/ + +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + + void vQueueUnregisterQueue( QueueHandle_t xQueue ) + { + UBaseType_t ux; + + /* See if the handle of the queue being unregistered in actually in the + * registry. */ + for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) + { + if( xQueueRegistry[ ux ].xHandle == xQueue ) + { + /* Set the name to NULL to show that this slot if free again. */ + xQueueRegistry[ ux ].pcQueueName = NULL; + + /* Set the handle to NULL to ensure the same queue handle cannot + * appear in the registry twice if it is added, removed, then + * added again. */ + xQueueRegistry[ ux ].xHandle = ( QueueHandle_t ) 0; + break; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } /*lint !e818 xQueue could not be pointer to const because it is a typedef. */ + +#endif /* configQUEUE_REGISTRY_SIZE */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TIMERS == 1 ) + + void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) + { + Queue_t * const pxQueue = xQueue; + + /* This function should not be called by application code hence the + * 'Restricted' in its name. It is not part of the public API. It is + * designed for use by kernel code, and has special calling requirements. + * It can result in vListInsert() being called on a list that can only + * possibly ever have one item in it, so the list will be fast, but even + * so it should be called with the scheduler locked and not from a critical + * section. */ + + /* Only do anything if there are no messages in the queue. This function + * will not actually cause the task to block, just place it on a blocked + * list. It will not block until the scheduler is unlocked - at which + * time a yield will be performed. If an item is added to the queue while + * the queue is locked, and the calling task blocks on the queue, then the + * calling task will be immediately unblocked when the queue is unlocked. */ + prvLockQueue( pxQueue ); + + if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U ) + { + /* There is nothing in the queue, block for the specified period. */ + vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait, xWaitIndefinitely ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + prvUnlockQueue( pxQueue ); + } + +#endif /* configUSE_TIMERS */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) + { + QueueSetHandle_t pxQueue; + + pxQueue = xQueueGenericCreate( uxEventQueueLength, ( UBaseType_t ) sizeof( Queue_t * ), queueQUEUE_TYPE_SET ); + + return pxQueue; + } + +#endif /* configUSE_QUEUE_SETS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + + BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) + { + BaseType_t xReturn; + + taskENTER_CRITICAL(); + { + if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL ) + { + /* Cannot add a queue/semaphore to more than one queue set. */ + xReturn = pdFAIL; + } + else if( ( ( Queue_t * ) xQueueOrSemaphore )->uxMessagesWaiting != ( UBaseType_t ) 0 ) + { + /* Cannot add a queue/semaphore to a queue set if there are already + * items in the queue/semaphore. */ + xReturn = pdFAIL; + } + else + { + ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer = xQueueSet; + xReturn = pdPASS; + } + } + taskEXIT_CRITICAL(); + + return xReturn; + } + +#endif /* configUSE_QUEUE_SETS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + + BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) + { + BaseType_t xReturn; + Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore; + + if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet ) + { + /* The queue was not a member of the set. */ + xReturn = pdFAIL; + } + else if( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 ) + { + /* It is dangerous to remove a queue from a set when the queue is + * not empty because the queue set will still hold pending events for + * the queue. */ + xReturn = pdFAIL; + } + else + { + taskENTER_CRITICAL(); + { + /* The queue is no longer contained in the set. */ + pxQueueOrSemaphore->pxQueueSetContainer = NULL; + } + taskEXIT_CRITICAL(); + xReturn = pdPASS; + } + + return xReturn; + } /*lint !e818 xQueueSet could not be declared as pointing to const as it is a typedef. */ + +#endif /* configUSE_QUEUE_SETS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + + QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + TickType_t const xTicksToWait ) + { + QueueSetMemberHandle_t xReturn = NULL; + + ( void ) xQueueReceive( ( QueueHandle_t ) xQueueSet, &xReturn, xTicksToWait ); /*lint !e961 Casting from one typedef to another is not redundant. */ + return xReturn; + } + +#endif /* configUSE_QUEUE_SETS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + + QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) + { + QueueSetMemberHandle_t xReturn = NULL; + + ( void ) xQueueReceiveFromISR( ( QueueHandle_t ) xQueueSet, &xReturn, NULL ); /*lint !e961 Casting from one typedef to another is not redundant. */ + return xReturn; + } + +#endif /* configUSE_QUEUE_SETS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_QUEUE_SETS == 1 ) + + static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue ) + { + Queue_t * pxQueueSetContainer = pxQueue->pxQueueSetContainer; + BaseType_t xReturn = pdFALSE; + + /* This function must be called form a critical section. */ + + configASSERT( pxQueueSetContainer ); + configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ); + + if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ) + { + const int8_t cTxLock = pxQueueSetContainer->cTxLock; + + traceQUEUE_SET_SEND( pxQueueSetContainer ); + + /* The data copied is the handle of the queue that contains data. */ + xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, queueSEND_TO_BACK ); + + if( cTxLock == queueUNLOCKED ) + { + if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority. */ + xReturn = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + configASSERT( cTxLock != queueINT8_MAX ); + + pxQueueSetContainer->cTxLock = ( int8_t ) ( cTxLock + 1 ); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xReturn; + } + +#endif /* configUSE_QUEUE_SETS */ diff --git a/FreeRTOS/tasks.c b/FreeRTOS/tasks.c new file mode 100644 index 0000000..8b5f157 --- /dev/null +++ b/FreeRTOS/tasks.c @@ -0,0 +1,5395 @@ +/* + * FreeRTOS Kernel V10.4.2 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* Standard includes. */ +#include +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* FreeRTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "timers.h" +#include "stack_macros.h" + +/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified + * because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined + * for the header files above, but not in this file, in order to generate the + * correct privileged Vs unprivileged linkage and placement. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */ + +/* Set configUSE_STATS_FORMATTING_FUNCTIONS to 2 to include the stats formatting + * functions but without including stdio.h here. */ +#if ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) + +/* At the bottom of this file are two optional functions that can be used + * to generate human readable text from the raw data generated by the + * uxTaskGetSystemState() function. Note the formatting functions are provided + * for convenience only, and are NOT considered part of the kernel. */ + #include +#endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */ + +#if ( configUSE_PREEMPTION == 0 ) + +/* If the cooperative scheduler is being used then a yield should not be + * performed just because a higher priority task has been woken. */ + #define taskYIELD_IF_USING_PREEMPTION() +#else + #define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API() +#endif + +/* Values that can be assigned to the ucNotifyState member of the TCB. */ +#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 ) /* Must be zero as it is the initialised value. */ +#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 ) +#define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 ) + +/* + * The value used to fill the stack of a task when the task is created. This + * is used purely for checking the high water mark for tasks. + */ +#define tskSTACK_FILL_BYTE ( 0xa5U ) + +/* Bits used to recored how a task's stack and TCB were allocated. */ +#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 0 ) +#define tskSTATICALLY_ALLOCATED_STACK_ONLY ( ( uint8_t ) 1 ) +#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 2 ) + +/* If any of the following are set then task stacks are filled with a known + * value so the high water mark can be determined. If none of the following are + * set then don't fill the stack so there is no unnecessary dependency on memset. */ +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) ) + #define tskSET_NEW_STACKS_TO_KNOWN_VALUE 1 +#else + #define tskSET_NEW_STACKS_TO_KNOWN_VALUE 0 +#endif + +/* + * Macros used by vListTask to indicate which state a task is in. + */ +#define tskRUNNING_CHAR ( 'X' ) +#define tskBLOCKED_CHAR ( 'B' ) +#define tskREADY_CHAR ( 'R' ) +#define tskDELETED_CHAR ( 'D' ) +#define tskSUSPENDED_CHAR ( 'S' ) + +/* + * Some kernel aware debuggers require the data the debugger needs access to be + * global, rather than file scope. + */ +#ifdef portREMOVE_STATIC_QUALIFIER + #define static +#endif + +/* The name allocated to the Idle task. This can be overridden by defining + * configIDLE_TASK_NAME in FreeRTOSConfig.h. */ +#ifndef configIDLE_TASK_NAME + #define configIDLE_TASK_NAME "IDLE" +#endif + +#if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) + +/* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 0 then task selection is + * performed in a generic way that is not optimised to any particular + * microcontroller architecture. */ + +/* uxTopReadyPriority holds the priority of the highest priority ready + * state task. */ + #define taskRECORD_READY_PRIORITY( uxPriority ) \ + { \ + if( ( uxPriority ) > uxTopReadyPriority ) \ + { \ + uxTopReadyPriority = ( uxPriority ); \ + } \ + } /* taskRECORD_READY_PRIORITY */ + +/*-----------------------------------------------------------*/ + + #define taskSELECT_HIGHEST_PRIORITY_TASK() \ + { \ + UBaseType_t uxTopPriority = uxTopReadyPriority; \ + \ + /* Find the highest priority queue that contains ready tasks. */ \ + while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopPriority ] ) ) ) \ + { \ + configASSERT( uxTopPriority ); \ + --uxTopPriority; \ + } \ + \ + /* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of \ + * the same priority get an equal share of the processor time. */ \ + listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \ + uxTopReadyPriority = uxTopPriority; \ + } /* taskSELECT_HIGHEST_PRIORITY_TASK */ + +/*-----------------------------------------------------------*/ + +/* Define away taskRESET_READY_PRIORITY() and portRESET_READY_PRIORITY() as + * they are only required when a port optimised method of task selection is + * being used. */ + #define taskRESET_READY_PRIORITY( uxPriority ) + #define portRESET_READY_PRIORITY( uxPriority, uxTopReadyPriority ) + +#else /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ + +/* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 1 then task selection is + * performed in a way that is tailored to the particular microcontroller + * architecture being used. */ + +/* A port optimised version is provided. Call the port defined macros. */ + #define taskRECORD_READY_PRIORITY( uxPriority ) portRECORD_READY_PRIORITY( uxPriority, uxTopReadyPriority ) + +/*-----------------------------------------------------------*/ + + #define taskSELECT_HIGHEST_PRIORITY_TASK() \ + { \ + UBaseType_t uxTopPriority; \ + \ + /* Find the highest priority list that contains ready tasks. */ \ + portGET_HIGHEST_PRIORITY( uxTopPriority, uxTopReadyPriority ); \ + configASSERT( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ uxTopPriority ] ) ) > 0 ); \ + listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \ + } /* taskSELECT_HIGHEST_PRIORITY_TASK() */ + +/*-----------------------------------------------------------*/ + +/* A port optimised version is provided, call it only if the TCB being reset + * is being referenced from a ready list. If it is referenced from a delayed + * or suspended list then it won't be in a ready list. */ + #define taskRESET_READY_PRIORITY( uxPriority ) \ + { \ + if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == ( UBaseType_t ) 0 ) \ + { \ + portRESET_READY_PRIORITY( ( uxPriority ), ( uxTopReadyPriority ) ); \ + } \ + } + +#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ + +/*-----------------------------------------------------------*/ + +/* pxDelayedTaskList and pxOverflowDelayedTaskList are switched when the tick + * count overflows. */ +#define taskSWITCH_DELAYED_LISTS() \ + { \ + List_t * pxTemp; \ + \ + /* The delayed tasks list should be empty when the lists are switched. */ \ + configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) ); \ + \ + pxTemp = pxDelayedTaskList; \ + pxDelayedTaskList = pxOverflowDelayedTaskList; \ + pxOverflowDelayedTaskList = pxTemp; \ + xNumOfOverflows++; \ + prvResetNextTaskUnblockTime(); \ + } + +/*-----------------------------------------------------------*/ + +/* + * Place the task represented by pxTCB into the appropriate ready list for + * the task. It is inserted at the end of the list. + */ +#define prvAddTaskToReadyList( pxTCB ) \ + traceMOVED_TASK_TO_READY_STATE( pxTCB ); \ + taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \ + vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \ + tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) +/*-----------------------------------------------------------*/ + +/* + * Several functions take an TaskHandle_t parameter that can optionally be NULL, + * where NULL is used to indicate that the handle of the currently executing + * task should be used in place of the parameter. This macro simply checks to + * see if the parameter is NULL and returns a pointer to the appropriate TCB. + */ +#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? pxCurrentTCB : ( pxHandle ) ) + +/* The item value of the event list item is normally used to hold the priority + * of the task to which it belongs (coded to allow it to be held in reverse + * priority order). However, it is occasionally borrowed for other purposes. It + * is important its value is not updated due to a task priority change while it is + * being used for another purpose. The following bit definition is used to inform + * the scheduler that the value should not be changed - in which case it is the + * responsibility of whichever module is using the value to ensure it gets set back + * to its original value when it is released. */ +#if ( configUSE_16_BIT_TICKS == 1 ) + #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x8000U +#else + #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x80000000UL +#endif + +/* + * Task control block. A task control block (TCB) is allocated for each task, + * and stores task state information, including a pointer to the task's context + * (the task's run time environment, including register values) + */ +typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +{ + volatile StackType_t * pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */ + + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */ + #endif + + ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ + ListItem_t xEventListItem; /*< Used to reference a task from an event list. */ + UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */ + StackType_t * pxStack; /*< Points to the start of the stack. */ + char pcTaskName[ configMAX_TASK_NAME_LEN ]; /*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + + #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + StackType_t * pxEndOfStack; /*< Points to the highest valid address for the stack. */ + #endif + + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */ + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxTCBNumber; /*< Stores a number that increments each time a TCB is created. It allows debuggers to determine when a task has been deleted and then recreated. */ + UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */ + #endif + + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */ + UBaseType_t uxMutexesHeld; + #endif + + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + TaskHookFunction_t pxTaskTag; + #endif + + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + void * pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #endif + + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ + #endif + + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + + /* Allocate a Newlib reent structure that is specific to this task. + * Note Newlib support has been included by popular demand, but is not + * used by the FreeRTOS maintainers themselves. FreeRTOS is not + * responsible for resulting newlib operation. User must be familiar with + * newlib and must provide system-wide implementations of the necessary + * stubs. Be warned that (at the time of writing) the current newlib design + * implements a system-wide malloc() that must be provided with locks. + * + * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html + * for additional information. */ + struct _reent xNewLib_reent; + #endif + + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + volatile uint32_t ulNotifiedValue[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + volatile uint8_t ucNotifyState[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + #endif + + /* See the comments in FreeRTOS.h with the definition of + * tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */ + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ + uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */ + #endif + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + uint8_t ucDelayAborted; + #endif + + #if ( configUSE_POSIX_ERRNO == 1 ) + int iTaskErrno; + #endif +} tskTCB; + +/* The old tskTCB name is maintained above then typedefed to the new TCB_t name + * below to enable the use of older kernel aware debuggers. */ +typedef tskTCB TCB_t; + +/*lint -save -e956 A manual analysis and inspection has been used to determine + * which static variables must be declared volatile. */ +PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL; + +/* Lists for ready and blocked tasks. -------------------- + * xDelayedTaskList1 and xDelayedTaskList2 could be move to function scople but + * doing so breaks some kernel aware debuggers and debuggers that rely on removing + * the static qualifier. */ +PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ]; /*< Prioritised ready tasks. */ +PRIVILEGED_DATA static List_t xDelayedTaskList1; /*< Delayed tasks. */ +PRIVILEGED_DATA static List_t xDelayedTaskList2; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */ +PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList; /*< Points to the delayed task list currently being used. */ +PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */ +PRIVILEGED_DATA static List_t xPendingReadyList; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready list when the scheduler is resumed. */ + +#if ( INCLUDE_vTaskDelete == 1 ) + + PRIVILEGED_DATA static List_t xTasksWaitingTermination; /*< Tasks that have been deleted - but their memory not yet freed. */ + PRIVILEGED_DATA static volatile UBaseType_t uxDeletedTasksWaitingCleanUp = ( UBaseType_t ) 0U; + +#endif + +#if ( INCLUDE_vTaskSuspend == 1 ) + + PRIVILEGED_DATA static List_t xSuspendedTaskList; /*< Tasks that are currently suspended. */ + +#endif + +/* Global POSIX errno. Its value is changed upon context switching to match + * the errno of the currently running task. */ +#if ( configUSE_POSIX_ERRNO == 1 ) + int FreeRTOS_errno = 0; +#endif + +/* Other file private variables. --------------------------------*/ +PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U; +PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT; +PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY; +PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE; +PRIVILEGED_DATA static volatile TickType_t xPendedTicks = ( TickType_t ) 0U; +PRIVILEGED_DATA static volatile BaseType_t xYieldPending = pdFALSE; +PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0; +PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U; +PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime = ( TickType_t ) 0U; /* Initialised to portMAX_DELAY before the scheduler starts. */ +PRIVILEGED_DATA static TaskHandle_t xIdleTaskHandle = NULL; /*< Holds the handle of the idle task. The idle task is created automatically when the scheduler is started. */ + +/* Improve support for OpenOCD. The kernel tracks Ready tasks via priority lists. + * For tracking the state of remote threads, OpenOCD uses uxTopUsedPriority + * to determine the number of priority lists to read back from the remote target. */ +const volatile UBaseType_t uxTopUsedPriority = configMAX_PRIORITIES - 1U; + +/* Context switches are held pending while the scheduler is suspended. Also, + * interrupts must not manipulate the xStateListItem of a TCB, or any of the + * lists the xStateListItem can be referenced from, if the scheduler is suspended. + * If an interrupt needs to unblock a task while the scheduler is suspended then it + * moves the task's event list item into the xPendingReadyList, ready for the + * kernel to move the task from the pending ready list into the real ready list + * when the scheduler is unsuspended. The pending ready list itself can only be + * accessed from a critical section. */ +PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE; + +#if ( configGENERATE_RUN_TIME_STATS == 1 ) + +/* Do not move these variables to function scope as doing so prevents the + * code working with debuggers that need to remove the static qualifier. */ + PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ + PRIVILEGED_DATA static volatile uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ + +#endif + +/*lint -restore */ + +/*-----------------------------------------------------------*/ + +/* File private functions. --------------------------------*/ + +/** + * Utility task that simply returns pdTRUE if the task referenced by xTask is + * currently in the Suspended state, or pdFALSE if the task referenced by xTask + * is in any other state. + */ +#if ( INCLUDE_vTaskSuspend == 1 ) + + static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +#endif /* INCLUDE_vTaskSuspend */ + +/* + * Utility to ready all the lists used by the scheduler. This is called + * automatically upon the creation of the first task. + */ +static void prvInitialiseTaskLists( void ) PRIVILEGED_FUNCTION; + +/* + * The idle task, which as all tasks is implemented as a never ending loop. + * The idle task is automatically created and added to the ready lists upon + * creation of the first user task. + * + * The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific + * language extensions. The equivalent prototype for this function is: + * + * void prvIdleTask( void *pvParameters ); + * + */ +static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ) PRIVILEGED_FUNCTION; + +/* + * Utility to free all memory allocated by the scheduler to hold a TCB, + * including the stack pointed to by the TCB. + * + * This does not free memory allocated by the task itself (i.e. memory + * allocated by calls to pvPortMalloc from within the tasks application code). + */ +#if ( INCLUDE_vTaskDelete == 1 ) + + static void prvDeleteTCB( TCB_t * pxTCB ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Used only by the idle task. This checks to see if anything has been placed + * in the list of tasks waiting to be deleted. If so the task is cleaned up + * and its TCB deleted. + */ +static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION; + +/* + * The currently executing task is entering the Blocked state. Add the task to + * either the current or the overflow delayed task list. + */ +static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, + const BaseType_t xCanBlockIndefinitely ) PRIVILEGED_FUNCTION; + +/* + * Fills an TaskStatus_t structure with information on each task that is + * referenced from the pxList list (which may be a ready list, a delayed list, + * a suspended list, etc.). + * + * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM + * NORMAL APPLICATION CODE. + */ +#if ( configUSE_TRACE_FACILITY == 1 ) + + static UBaseType_t prvListTasksWithinSingleList( TaskStatus_t * pxTaskStatusArray, + List_t * pxList, + eTaskState eState ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Searches pxList for a task with name pcNameToQuery - returning a handle to + * the task if it is found, or NULL if the task is not found. + */ +#if ( INCLUDE_xTaskGetHandle == 1 ) + + static TCB_t * prvSearchForNameWithinSingleList( List_t * pxList, + const char pcNameToQuery[] ) PRIVILEGED_FUNCTION; + +#endif + +/* + * When a task is created, the stack of the task is filled with a known value. + * This function determines the 'high water mark' of the task stack by + * determining how much of the stack remains at the original preset value. + */ +#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) ) + + static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Return the amount of time, in ticks, that will pass before the kernel will + * next move a task from the Blocked state to the Running state. + * + * This conditional compilation should use inequality to 0, not equality to 1. + * This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user + * defined low power mode implementations require configUSE_TICKLESS_IDLE to be + * set to a value other than 1. + */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + + static TickType_t prvGetExpectedIdleTime( void ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Set xNextTaskUnblockTime to the time at which the next Blocked state task + * will exit the Blocked state. + */ +static void prvResetNextTaskUnblockTime( void ) PRIVILEGED_FUNCTION; + +#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) + +/* + * Helper function used to pad task names with spaces when printing out + * human readable tables of task information. + */ + static char * prvWriteNameToBuffer( char * pcBuffer, + const char * pcTaskName ) PRIVILEGED_FUNCTION; + +#endif + +/* + * Called after a Task_t structure has been allocated either statically or + * dynamically to fill in the structure's members. + */ +static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask, + TCB_t * pxNewTCB, + const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; + +/* + * Called after a new task has been created and initialised to place the task + * under the control of the scheduler. + */ +static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION; + +/* + * freertos_tasks_c_additions_init() should only be called if the user definable + * macro FREERTOS_TASKS_C_ADDITIONS_INIT() is defined, as that is the only macro + * called by the function. + */ +#ifdef FREERTOS_TASKS_C_ADDITIONS_INIT + + static void freertos_tasks_c_additions_init( void ) PRIVILEGED_FUNCTION; + +#endif + +/*-----------------------------------------------------------*/ + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + + TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const puxStackBuffer, + StaticTask_t * const pxTaskBuffer ) + { + TCB_t * pxNewTCB; + TaskHandle_t xReturn; + + configASSERT( puxStackBuffer != NULL ); + configASSERT( pxTaskBuffer != NULL ); + + #if ( configASSERT_DEFINED == 1 ) + { + /* Sanity check that the size of the structure used to declare a + * variable of type StaticTask_t equals the size of the real task + * structure. */ + volatile size_t xSize = sizeof( StaticTask_t ); + configASSERT( xSize == sizeof( TCB_t ) ); + ( void ) xSize; /* Prevent lint warning when configASSERT() is not used. */ + } + #endif /* configASSERT_DEFINED */ + + if( ( pxTaskBuffer != NULL ) && ( puxStackBuffer != NULL ) ) + { + /* The memory used for the task's TCB and stack are passed into this + * function - use them. */ + pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ + pxNewTCB->pxStack = ( StackType_t * ) puxStackBuffer; + + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ + { + /* Tasks can be created statically or dynamically, so note this + * task was created statically in case the task is later deleted. */ + pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB; + } + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ + + prvInitialiseNewTask( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, &xReturn, pxNewTCB, NULL ); + prvAddNewTaskToReadyList( pxNewTCB ); + } + else + { + xReturn = NULL; + } + + return xReturn; + } + +#endif /* SUPPORT_STATIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + + BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ) + { + TCB_t * pxNewTCB; + BaseType_t xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + + configASSERT( pxTaskDefinition->puxStackBuffer != NULL ); + configASSERT( pxTaskDefinition->pxTaskBuffer != NULL ); + + if( ( pxTaskDefinition->puxStackBuffer != NULL ) && ( pxTaskDefinition->pxTaskBuffer != NULL ) ) + { + /* Allocate space for the TCB. Where the memory comes from depends + * on the implementation of the port malloc function and whether or + * not static allocation is being used. */ + pxNewTCB = ( TCB_t * ) pxTaskDefinition->pxTaskBuffer; + + /* Store the stack location in the TCB. */ + pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer; + + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) + { + /* Tasks can be created statically or dynamically, so note this + * task was created statically in case the task is later deleted. */ + pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB; + } + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ + + prvInitialiseNewTask( pxTaskDefinition->pvTaskCode, + pxTaskDefinition->pcName, + ( uint32_t ) pxTaskDefinition->usStackDepth, + pxTaskDefinition->pvParameters, + pxTaskDefinition->uxPriority, + pxCreatedTask, pxNewTCB, + pxTaskDefinition->xRegions ); + + prvAddNewTaskToReadyList( pxNewTCB ); + xReturn = pdPASS; + } + + return xReturn; + } + +#endif /* ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ +/*-----------------------------------------------------------*/ + +#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ) + { + TCB_t * pxNewTCB; + BaseType_t xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + + configASSERT( pxTaskDefinition->puxStackBuffer ); + + if( pxTaskDefinition->puxStackBuffer != NULL ) + { + /* Allocate space for the TCB. Where the memory comes from depends + * on the implementation of the port malloc function and whether or + * not static allocation is being used. */ + pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); + + if( pxNewTCB != NULL ) + { + /* Store the stack location in the TCB. */ + pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer; + + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) + { + /* Tasks can be created statically or dynamically, so note + * this task had a statically allocated stack in case it is + * later deleted. The TCB was allocated dynamically. */ + pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY; + } + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ + + prvInitialiseNewTask( pxTaskDefinition->pvTaskCode, + pxTaskDefinition->pcName, + ( uint32_t ) pxTaskDefinition->usStackDepth, + pxTaskDefinition->pvParameters, + pxTaskDefinition->uxPriority, + pxCreatedTask, pxNewTCB, + pxTaskDefinition->xRegions ); + + prvAddNewTaskToReadyList( pxNewTCB ); + xReturn = pdPASS; + } + } + + return xReturn; + } + +#endif /* portUSING_MPU_WRAPPERS */ +/*-----------------------------------------------------------*/ + +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + + BaseType_t xTaskCreate( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const configSTACK_DEPTH_TYPE usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask ) + { + TCB_t * pxNewTCB; + BaseType_t xReturn; + + /* If the stack grows down then allocate the stack then the TCB so the stack + * does not grow into the TCB. Likewise if the stack grows up then allocate + * the TCB then the stack. */ + #if ( portSTACK_GROWTH > 0 ) + { + /* Allocate space for the TCB. Where the memory comes from depends on + * the implementation of the port malloc function and whether or not static + * allocation is being used. */ + pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); + + if( pxNewTCB != NULL ) + { + /* Allocate space for the stack used by the task being created. + * The base of the stack memory stored in the TCB so the task can + * be deleted later if required. */ + pxNewTCB->pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + if( pxNewTCB->pxStack == NULL ) + { + /* Could not allocate the stack. Delete the allocated TCB. */ + vPortFree( pxNewTCB ); + pxNewTCB = NULL; + } + } + } + #else /* portSTACK_GROWTH */ + { + StackType_t * pxStack; + + /* Allocate space for the stack used by the task being created. */ + pxStack = pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation is the stack. */ + + if( pxStack != NULL ) + { + /* Allocate space for the TCB. */ + pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); /*lint !e9087 !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack, and the first member of TCB_t is always a pointer to the task's stack. */ + + if( pxNewTCB != NULL ) + { + /* Store the stack location in the TCB. */ + pxNewTCB->pxStack = pxStack; + } + else + { + /* The stack cannot be used as the TCB was not created. Free + * it again. */ + vPortFree( pxStack ); + } + } + else + { + pxNewTCB = NULL; + } + } + #endif /* portSTACK_GROWTH */ + + if( pxNewTCB != NULL ) + { + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e9029 !e731 Macro has been consolidated for readability reasons. */ + { + /* Tasks can be created statically or dynamically, so note this + * task was created dynamically in case it is later deleted. */ + pxNewTCB->ucStaticallyAllocated = tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB; + } + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ + + prvInitialiseNewTask( pxTaskCode, pcName, ( uint32_t ) usStackDepth, pvParameters, uxPriority, pxCreatedTask, pxNewTCB, NULL ); + prvAddNewTaskToReadyList( pxNewTCB ); + xReturn = pdPASS; + } + else + { + xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + } + + return xReturn; + } + +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ +/*-----------------------------------------------------------*/ + +static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask, + TCB_t * pxNewTCB, + const MemoryRegion_t * const xRegions ) +{ + StackType_t * pxTopOfStack; + UBaseType_t x; + + #if ( portUSING_MPU_WRAPPERS == 1 ) + /* Should the task be created in privileged mode? */ + BaseType_t xRunPrivileged; + + if( ( uxPriority & portPRIVILEGE_BIT ) != 0U ) + { + xRunPrivileged = pdTRUE; + } + else + { + xRunPrivileged = pdFALSE; + } + uxPriority &= ~portPRIVILEGE_BIT; + #endif /* portUSING_MPU_WRAPPERS == 1 */ + + /* Avoid dependency on memset() if it is not required. */ + #if ( tskSET_NEW_STACKS_TO_KNOWN_VALUE == 1 ) + { + /* Fill the stack with a known value to assist debugging. */ + ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) ulStackDepth * sizeof( StackType_t ) ); + } + #endif /* tskSET_NEW_STACKS_TO_KNOWN_VALUE */ + + /* Calculate the top of stack address. This depends on whether the stack + * grows from high memory to low (as per the 80x86) or vice versa. + * portSTACK_GROWTH is used to make the result positive or negative as required + * by the port. */ + #if ( portSTACK_GROWTH < 0 ) + { + pxTopOfStack = &( pxNewTCB->pxStack[ ulStackDepth - ( uint32_t ) 1 ] ); + pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 !e9033 !e9078 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. Checked by assert(). */ + + /* Check the alignment of the calculated top of stack is correct. */ + configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); + + #if ( configRECORD_STACK_HIGH_ADDRESS == 1 ) + { + /* Also record the stack's high address, which may assist + * debugging. */ + pxNewTCB->pxEndOfStack = pxTopOfStack; + } + #endif /* configRECORD_STACK_HIGH_ADDRESS */ + } + #else /* portSTACK_GROWTH */ + { + pxTopOfStack = pxNewTCB->pxStack; + + /* Check the alignment of the stack buffer is correct. */ + configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); + + /* The other extreme of the stack space is required if stack checking is + * performed. */ + pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( ulStackDepth - ( uint32_t ) 1 ); + } + #endif /* portSTACK_GROWTH */ + + /* Store the task name in the TCB. */ + if( pcName != NULL ) + { + for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ ) + { + pxNewTCB->pcTaskName[ x ] = pcName[ x ]; + + /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than + * configMAX_TASK_NAME_LEN characters just in case the memory after the + * string is not accessible (extremely unlikely). */ + if( pcName[ x ] == ( char ) 0x00 ) + { + break; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + /* Ensure the name string is terminated in the case that the string length + * was greater or equal to configMAX_TASK_NAME_LEN. */ + pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0'; + } + else + { + /* The task has not been given a name, so just ensure there is a NULL + * terminator when it is read out. */ + pxNewTCB->pcTaskName[ 0 ] = 0x00; + } + + /* This is used as an array index so must ensure it's not too large. First + * remove the privilege bit if one is present. */ + if( uxPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + { + uxPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + pxNewTCB->uxPriority = uxPriority; + #if ( configUSE_MUTEXES == 1 ) + { + pxNewTCB->uxBasePriority = uxPriority; + pxNewTCB->uxMutexesHeld = 0; + } + #endif /* configUSE_MUTEXES */ + + vListInitialiseItem( &( pxNewTCB->xStateListItem ) ); + vListInitialiseItem( &( pxNewTCB->xEventListItem ) ); + + /* Set the pxNewTCB as a link back from the ListItem_t. This is so we can get + * back to the containing TCB from a generic item in a list. */ + listSET_LIST_ITEM_OWNER( &( pxNewTCB->xStateListItem ), pxNewTCB ); + + /* Event lists are always in priority order. */ + listSET_LIST_ITEM_VALUE( &( pxNewTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + listSET_LIST_ITEM_OWNER( &( pxNewTCB->xEventListItem ), pxNewTCB ); + + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + { + pxNewTCB->uxCriticalNesting = ( UBaseType_t ) 0U; + } + #endif /* portCRITICAL_NESTING_IN_TCB */ + + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + { + pxNewTCB->pxTaskTag = NULL; + } + #endif /* configUSE_APPLICATION_TASK_TAG */ + + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + { + pxNewTCB->ulRunTimeCounter = 0UL; + } + #endif /* configGENERATE_RUN_TIME_STATS */ + + #if ( portUSING_MPU_WRAPPERS == 1 ) + { + vPortStoreTaskMPUSettings( &( pxNewTCB->xMPUSettings ), xRegions, pxNewTCB->pxStack, ulStackDepth ); + } + #else + { + /* Avoid compiler warning about unreferenced parameter. */ + ( void ) xRegions; + } + #endif + + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) + { + memset( ( void * ) &( pxNewTCB->pvThreadLocalStoragePointers[ 0 ] ), 0x00, sizeof( pxNewTCB->pvThreadLocalStoragePointers ) ); + } + #endif + + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + { + memset( ( void * ) &( pxNewTCB->ulNotifiedValue[ 0 ] ), 0x00, sizeof( pxNewTCB->ulNotifiedValue ) ); + memset( ( void * ) &( pxNewTCB->ucNotifyState[ 0 ] ), 0x00, sizeof( pxNewTCB->ucNotifyState ) ); + } + #endif + + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + { + /* Initialise this task's Newlib reent structure. + * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html + * for additional information. */ + _REENT_INIT_PTR( ( &( pxNewTCB->xNewLib_reent ) ) ); + } + #endif + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + { + pxNewTCB->ucDelayAborted = pdFALSE; + } + #endif + + /* Initialize the TCB stack to look as if the task was already running, + * but had been interrupted by the scheduler. The return address is set + * to the start of the task function. Once the stack has been initialised + * the top of stack variable is updated. */ + #if ( portUSING_MPU_WRAPPERS == 1 ) + { + /* If the port has capability to detect stack overflow, + * pass the stack end address to the stack initialization + * function as well. */ + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + { + #if ( portSTACK_GROWTH < 0 ) + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxStack, pxTaskCode, pvParameters, xRunPrivileged ); + } + #else /* portSTACK_GROWTH */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxEndOfStack, pxTaskCode, pvParameters, xRunPrivileged ); + } + #endif /* portSTACK_GROWTH */ + } + #else /* portHAS_STACK_OVERFLOW_CHECKING */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged ); + } + #endif /* portHAS_STACK_OVERFLOW_CHECKING */ + } + #else /* portUSING_MPU_WRAPPERS */ + { + /* If the port has capability to detect stack overflow, + * pass the stack end address to the stack initialization + * function as well. */ + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + { + #if ( portSTACK_GROWTH < 0 ) + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxStack, pxTaskCode, pvParameters ); + } + #else /* portSTACK_GROWTH */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxEndOfStack, pxTaskCode, pvParameters ); + } + #endif /* portSTACK_GROWTH */ + } + #else /* portHAS_STACK_OVERFLOW_CHECKING */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); + } + #endif /* portHAS_STACK_OVERFLOW_CHECKING */ + } + #endif /* portUSING_MPU_WRAPPERS */ + + if( pxCreatedTask != NULL ) + { + /* Pass the handle out in an anonymous way. The handle can be used to + * change the created task's priority, delete the created task, etc.*/ + *pxCreatedTask = ( TaskHandle_t ) pxNewTCB; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) +{ + /* Ensure interrupts don't access the task lists while the lists are being + * updated. */ + taskENTER_CRITICAL(); + { + uxCurrentNumberOfTasks++; + + if( pxCurrentTCB == NULL ) + { + /* There are no other tasks, or all the other tasks are in + * the suspended state - make this the current task. */ + pxCurrentTCB = pxNewTCB; + + if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 ) + { + /* This is the first task to be created so do the preliminary + * initialisation required. We will not recover if this call + * fails, but we will report the failure. */ + prvInitialiseTaskLists(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* If the scheduler is not already running, make this task the + * current task if it is the highest priority task to be created + * so far. */ + if( xSchedulerRunning == pdFALSE ) + { + if( pxCurrentTCB->uxPriority <= pxNewTCB->uxPriority ) + { + pxCurrentTCB = pxNewTCB; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + uxTaskNumber++; + + #if ( configUSE_TRACE_FACILITY == 1 ) + { + /* Add a counter into the TCB for tracing only. */ + pxNewTCB->uxTCBNumber = uxTaskNumber; + } + #endif /* configUSE_TRACE_FACILITY */ + traceTASK_CREATE( pxNewTCB ); + + prvAddTaskToReadyList( pxNewTCB ); + + portSETUP_TCB( pxNewTCB ); + } + taskEXIT_CRITICAL(); + + if( xSchedulerRunning != pdFALSE ) + { + /* If the created task is of a higher priority than the current task + * then it should run now. */ + if( pxCurrentTCB->uxPriority < pxNewTCB->uxPriority ) + { + taskYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelete == 1 ) + + void vTaskDelete( TaskHandle_t xTaskToDelete ) + { + TCB_t * pxTCB; + + taskENTER_CRITICAL(); + { + /* If null is passed in here then it is the calling task that is + * being deleted. */ + pxTCB = prvGetTCBFromHandle( xTaskToDelete ); + + /* Remove task from the ready/delayed list. */ + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + taskRESET_READY_PRIORITY( pxTCB->uxPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Is the task waiting on an event also? */ + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Increment the uxTaskNumber also so kernel aware debuggers can + * detect that the task lists need re-generating. This is done before + * portPRE_TASK_DELETE_HOOK() as in the Windows port that macro will + * not return. */ + uxTaskNumber++; + + if( pxTCB == pxCurrentTCB ) + { + /* A task is deleting itself. This cannot complete within the + * task itself, as a context switch to another task is required. + * Place the task in the termination list. The idle task will + * check the termination list and free up any memory allocated by + * the scheduler for the TCB and stack of the deleted task. */ + vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xStateListItem ) ); + + /* Increment the ucTasksDeleted variable so the idle task knows + * there is a task that has been deleted and that it should therefore + * check the xTasksWaitingTermination list. */ + ++uxDeletedTasksWaitingCleanUp; + + /* Call the delete hook before portPRE_TASK_DELETE_HOOK() as + * portPRE_TASK_DELETE_HOOK() does not return in the Win32 port. */ + traceTASK_DELETE( pxTCB ); + + /* The pre-delete hook is primarily for the Windows simulator, + * in which Windows specific clean up operations are performed, + * after which it is not possible to yield away from this task - + * hence xYieldPending is used to latch that a context switch is + * required. */ + portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending ); + } + else + { + --uxCurrentNumberOfTasks; + traceTASK_DELETE( pxTCB ); + prvDeleteTCB( pxTCB ); + + /* Reset the next expected unblock time in case it referred to + * the task that has just been deleted. */ + prvResetNextTaskUnblockTime(); + } + } + taskEXIT_CRITICAL(); + + /* Force a reschedule if it is the currently running task that has just + * been deleted. */ + if( xSchedulerRunning != pdFALSE ) + { + if( pxTCB == pxCurrentTCB ) + { + configASSERT( uxSchedulerSuspended == 0 ); + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + +#endif /* INCLUDE_vTaskDelete */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskDelayUntil == 1 ) + + BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) + { + TickType_t xTimeToWake; + BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE; + + configASSERT( pxPreviousWakeTime ); + configASSERT( ( xTimeIncrement > 0U ) ); + configASSERT( uxSchedulerSuspended == 0 ); + + vTaskSuspendAll(); + { + /* Minor optimisation. The tick count cannot change in this + * block. */ + const TickType_t xConstTickCount = xTickCount; + + /* Generate the tick time at which the task wants to wake. */ + xTimeToWake = *pxPreviousWakeTime + xTimeIncrement; + + if( xConstTickCount < *pxPreviousWakeTime ) + { + /* The tick count has overflowed since this function was + * lasted called. In this case the only time we should ever + * actually delay is if the wake time has also overflowed, + * and the wake time is greater than the tick time. When this + * is the case it is as if neither time had overflowed. */ + if( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xConstTickCount ) ) + { + xShouldDelay = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* The tick time has not overflowed. In this case we will + * delay if either the wake time has overflowed, and/or the + * tick time is less than the wake time. */ + if( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xConstTickCount ) ) + { + xShouldDelay = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + /* Update the wake time ready for the next call. */ + *pxPreviousWakeTime = xTimeToWake; + + if( xShouldDelay != pdFALSE ) + { + traceTASK_DELAY_UNTIL( xTimeToWake ); + + /* prvAddCurrentTaskToDelayedList() needs the block time, not + * the time to wake, so subtract the current tick count. */ + prvAddCurrentTaskToDelayedList( xTimeToWake - xConstTickCount, pdFALSE ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + xAlreadyYielded = xTaskResumeAll(); + + /* Force a reschedule if xTaskResumeAll has not already done so, we may + * have put ourselves to sleep. */ + if( xAlreadyYielded == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xShouldDelay; + } + +#endif /* INCLUDE_xTaskDelayUntil */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelay == 1 ) + + void vTaskDelay( const TickType_t xTicksToDelay ) + { + BaseType_t xAlreadyYielded = pdFALSE; + + /* A delay time of zero just forces a reschedule. */ + if( xTicksToDelay > ( TickType_t ) 0U ) + { + configASSERT( uxSchedulerSuspended == 0 ); + vTaskSuspendAll(); + { + traceTASK_DELAY(); + + /* A task that is removed from the event list while the + * scheduler is suspended will not get placed in the ready + * list or removed from the blocked list until the scheduler + * is resumed. + * + * This task cannot be in an event list as it is the currently + * executing task. */ + prvAddCurrentTaskToDelayedList( xTicksToDelay, pdFALSE ); + } + xAlreadyYielded = xTaskResumeAll(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Force a reschedule if xTaskResumeAll has not already done so, we may + * have put ourselves to sleep. */ + if( xAlreadyYielded == pdFALSE ) + { + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* INCLUDE_vTaskDelay */ +/*-----------------------------------------------------------*/ + +#if ( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_xTaskAbortDelay == 1 ) ) + + eTaskState eTaskGetState( TaskHandle_t xTask ) + { + eTaskState eReturn; + List_t const * pxStateList, * pxDelayedList, * pxOverflowedDelayedList; + const TCB_t * const pxTCB = xTask; + + configASSERT( pxTCB ); + + if( pxTCB == pxCurrentTCB ) + { + /* The task calling this function is querying its own state. */ + eReturn = eRunning; + } + else + { + taskENTER_CRITICAL(); + { + pxStateList = listLIST_ITEM_CONTAINER( &( pxTCB->xStateListItem ) ); + pxDelayedList = pxDelayedTaskList; + pxOverflowedDelayedList = pxOverflowDelayedTaskList; + } + taskEXIT_CRITICAL(); + + if( ( pxStateList == pxDelayedList ) || ( pxStateList == pxOverflowedDelayedList ) ) + { + /* The task being queried is referenced from one of the Blocked + * lists. */ + eReturn = eBlocked; + } + + #if ( INCLUDE_vTaskSuspend == 1 ) + else if( pxStateList == &xSuspendedTaskList ) + { + /* The task being queried is referenced from the suspended + * list. Is it genuinely suspended or is it blocked + * indefinitely? */ + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ) + { + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + { + BaseType_t x; + + /* The task does not appear on the event list item of + * and of the RTOS objects, but could still be in the + * blocked state if it is waiting on its notification + * rather than waiting on an object. If not, is + * suspended. */ + eReturn = eSuspended; + + for( x = 0; x < configTASK_NOTIFICATION_ARRAY_ENTRIES; x++ ) + { + if( pxTCB->ucNotifyState[ x ] == taskWAITING_NOTIFICATION ) + { + eReturn = eBlocked; + break; + } + } + } + #else /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ + { + eReturn = eSuspended; + } + #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ + } + else + { + eReturn = eBlocked; + } + } + #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */ + + #if ( INCLUDE_vTaskDelete == 1 ) + else if( ( pxStateList == &xTasksWaitingTermination ) || ( pxStateList == NULL ) ) + { + /* The task being queried is referenced from the deleted + * tasks list, or it is not referenced from any lists at + * all. */ + eReturn = eDeleted; + } + #endif + + else /*lint !e525 Negative indentation is intended to make use of pre-processor clearer. */ + { + /* If the task is not in any other state, it must be in the + * Ready (including pending ready) state. */ + eReturn = eReady; + } + } + + return eReturn; + } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */ + +#endif /* INCLUDE_eTaskGetState */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_uxTaskPriorityGet == 1 ) + + UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) + { + TCB_t const * pxTCB; + UBaseType_t uxReturn; + + taskENTER_CRITICAL(); + { + /* If null is passed in here then it is the priority of the task + * that called uxTaskPriorityGet() that is being queried. */ + pxTCB = prvGetTCBFromHandle( xTask ); + uxReturn = pxTCB->uxPriority; + } + taskEXIT_CRITICAL(); + + return uxReturn; + } + +#endif /* INCLUDE_uxTaskPriorityGet */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_uxTaskPriorityGet == 1 ) + + UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) + { + TCB_t const * pxTCB; + UBaseType_t uxReturn, uxSavedInterruptState; + + /* RTOS ports that support interrupt nesting have the concept of a + * maximum system call (or maximum API call) interrupt priority. + * Interrupts that are above the maximum system call priority are keep + * permanently enabled, even when the RTOS kernel is in a critical section, + * but cannot make any calls to FreeRTOS API functions. If configASSERT() + * is defined in FreeRTOSConfig.h then + * portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has + * been assigned a priority above the configured maximum system call + * priority. Only FreeRTOS functions that end in FromISR can be called + * from interrupts that have been assigned a priority at or (logically) + * below the maximum system call interrupt priority. FreeRTOS maintains a + * separate interrupt safe API to ensure interrupt entry is as fast and as + * simple as possible. More information (albeit Cortex-M specific) is + * provided on the following link: + * https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + uxSavedInterruptState = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* If null is passed in here then it is the priority of the calling + * task that is being queried. */ + pxTCB = prvGetTCBFromHandle( xTask ); + uxReturn = pxTCB->uxPriority; + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptState ); + + return uxReturn; + } + +#endif /* INCLUDE_uxTaskPriorityGet */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskPrioritySet == 1 ) + + void vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) + { + TCB_t * pxTCB; + UBaseType_t uxCurrentBasePriority, uxPriorityUsedOnEntry; + BaseType_t xYieldRequired = pdFALSE; + + configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) ); + + /* Ensure the new priority is valid. */ + if( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + { + uxNewPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + taskENTER_CRITICAL(); + { + /* If null is passed in here then it is the priority of the calling + * task that is being changed. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + traceTASK_PRIORITY_SET( pxTCB, uxNewPriority ); + + #if ( configUSE_MUTEXES == 1 ) + { + uxCurrentBasePriority = pxTCB->uxBasePriority; + } + #else + { + uxCurrentBasePriority = pxTCB->uxPriority; + } + #endif + + if( uxCurrentBasePriority != uxNewPriority ) + { + /* The priority change may have readied a task of higher + * priority than the calling task. */ + if( uxNewPriority > uxCurrentBasePriority ) + { + if( pxTCB != pxCurrentTCB ) + { + /* The priority of a task other than the currently + * running task is being raised. Is the priority being + * raised above that of the running task? */ + if( uxNewPriority >= pxCurrentTCB->uxPriority ) + { + xYieldRequired = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + /* The priority of the running task is being raised, + * but the running task must already be the highest + * priority task able to run so no yield is required. */ + } + } + else if( pxTCB == pxCurrentTCB ) + { + /* Setting the priority of the running task down means + * there may now be another task of higher priority that + * is ready to execute. */ + xYieldRequired = pdTRUE; + } + else + { + /* Setting the priority of any other task down does not + * require a yield as the running task must be above the + * new priority of the task being modified. */ + } + + /* Remember the ready list the task might be referenced from + * before its uxPriority member is changed so the + * taskRESET_READY_PRIORITY() macro can function correctly. */ + uxPriorityUsedOnEntry = pxTCB->uxPriority; + + #if ( configUSE_MUTEXES == 1 ) + { + /* Only change the priority being used if the task is not + * currently using an inherited priority. */ + if( pxTCB->uxBasePriority == pxTCB->uxPriority ) + { + pxTCB->uxPriority = uxNewPriority; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The base priority gets set whatever. */ + pxTCB->uxBasePriority = uxNewPriority; + } + #else /* if ( configUSE_MUTEXES == 1 ) */ + { + pxTCB->uxPriority = uxNewPriority; + } + #endif /* if ( configUSE_MUTEXES == 1 ) */ + + /* Only reset the event list item value if the value is not + * being used for anything else. */ + if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) + { + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxNewPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* If the task is in the blocked or suspended list we need do + * nothing more than change its priority variable. However, if + * the task is in a ready list it needs to be removed and placed + * in the list appropriate to its new priority. */ + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE ) + { + /* The task is currently in its ready list - remove before + * adding it to it's new ready list. As we are in a critical + * section we can do this even if the scheduler is suspended. */ + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + /* It is known that the task is in its ready list so + * there is no need to check again and the port level + * reset macro can be called directly. */ + portRESET_READY_PRIORITY( uxPriorityUsedOnEntry, uxTopReadyPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + prvAddTaskToReadyList( pxTCB ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( xYieldRequired != pdFALSE ) + { + taskYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Remove compiler warning about unused variables when the port + * optimised task selection is not being used. */ + ( void ) uxPriorityUsedOnEntry; + } + } + taskEXIT_CRITICAL(); + } + +#endif /* INCLUDE_vTaskPrioritySet */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + + void vTaskSuspend( TaskHandle_t xTaskToSuspend ) + { + TCB_t * pxTCB; + + taskENTER_CRITICAL(); + { + /* If null is passed in here then it is the running task that is + * being suspended. */ + pxTCB = prvGetTCBFromHandle( xTaskToSuspend ); + + traceTASK_SUSPEND( pxTCB ); + + /* Remove task from the ready/delayed list and place in the + * suspended list. */ + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + taskRESET_READY_PRIORITY( pxTCB->uxPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Is the task waiting on an event also? */ + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xStateListItem ) ); + + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + { + BaseType_t x; + + for( x = 0; x < configTASK_NOTIFICATION_ARRAY_ENTRIES; x++ ) + { + if( pxTCB->ucNotifyState[ x ] == taskWAITING_NOTIFICATION ) + { + /* The task was blocked to wait for a notification, but is + * now suspended, so no notification was received. */ + pxTCB->ucNotifyState[ x ] = taskNOT_WAITING_NOTIFICATION; + } + } + } + #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ + } + taskEXIT_CRITICAL(); + + if( xSchedulerRunning != pdFALSE ) + { + /* Reset the next expected unblock time in case it referred to the + * task that is now in the Suspended state. */ + taskENTER_CRITICAL(); + { + prvResetNextTaskUnblockTime(); + } + taskEXIT_CRITICAL(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( pxTCB == pxCurrentTCB ) + { + if( xSchedulerRunning != pdFALSE ) + { + /* The current task has just been suspended. */ + configASSERT( uxSchedulerSuspended == 0 ); + portYIELD_WITHIN_API(); + } + else + { + /* The scheduler is not running, but the task that was pointed + * to by pxCurrentTCB has just been suspended and pxCurrentTCB + * must be adjusted to point to a different task. */ + if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) /*lint !e931 Right has no side effect, just volatile. */ + { + /* No other tasks are ready, so set pxCurrentTCB back to + * NULL so when the next task is created pxCurrentTCB will + * be set to point to it no matter what its relative priority + * is. */ + pxCurrentTCB = NULL; + } + else + { + vTaskSwitchContext(); + } + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* INCLUDE_vTaskSuspend */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + + static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) + { + BaseType_t xReturn = pdFALSE; + const TCB_t * const pxTCB = xTask; + + /* Accesses xPendingReadyList so must be called from a critical + * section. */ + + /* It does not make sense to check if the calling task is suspended. */ + configASSERT( xTask ); + + /* Is the task being resumed actually in the suspended list? */ + if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xStateListItem ) ) != pdFALSE ) + { + /* Has the task already been resumed from within an ISR? */ + if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE ) + { + /* Is it in the suspended list because it is in the Suspended + * state, or because is is blocked with no timeout? */ + if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE ) /*lint !e961. The cast is only redundant when NULL is used. */ + { + xReturn = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xReturn; + } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */ + +#endif /* INCLUDE_vTaskSuspend */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + + void vTaskResume( TaskHandle_t xTaskToResume ) + { + TCB_t * const pxTCB = xTaskToResume; + + /* It does not make sense to resume the calling task. */ + configASSERT( xTaskToResume ); + + /* The parameter cannot be NULL as it is impossible to resume the + * currently executing task. */ + if( ( pxTCB != pxCurrentTCB ) && ( pxTCB != NULL ) ) + { + taskENTER_CRITICAL(); + { + if( prvTaskIsTaskSuspended( pxTCB ) != pdFALSE ) + { + traceTASK_RESUME( pxTCB ); + + /* The ready list can be accessed even if the scheduler is + * suspended because this is inside a critical section. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxTCB ); + + /* A higher priority task may have just been resumed. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + { + /* This yield may not cause the task just resumed to run, + * but will leave the lists in the correct state for the + * next yield. */ + taskYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* INCLUDE_vTaskSuspend */ + +/*-----------------------------------------------------------*/ + +#if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) + + BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) + { + BaseType_t xYieldRequired = pdFALSE; + TCB_t * const pxTCB = xTaskToResume; + UBaseType_t uxSavedInterruptStatus; + + configASSERT( xTaskToResume ); + + /* RTOS ports that support interrupt nesting have the concept of a + * maximum system call (or maximum API call) interrupt priority. + * Interrupts that are above the maximum system call priority are keep + * permanently enabled, even when the RTOS kernel is in a critical section, + * but cannot make any calls to FreeRTOS API functions. If configASSERT() + * is defined in FreeRTOSConfig.h then + * portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has + * been assigned a priority above the configured maximum system call + * priority. Only FreeRTOS functions that end in FromISR can be called + * from interrupts that have been assigned a priority at or (logically) + * below the maximum system call interrupt priority. FreeRTOS maintains a + * separate interrupt safe API to ensure interrupt entry is as fast and as + * simple as possible. More information (albeit Cortex-M specific) is + * provided on the following link: + * https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + if( prvTaskIsTaskSuspended( pxTCB ) != pdFALSE ) + { + traceTASK_RESUME_FROM_ISR( pxTCB ); + + /* Check the ready lists can be accessed. */ + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + { + /* Ready lists can be accessed so move the task from the + * suspended list to the ready list directly. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + { + xYieldRequired = pdTRUE; + + /* Mark that a yield is pending in case the user is not + * using the return value to initiate a context switch + * from the ISR using portYIELD_FROM_ISR. */ + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxTCB ); + } + else + { + /* The delayed or ready lists cannot be accessed so the task + * is held in the pending ready list until the scheduler is + * unsuspended. */ + vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xYieldRequired; + } + +#endif /* ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) */ +/*-----------------------------------------------------------*/ + +void vTaskStartScheduler( void ) +{ + BaseType_t xReturn; + + /* Add the idle task at the lowest priority. */ + #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + StaticTask_t * pxIdleTaskTCBBuffer = NULL; + StackType_t * pxIdleTaskStackBuffer = NULL; + uint32_t ulIdleTaskStackSize; + + /* The Idle task is created using user provided RAM - obtain the + * address of the RAM then create the idle task. */ + vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize ); + xIdleTaskHandle = xTaskCreateStatic( prvIdleTask, + configIDLE_TASK_NAME, + ulIdleTaskStackSize, + ( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */ + portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */ + pxIdleTaskStackBuffer, + pxIdleTaskTCBBuffer ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ + + if( xIdleTaskHandle != NULL ) + { + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + } + } + #else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ + { + /* The Idle task is being created using dynamically allocated RAM. */ + xReturn = xTaskCreate( prvIdleTask, + configIDLE_TASK_NAME, + configMINIMAL_STACK_SIZE, + ( void * ) NULL, + portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */ + &xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ + } + #endif /* configSUPPORT_STATIC_ALLOCATION */ + + #if ( configUSE_TIMERS == 1 ) + { + if( xReturn == pdPASS ) + { + xReturn = xTimerCreateTimerTask(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_TIMERS */ + + if( xReturn == pdPASS ) + { + /* freertos_tasks_c_additions_init() should only be called if the user + * definable macro FREERTOS_TASKS_C_ADDITIONS_INIT() is defined, as that is + * the only macro called by the function. */ + #ifdef FREERTOS_TASKS_C_ADDITIONS_INIT + { + freertos_tasks_c_additions_init(); + } + #endif + + /* Interrupts are turned off here, to ensure a tick does not occur + * before or during the call to xPortStartScheduler(). The stacks of + * the created tasks contain a status word with interrupts switched on + * so interrupts will automatically get re-enabled when the first task + * starts to run. */ + portDISABLE_INTERRUPTS(); + + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + { + /* Switch Newlib's _impure_ptr variable to point to the _reent + * structure specific to the task that will run first. + * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html + * for additional information. */ + _impure_ptr = &( pxCurrentTCB->xNewLib_reent ); + } + #endif /* configUSE_NEWLIB_REENTRANT */ + + xNextTaskUnblockTime = portMAX_DELAY; + xSchedulerRunning = pdTRUE; + xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT; + + /* If configGENERATE_RUN_TIME_STATS is defined then the following + * macro must be defined to configure the timer/counter used to generate + * the run time counter time base. NOTE: If configGENERATE_RUN_TIME_STATS + * is set to 0 and the following line fails to build then ensure you do not + * have portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() defined in your + * FreeRTOSConfig.h file. */ + portCONFIGURE_TIMER_FOR_RUN_TIME_STATS(); + + traceTASK_SWITCHED_IN(); + + /* Setting up the timer tick is hardware specific and thus in the + * portable interface. */ + if( xPortStartScheduler() != pdFALSE ) + { + /* Should not reach here as if the scheduler is running the + * function will not return. */ + } + else + { + /* Should only reach here if a task calls xTaskEndScheduler(). */ + } + } + else + { + /* This line will only be reached if the kernel could not be started, + * because there was not enough FreeRTOS heap to create the idle task + * or the timer task. */ + configASSERT( xReturn != errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ); + } + + /* Prevent compiler warnings if INCLUDE_xTaskGetIdleTaskHandle is set to 0, + * meaning xIdleTaskHandle is not used anywhere else. */ + ( void ) xIdleTaskHandle; + + /* OpenOCD makes use of uxTopUsedPriority for thread debugging. Prevent uxTopUsedPriority + * from getting optimized out as it is no longer used by the kernel. */ + ( void ) uxTopUsedPriority; +} +/*-----------------------------------------------------------*/ + +void vTaskEndScheduler( void ) +{ + /* Stop the scheduler interrupts and call the portable scheduler end + * routine so the original ISRs can be restored if necessary. The port + * layer must ensure interrupts enable bit is left in the correct state. */ + portDISABLE_INTERRUPTS(); + xSchedulerRunning = pdFALSE; + vPortEndScheduler(); +} +/*----------------------------------------------------------*/ + +void vTaskSuspendAll( void ) +{ + /* A critical section is not required as the variable is of type + * BaseType_t. Please read Richard Barry's reply in the following link to a + * post in the FreeRTOS support forum before reporting this as a bug! - + * https://goo.gl/wu4acr */ + + /* portSOFRWARE_BARRIER() is only implemented for emulated/simulated ports that + * do not otherwise exhibit real time behaviour. */ + portSOFTWARE_BARRIER(); + + /* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment + * is used to allow calls to vTaskSuspendAll() to nest. */ + ++uxSchedulerSuspended; + + /* Enforces ordering for ports and optimised compilers that may otherwise place + * the above increment elsewhere. */ + portMEMORY_BARRIER(); +} +/*----------------------------------------------------------*/ + +#if ( configUSE_TICKLESS_IDLE != 0 ) + + static TickType_t prvGetExpectedIdleTime( void ) + { + TickType_t xReturn; + UBaseType_t uxHigherPriorityReadyTasks = pdFALSE; + + /* uxHigherPriorityReadyTasks takes care of the case where + * configUSE_PREEMPTION is 0, so there may be tasks above the idle priority + * task that are in the Ready state, even though the idle task is + * running. */ + #if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) + { + if( uxTopReadyPriority > tskIDLE_PRIORITY ) + { + uxHigherPriorityReadyTasks = pdTRUE; + } + } + #else + { + const UBaseType_t uxLeastSignificantBit = ( UBaseType_t ) 0x01; + + /* When port optimised task selection is used the uxTopReadyPriority + * variable is used as a bit map. If bits other than the least + * significant bit are set then there are tasks that have a priority + * above the idle priority that are in the Ready state. This takes + * care of the case where the co-operative scheduler is in use. */ + if( uxTopReadyPriority > uxLeastSignificantBit ) + { + uxHigherPriorityReadyTasks = pdTRUE; + } + } + #endif /* if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) */ + + if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY ) + { + xReturn = 0; + } + else if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1 ) + { + /* There are other idle priority tasks in the ready state. If + * time slicing is used then the very next tick interrupt must be + * processed. */ + xReturn = 0; + } + else if( uxHigherPriorityReadyTasks != pdFALSE ) + { + /* There are tasks in the Ready state that have a priority above the + * idle priority. This path can only be reached if + * configUSE_PREEMPTION is 0. */ + xReturn = 0; + } + else + { + xReturn = xNextTaskUnblockTime - xTickCount; + } + + return xReturn; + } + +#endif /* configUSE_TICKLESS_IDLE */ +/*----------------------------------------------------------*/ + +BaseType_t xTaskResumeAll( void ) +{ + TCB_t * pxTCB = NULL; + BaseType_t xAlreadyYielded = pdFALSE; + + /* If uxSchedulerSuspended is zero then this function does not match a + * previous call to vTaskSuspendAll(). */ + configASSERT( uxSchedulerSuspended ); + + /* It is possible that an ISR caused a task to be removed from an event + * list while the scheduler was suspended. If this was the case then the + * removed task will have been added to the xPendingReadyList. Once the + * scheduler has been resumed it is safe to move all the pending ready + * tasks from this list into their appropriate ready list. */ + taskENTER_CRITICAL(); + { + --uxSchedulerSuspended; + + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + { + if( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U ) + { + /* Move any readied tasks from the pending list into the + * appropriate ready list. */ + while( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE ) + { + pxTCB = listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxTCB ); + + /* If the moved task has a priority higher than the current + * task then a yield must be performed. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + { + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + if( pxTCB != NULL ) + { + /* A task was unblocked while the scheduler was suspended, + * which may have prevented the next unblock time from being + * re-calculated, in which case re-calculate it now. Mainly + * important for low power tickless implementations, where + * this can prevent an unnecessary exit from low power + * state. */ + prvResetNextTaskUnblockTime(); + } + + /* If any ticks occurred while the scheduler was suspended then + * they should be processed now. This ensures the tick count does + * not slip, and that any delayed tasks are resumed at the correct + * time. */ + { + TickType_t xPendedCounts = xPendedTicks; /* Non-volatile copy. */ + + if( xPendedCounts > ( TickType_t ) 0U ) + { + do + { + if( xTaskIncrementTick() != pdFALSE ) + { + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + --xPendedCounts; + } while( xPendedCounts > ( TickType_t ) 0U ); + + xPendedTicks = 0; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + if( xYieldPending != pdFALSE ) + { + #if ( configUSE_PREEMPTION != 0 ) + { + xAlreadyYielded = pdTRUE; + } + #endif + taskYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + + return xAlreadyYielded; +} +/*-----------------------------------------------------------*/ + +TickType_t xTaskGetTickCount( void ) +{ + TickType_t xTicks; + + /* Critical section required if running on a 16 bit processor. */ + portTICK_TYPE_ENTER_CRITICAL(); + { + xTicks = xTickCount; + } + portTICK_TYPE_EXIT_CRITICAL(); + + return xTicks; +} +/*-----------------------------------------------------------*/ + +TickType_t xTaskGetTickCountFromISR( void ) +{ + TickType_t xReturn; + UBaseType_t uxSavedInterruptStatus; + + /* RTOS ports that support interrupt nesting have the concept of a maximum + * system call (or maximum API call) interrupt priority. Interrupts that are + * above the maximum system call priority are kept permanently enabled, even + * when the RTOS kernel is in a critical section, but cannot make any calls to + * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h + * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has been + * assigned a priority above the configured maximum system call priority. + * Only FreeRTOS functions that end in FromISR can be called from interrupts + * that have been assigned a priority at or (logically) below the maximum + * system call interrupt priority. FreeRTOS maintains a separate interrupt + * safe API to ensure interrupt entry is as fast and as simple as possible. + * More information (albeit Cortex-M specific) is provided on the following + * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + uxSavedInterruptStatus = portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR(); + { + xReturn = xTickCount; + } + portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +UBaseType_t uxTaskGetNumberOfTasks( void ) +{ + /* A critical section is not required because the variables are of type + * BaseType_t. */ + return uxCurrentNumberOfTasks; +} +/*-----------------------------------------------------------*/ + +char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +{ + TCB_t * pxTCB; + + /* If null is passed in here then the name of the calling task is being + * queried. */ + pxTCB = prvGetTCBFromHandle( xTaskToQuery ); + configASSERT( pxTCB ); + return &( pxTCB->pcTaskName[ 0 ] ); +} +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetHandle == 1 ) + + static TCB_t * prvSearchForNameWithinSingleList( List_t * pxList, + const char pcNameToQuery[] ) + { + TCB_t * pxNextTCB, * pxFirstTCB, * pxReturn = NULL; + UBaseType_t x; + char cNextChar; + BaseType_t xBreakLoop; + + /* This function is called with the scheduler suspended. */ + + if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + + do + { + listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + + /* Check each character in the name looking for a match or + * mismatch. */ + xBreakLoop = pdFALSE; + + for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ ) + { + cNextChar = pxNextTCB->pcTaskName[ x ]; + + if( cNextChar != pcNameToQuery[ x ] ) + { + /* Characters didn't match. */ + xBreakLoop = pdTRUE; + } + else if( cNextChar == ( char ) 0x00 ) + { + /* Both strings terminated, a match must have been + * found. */ + pxReturn = pxNextTCB; + xBreakLoop = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( xBreakLoop != pdFALSE ) + { + break; + } + } + + if( pxReturn != NULL ) + { + /* The handle has been found. */ + break; + } + } while( pxNextTCB != pxFirstTCB ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return pxReturn; + } + +#endif /* INCLUDE_xTaskGetHandle */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetHandle == 1 ) + + TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + { + UBaseType_t uxQueue = configMAX_PRIORITIES; + TCB_t * pxTCB; + + /* Task names will be truncated to configMAX_TASK_NAME_LEN - 1 bytes. */ + configASSERT( strlen( pcNameToQuery ) < configMAX_TASK_NAME_LEN ); + + vTaskSuspendAll(); + { + /* Search the ready lists. */ + do + { + uxQueue--; + pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) &( pxReadyTasksLists[ uxQueue ] ), pcNameToQuery ); + + if( pxTCB != NULL ) + { + /* Found the handle. */ + break; + } + } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + /* Search the delayed lists. */ + if( pxTCB == NULL ) + { + pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) pxDelayedTaskList, pcNameToQuery ); + } + + if( pxTCB == NULL ) + { + pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) pxOverflowDelayedTaskList, pcNameToQuery ); + } + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + if( pxTCB == NULL ) + { + /* Search the suspended list. */ + pxTCB = prvSearchForNameWithinSingleList( &xSuspendedTaskList, pcNameToQuery ); + } + } + #endif + + #if ( INCLUDE_vTaskDelete == 1 ) + { + if( pxTCB == NULL ) + { + /* Search the deleted list. */ + pxTCB = prvSearchForNameWithinSingleList( &xTasksWaitingTermination, pcNameToQuery ); + } + } + #endif + } + ( void ) xTaskResumeAll(); + + return pxTCB; + } + +#endif /* INCLUDE_xTaskGetHandle */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) + { + UBaseType_t uxTask = 0, uxQueue = configMAX_PRIORITIES; + + vTaskSuspendAll(); + { + /* Is there a space in the array for each task in the system? */ + if( uxArraySize >= uxCurrentNumberOfTasks ) + { + /* Fill in an TaskStatus_t structure with information on each + * task in the Ready state. */ + do + { + uxQueue--; + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady ); + } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + /* Fill in an TaskStatus_t structure with information on each + * task in the Blocked state. */ + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked ); + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked ); + + #if ( INCLUDE_vTaskDelete == 1 ) + { + /* Fill in an TaskStatus_t structure with information on + * each task that has been deleted but not yet cleaned up. */ + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted ); + } + #endif + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + /* Fill in an TaskStatus_t structure with information on + * each task in the Suspended state. */ + uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended ); + } + #endif + + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + { + if( pulTotalRunTime != NULL ) + { + #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE + portALT_GET_RUN_TIME_COUNTER_VALUE( ( *pulTotalRunTime ) ); + #else + *pulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); + #endif + } + } + #else /* if ( configGENERATE_RUN_TIME_STATS == 1 ) */ + { + if( pulTotalRunTime != NULL ) + { + *pulTotalRunTime = 0; + } + } + #endif /* if ( configGENERATE_RUN_TIME_STATS == 1 ) */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + ( void ) xTaskResumeAll(); + + return uxTask; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) + + TaskHandle_t xTaskGetIdleTaskHandle( void ) + { + /* If xTaskGetIdleTaskHandle() is called before the scheduler has been + * started, then xIdleTaskHandle will be NULL. */ + configASSERT( ( xIdleTaskHandle != NULL ) ); + return xIdleTaskHandle; + } + +#endif /* INCLUDE_xTaskGetIdleTaskHandle */ +/*----------------------------------------------------------*/ + +/* This conditional compilation should use inequality to 0, not equality to 1. + * This is to ensure vTaskStepTick() is available when user defined low power mode + * implementations require configUSE_TICKLESS_IDLE to be set to a value other than + * 1. */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + + void vTaskStepTick( const TickType_t xTicksToJump ) + { + /* Correct the tick count value after a period during which the tick + * was suppressed. Note this does *not* call the tick hook function for + * each stepped tick. */ + configASSERT( ( xTickCount + xTicksToJump ) <= xNextTaskUnblockTime ); + xTickCount += xTicksToJump; + traceINCREASE_TICK_COUNT( xTicksToJump ); + } + +#endif /* configUSE_TICKLESS_IDLE */ +/*----------------------------------------------------------*/ + +BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) +{ + BaseType_t xYieldOccurred; + + /* Must not be called with the scheduler suspended as the implementation + * relies on xPendedTicks being wound down to 0 in xTaskResumeAll(). */ + configASSERT( uxSchedulerSuspended == 0 ); + + /* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occurring when + * the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */ + vTaskSuspendAll(); + xPendedTicks += xTicksToCatchUp; + xYieldOccurred = xTaskResumeAll(); + + return xYieldOccurred; +} +/*----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskAbortDelay == 1 ) + + BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) + { + TCB_t * pxTCB = xTask; + BaseType_t xReturn; + + configASSERT( pxTCB ); + + vTaskSuspendAll(); + { + /* A task can only be prematurely removed from the Blocked state if + * it is actually in the Blocked state. */ + if( eTaskGetState( xTask ) == eBlocked ) + { + xReturn = pdPASS; + + /* Remove the reference to the task from the blocked list. An + * interrupt won't touch the xStateListItem because the + * scheduler is suspended. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + + /* Is the task waiting on an event also? If so remove it from + * the event list too. Interrupts can touch the event list item, + * even though the scheduler is suspended, so a critical section + * is used. */ + taskENTER_CRITICAL(); + { + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + + /* This lets the task know it was forcibly removed from the + * blocked state so it should not re-evaluate its block time and + * then block again. */ + pxTCB->ucDelayAborted = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + + /* Place the unblocked task into the appropriate ready list. */ + prvAddTaskToReadyList( pxTCB ); + + /* A task being unblocked cannot cause an immediate context + * switch if preemption is turned off. */ + #if ( configUSE_PREEMPTION == 1 ) + { + /* Preemption is on, but a context switch should only be + * performed if the unblocked task has a priority that is + * equal to or higher than the currently executing task. */ + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + /* Pend the yield to be performed when the scheduler + * is unsuspended. */ + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_PREEMPTION */ + } + else + { + xReturn = pdFAIL; + } + } + ( void ) xTaskResumeAll(); + + return xReturn; + } + +#endif /* INCLUDE_xTaskAbortDelay */ +/*----------------------------------------------------------*/ + +BaseType_t xTaskIncrementTick( void ) +{ + TCB_t * pxTCB; + TickType_t xItemValue; + BaseType_t xSwitchRequired = pdFALSE; + + /* Called by the portable layer each time a tick interrupt occurs. + * Increments the tick then checks to see if the new tick value will cause any + * tasks to be unblocked. */ + traceTASK_INCREMENT_TICK( xTickCount ); + + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + { + /* Minor optimisation. The tick count cannot change in this + * block. */ + const TickType_t xConstTickCount = xTickCount + ( TickType_t ) 1; + + /* Increment the RTOS tick, switching the delayed and overflowed + * delayed lists if it wraps to 0. */ + xTickCount = xConstTickCount; + + if( xConstTickCount == ( TickType_t ) 0U ) /*lint !e774 'if' does not always evaluate to false as it is looking for an overflow. */ + { + taskSWITCH_DELAYED_LISTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* See if this tick has made a timeout expire. Tasks are stored in + * the queue in the order of their wake time - meaning once one task + * has been found whose block time has not expired there is no need to + * look any further down the list. */ + if( xConstTickCount >= xNextTaskUnblockTime ) + { + for( ; ; ) + { + if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) + { + /* The delayed list is empty. Set xNextTaskUnblockTime + * to the maximum possible value so it is extremely + * unlikely that the + * if( xTickCount >= xNextTaskUnblockTime ) test will pass + * next time through. */ + xNextTaskUnblockTime = portMAX_DELAY; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + break; + } + else + { + /* The delayed list is not empty, get the value of the + * item at the head of the delayed list. This is the time + * at which the task at the head of the delayed list must + * be removed from the Blocked state. */ + pxTCB = listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xStateListItem ) ); + + if( xConstTickCount < xItemValue ) + { + /* It is not time to unblock this item yet, but the + * item value is the time at which the task at the head + * of the blocked list must be removed from the Blocked + * state - so record the item value in + * xNextTaskUnblockTime. */ + xNextTaskUnblockTime = xItemValue; + break; /*lint !e9011 Code structure here is deedmed easier to understand with multiple breaks. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* It is time to remove the item from the Blocked state. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + + /* Is the task waiting on an event also? If so remove + * it from the event list. */ + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Place the unblocked task into the appropriate ready + * list. */ + prvAddTaskToReadyList( pxTCB ); + + /* A task being unblocked cannot cause an immediate + * context switch if preemption is turned off. */ + #if ( configUSE_PREEMPTION == 1 ) + { + /* Preemption is on, but a context switch should + * only be performed if the unblocked task has a + * priority that is equal to or higher than the + * currently executing task. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + { + xSwitchRequired = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_PREEMPTION */ + } + } + } + + /* Tasks of equal priority to the currently running task will share + * processing time (time slice) if preemption is on, and the application + * writer has not explicitly turned time slicing off. */ + #if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) + { + if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 ) + { + xSwitchRequired = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */ + + #if ( configUSE_TICK_HOOK == 1 ) + { + /* Guard against the tick hook being called when the pended tick + * count is being unwound (when the scheduler is being unlocked). */ + if( xPendedTicks == ( TickType_t ) 0 ) + { + vApplicationTickHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_TICK_HOOK */ + + #if ( configUSE_PREEMPTION == 1 ) + { + if( xYieldPending != pdFALSE ) + { + xSwitchRequired = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_PREEMPTION */ + } + else + { + ++xPendedTicks; + + /* The tick hook gets called at regular intervals, even if the + * scheduler is locked. */ + #if ( configUSE_TICK_HOOK == 1 ) + { + vApplicationTickHook(); + } + #endif + } + + return xSwitchRequired; +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + + void vTaskSetApplicationTaskTag( TaskHandle_t xTask, + TaskHookFunction_t pxHookFunction ) + { + TCB_t * xTCB; + + /* If xTask is NULL then it is the task hook of the calling task that is + * getting set. */ + if( xTask == NULL ) + { + xTCB = ( TCB_t * ) pxCurrentTCB; + } + else + { + xTCB = xTask; + } + + /* Save the hook function in the TCB. A critical section is required as + * the value can be accessed from an interrupt. */ + taskENTER_CRITICAL(); + { + xTCB->pxTaskTag = pxHookFunction; + } + taskEXIT_CRITICAL(); + } + +#endif /* configUSE_APPLICATION_TASK_TAG */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + + TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) + { + TCB_t * pxTCB; + TaskHookFunction_t xReturn; + + /* If xTask is NULL then set the calling task's hook. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + /* Save the hook function in the TCB. A critical section is required as + * the value can be accessed from an interrupt. */ + taskENTER_CRITICAL(); + { + xReturn = pxTCB->pxTaskTag; + } + taskEXIT_CRITICAL(); + + return xReturn; + } + +#endif /* configUSE_APPLICATION_TASK_TAG */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + + TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) + { + TCB_t * pxTCB; + TaskHookFunction_t xReturn; + UBaseType_t uxSavedInterruptStatus; + + /* If xTask is NULL then set the calling task's hook. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + /* Save the hook function in the TCB. A critical section is required as + * the value can be accessed from an interrupt. */ + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + xReturn = pxTCB->pxTaskTag; + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; + } + +#endif /* configUSE_APPLICATION_TASK_TAG */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + + BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) + { + TCB_t * xTCB; + BaseType_t xReturn; + + /* If xTask is NULL then we are calling our own task hook. */ + if( xTask == NULL ) + { + xTCB = pxCurrentTCB; + } + else + { + xTCB = xTask; + } + + if( xTCB->pxTaskTag != NULL ) + { + xReturn = xTCB->pxTaskTag( pvParameter ); + } + else + { + xReturn = pdFAIL; + } + + return xReturn; + } + +#endif /* configUSE_APPLICATION_TASK_TAG */ +/*-----------------------------------------------------------*/ + +void vTaskSwitchContext( void ) +{ + if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE ) + { + /* The scheduler is currently suspended - do not allow a context + * switch. */ + xYieldPending = pdTRUE; + } + else + { + xYieldPending = pdFALSE; + traceTASK_SWITCHED_OUT(); + + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + { + #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE + portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime ); + #else + ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); + #endif + + /* Add the amount of time the task has been running to the + * accumulated time so far. The time the task started running was + * stored in ulTaskSwitchedInTime. Note that there is no overflow + * protection here so count values are only valid until the timer + * overflows. The guard against negative values is to protect + * against suspect run time stat counter implementations - which + * are provided by the application, not the kernel. */ + if( ulTotalRunTime > ulTaskSwitchedInTime ) + { + pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + ulTaskSwitchedInTime = ulTotalRunTime; + } + #endif /* configGENERATE_RUN_TIME_STATS */ + + /* Check for stack overflow, if configured. */ + taskCHECK_FOR_STACK_OVERFLOW(); + + /* Before the currently running task is switched out, save its errno. */ + #if ( configUSE_POSIX_ERRNO == 1 ) + { + pxCurrentTCB->iTaskErrno = FreeRTOS_errno; + } + #endif + + /* Select a new task to run using either the generic C or port + * optimised asm code. */ + taskSELECT_HIGHEST_PRIORITY_TASK(); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + traceTASK_SWITCHED_IN(); + + /* After the new task is switched in, update the global errno. */ + #if ( configUSE_POSIX_ERRNO == 1 ) + { + FreeRTOS_errno = pxCurrentTCB->iTaskErrno; + } + #endif + + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + { + /* Switch Newlib's _impure_ptr variable to point to the _reent + * structure specific to this task. + * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html + * for additional information. */ + _impure_ptr = &( pxCurrentTCB->xNewLib_reent ); + } + #endif /* configUSE_NEWLIB_REENTRANT */ + } +} +/*-----------------------------------------------------------*/ + +void vTaskPlaceOnEventList( List_t * const pxEventList, + const TickType_t xTicksToWait ) +{ + configASSERT( pxEventList ); + + /* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE + * SCHEDULER SUSPENDED AND THE QUEUE BEING ACCESSED LOCKED. */ + + /* Place the event list item of the TCB in the appropriate event list. + * This is placed in the list in priority order so the highest priority task + * is the first to be woken by the event. The queue that contains the event + * list is locked, preventing simultaneous access from interrupts. */ + vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) ); + + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); +} +/*-----------------------------------------------------------*/ + +void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, + const TickType_t xItemValue, + const TickType_t xTicksToWait ) +{ + configASSERT( pxEventList ); + + /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by + * the event groups implementation. */ + configASSERT( uxSchedulerSuspended != 0 ); + + /* Store the item value in the event list item. It is safe to access the + * event list item here as interrupts won't access the event list item of a + * task that is not in the Blocked state. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE ); + + /* Place the event list item of the TCB at the end of the appropriate event + * list. It is safe to access the event list here because it is part of an + * event group implementation - and interrupts don't access event groups + * directly (instead they access them indirectly by pending function calls to + * the task level). */ + vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); + + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_TIMERS == 1 ) + + void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) + { + configASSERT( pxEventList ); + + /* This function should not be called by application code hence the + * 'Restricted' in its name. It is not part of the public API. It is + * designed for use by kernel code, and has special calling requirements - + * it should be called with the scheduler suspended. */ + + + /* Place the event list item of the TCB in the appropriate event list. + * In this case it is assume that this is the only task that is going to + * be waiting on this event list, so the faster vListInsertEnd() function + * can be used in place of vListInsert. */ + vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); + + /* If the task should block indefinitely then set the block time to a + * value that will be recognised as an indefinite delay inside the + * prvAddCurrentTaskToDelayedList() function. */ + if( xWaitIndefinitely != pdFALSE ) + { + xTicksToWait = portMAX_DELAY; + } + + traceTASK_DELAY_UNTIL( ( xTickCount + xTicksToWait ) ); + prvAddCurrentTaskToDelayedList( xTicksToWait, xWaitIndefinitely ); + } + +#endif /* configUSE_TIMERS */ +/*-----------------------------------------------------------*/ + +BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) +{ + TCB_t * pxUnblockedTCB; + BaseType_t xReturn; + + /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION. It can also be + * called from a critical section within an ISR. */ + + /* The event list is sorted in priority order, so the first in the list can + * be removed as it is known to be the highest priority. Remove the TCB from + * the delayed list, and add it to the ready list. + * + * If an event is for a queue that is locked then this function will never + * get called - the lock count on the queue will get modified instead. This + * means exclusive access to the event list is guaranteed here. + * + * This function assumes that a check has already been made to ensure that + * pxEventList is not empty. */ + pxUnblockedTCB = listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + configASSERT( pxUnblockedTCB ); + ( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) ); + + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + { + ( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxUnblockedTCB ); + + #if ( configUSE_TICKLESS_IDLE != 0 ) + { + /* If a task is blocked on a kernel object then xNextTaskUnblockTime + * might be set to the blocked task's time out time. If the task is + * unblocked for a reason other than a timeout xNextTaskUnblockTime is + * normally left unchanged, because it is automatically reset to a new + * value when the tick count equals xNextTaskUnblockTime. However if + * tickless idling is used it might be more important to enter sleep mode + * at the earliest possible time - so reset xNextTaskUnblockTime here to + * ensure it is updated at the earliest possible time. */ + prvResetNextTaskUnblockTime(); + } + #endif + } + else + { + /* The delayed and ready lists cannot be accessed, so hold this task + * pending until the scheduler is resumed. */ + vListInsertEnd( &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) ); + } + + if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + /* Return true if the task removed from the event list has a higher + * priority than the calling task. This allows the calling task to know if + * it should force a context switch now. */ + xReturn = pdTRUE; + + /* Mark that a yield is pending in case the user is not using the + * "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */ + xYieldPending = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, + const TickType_t xItemValue ) +{ + TCB_t * pxUnblockedTCB; + + /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by + * the event flags implementation. */ + configASSERT( uxSchedulerSuspended != pdFALSE ); + + /* Store the new item value in the event list. */ + listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE ); + + /* Remove the event list form the event flag. Interrupts do not access + * event flags. */ + pxUnblockedTCB = listGET_LIST_ITEM_OWNER( pxEventListItem ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + configASSERT( pxUnblockedTCB ); + ( void ) uxListRemove( pxEventListItem ); + + #if ( configUSE_TICKLESS_IDLE != 0 ) + { + /* If a task is blocked on a kernel object then xNextTaskUnblockTime + * might be set to the blocked task's time out time. If the task is + * unblocked for a reason other than a timeout xNextTaskUnblockTime is + * normally left unchanged, because it is automatically reset to a new + * value when the tick count equals xNextTaskUnblockTime. However if + * tickless idling is used it might be more important to enter sleep mode + * at the earliest possible time - so reset xNextTaskUnblockTime here to + * ensure it is updated at the earliest possible time. */ + prvResetNextTaskUnblockTime(); + } + #endif + + /* Remove the task from the delayed list and add it to the ready list. The + * scheduler is suspended so interrupts will not be accessing the ready + * lists. */ + ( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxUnblockedTCB ); + + if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + /* The unblocked task has a priority above that of the calling task, so + * a context switch is required. This function is called with the + * scheduler suspended so xYieldPending is set so the context switch + * occurs immediately that the scheduler is resumed (unsuspended). */ + xYieldPending = pdTRUE; + } +} +/*-----------------------------------------------------------*/ + +void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) +{ + configASSERT( pxTimeOut ); + taskENTER_CRITICAL(); + { + pxTimeOut->xOverflowCount = xNumOfOverflows; + pxTimeOut->xTimeOnEntering = xTickCount; + } + taskEXIT_CRITICAL(); +} +/*-----------------------------------------------------------*/ + +void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) +{ + /* For internal use only as it does not use a critical section. */ + pxTimeOut->xOverflowCount = xNumOfOverflows; + pxTimeOut->xTimeOnEntering = xTickCount; +} +/*-----------------------------------------------------------*/ + +BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) +{ + BaseType_t xReturn; + + configASSERT( pxTimeOut ); + configASSERT( pxTicksToWait ); + + taskENTER_CRITICAL(); + { + /* Minor optimisation. The tick count cannot change in this block. */ + const TickType_t xConstTickCount = xTickCount; + const TickType_t xElapsedTime = xConstTickCount - pxTimeOut->xTimeOnEntering; + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + if( pxCurrentTCB->ucDelayAborted != ( uint8_t ) pdFALSE ) + { + /* The delay was aborted, which is not the same as a time out, + * but has the same result. */ + pxCurrentTCB->ucDelayAborted = pdFALSE; + xReturn = pdTRUE; + } + else + #endif + + #if ( INCLUDE_vTaskSuspend == 1 ) + if( *pxTicksToWait == portMAX_DELAY ) + { + /* If INCLUDE_vTaskSuspend is set to 1 and the block time + * specified is the maximum block time then the task should block + * indefinitely, and therefore never time out. */ + xReturn = pdFALSE; + } + else + #endif + + if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */ + { + /* The tick count is greater than the time at which + * vTaskSetTimeout() was called, but has also overflowed since + * vTaskSetTimeOut() was called. It must have wrapped all the way + * around and gone past again. This passed since vTaskSetTimeout() + * was called. */ + xReturn = pdTRUE; + *pxTicksToWait = ( TickType_t ) 0; + } + else if( xElapsedTime < *pxTicksToWait ) /*lint !e961 Explicit casting is only redundant with some compilers, whereas others require it to prevent integer conversion errors. */ + { + /* Not a genuine timeout. Adjust parameters for time remaining. */ + *pxTicksToWait -= xElapsedTime; + vTaskInternalSetTimeOutState( pxTimeOut ); + xReturn = pdFALSE; + } + else + { + *pxTicksToWait = ( TickType_t ) 0; + xReturn = pdTRUE; + } + } + taskEXIT_CRITICAL(); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +void vTaskMissedYield( void ) +{ + xYieldPending = pdTRUE; +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) + { + UBaseType_t uxReturn; + TCB_t const * pxTCB; + + if( xTask != NULL ) + { + pxTCB = xTask; + uxReturn = pxTCB->uxTaskNumber; + } + else + { + uxReturn = 0U; + } + + return uxReturn; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + void vTaskSetTaskNumber( TaskHandle_t xTask, + const UBaseType_t uxHandle ) + { + TCB_t * pxTCB; + + if( xTask != NULL ) + { + pxTCB = xTask; + pxTCB->uxTaskNumber = uxHandle; + } + } + +#endif /* configUSE_TRACE_FACILITY */ + +/* + * ----------------------------------------------------------- + * The Idle task. + * ---------------------------------------------------------- + * + * The portTASK_FUNCTION() macro is used to allow port/compiler specific + * language extensions. The equivalent prototype for this function is: + * + * void prvIdleTask( void *pvParameters ); + * + */ +static portTASK_FUNCTION( prvIdleTask, pvParameters ) +{ + /* Stop warnings. */ + ( void ) pvParameters; + + /** THIS IS THE RTOS IDLE TASK - WHICH IS CREATED AUTOMATICALLY WHEN THE + * SCHEDULER IS STARTED. **/ + + /* In case a task that has a secure context deletes itself, in which case + * the idle task is responsible for deleting the task's secure context, if + * any. */ + portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE ); + + for( ; ; ) + { + /* See if any tasks have deleted themselves - if so then the idle task + * is responsible for freeing the deleted task's TCB and stack. */ + prvCheckTasksWaitingTermination(); + + #if ( configUSE_PREEMPTION == 0 ) + { + /* If we are not using preemption we keep forcing a task switch to + * see if any other task has become available. If we are using + * preemption we don't need to do this as any task becoming available + * will automatically get the processor anyway. */ + taskYIELD(); + } + #endif /* configUSE_PREEMPTION */ + + #if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) + { + /* When using preemption tasks of equal priority will be + * timesliced. If a task that is sharing the idle priority is ready + * to run then the idle task should yield before the end of the + * timeslice. + * + * A critical region is not required here as we are just reading from + * the list, and an occasional incorrect value will not matter. If + * the ready list at the idle priority contains more than one task + * then a task other than the idle task is ready to execute. */ + if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 ) + { + taskYIELD(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */ + + #if ( configUSE_IDLE_HOOK == 1 ) + { + extern void vApplicationIdleHook( void ); + + /* Call the user defined function from within the idle task. This + * allows the application designer to add background functionality + * without the overhead of a separate task. + * NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, + * CALL A FUNCTION THAT MIGHT BLOCK. */ + vApplicationIdleHook(); + } + #endif /* configUSE_IDLE_HOOK */ + + /* This conditional compilation should use inequality to 0, not equality + * to 1. This is to ensure portSUPPRESS_TICKS_AND_SLEEP() is called when + * user defined low power mode implementations require + * configUSE_TICKLESS_IDLE to be set to a value other than 1. */ + #if ( configUSE_TICKLESS_IDLE != 0 ) + { + TickType_t xExpectedIdleTime; + + /* It is not desirable to suspend then resume the scheduler on + * each iteration of the idle task. Therefore, a preliminary + * test of the expected idle time is performed without the + * scheduler suspended. The result here is not necessarily + * valid. */ + xExpectedIdleTime = prvGetExpectedIdleTime(); + + if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) + { + vTaskSuspendAll(); + { + /* Now the scheduler is suspended, the expected idle + * time can be sampled again, and this time its value can + * be used. */ + configASSERT( xNextTaskUnblockTime >= xTickCount ); + xExpectedIdleTime = prvGetExpectedIdleTime(); + + /* Define the following macro to set xExpectedIdleTime to 0 + * if the application does not want + * portSUPPRESS_TICKS_AND_SLEEP() to be called. */ + configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( xExpectedIdleTime ); + + if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) + { + traceLOW_POWER_IDLE_BEGIN(); + portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ); + traceLOW_POWER_IDLE_END(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + ( void ) xTaskResumeAll(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configUSE_TICKLESS_IDLE */ + } +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_TICKLESS_IDLE != 0 ) + + eSleepModeStatus eTaskConfirmSleepModeStatus( void ) + { + /* The idle task exists in addition to the application tasks. */ + const UBaseType_t uxNonApplicationTasks = 1; + eSleepModeStatus eReturn = eStandardSleep; + + /* This function must be called from a critical section. */ + + if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 ) + { + /* A task was made ready while the scheduler was suspended. */ + eReturn = eAbortSleep; + } + else if( xYieldPending != pdFALSE ) + { + /* A yield was pended while the scheduler was suspended. */ + eReturn = eAbortSleep; + } + else if( xPendedTicks != 0 ) + { + /* A tick interrupt has already occurred but was held pending + * because the scheduler is suspended. */ + eReturn = eAbortSleep; + } + else + { + /* If all the tasks are in the suspended list (which might mean they + * have an infinite block time rather than actually being suspended) + * then it is safe to turn all clocks off and just wait for external + * interrupts. */ + if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) ) + { + eReturn = eNoTasksWaitingTimeout; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + return eReturn; + } + +#endif /* configUSE_TICKLESS_IDLE */ +/*-----------------------------------------------------------*/ + +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) + + void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, + BaseType_t xIndex, + void * pvValue ) + { + TCB_t * pxTCB; + + if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) + { + pxTCB = prvGetTCBFromHandle( xTaskToSet ); + configASSERT( pxTCB != NULL ); + pxTCB->pvThreadLocalStoragePointers[ xIndex ] = pvValue; + } + } + +#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */ +/*-----------------------------------------------------------*/ + +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) + + void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, + BaseType_t xIndex ) + { + void * pvReturn = NULL; + TCB_t * pxTCB; + + if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) + { + pxTCB = prvGetTCBFromHandle( xTaskToQuery ); + pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ]; + } + else + { + pvReturn = NULL; + } + + return pvReturn; + } + +#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */ +/*-----------------------------------------------------------*/ + +#if ( portUSING_MPU_WRAPPERS == 1 ) + + void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify, + const MemoryRegion_t * const xRegions ) + { + TCB_t * pxTCB; + + /* If null is passed in here then we are modifying the MPU settings of + * the calling task. */ + pxTCB = prvGetTCBFromHandle( xTaskToModify ); + + vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 ); + } + +#endif /* portUSING_MPU_WRAPPERS */ +/*-----------------------------------------------------------*/ + +static void prvInitialiseTaskLists( void ) +{ + UBaseType_t uxPriority; + + for( uxPriority = ( UBaseType_t ) 0U; uxPriority < ( UBaseType_t ) configMAX_PRIORITIES; uxPriority++ ) + { + vListInitialise( &( pxReadyTasksLists[ uxPriority ] ) ); + } + + vListInitialise( &xDelayedTaskList1 ); + vListInitialise( &xDelayedTaskList2 ); + vListInitialise( &xPendingReadyList ); + + #if ( INCLUDE_vTaskDelete == 1 ) + { + vListInitialise( &xTasksWaitingTermination ); + } + #endif /* INCLUDE_vTaskDelete */ + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + vListInitialise( &xSuspendedTaskList ); + } + #endif /* INCLUDE_vTaskSuspend */ + + /* Start with pxDelayedTaskList using list1 and the pxOverflowDelayedTaskList + * using list2. */ + pxDelayedTaskList = &xDelayedTaskList1; + pxOverflowDelayedTaskList = &xDelayedTaskList2; +} +/*-----------------------------------------------------------*/ + +static void prvCheckTasksWaitingTermination( void ) +{ + /** THIS FUNCTION IS CALLED FROM THE RTOS IDLE TASK **/ + + #if ( INCLUDE_vTaskDelete == 1 ) + { + TCB_t * pxTCB; + + /* uxDeletedTasksWaitingCleanUp is used to prevent taskENTER_CRITICAL() + * being called too often in the idle task. */ + while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U ) + { + taskENTER_CRITICAL(); + { + pxTCB = listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + --uxCurrentNumberOfTasks; + --uxDeletedTasksWaitingCleanUp; + } + taskEXIT_CRITICAL(); + + prvDeleteTCB( pxTCB ); + } + } + #endif /* INCLUDE_vTaskDelete */ +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + void vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) + { + TCB_t * pxTCB; + + /* xTask is NULL then get the state of the calling task. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + pxTaskStatus->xHandle = ( TaskHandle_t ) pxTCB; + pxTaskStatus->pcTaskName = ( const char * ) &( pxTCB->pcTaskName[ 0 ] ); + pxTaskStatus->uxCurrentPriority = pxTCB->uxPriority; + pxTaskStatus->pxStackBase = pxTCB->pxStack; + pxTaskStatus->xTaskNumber = pxTCB->uxTCBNumber; + + #if ( configUSE_MUTEXES == 1 ) + { + pxTaskStatus->uxBasePriority = pxTCB->uxBasePriority; + } + #else + { + pxTaskStatus->uxBasePriority = 0; + } + #endif + + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + { + pxTaskStatus->ulRunTimeCounter = pxTCB->ulRunTimeCounter; + } + #else + { + pxTaskStatus->ulRunTimeCounter = 0; + } + #endif + + /* Obtaining the task state is a little fiddly, so is only done if the + * value of eState passed into this function is eInvalid - otherwise the + * state is just set to whatever is passed in. */ + if( eState != eInvalid ) + { + if( pxTCB == pxCurrentTCB ) + { + pxTaskStatus->eCurrentState = eRunning; + } + else + { + pxTaskStatus->eCurrentState = eState; + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + /* If the task is in the suspended list then there is a + * chance it is actually just blocked indefinitely - so really + * it should be reported as being in the Blocked state. */ + if( eState == eSuspended ) + { + vTaskSuspendAll(); + { + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + pxTaskStatus->eCurrentState = eBlocked; + } + } + ( void ) xTaskResumeAll(); + } + } + #endif /* INCLUDE_vTaskSuspend */ + } + } + else + { + pxTaskStatus->eCurrentState = eTaskGetState( pxTCB ); + } + + /* Obtaining the stack space takes some time, so the xGetFreeStackSpace + * parameter is provided to allow it to be skipped. */ + if( xGetFreeStackSpace != pdFALSE ) + { + #if ( portSTACK_GROWTH > 0 ) + { + pxTaskStatus->usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxTCB->pxEndOfStack ); + } + #else + { + pxTaskStatus->usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxTCB->pxStack ); + } + #endif + } + else + { + pxTaskStatus->usStackHighWaterMark = 0; + } + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + static UBaseType_t prvListTasksWithinSingleList( TaskStatus_t * pxTaskStatusArray, + List_t * pxList, + eTaskState eState ) + { + configLIST_VOLATILE TCB_t * pxNextTCB, * pxFirstTCB; + UBaseType_t uxTask = 0; + + if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + + /* Populate an TaskStatus_t structure within the + * pxTaskStatusArray array for each task that is referenced from + * pxList. See the definition of TaskStatus_t in task.h for the + * meaning of each TaskStatus_t structure member. */ + do + { + listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState ); + uxTask++; + } while( pxNextTCB != pxFirstTCB ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return uxTask; + } + +#endif /* configUSE_TRACE_FACILITY */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) ) + + static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) + { + uint32_t ulCount = 0U; + + while( *pucStackByte == ( uint8_t ) tskSTACK_FILL_BYTE ) + { + pucStackByte -= portSTACK_GROWTH; + ulCount++; + } + + ulCount /= ( uint32_t ) sizeof( StackType_t ); /*lint !e961 Casting is not redundant on smaller architectures. */ + + return ( configSTACK_DEPTH_TYPE ) ulCount; + } + +#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) ) */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) + +/* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the + * same except for their return type. Using configSTACK_DEPTH_TYPE allows the + * user to determine the return type. It gets around the problem of the value + * overflowing on 8-bit types without breaking backward compatibility for + * applications that expect an 8-bit return type. */ + configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) + { + TCB_t * pxTCB; + uint8_t * pucEndOfStack; + configSTACK_DEPTH_TYPE uxReturn; + + /* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are + * the same except for their return type. Using configSTACK_DEPTH_TYPE + * allows the user to determine the return type. It gets around the + * problem of the value overflowing on 8-bit types without breaking + * backward compatibility for applications that expect an 8-bit return + * type. */ + + pxTCB = prvGetTCBFromHandle( xTask ); + + #if portSTACK_GROWTH < 0 + { + pucEndOfStack = ( uint8_t * ) pxTCB->pxStack; + } + #else + { + pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack; + } + #endif + + uxReturn = prvTaskCheckFreeStackSpace( pucEndOfStack ); + + return uxReturn; + } + +#endif /* INCLUDE_uxTaskGetStackHighWaterMark2 */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) + + UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) + { + TCB_t * pxTCB; + uint8_t * pucEndOfStack; + UBaseType_t uxReturn; + + pxTCB = prvGetTCBFromHandle( xTask ); + + #if portSTACK_GROWTH < 0 + { + pucEndOfStack = ( uint8_t * ) pxTCB->pxStack; + } + #else + { + pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack; + } + #endif + + uxReturn = ( UBaseType_t ) prvTaskCheckFreeStackSpace( pucEndOfStack ); + + return uxReturn; + } + +#endif /* INCLUDE_uxTaskGetStackHighWaterMark */ +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelete == 1 ) + + static void prvDeleteTCB( TCB_t * pxTCB ) + { + /* This call is required specifically for the TriCore port. It must be + * above the vPortFree() calls. The call is also used by ports/demos that + * want to allocate and clean RAM statically. */ + portCLEAN_UP_TCB( pxTCB ); + + /* Free up the memory allocated by the scheduler for the task. It is up + * to the task to free any memory allocated at the application level. + * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html + * for additional information. */ + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + { + _reclaim_reent( &( pxTCB->xNewLib_reent ) ); + } + #endif /* configUSE_NEWLIB_REENTRANT */ + + #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( portUSING_MPU_WRAPPERS == 0 ) ) + { + /* The task can only have been allocated dynamically - free both + * the stack and TCB. */ + vPortFree( pxTCB->pxStack ); + vPortFree( pxTCB ); + } + #elif ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ + { + /* The task could have been allocated statically or dynamically, so + * check what was statically allocated before trying to free the + * memory. */ + if( pxTCB->ucStaticallyAllocated == tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ) + { + /* Both the stack and TCB were allocated dynamically, so both + * must be freed. */ + vPortFree( pxTCB->pxStack ); + vPortFree( pxTCB ); + } + else if( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_ONLY ) + { + /* Only the stack was statically allocated, so the TCB is the + * only memory that must be freed. */ + vPortFree( pxTCB ); + } + else + { + /* Neither the stack nor the TCB were allocated dynamically, so + * nothing needs to be freed. */ + configASSERT( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB ); + mtCOVERAGE_TEST_MARKER(); + } + } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + } + +#endif /* INCLUDE_vTaskDelete */ +/*-----------------------------------------------------------*/ + +static void prvResetNextTaskUnblockTime( void ) +{ + if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) + { + /* The new current delayed list is empty. Set xNextTaskUnblockTime to + * the maximum possible value so it is extremely unlikely that the + * if( xTickCount >= xNextTaskUnblockTime ) test will pass until + * there is an item in the delayed list. */ + xNextTaskUnblockTime = portMAX_DELAY; + } + else + { + /* The new current delayed list is not empty, get the value of + * the item at the head of the delayed list. This is the time at + * which the task at the head of the delayed list should be removed + * from the Blocked state. */ + xNextTaskUnblockTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxDelayedTaskList ); + } +} +/*-----------------------------------------------------------*/ + +#if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) + + TaskHandle_t xTaskGetCurrentTaskHandle( void ) + { + TaskHandle_t xReturn; + + /* A critical section is not required as this is not called from + * an interrupt and the current TCB will always be the same for any + * individual execution thread. */ + xReturn = pxCurrentTCB; + + return xReturn; + } + +#endif /* ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */ +/*-----------------------------------------------------------*/ + +#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) + + BaseType_t xTaskGetSchedulerState( void ) + { + BaseType_t xReturn; + + if( xSchedulerRunning == pdFALSE ) + { + xReturn = taskSCHEDULER_NOT_STARTED; + } + else + { + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + { + xReturn = taskSCHEDULER_RUNNING; + } + else + { + xReturn = taskSCHEDULER_SUSPENDED; + } + } + + return xReturn; + } + +#endif /* ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + + BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) + { + TCB_t * const pxMutexHolderTCB = pxMutexHolder; + BaseType_t xReturn = pdFALSE; + + /* If the mutex was given back by an interrupt while the queue was + * locked then the mutex holder might now be NULL. _RB_ Is this still + * needed as interrupts can no longer use mutexes? */ + if( pxMutexHolder != NULL ) + { + /* If the holder of the mutex has a priority below the priority of + * the task attempting to obtain the mutex then it will temporarily + * inherit the priority of the task attempting to obtain the mutex. */ + if( pxMutexHolderTCB->uxPriority < pxCurrentTCB->uxPriority ) + { + /* Adjust the mutex holder state to account for its new + * priority. Only reset the event list item value if the value is + * not being used for anything else. */ + if( ( listGET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) + { + listSET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* If the task being modified is in the ready state it will need + * to be moved into a new list. */ + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxMutexHolderTCB->uxPriority ] ), &( pxMutexHolderTCB->xStateListItem ) ) != pdFALSE ) + { + if( uxListRemove( &( pxMutexHolderTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + /* It is known that the task is in its ready list so + * there is no need to check again and the port level + * reset macro can be called directly. */ + portRESET_READY_PRIORITY( pxMutexHolderTCB->uxPriority, uxTopReadyPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Inherit the priority before being moved into the new list. */ + pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority; + prvAddTaskToReadyList( pxMutexHolderTCB ); + } + else + { + /* Just inherit the priority. */ + pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority; + } + + traceTASK_PRIORITY_INHERIT( pxMutexHolderTCB, pxCurrentTCB->uxPriority ); + + /* Inheritance occurred. */ + xReturn = pdTRUE; + } + else + { + if( pxMutexHolderTCB->uxBasePriority < pxCurrentTCB->uxPriority ) + { + /* The base priority of the mutex holder is lower than the + * priority of the task attempting to take the mutex, but the + * current priority of the mutex holder is not lower than the + * priority of the task attempting to take the mutex. + * Therefore the mutex holder must have already inherited a + * priority, but inheritance would have occurred if that had + * not been the case. */ + xReturn = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xReturn; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + + BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) + { + TCB_t * const pxTCB = pxMutexHolder; + BaseType_t xReturn = pdFALSE; + + if( pxMutexHolder != NULL ) + { + /* A task can only have an inherited priority if it holds the mutex. + * If the mutex is held by a task then it cannot be given from an + * interrupt, and if a mutex is given by the holding task then it must + * be the running state task. */ + configASSERT( pxTCB == pxCurrentTCB ); + configASSERT( pxTCB->uxMutexesHeld ); + ( pxTCB->uxMutexesHeld )--; + + /* Has the holder of the mutex inherited the priority of another + * task? */ + if( pxTCB->uxPriority != pxTCB->uxBasePriority ) + { + /* Only disinherit if no other mutexes are held. */ + if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 ) + { + /* A task can only have an inherited priority if it holds + * the mutex. If the mutex is held by a task then it cannot be + * given from an interrupt, and if a mutex is given by the + * holding task then it must be the running state task. Remove + * the holding task from the ready list. */ + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Disinherit the priority before adding the task into the + * new ready list. */ + traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority ); + pxTCB->uxPriority = pxTCB->uxBasePriority; + + /* Reset the event list item value. It cannot be in use for + * any other purpose if this task is running, and it must be + * running to give back the mutex. */ + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + prvAddTaskToReadyList( pxTCB ); + + /* Return true to indicate that a context switch is required. + * This is only actually required in the corner case whereby + * multiple mutexes were held and the mutexes were given back + * in an order different to that in which they were taken. + * If a context switch did not occur when the first mutex was + * returned, even if a task was waiting on it, then a context + * switch should occur when the last mutex is returned whether + * a task is waiting on it or not. */ + xReturn = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + return xReturn; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + + void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, + UBaseType_t uxHighestPriorityWaitingTask ) + { + TCB_t * const pxTCB = pxMutexHolder; + UBaseType_t uxPriorityUsedOnEntry, uxPriorityToUse; + const UBaseType_t uxOnlyOneMutexHeld = ( UBaseType_t ) 1; + + if( pxMutexHolder != NULL ) + { + /* If pxMutexHolder is not NULL then the holder must hold at least + * one mutex. */ + configASSERT( pxTCB->uxMutexesHeld ); + + /* Determine the priority to which the priority of the task that + * holds the mutex should be set. This will be the greater of the + * holding task's base priority and the priority of the highest + * priority task that is waiting to obtain the mutex. */ + if( pxTCB->uxBasePriority < uxHighestPriorityWaitingTask ) + { + uxPriorityToUse = uxHighestPriorityWaitingTask; + } + else + { + uxPriorityToUse = pxTCB->uxBasePriority; + } + + /* Does the priority need to change? */ + if( pxTCB->uxPriority != uxPriorityToUse ) + { + /* Only disinherit if no other mutexes are held. This is a + * simplification in the priority inheritance implementation. If + * the task that holds the mutex is also holding other mutexes then + * the other mutexes may have caused the priority inheritance. */ + if( pxTCB->uxMutexesHeld == uxOnlyOneMutexHeld ) + { + /* If a task has timed out because it already holds the + * mutex it was trying to obtain then it cannot of inherited + * its own priority. */ + configASSERT( pxTCB != pxCurrentTCB ); + + /* Disinherit the priority, remembering the previous + * priority to facilitate determining the subject task's + * state. */ + traceTASK_PRIORITY_DISINHERIT( pxTCB, uxPriorityToUse ); + uxPriorityUsedOnEntry = pxTCB->uxPriority; + pxTCB->uxPriority = uxPriorityToUse; + + /* Only reset the event list item value if the value is not + * being used for anything else. */ + if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) + { + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriorityToUse ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* If the running task is not the task that holds the mutex + * then the task that holds the mutex could be in either the + * Ready, Blocked or Suspended states. Only remove the task + * from its current state list if it is in the Ready state as + * the task's priority is going to change and there is one + * Ready list per priority. */ + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE ) + { + if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + /* It is known that the task is in its ready list so + * there is no need to check again and the port level + * reset macro can be called directly. */ + portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + prvAddTaskToReadyList( pxTCB ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( portCRITICAL_NESTING_IN_TCB == 1 ) + + void vTaskEnterCritical( void ) + { + portDISABLE_INTERRUPTS(); + + if( xSchedulerRunning != pdFALSE ) + { + ( pxCurrentTCB->uxCriticalNesting )++; + + /* This is not the interrupt safe version of the enter critical + * function so assert() if it is being called from an interrupt + * context. Only API functions that end in "FromISR" can be used in an + * interrupt. Only assert if the critical nesting count is 1 to + * protect against recursive calls if the assert function also uses a + * critical section. */ + if( pxCurrentTCB->uxCriticalNesting == 1 ) + { + portASSERT_IF_IN_ISR(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* portCRITICAL_NESTING_IN_TCB */ +/*-----------------------------------------------------------*/ + +#if ( portCRITICAL_NESTING_IN_TCB == 1 ) + + void vTaskExitCritical( void ) + { + if( xSchedulerRunning != pdFALSE ) + { + if( pxCurrentTCB->uxCriticalNesting > 0U ) + { + ( pxCurrentTCB->uxCriticalNesting )--; + + if( pxCurrentTCB->uxCriticalNesting == 0U ) + { + portENABLE_INTERRUPTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* portCRITICAL_NESTING_IN_TCB */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) + + static char * prvWriteNameToBuffer( char * pcBuffer, + const char * pcTaskName ) + { + size_t x; + + /* Start by copying the entire string. */ + strcpy( pcBuffer, pcTaskName ); + + /* Pad the end of the string with spaces to ensure columns line up when + * printed out. */ + for( x = strlen( pcBuffer ); x < ( size_t ) ( configMAX_TASK_NAME_LEN - 1 ); x++ ) + { + pcBuffer[ x ] = ' '; + } + + /* Terminate. */ + pcBuffer[ x ] = ( char ) 0x00; + + /* Return the new end of string. */ + return &( pcBuffer[ x ] ); + } + +#endif /* ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) */ +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + void vTaskList( char * pcWriteBuffer ) + { + TaskStatus_t * pxTaskStatusArray; + UBaseType_t uxArraySize, x; + char cStatus; + + /* + * PLEASE NOTE: + * + * This function is provided for convenience only, and is used by many + * of the demo applications. Do not consider it to be part of the + * scheduler. + * + * vTaskList() calls uxTaskGetSystemState(), then formats part of the + * uxTaskGetSystemState() output into a human readable table that + * displays task names, states and stack usage. + * + * vTaskList() has a dependency on the sprintf() C library function that + * might bloat the code size, use a lot of stack, and provide different + * results on different platforms. An alternative, tiny, third party, + * and limited functionality implementation of sprintf() is provided in + * many of the FreeRTOS/Demo sub-directories in a file called + * printf-stdarg.c (note printf-stdarg.c does not provide a full + * snprintf() implementation!). + * + * It is recommended that production systems call uxTaskGetSystemState() + * directly to get access to raw stats data, rather than indirectly + * through a call to vTaskList(). + */ + + + /* Make sure the write buffer does not contain a string. */ + *pcWriteBuffer = ( char ) 0x00; + + /* Take a snapshot of the number of tasks in case it changes while this + * function is executing. */ + uxArraySize = uxCurrentNumberOfTasks; + + /* Allocate an array index for each task. NOTE! if + * configSUPPORT_DYNAMIC_ALLOCATION is set to 0 then pvPortMalloc() will + * equate to NULL. */ + pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation allocates a struct that has the alignment requirements of a pointer. */ + + if( pxTaskStatusArray != NULL ) + { + /* Generate the (binary) data. */ + uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL ); + + /* Create a human readable table from the binary data. */ + for( x = 0; x < uxArraySize; x++ ) + { + switch( pxTaskStatusArray[ x ].eCurrentState ) + { + case eRunning: + cStatus = tskRUNNING_CHAR; + break; + + case eReady: + cStatus = tskREADY_CHAR; + break; + + case eBlocked: + cStatus = tskBLOCKED_CHAR; + break; + + case eSuspended: + cStatus = tskSUSPENDED_CHAR; + break; + + case eDeleted: + cStatus = tskDELETED_CHAR; + break; + + case eInvalid: /* Fall through. */ + default: /* Should not get here, but it is included + * to prevent static checking errors. */ + cStatus = ( char ) 0x00; + break; + } + + /* Write the task name to the string, padding with spaces so it + * can be printed in tabular form more easily. */ + pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); + + /* Write the rest of the string. */ + sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ + pcWriteBuffer += strlen( pcWriteBuffer ); /*lint !e9016 Pointer arithmetic ok on char pointers especially as in this case where it best denotes the intent of the code. */ + } + + /* Free the array again. NOTE! If configSUPPORT_DYNAMIC_ALLOCATION + * is 0 then vPortFree() will be #defined to nothing. */ + vPortFree( pxTaskStatusArray ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ +/*----------------------------------------------------------*/ + +#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + + void vTaskGetRunTimeStats( char * pcWriteBuffer ) + { + TaskStatus_t * pxTaskStatusArray; + UBaseType_t uxArraySize, x; + uint32_t ulTotalTime, ulStatsAsPercentage; + + #if ( configUSE_TRACE_FACILITY != 1 ) + { + #error configUSE_TRACE_FACILITY must also be set to 1 in FreeRTOSConfig.h to use vTaskGetRunTimeStats(). + } + #endif + + /* + * PLEASE NOTE: + * + * This function is provided for convenience only, and is used by many + * of the demo applications. Do not consider it to be part of the + * scheduler. + * + * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part + * of the uxTaskGetSystemState() output into a human readable table that + * displays the amount of time each task has spent in the Running state + * in both absolute and percentage terms. + * + * vTaskGetRunTimeStats() has a dependency on the sprintf() C library + * function that might bloat the code size, use a lot of stack, and + * provide different results on different platforms. An alternative, + * tiny, third party, and limited functionality implementation of + * sprintf() is provided in many of the FreeRTOS/Demo sub-directories in + * a file called printf-stdarg.c (note printf-stdarg.c does not provide + * a full snprintf() implementation!). + * + * It is recommended that production systems call uxTaskGetSystemState() + * directly to get access to raw stats data, rather than indirectly + * through a call to vTaskGetRunTimeStats(). + */ + + /* Make sure the write buffer does not contain a string. */ + *pcWriteBuffer = ( char ) 0x00; + + /* Take a snapshot of the number of tasks in case it changes while this + * function is executing. */ + uxArraySize = uxCurrentNumberOfTasks; + + /* Allocate an array index for each task. NOTE! If + * configSUPPORT_DYNAMIC_ALLOCATION is set to 0 then pvPortMalloc() will + * equate to NULL. */ + pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation allocates a struct that has the alignment requirements of a pointer. */ + + if( pxTaskStatusArray != NULL ) + { + /* Generate the (binary) data. */ + uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalTime ); + + /* For percentage calculations. */ + ulTotalTime /= 100UL; + + /* Avoid divide by zero errors. */ + if( ulTotalTime > 0UL ) + { + /* Create a human readable table from the binary data. */ + for( x = 0; x < uxArraySize; x++ ) + { + /* What percentage of the total run time has the task used? + * This will always be rounded down to the nearest integer. + * ulTotalRunTimeDiv100 has already been divided by 100. */ + ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalTime; + + /* Write the task name to the string, padding with + * spaces so it can be printed in tabular form more + * easily. */ + pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); + + if( ulStatsAsPercentage > 0UL ) + { + #ifdef portLU_PRINTF_SPECIFIER_REQUIRED + { + sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); + } + #else + { + /* sizeof( int ) == sizeof( long ) so a smaller + * printf() library can be used. */ + sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ + } + #endif + } + else + { + /* If the percentage is zero here then the task has + * consumed less than 1% of the total run time. */ + #ifdef portLU_PRINTF_SPECIFIER_REQUIRED + { + sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter ); + } + #else + { + /* sizeof( int ) == sizeof( long ) so a smaller + * printf() library can be used. */ + sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ + } + #endif + } + + pcWriteBuffer += strlen( pcWriteBuffer ); /*lint !e9016 Pointer arithmetic ok on char pointers especially as in this case where it best denotes the intent of the code. */ + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Free the array again. NOTE! If configSUPPORT_DYNAMIC_ALLOCATION + * is 0 then vPortFree() will be #defined to nothing. */ + vPortFree( pxTaskStatusArray ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + +#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */ +/*-----------------------------------------------------------*/ + +TickType_t uxTaskResetEventItemValue( void ) +{ + TickType_t uxReturn; + + uxReturn = listGET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ) ); + + /* Reset the event list item to its normal value - so it can be used with + * queues and semaphores. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + return uxReturn; +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + + TaskHandle_t pvTaskIncrementMutexHeldCount( void ) + { + /* If xSemaphoreCreateMutex() is called before any tasks have been created + * then pxCurrentTCB will be NULL. */ + if( pxCurrentTCB != NULL ) + { + ( pxCurrentTCB->uxMutexesHeld )++; + } + + return pxCurrentTCB; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TASK_NOTIFICATIONS == 1 ) + + uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWait, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) + { + uint32_t ulReturn; + + configASSERT( uxIndexToWait < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + + taskENTER_CRITICAL(); + { + /* Only block if the notification count is not already non-zero. */ + if( pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] == 0UL ) + { + /* Mark this task as waiting for a notification. */ + pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskWAITING_NOTIFICATION; + + if( xTicksToWait > ( TickType_t ) 0 ) + { + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); + traceTASK_NOTIFY_TAKE_BLOCK( uxIndexToWait ); + + /* All ports are written to allow a yield in a critical + * section (some will yield immediately, others wait until the + * critical section exits) - but it is not something that + * application code should ever do. */ + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + + taskENTER_CRITICAL(); + { + traceTASK_NOTIFY_TAKE( uxIndexToWait ); + ulReturn = pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ]; + + if( ulReturn != 0UL ) + { + if( xClearCountOnExit != pdFALSE ) + { + pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] = 0UL; + } + else + { + pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] = ulReturn - ( uint32_t ) 1; + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskNOT_WAITING_NOTIFICATION; + } + taskEXIT_CRITICAL(); + + return ulReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TASK_NOTIFICATIONS == 1 ) + + BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWait, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) + { + BaseType_t xReturn; + + configASSERT( uxIndexToWait < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + + taskENTER_CRITICAL(); + { + /* Only block if a notification is not already pending. */ + if( pxCurrentTCB->ucNotifyState[ uxIndexToWait ] != taskNOTIFICATION_RECEIVED ) + { + /* Clear bits in the task's notification value as bits may get + * set by the notifying task or interrupt. This can be used to + * clear the value to zero. */ + pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] &= ~ulBitsToClearOnEntry; + + /* Mark this task as waiting for a notification. */ + pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskWAITING_NOTIFICATION; + + if( xTicksToWait > ( TickType_t ) 0 ) + { + prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); + traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait ); + + /* All ports are written to allow a yield in a critical + * section (some will yield immediately, others wait until the + * critical section exits) - but it is not something that + * application code should ever do. */ + portYIELD_WITHIN_API(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + + taskENTER_CRITICAL(); + { + traceTASK_NOTIFY_WAIT( uxIndexToWait ); + + if( pulNotificationValue != NULL ) + { + /* Output the current notification value, which may or may not + * have changed. */ + *pulNotificationValue = pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ]; + } + + /* If ucNotifyValue is set then either the task never entered the + * blocked state (because a notification was already pending) or the + * task unblocked because of a notification. Otherwise the task + * unblocked because of a timeout. */ + if( pxCurrentTCB->ucNotifyState[ uxIndexToWait ] != taskNOTIFICATION_RECEIVED ) + { + /* A notification was not received. */ + xReturn = pdFALSE; + } + else + { + /* A notification was already pending or a notification was + * received while the task was waiting. */ + pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] &= ~ulBitsToClearOnExit; + xReturn = pdTRUE; + } + + pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskNOT_WAITING_NOTIFICATION; + } + taskEXIT_CRITICAL(); + + return xReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TASK_NOTIFICATIONS == 1 ) + + BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) + { + TCB_t * pxTCB; + BaseType_t xReturn = pdPASS; + uint8_t ucOriginalNotifyState; + + configASSERT( uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + configASSERT( xTaskToNotify ); + pxTCB = xTaskToNotify; + + taskENTER_CRITICAL(); + { + if( pulPreviousNotificationValue != NULL ) + { + *pulPreviousNotificationValue = pxTCB->ulNotifiedValue[ uxIndexToNotify ]; + } + + ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ]; + + pxTCB->ucNotifyState[ uxIndexToNotify ] = taskNOTIFICATION_RECEIVED; + + switch( eAction ) + { + case eSetBits: + pxTCB->ulNotifiedValue[ uxIndexToNotify ] |= ulValue; + break; + + case eIncrement: + ( pxTCB->ulNotifiedValue[ uxIndexToNotify ] )++; + break; + + case eSetValueWithOverwrite: + pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue; + break; + + case eSetValueWithoutOverwrite: + + if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED ) + { + pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue; + } + else + { + /* The value could not be written to the task. */ + xReturn = pdFAIL; + } + + break; + + case eNoAction: + + /* The task is being notified without its notify value being + * updated. */ + break; + + default: + + /* Should not get here if all enums are handled. + * Artificially force an assert by testing a value the + * compiler can't assume is const. */ + configASSERT( xTickCount == ( TickType_t ) 0 ); + + break; + } + + traceTASK_NOTIFY( uxIndexToNotify ); + + /* If the task is in the blocked state specifically to wait for a + * notification then unblock it now. */ + if( ucOriginalNotifyState == taskWAITING_NOTIFICATION ) + { + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxTCB ); + + /* The task should not have been on an event list. */ + configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); + + #if ( configUSE_TICKLESS_IDLE != 0 ) + { + /* If a task is blocked waiting for a notification then + * xNextTaskUnblockTime might be set to the blocked task's time + * out time. If the task is unblocked for a reason other than + * a timeout xNextTaskUnblockTime is normally left unchanged, + * because it will automatically get reset to a new value when + * the tick count equals xNextTaskUnblockTime. However if + * tickless idling is used it might be more important to enter + * sleep mode at the earliest possible time - so reset + * xNextTaskUnblockTime here to ensure it is updated at the + * earliest possible time. */ + prvResetNextTaskUnblockTime(); + } + #endif + + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + /* The notified task has a priority above the currently + * executing task so a yield is required. */ + taskYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + taskEXIT_CRITICAL(); + + return xReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TASK_NOTIFICATIONS == 1 ) + + BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue, + BaseType_t * pxHigherPriorityTaskWoken ) + { + TCB_t * pxTCB; + uint8_t ucOriginalNotifyState; + BaseType_t xReturn = pdPASS; + UBaseType_t uxSavedInterruptStatus; + + configASSERT( xTaskToNotify ); + configASSERT( uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + + /* RTOS ports that support interrupt nesting have the concept of a + * maximum system call (or maximum API call) interrupt priority. + * Interrupts that are above the maximum system call priority are keep + * permanently enabled, even when the RTOS kernel is in a critical section, + * but cannot make any calls to FreeRTOS API functions. If configASSERT() + * is defined in FreeRTOSConfig.h then + * portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has + * been assigned a priority above the configured maximum system call + * priority. Only FreeRTOS functions that end in FromISR can be called + * from interrupts that have been assigned a priority at or (logically) + * below the maximum system call interrupt priority. FreeRTOS maintains a + * separate interrupt safe API to ensure interrupt entry is as fast and as + * simple as possible. More information (albeit Cortex-M specific) is + * provided on the following link: + * https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + pxTCB = xTaskToNotify; + + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + if( pulPreviousNotificationValue != NULL ) + { + *pulPreviousNotificationValue = pxTCB->ulNotifiedValue[ uxIndexToNotify ]; + } + + ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ]; + pxTCB->ucNotifyState[ uxIndexToNotify ] = taskNOTIFICATION_RECEIVED; + + switch( eAction ) + { + case eSetBits: + pxTCB->ulNotifiedValue[ uxIndexToNotify ] |= ulValue; + break; + + case eIncrement: + ( pxTCB->ulNotifiedValue[ uxIndexToNotify ] )++; + break; + + case eSetValueWithOverwrite: + pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue; + break; + + case eSetValueWithoutOverwrite: + + if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED ) + { + pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue; + } + else + { + /* The value could not be written to the task. */ + xReturn = pdFAIL; + } + + break; + + case eNoAction: + + /* The task is being notified without its notify value being + * updated. */ + break; + + default: + + /* Should not get here if all enums are handled. + * Artificially force an assert by testing a value the + * compiler can't assume is const. */ + configASSERT( xTickCount == ( TickType_t ) 0 ); + break; + } + + traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ); + + /* If the task is in the blocked state specifically to wait for a + * notification then unblock it now. */ + if( ucOriginalNotifyState == taskWAITING_NOTIFICATION ) + { + /* The task should not have been on an event list. */ + configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); + + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + { + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxTCB ); + } + else + { + /* The delayed and ready lists cannot be accessed, so hold + * this task pending until the scheduler is resumed. */ + vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); + } + + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + /* The notified task has a priority above the currently + * executing task so a yield is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + + /* Mark that a yield is pending in case the user is not + * using the "xHigherPriorityTaskWoken" parameter to an ISR + * safe FreeRTOS function. */ + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TASK_NOTIFICATIONS == 1 ) + + void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + BaseType_t * pxHigherPriorityTaskWoken ) + { + TCB_t * pxTCB; + uint8_t ucOriginalNotifyState; + UBaseType_t uxSavedInterruptStatus; + + configASSERT( xTaskToNotify ); + configASSERT( uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + + /* RTOS ports that support interrupt nesting have the concept of a + * maximum system call (or maximum API call) interrupt priority. + * Interrupts that are above the maximum system call priority are keep + * permanently enabled, even when the RTOS kernel is in a critical section, + * but cannot make any calls to FreeRTOS API functions. If configASSERT() + * is defined in FreeRTOSConfig.h then + * portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + * failure if a FreeRTOS API function is called from an interrupt that has + * been assigned a priority above the configured maximum system call + * priority. Only FreeRTOS functions that end in FromISR can be called + * from interrupts that have been assigned a priority at or (logically) + * below the maximum system call interrupt priority. FreeRTOS maintains a + * separate interrupt safe API to ensure interrupt entry is as fast and as + * simple as possible. More information (albeit Cortex-M specific) is + * provided on the following link: + * https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + pxTCB = xTaskToNotify; + + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ]; + pxTCB->ucNotifyState[ uxIndexToNotify ] = taskNOTIFICATION_RECEIVED; + + /* 'Giving' is equivalent to incrementing a count in a counting + * semaphore. */ + ( pxTCB->ulNotifiedValue[ uxIndexToNotify ] )++; + + traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify ); + + /* If the task is in the blocked state specifically to wait for a + * notification then unblock it now. */ + if( ucOriginalNotifyState == taskWAITING_NOTIFICATION ) + { + /* The task should not have been on an event list. */ + configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); + + if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) + { + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + prvAddTaskToReadyList( pxTCB ); + } + else + { + /* The delayed and ready lists cannot be accessed, so hold + * this task pending until the scheduler is resumed. */ + vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); + } + + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + /* The notified task has a priority above the currently + * executing task so a yield is required. */ + if( pxHigherPriorityTaskWoken != NULL ) + { + *pxHigherPriorityTaskWoken = pdTRUE; + } + + /* Mark that a yield is pending in case the user is not + * using the "xHigherPriorityTaskWoken" parameter in an ISR + * safe FreeRTOS function. */ + xYieldPending = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TASK_NOTIFICATIONS == 1 ) + + BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) + { + TCB_t * pxTCB; + BaseType_t xReturn; + + configASSERT( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + + /* If null is passed in here then it is the calling task that is having + * its notification state cleared. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + taskENTER_CRITICAL(); + { + if( pxTCB->ucNotifyState[ uxIndexToClear ] == taskNOTIFICATION_RECEIVED ) + { + pxTCB->ucNotifyState[ uxIndexToClear ] = taskNOT_WAITING_NOTIFICATION; + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + } + } + taskEXIT_CRITICAL(); + + return xReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + +#if ( configUSE_TASK_NOTIFICATIONS == 1 ) + + uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) + { + TCB_t * pxTCB; + uint32_t ulReturn; + + /* If null is passed in here then it is the calling task that is having + * its notification state cleared. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + taskENTER_CRITICAL(); + { + /* Return the notification as it was before the bits were cleared, + * then clear the bit mask. */ + ulReturn = pxTCB->ulNotifiedValue[ uxIndexToClear ]; + pxTCB->ulNotifiedValue[ uxIndexToClear ] &= ~ulBitsToClear; + } + taskEXIT_CRITICAL(); + + return ulReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + +#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) + + uint32_t ulTaskGetIdleRunTimeCounter( void ) + { + return xIdleTaskHandle->ulRunTimeCounter; + } + +#endif +/*-----------------------------------------------------------*/ + +static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, + const BaseType_t xCanBlockIndefinitely ) +{ + TickType_t xTimeToWake; + const TickType_t xConstTickCount = xTickCount; + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + { + /* About to enter a delayed list, so ensure the ucDelayAborted flag is + * reset to pdFALSE so it can be detected as having been set to pdTRUE + * when the task leaves the Blocked state. */ + pxCurrentTCB->ucDelayAborted = pdFALSE; + } + #endif + + /* Remove the task from the ready list before adding it to the blocked list + * as the same list item is used for both lists. */ + if( uxListRemove( &( pxCurrentTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) + { + /* The current task must be in a ready list, so there is no need to + * check, and the port reset macro can be called directly. */ + portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); /*lint !e931 pxCurrentTCB cannot change as it is the calling task. pxCurrentTCB->uxPriority and uxTopReadyPriority cannot change as called with scheduler suspended or in a critical section. */ + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + if( ( xTicksToWait == portMAX_DELAY ) && ( xCanBlockIndefinitely != pdFALSE ) ) + { + /* Add the task to the suspended task list instead of a delayed task + * list to ensure it is not woken by a timing event. It will block + * indefinitely. */ + vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) ); + } + else + { + /* Calculate the time at which the task should be woken if the event + * does not occur. This may overflow but this doesn't matter, the + * kernel will manage it correctly. */ + xTimeToWake = xConstTickCount + xTicksToWait; + + /* The list item will be inserted in wake time order. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWake ); + + if( xTimeToWake < xConstTickCount ) + { + /* Wake time has overflowed. Place this item in the overflow + * list. */ + vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + } + else + { + /* The wake time has not overflowed, so the current block list + * is used. */ + vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + + /* If the task entering the blocked state was placed at the + * head of the list of blocked tasks then xNextTaskUnblockTime + * needs to be updated too. */ + if( xTimeToWake < xNextTaskUnblockTime ) + { + xNextTaskUnblockTime = xTimeToWake; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + } + } + #else /* INCLUDE_vTaskSuspend */ + { + /* Calculate the time at which the task should be woken if the event + * does not occur. This may overflow but this doesn't matter, the kernel + * will manage it correctly. */ + xTimeToWake = xConstTickCount + xTicksToWait; + + /* The list item will be inserted in wake time order. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWake ); + + if( xTimeToWake < xConstTickCount ) + { + /* Wake time has overflowed. Place this item in the overflow list. */ + vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + } + else + { + /* The wake time has not overflowed, so the current block list is used. */ + vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) ); + + /* If the task entering the blocked state was placed at the head of the + * list of blocked tasks then xNextTaskUnblockTime needs to be updated + * too. */ + if( xTimeToWake < xNextTaskUnblockTime ) + { + xNextTaskUnblockTime = xTimeToWake; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + + /* Avoid compiler warning when INCLUDE_vTaskSuspend is not 1. */ + ( void ) xCanBlockIndefinitely; + } + #endif /* INCLUDE_vTaskSuspend */ +} + +/* Code below here allows additional code to be inserted into this source file, + * especially where access to file scope functions and data is needed (for example + * when performing module tests). */ + +#ifdef FREERTOS_MODULE_TEST + #include "tasks_test_access_functions.h" +#endif + + +#if ( configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H == 1 ) + + #include "freertos_tasks_c_additions.h" + + #ifdef FREERTOS_TASKS_C_ADDITIONS_INIT + static void freertos_tasks_c_additions_init( void ) + { + FREERTOS_TASKS_C_ADDITIONS_INIT(); + } + #endif + +#endif /* if ( configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H == 1 ) */ diff --git a/Makefile b/Makefile index 1cbd608..aa608f7 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ include $(TOPDIR)/env/make/Makefile.config DIRECTORIES += env + DIRECTORIES += FreeRTOS DIRECTORIES += applications ################################################################################ diff --git a/applications/Makefile b/applications/Makefile index f10c968..6a7d4a5 100644 --- a/applications/Makefile +++ b/applications/Makefile @@ -22,6 +22,7 @@ include $(TOPDIR)/env/make/Makefile.config ################################################################################ DIRECTORIES += v2.3 + DIRECTORIES += freertos_app ################################################################################ # define user targets diff --git a/applications/freertos_app/Handle0Key.c b/applications/freertos_app/Handle0Key.c new file mode 100644 index 0000000..5b5da47 --- /dev/null +++ b/applications/freertos_app/Handle0Key.c @@ -0,0 +1,432 @@ + + +/* 69348 - todo */ +void Handle0Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x6958c + if (g_bLandTarget == 0) + { + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + if (g_bSlewingStop == 0) + { + g_bSlewingStop = 1; + + StopSlewing(); + //->0x69780 + } + else + { + //0x695d4 + g_bSlewingStop = 0; + + convert_horizontal_to_equatorial(dData_40002dc0_Azimuth + dData_400033e8, + dData_40002df8 + dData_400033f0, + &dData_40002c88, &dData_40002c90); + + GotoEQCoordinates(dData_40002c88, dData_40002c90); + + bData_400034cc = 1; + + ResumeSlewing(); + //->0x69780 + } + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0x69658 + if (g_bSlewingStop == 0) + { + g_bSlewingStop = 1; + + StopSlewing(); + //->0x69780 + } + else + { + //0x6967c + g_bSlewingStop = 0; + dData_40002c90 = dData_40002d98; + + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - + dData_40002d78; + + dData_40002c88 += dData_400033e8; + //->0x6970c + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + + GotoEQCoordinates(dData_40002c88, dData_40002c90); + + bData_400034cc = 1; + + ResumeSlewing(); + } + } + } //if (g_bLandTarget == 0) + //0x69780 -> 0x6a0d4 + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x69784 + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x6978c + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + //0x69790 + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + //0x69794 + if (g_bSlewingStop == 0) + { + g_bSlewingStop = 1; + + StopSlewing(); + } + else + { + //0x697b8 + g_bSlewingStop = 0; + + ResumeSlewing(); + } + //->0x6a0d4 + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x697cc + if (Data_40004128.alignmentPause == 0) + { + Data_40004128.alignmentPause = 1; + } + else + { + Data_40004128.alignmentPause = 0; + } + break; + + case 101: + //0x69800 + if (bData_40002c5a == 0) + { + bData_40002c5a = 1; + } + else + { + bData_40002c5a = 0; + } + break; + + case 5000: + //0x69834 + g_eSlewRateIndex = 0; + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x69848 + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x69850 + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x69854 + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x69858 + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x6985c + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x69860 + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x69864 + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x69868 + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x6986c + if (bTrackingModeMenu == MENU_TRACKING_MODE_PAUSE) //4) + { + ResumeSlewing(); + } + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_POINTING/*1*/) || + (bTrackingModeMenu == MENU_TRACKING_MODE_TRACKING/*2*/)) + { + bTrackingModeMenu = MENU_TRACKING_MODE_PAUSE; //4; + + StopSlewing(); + } + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x698b4 + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x698bc + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 0) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 0) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr; + } + //0x69908 + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x6993c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 0) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 0) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x699c8 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 0) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 0) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x69a54 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 0) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 0) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x69ae0 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 0) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 0) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x69b64 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 0) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 0) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + //0x69bf0 + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x69bf8 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '0'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '0'; + + func_57b40(); + //->0x6a0d4 + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x69c2c + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '0'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '0'; + + func_57a4c(); + break; + + case 29002: + //0x69c64 + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x69c6c + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x69c70 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '0'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '0'; + } + else + { + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x69d30 + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x69d38 + switch (bCustomerObjectNameChar) + { + case '0': + //69d50 + bCustomerObjectNameChar = ' '; + break; + + case ' ': + //0x69d64 + bCustomerObjectNameChar = '0'; + break; + + default: + //0x69d78 + bCustomerObjectNameChar = '0'; + break; + } + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x69e54 + if (bCharacterInputPosition != 1) + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '0'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '0'; + } + else + { + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x69f18 + if (bDateTimeInputMode == 0) + { + Data_40002655[bCharacterInputPosition - 1] = '0'; + Data_400037ec[bCharacterInputPosition - 1] = '0'; + } + else + { + Data_40002660[bCharacterInputPosition - 1] = '0'; + Data_40003150[bCharacterInputPosition - 1] = '0'; + } + + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x69f90 + HandleCustomSiteInputChar(0); + //->0x6a0d4 + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x69fa0 + func_623d0(0); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x69fb0 + Data_4000294a[bCharacterInputPosition - 1] = '0'; + strEng00000s[bCharacterInputPosition - 1] = '0'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //0x69fe8 + Data_40002a3f[bCharacterInputPosition - 1] = '0'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '0'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x6a020 + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x6a028 + Data_40002474[bCharacterInputPosition - 1] = '0'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '0'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x6a05c + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x6a064 + Data_40002481[bCharacterInputPosition - 1] = '0'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '0'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x6a098 + strEyepieceFovInput[bCharacterInputPosition - 1] = '0'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //0x6a0bc + func_61ecc(0); + break; + + default: + //0x6a0cc + break; + } +} + diff --git a/applications/freertos_app/Handle1Key.c b/applications/freertos_app/Handle1Key.c new file mode 100644 index 0000000..bb473aa --- /dev/null +++ b/applications/freertos_app/Handle1Key.c @@ -0,0 +1,278 @@ + + +/* 68934 - todo */ +void Handle1Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x68af8 + g_eSlewRateIndex = SLEW_RATE_1X; //1; + //->0x6933c + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //68b18 + bData_4000319a_SkyLandTargetId = 1; + break; + + case 5000: + //68b28 + g_eSlewRateIndex = SLEW_RATE_1X; //1; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //68b50 + g_eSlewRateIndex = SLEW_RATE_1X; //1; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //68b68 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 1) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 1) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 1; + } + //0x62fbc + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //68bf0 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 1) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 1) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 1; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //68c84 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 1) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 1) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 1; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //68d18 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 1) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 1) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 1; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //68e28 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 1) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 1) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 1; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //68eb4 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 1) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 1) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 1; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //68f50 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '1'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '1'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //68f84 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '1'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '1'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //68fc8 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '1'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '1'; + } + else + { + //0x6338c + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //69090 + bCustomerObjectNameChar = '1'; + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //690bc + if (bCharacterInputPosition != 1) + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '1'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '1'; + } + else + { + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //69180 + if (bDateTimeInputMode == 0) + { + Data_40002655[bCharacterInputPosition - 1] = '1'; + Data_400037ec[bCharacterInputPosition - 1] = '1'; + } + else + { + Data_40002660[bCharacterInputPosition - 1] = '1'; + Data_40003150[bCharacterInputPosition - 1] = '1'; + } + + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //691f8 + HandleCustomSiteInputChar(1); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //69208 + func_623d0(1); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //69218 + Data_4000294a[bCharacterInputPosition - 1] = '1'; + strEng00000s[bCharacterInputPosition - 1] = '1'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //69250 + Data_40002a3f[bCharacterInputPosition - 1] = '1'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '1'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //69290 + Data_40002474[bCharacterInputPosition - 1] = '1'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '1'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //692cc + Data_40002481[bCharacterInputPosition - 1] = '1'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '1'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //69300 + strEyepieceFovInput[bCharacterInputPosition - 1] = '1'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //69324 + func_61ecc(1); + break; + + default: + //0x69334 + break; + } +} + diff --git a/applications/freertos_app/Handle2Key.c b/applications/freertos_app/Handle2Key.c new file mode 100644 index 0000000..208012e --- /dev/null +++ b/applications/freertos_app/Handle2Key.c @@ -0,0 +1,319 @@ + + +/* 678b8 - todo */ +void Handle2Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x67a7c + g_eSlewRateIndex = SLEW_RATE_2X; //2; + //->0x68388 + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //67a9c + bData_4000319a_SkyLandTargetId = 2; + break; + + case 5000: + //67aac + g_eSlewRateIndex = SLEW_RATE_2X; //2; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //67ad4 + g_eSlewRateIndex = SLEW_RATE_2X; //2; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //67aec + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 2) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 2) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 2; + } + //0x62fbc + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //67b74 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 2) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 2) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 2; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //67c08 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 2) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 2) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 2; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //67c9c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 2) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 2) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 2; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //67d90 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 2) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 2) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 2; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //67e1c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 2) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 2) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 2; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //67eb8 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '2'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '2'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //67eec + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '2'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '2'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //67f30 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '2'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '2'; + } + else + { + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //67ff8 + switch (bCustomerObjectNameChar) + { + case '2': + //0x68044 + bCustomerObjectNameChar = 'a'; + break; + + case 'a': //97 + //0x68058 + bCustomerObjectNameChar = 'b'; + break; + + case 'b': //98 + //0x6806c + bCustomerObjectNameChar = 'c'; + break; + + case 'c': //99 + //0x68080 + bCustomerObjectNameChar = 'A'; + break; + + case 'A': //65 + //0x68094 + bCustomerObjectNameChar = 'B'; + break; + + case 'B': //66 + //0x680a8 + bCustomerObjectNameChar = 'C'; + break; + + case 'C': //67 + //0x680bc + bCustomerObjectNameChar = '2'; + break; + + default: + //0x680d0 + bCustomerObjectNameChar = '2'; + break; + } + + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //68108 + if (bCharacterInputPosition != 1) + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '2'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '2'; + } + else + { + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //681cc + if (bDateTimeInputMode == 0) + { + Data_40002655[bCharacterInputPosition - 1] = '2'; + Data_400037ec[bCharacterInputPosition - 1] = '2'; + } + else + { + Data_40002660[bCharacterInputPosition - 1] = '2'; + Data_40003150[bCharacterInputPosition - 1] = '2'; + } + + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //68244 + HandleCustomSiteInputChar(2); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //68254 + func_623d0(2); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //68264 + Data_4000294a[bCharacterInputPosition - 1] = '2'; + strEng00000s[bCharacterInputPosition - 1] = '2'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //6829c + Data_40002a3f[bCharacterInputPosition - 1] = '2'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '2'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //682dc + Data_40002474[bCharacterInputPosition - 1] = '2'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '2'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //68318 + Data_40002481[bCharacterInputPosition - 1] = '2'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '2'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //6834c + strEyepieceFovInput[bCharacterInputPosition - 1] = '2'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //68370 + func_61ecc(2); + break; + + default: + //0x68380 + break; + } +} + diff --git a/applications/freertos_app/Handle3Key.c b/applications/freertos_app/Handle3Key.c new file mode 100644 index 0000000..d668e3a --- /dev/null +++ b/applications/freertos_app/Handle3Key.c @@ -0,0 +1,322 @@ + + +/* 66e3c - todo */ +void Handle3Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x67000 + g_eSlewRateIndex = SLEW_RATE_8X; //3; + //->0x678ac + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //67020 + bData_4000319a_SkyLandTargetId = 3; + break; + + case 5000: + //67030 + g_eSlewRateIndex = SLEW_RATE_8X; //3; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //67058 + g_eSlewRateIndex = SLEW_RATE_8X; //3; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //67070 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 3) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 3) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 3; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //670f8 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 3) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 3) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 3; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //6718c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 3) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 3) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 3; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //67220 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 3) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 3) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 3; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //672b4 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 3) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 3) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 3; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //67340 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 3) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 3) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 3; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //673dc + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '3'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '3'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //67410 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '3'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '3'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //67454 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '3'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '3'; + } + else + { + //0x67494 + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //6751c + switch (bCustomerObjectNameChar) + { + case '3': + //0x67568 + bCustomerObjectNameChar = 'd'; + break; + + case 'd': //100 + //0x6757c + bCustomerObjectNameChar = 'e'; + break; + + case 'e': //101 + //0x67590 + bCustomerObjectNameChar = 'f'; + break; + + case 'f': //102 + //0x675a4 + bCustomerObjectNameChar = 'D'; + break; + + case 'D': //68 + //0x675b8 + bCustomerObjectNameChar = 'E'; + break; + + case 'E': //69 + //0x675cc + bCustomerObjectNameChar = 'F'; + break; + + case 'F': //70 + //0x675e0 + bCustomerObjectNameChar = '3'; + break; + + default: + //0x675f4 + bCustomerObjectNameChar = '3'; + break; + } + //0x67608 + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //6762c + if (bCharacterInputPosition != 1) + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '3'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '3'; + } + else + { + //0x67670 + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + //0x676e8 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //676f0 + if (bDateTimeInputMode == 0) + { + Data_40002655[bCharacterInputPosition - 1] = '3'; + Data_400037ec[bCharacterInputPosition - 1] = '3'; + } + else + { + //0x67734 + Data_40002660[bCharacterInputPosition - 1] = '3'; + Data_40003150[bCharacterInputPosition - 1] = '3'; + } + //0x67760 + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //67768 + HandleCustomSiteInputChar(3); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //67778 + func_623d0(3); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //67788 + Data_4000294a[bCharacterInputPosition - 1] = '3'; + strEng00000s[bCharacterInputPosition - 1] = '3'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //677c0 + Data_40002a3f[bCharacterInputPosition - 1] = '3'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '3'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //67800 + Data_40002474[bCharacterInputPosition - 1] = '3'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '3'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //6783c + Data_40002481[bCharacterInputPosition - 1] = '3'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '3'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //67870 + strEyepieceFovInput[bCharacterInputPosition - 1] = '3'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //67894 + func_61ecc(3); + break; + + default: + //0x678a4 + break; + } +} + diff --git a/applications/freertos_app/Handle4Key.c b/applications/freertos_app/Handle4Key.c new file mode 100644 index 0000000..7b55030 --- /dev/null +++ b/applications/freertos_app/Handle4Key.c @@ -0,0 +1,322 @@ + + +/* 66378 - todo */ +void Handle4Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x6653c + g_eSlewRateIndex = SLEW_RATE_16X; //4; + //->0x66e30 + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //6655c + bData_4000319a_SkyLandTargetId = 4; + break; + + case 5000: + //6656c + g_eSlewRateIndex = SLEW_RATE_16X; //4; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //66594 + g_eSlewRateIndex = SLEW_RATE_16X; //4; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //665ac + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 4) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 4) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 4; + } + //0x62fbc + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //66634 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 4) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 4) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 4; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //666c8 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 4) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 4) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 4; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //6675c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 4) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 4) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 4; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //667f0 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 4) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 4) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 4; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //6687c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 4) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 4) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 4; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //66918 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '4'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '4'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //6694c + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '4'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '4'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //66990 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '4'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '4'; + } + else + { + //0x669d0 + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //66a58 + switch (bCustomerObjectNameChar) + { + case '4': + //0x66aa4 + bCustomerObjectNameChar = 'g'; + break; + + case 'g': //103 + //0x66ab8 + bCustomerObjectNameChar = 'h'; + break; + + case 'h': //104 + //0x66acc + bCustomerObjectNameChar = 'i'; + break; + + case 'i': //105 + //0x66ae0 + bCustomerObjectNameChar = 'G'; + break; + + case 'G': //71 + //0x66af4 + bCustomerObjectNameChar = 'H'; + break; + + case 'H': //72 + //0x66b08 + bCustomerObjectNameChar = 'I'; + break; + + case 'I': //73 + //0x66b1c + bCustomerObjectNameChar = '4'; + break; + + default: + //0x66b30 + bCustomerObjectNameChar = '4'; + break; + } + //0x66b44 + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //66b68 + if (bCharacterInputPosition != 1) + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '4'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '4'; + } + else + { + //0x66bac + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + //0x66c24 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //66c2c + if (bDateTimeInputMode == 0) + { + Data_40002655[bCharacterInputPosition - 1] = '4'; + Data_400037ec[bCharacterInputPosition - 1] = '4'; + } + else + { + //0x66c70 + Data_40002660[bCharacterInputPosition - 1] = '4'; + Data_40003150[bCharacterInputPosition - 1] = '4'; + } + //0x66c9c + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //66ca4 + HandleCustomSiteInputChar(4); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //66cb4 + func_623d0(4); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //66cc4 + Data_4000294a[bCharacterInputPosition - 1] = '4'; + strEng00000s[bCharacterInputPosition - 1] = '4'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //66cfc + Data_40002a3f[bCharacterInputPosition - 1] = '4'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '4'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //66d3c + Data_40002474[bCharacterInputPosition - 1] = '4'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '4'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //66d78 + Data_40002481[bCharacterInputPosition - 1] = '4'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '4'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //66df4 + strEyepieceFovInput[bCharacterInputPosition - 1] = '4'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //66e18 + func_61ecc(4); + break; + + default: + //0x66e28 + break; + } +} + diff --git a/applications/freertos_app/Handle5Key.c b/applications/freertos_app/Handle5Key.c new file mode 100644 index 0000000..38f940b --- /dev/null +++ b/applications/freertos_app/Handle5Key.c @@ -0,0 +1,322 @@ + + +/* 65894 - todo */ +void Handle5Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x65a58 + g_eSlewRateIndex = SLEW_RATE_64X; //5; + //->0x6636c + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //65a78 + bData_4000319a_SkyLandTargetId = 5; + break; + + case 5000: + //65a88 + g_eSlewRateIndex = SLEW_RATE_64X; //5; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //65ab0 + g_eSlewRateIndex = SLEW_RATE_64X; //5; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //65ac8 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 5) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 5) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 5; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //65b50 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 5) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 5) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 5; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //65be4 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 5) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 5) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 5; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //65c78 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 5) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 5) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 5; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //65d74 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 5) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 5) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 5; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //65e00 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 5) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 5) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 5; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //65e9c + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '5'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '5'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //65ed0 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '5'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '5'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //65f14 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '5'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '5'; + } + else + { + //0x65f54 + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //65fdc + switch (bCustomerObjectNameChar) + { + case '5': + //0x66028 + bCustomerObjectNameChar = 'j'; + break; + + case 'j': //106: + //0x6603c + bCustomerObjectNameChar = 'k'; + break; + + case 'k': //107 + //0x66050 + bCustomerObjectNameChar = 'l'; + break; + + case 'l': //108 + //0x66064 + bCustomerObjectNameChar = 'J'; + break; + + case 'J': //74: + //0x66078 + bCustomerObjectNameChar = 'K'; + break; + + case 'K': //75: + //0x6608c + bCustomerObjectNameChar = 'L'; + break; + + case 'L': //76: + //0x660a0 + bCustomerObjectNameChar = '5'; + break; + + default: + //0x660b4 + bCustomerObjectNameChar = '5'; + break; + } + //0x660c8 + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //660ec + if (bCharacterInputPosition != 1) + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '5'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '5'; + } + else + { + //0x66130 + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + //0x661a8 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //661b0 + if (bDateTimeInputMode == 0) + { + Data_40002655[bCharacterInputPosition - 1] = '5'; + Data_400037ec[bCharacterInputPosition - 1] = '5'; + } + else + { + //0x661f4 + Data_40002660[bCharacterInputPosition - 1] = '5'; + Data_40003150[bCharacterInputPosition - 1] = '5'; + } + //0x66220 + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //66228 + HandleCustomSiteInputChar(5); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //66238 + func_623d0(5); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //66248 + Data_4000294a[bCharacterInputPosition - 1] = '5'; + strEng00000s[bCharacterInputPosition - 1] = '5'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //66280 + Data_40002a3f[bCharacterInputPosition - 1] = '5'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '5'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //662c0 + Data_40002474[bCharacterInputPosition - 1] = '5'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '5'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //662fc + Data_40002481[bCharacterInputPosition - 1] = '5'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '5'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //66330 + strEyepieceFovInput[bCharacterInputPosition - 1] = '5'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //66354 + func_61ecc(5); + break; + + default: + //0x66364 + break; + } +} + diff --git a/applications/freertos_app/Handle6Key.c b/applications/freertos_app/Handle6Key.c new file mode 100644 index 0000000..7300cb7 --- /dev/null +++ b/applications/freertos_app/Handle6Key.c @@ -0,0 +1,322 @@ + + +/* 64e18 - todo */ +void Handle6Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x64fdc + g_eSlewRateIndex = SLEW_RATE_128X; //6; + //->0x65888 + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //64ffc + bData_4000319a_SkyLandTargetId = 6; + break; + + case 5000: + //6500c + g_eSlewRateIndex = SLEW_RATE_128X; //6; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //65034 + g_eSlewRateIndex = SLEW_RATE_128X; //6; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //6504c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 6) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 6) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 6; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //650d4 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 6) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 6) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 6; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //65168 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 6) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 6) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 6; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //651fc + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 6) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 6) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 6; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //65290 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 6) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 6) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 6; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //6531c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 6) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 6) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 6; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //653b8 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '6'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '6'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //653ec + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '6'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '6'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //65430 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '6'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '6'; + } + else + { + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //654f8 + switch (bCustomerObjectNameChar) + { + case '6': + //0x65544 + bCustomerObjectNameChar = 'm'; + break; + + case 'm': //109: + //0x65558 + bCustomerObjectNameChar = 'n'; + break; + + case 'n': //110: + //0x6556c + bCustomerObjectNameChar = 'o'; + break; + + case 'o': //111: + //0x65580 + bCustomerObjectNameChar = 'M'; + break; + + case 'M': //77: + //0x65594 + bCustomerObjectNameChar = 'N'; + break; + + case 'N': //78: + //0x655a8 + bCustomerObjectNameChar = 'O'; + break; + + case 'O': //79: + //0x655bc + bCustomerObjectNameChar = '6'; + break; + + default: + //0x655d0 + bCustomerObjectNameChar = '6'; + break; + } + //0x655e4 + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //65608 + if (bCharacterInputPosition != 1) + { + //6561c + strTrackingRateCustInput[bCharacterInputPosition - 1] = '6'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '6'; + } + else + { + //0x6564c + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + //0x656c4 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //656cc + if (bDateTimeInputMode == 0) + { + Data_40002655[bCharacterInputPosition - 1] = '6'; + Data_400037ec[bCharacterInputPosition - 1] = '6'; + } + else + { + //0x65710 + Data_40002660[bCharacterInputPosition - 1] = '6'; + Data_40003150[bCharacterInputPosition - 1] = '6'; + } + //0x6573c + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //65744 + HandleCustomSiteInputChar(6); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //65754 + func_623d0(6); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //65764 + Data_4000294a[bCharacterInputPosition - 1] = '6'; + strEng00000s[bCharacterInputPosition - 1] = '6'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //6579c + Data_40002a3f[bCharacterInputPosition - 1] = '6'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '6'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //657dc + Data_40002474[bCharacterInputPosition - 1] = '6'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '6'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //65818 + Data_40002481[bCharacterInputPosition - 1] = '6'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '6'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //6584c + strEyepieceFovInput[bCharacterInputPosition - 1] = '6'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //65870 + func_61ecc(6); + break; + + default: + //0x65880 + break; + } +} + diff --git a/applications/freertos_app/Handle7Key.c b/applications/freertos_app/Handle7Key.c new file mode 100644 index 0000000..ebef5fb --- /dev/null +++ b/applications/freertos_app/Handle7Key.c @@ -0,0 +1,335 @@ + + +/* 64324 - todo */ +void Handle7Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x644e8 + g_eSlewRateIndex = SLEW_RATE_256X; //7; + //->0x64e0c + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //64508 + bData_4000319a_SkyLandTargetId = 7; + break; + + case 5000: + //64518 + g_eSlewRateIndex = SLEW_RATE_256X; //7; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //64540 + g_eSlewRateIndex = SLEW_RATE_256X; //7; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //64558 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 7) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 7) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 7; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //645e0 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 7) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 7) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 7; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //64674 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 7) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 7) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 7; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //64708 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 7) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 7) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 7; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //6479c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 7) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 7) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 7; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //64828 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 7) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 7) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 7; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //648c4 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '7'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '7'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //648f8 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '7'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '7'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //6493c + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '7'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '7'; + } + else + { + //0x6497c + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + //0x649c8 + Data_40002302[bCharacterInputPosition - 1] = '-'; //'+'; //BUG! + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; //'+'; //BUG! + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //64a04 + switch (bCustomerObjectNameChar) + { + case '7': + //0x64a60 + bCustomerObjectNameChar = 'p'; + break; + + case 'p': //112: + //0x64a74 + bCustomerObjectNameChar = 'q'; + break; + + case 'q': //113: + //0x64a88 + bCustomerObjectNameChar = 'r'; + break; + + case 'r': //114: + //0x64a9c + bCustomerObjectNameChar = 's'; + break; + + case 's': //115: + //0x64ab0 + bCustomerObjectNameChar = 'P'; + break; + + case 'P': //80: + //0x64ac4 + bCustomerObjectNameChar = 'Q'; + break; + + case 'Q': //81: + //0x64ad8 + bCustomerObjectNameChar = 'R'; + break; + + case 'R': //82: + //0x64aec + bCustomerObjectNameChar = 'S'; + break; + + case 'S': //83 + //0x64b00 + bCustomerObjectNameChar = '7'; + break; + + default: + //0x64b14 + bCustomerObjectNameChar = '7'; + break; + } + //0x64b28 + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //64b4c + if (bCharacterInputPosition != 1) + { + //64b60 + strTrackingRateCustInput[bCharacterInputPosition - 1] = '7'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '7'; + } + else + { + //0x64b90 + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + //0x64c08 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //64c10 + if (bDateTimeInputMode == 0) + { + //64c24 + Data_40002655[bCharacterInputPosition - 1] = '7'; + Data_400037ec[bCharacterInputPosition - 1] = '7'; + } + else + { + //0x64c54 + Data_40002660[bCharacterInputPosition - 1] = '7'; + Data_40003150[bCharacterInputPosition - 1] = '7'; + } + //0x64c80 + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //64c88 + HandleCustomSiteInputChar(7); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //64c98 + func_623d0(7); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //64ca8 + Data_4000294a[bCharacterInputPosition - 1] = '7'; + strEng00000s[bCharacterInputPosition - 1] = '7'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //64ce0 + Data_40002a3f[bCharacterInputPosition - 1] = '7'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '7'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //64d20 + Data_40002474[bCharacterInputPosition - 1] = '7'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '7'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //64d9c + Data_40002481[bCharacterInputPosition - 1] = '7'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '7'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //64dd0 + strEyepieceFovInput[bCharacterInputPosition - 1] = '7'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //64df4 + func_61ecc(7); + break; + + default: + //0x64e04 + break; + } +} + diff --git a/applications/freertos_app/Handle8Key.c b/applications/freertos_app/Handle8Key.c new file mode 100644 index 0000000..b274786 --- /dev/null +++ b/applications/freertos_app/Handle8Key.c @@ -0,0 +1,324 @@ + + +/* 637e8 - todo */ +void Handle8Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x639ac + g_eSlewRateIndex = SLEW_RATE_512X; //8; + //->0x64318 + break; + + case 101: + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //639cc + bData_4000319a_SkyLandTargetId = 8; + break; + + case 5000: + //639dc + g_eSlewRateIndex = SLEW_RATE_512X; //8; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //63a04 + g_eSlewRateIndex = SLEW_RATE_512X; //8; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //63adc + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 8) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 8) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 8; + } + //0x63b30 + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //63b64 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 8) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 8) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 8; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //63bf8 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 8) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 8) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 8; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //63c8c + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 8) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 8) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 8; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //63d20 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 8) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 8) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 8; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //63dac + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 8) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 8) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 8; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //63e48 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '8'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '8'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //63e7c + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '8'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '8'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //63ec0 + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '8'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '8'; + } + else + { + //0x63f00 + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //63f88 + switch (bCustomerObjectNameChar) + { + case '8': + //0x63fd4 + bCustomerObjectNameChar = 't'; + break; + + case 't': //116: + //0x63fe8 + bCustomerObjectNameChar = 'u'; + break; + + case 'u': //117: + //0x63ffc + bCustomerObjectNameChar = 'v'; + break; + + case 'v': //118: + //0x64010 + bCustomerObjectNameChar = 'T'; + break; + + case 'T': //84: + //0x64024 + bCustomerObjectNameChar = 'U'; + break; + + case 'U': //85: + //0x64038 + bCustomerObjectNameChar = 'V'; + break; + + case 'V': //86: + //0x6404c + bCustomerObjectNameChar = '8'; + break; + + default: + //0x64060 + bCustomerObjectNameChar = '8'; + break; + } + //0x64074 + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //64098 + if (bCharacterInputPosition != 1) + { + //640ac + strTrackingRateCustInput[bCharacterInputPosition - 1] = '8'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '8'; + } + else + { + //0x640dc + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + //0x64154 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //6415c + if (bDateTimeInputMode == 0) + { + //64170 + Data_40002655[bCharacterInputPosition - 1] = '8'; + Data_400037ec[bCharacterInputPosition - 1] = '8'; + } + else + { + //0x641a0 + Data_40002660[bCharacterInputPosition - 1] = '8'; + Data_40003150[bCharacterInputPosition - 1] = '8'; + } + //0x641cc + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //641d4 + HandleCustomSiteInputChar(8); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //641e4 + func_623d0(8); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //641f4 + Data_4000294a[bCharacterInputPosition - 1] = '8'; + strEng00000s[bCharacterInputPosition - 1] = '8'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //6422c + Data_40002a3f[bCharacterInputPosition - 1] = '8'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '8'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //6426c + Data_40002474[bCharacterInputPosition - 1] = '8'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '8'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //642a8 + Data_40002481[bCharacterInputPosition - 1] = '8'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '8'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //642dc + strEyepieceFovInput[bCharacterInputPosition - 1] = '8'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //64300 + func_61ecc(8); + break; + + default: + //0x64310 + break; + } +} + diff --git a/applications/freertos_app/Handle9Key.c b/applications/freertos_app/Handle9Key.c new file mode 100644 index 0000000..bf65102 --- /dev/null +++ b/applications/freertos_app/Handle9Key.c @@ -0,0 +1,359 @@ + + +/* 62ce0 - todo */ +void Handle9Key(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x62ea4 + g_eSlewRateIndex = SLEW_RATE_MAX; //9; + if (g_bSlewingStop == 0) + { + g_eSlewRateIndex = SLEW_RATE_512X; //8; + } + //0x62ed0 -> 0x637dc + break; + + case 101: + //0x62ed4 + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x62edc + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x62ee0 + bData_4000319a_SkyLandTargetId = 9; + break; + + case 5000: + //0x62ef0 + g_eSlewRateIndex = SLEW_RATE_MAX; //9; + if (g_bSlewingStop == 0) + { + g_eSlewRateIndex = SLEW_RATE_512X; //8; + } + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x62f20 + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x62f28 + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + //0x62f2c + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + //0x62f30 + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x62f34 + g_eSlewRateIndex = SLEW_RATE_MAX; //9; + if (g_bSlewingStop == 0) + { + g_eSlewRateIndex = SLEW_RATE_512X; //8; + } + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x62f60 + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x62f68 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 9) <= 110) && ((10*Data_40002ec8_NavigationDirectInputNr + 9) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 9; + } + //0x62fbc + if ((Data_40002ec8_NavigationDirectInputNr <= 110) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eb8_MessierNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x62ff0 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 9) <= 7840) && ((10*Data_40002ec8_NavigationDirectInputNr + 9) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 9; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 7840) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002eba_NGCNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x63084 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 9) <= 5386) && ((10*Data_40002ec8_NavigationDirectInputNr + 9) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 9; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 5386) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebc_ICNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x63118 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 9) <= 313) && ((10*Data_40002ec8_NavigationDirectInputNr + 9) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 9; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 313) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ebe_ShNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x631ac + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 9) <= 167) && ((10*Data_40002ec8_NavigationDirectInputNr + 9) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 9; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 167) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + wData_40002ec0_BrightStarNr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x63238 + lcd_display_clear(); + + if (((10*Data_40002ec8_NavigationDirectInputNr + 9) <= 258997) && ((10*Data_40002ec8_NavigationDirectInputNr + 9) != 0)) + { + Data_40002ec8_NavigationDirectInputNr = 10*Data_40002ec8_NavigationDirectInputNr + 9; + } + + if ((Data_40002ec8_NavigationDirectInputNr <= 258997) && (Data_40002ec8_NavigationDirectInputNr != 0)) + { + Data_40002ec4_SAONr = Data_40002ec8_NavigationDirectInputNr; + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + //0x632cc + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x632d4 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '9'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '9'; + + func_57b40(); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x63308 + strCustomerObjectRaAziInputForTracking[bCharacterInputPosition - 1] = '9'; + strCustomerObjectRaAziInputForStoring[bCharacterInputPosition - 1] = '9'; + + func_57a4c(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + //0x63340 + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x63348 + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x6334c + if (bCharacterInputPosition != 5) + { + Data_40002302[bCharacterInputPosition - 1] = '9'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '9'; + } + else + { + //0x6338c + if (Data_40002302[bCharacterInputPosition - 1] == '+') + { + Data_40002302[bCharacterInputPosition - 1] = '-'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '-'; + } + else + { + Data_40002302[bCharacterInputPosition - 1] = '+'; + strCustomerObjectDecAltInputForStoring[bCharacterInputPosition - 1] = '+'; + } + } + + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x6340c + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x63414 + switch (bCustomerObjectNameChar) + { + case '9': + //0x63470 + bCustomerObjectNameChar = 'w'; + break; + + case 'w': //119: + //0x63484 + bCustomerObjectNameChar = 'x'; + break; + + case 'x': //120: + //0x63498 + bCustomerObjectNameChar = 'y'; + break; + + case 'y': //121: + //0x634ac + bCustomerObjectNameChar = 'z'; + break; + + case 'z': //122: + //0x634c0 + bCustomerObjectNameChar = 'W'; + break; + + case 'W': //87: + //0x634d4 + bCustomerObjectNameChar = 'X'; + break; + + case 'X': //88: + //0x634e8 + bCustomerObjectNameChar = 'Y'; + break; + + case 'Y': //89: + //0x634fc + bCustomerObjectNameChar = 'Z'; + break; + + case 'Z': //90 + //0x63510 + bCustomerObjectNameChar = '9'; + break; + + default: + //0x63524 + bCustomerObjectNameChar = '9'; + break; + } + //0x63538 + strCustomerObjectNameInput[bCharacterInputPosition - 1] = bCustomerObjectNameChar; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x6355c + if (bCharacterInputPosition != 1) + { + //63570 + strTrackingRateCustInput[bCharacterInputPosition - 1] = '9'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '9'; + } + else + { + //0x635a0 + if (strTrackingRateCustInput[bCharacterInputPosition - 1] == '+') + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '-'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '-'; + } + else + { + strTrackingRateCustInput[bCharacterInputPosition - 1] = '+'; + strTrackingRateCustDisplay[bCharacterInputPosition - 1] = '+'; + } + } + //0x63618 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x63620 + if (bDateTimeInputMode == 0) + { + //63634 + Data_40002655[bCharacterInputPosition - 1] = '9'; + Data_400037ec[bCharacterInputPosition - 1] = '9'; + } + else + { + //0x63664 + Data_40002660[bCharacterInputPosition - 1] = '9'; + Data_40003150[bCharacterInputPosition - 1] = '9'; + } + //0x63690 + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x63698 + HandleCustomSiteInputChar(9); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x636a8 + func_623d0(9); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x636b8 + Data_4000294a[bCharacterInputPosition - 1] = '9'; + strEng00000s[bCharacterInputPosition - 1] = '9'; + + HandleNextTimerInputPosition(); + break; + + case 35001: + //0x636f0 + Data_40002a3f[bCharacterInputPosition - 1] = '9'; + strEngAlarm21h34m23s[bCharacterInputPosition - 1] = '9'; + + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x63728 + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x63730 + Data_40002474[bCharacterInputPosition - 1] = '9'; + strEyepieceFovMfInput[bCharacterInputPosition - 1] = '9'; + + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x63764 + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x6376c + Data_40002481[bCharacterInputPosition - 1] = '9'; + strEyepieceFovSfInput[bCharacterInputPosition - 1] = '9'; + + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x637a0 + strEyepieceFovInput[bCharacterInputPosition - 1] = '9'; + + HandleNextEyepieceFovInputPosition(); + break; + + case 211001: + //0x637c4 + func_61ecc(9); + break; + + default: + //0x637d4 + break; + } +} + diff --git a/applications/freertos_app/HandleDownKey.c b/applications/freertos_app/HandleDownKey.c new file mode 100644 index 0000000..ab4594b --- /dev/null +++ b/applications/freertos_app/HandleDownKey.c @@ -0,0 +1,1144 @@ + +//#include "menu.h" + +/* 5ab50 - todo */ +void HandleDownKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_RECENT_TARGETS: //1: + //0x5b27c + if (bData_4000316e_FocusLineOn8LineDisplay == bData_40002f14_RecentTargetCount) + { + bData_4000316e_FocusLineOn8LineDisplay = 1; + } + else + { + bData_4000316e_FocusLineOn8LineDisplay++; + } + //->0x5ca8c + break; + + case 500: + //0x5b2c0: Main Screen Help Pages + lcd_display_clear(); + + if (bData_40002c59_MainScreenHelpPage == 10) + { + bData_40002c59_MainScreenHelpPage = 1; + } + else + { + bData_40002c59_MainScreenHelpPage++; + } + //->0x5ca8c + break; + + case MENU_CONTEXT_ALIGNMENT: //1000: + //0x5b300: Telescope Align + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + //->0x5ca8c + break; + + case MENU_CONTEXT_NAVIGATION: //2000: + //0x5b314 + Data_40002c64_MenuContextId = MENU_CONTEXT_UTILITIES; //3000; + break; + + case MENU_CONTEXT_UTILITIES: //3000: + //0x5b328 + Data_40002c64_MenuContextId = MENU_CONTEXT_SETUP; //4000; + break; + + case MENU_CONTEXT_SETUP: //4000: + //0x5b33c + Data_40002c64_MenuContextId = 1000; + break; + + case MENU_CONTEXT_ONE_STAR_ALIGN: //1100: + //0x5b350: One Star Align + HandleLongListScroll(1, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_TWO_STAR_ALIGN; //1200; + break; + + case MENU_CONTEXT_TWO_STAR_ALIGN: //1200: + //0x5b370: Two Star Align + HandleLongListScroll(1, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_THREE_STAR_ALIGN; //1300; + break; + + case MENU_CONTEXT_THREE_STAR_ALIGN: //1300: + //0x5b390: Three Star Align + HandleLongListScroll(1, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_TARGET_SYNC; //1400; + break; + + case MENU_CONTEXT_TARGET_SYNC: //1400: + //0x5b3b0: Target Sync + HandleLongListScroll(1, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_POLE_AXIS_DEV; //1500; + break; + + case MENU_CONTEXT_POLE_AXIS_DEV: //1500: + //0x5b3d0: Pole-Axis Dev. + HandleLongListScroll(1, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR; //1600; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR: //1600: + //0x5b3f0: RA Bklash Corr. + HandleLongListScroll(1, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKLASH_CORR; //1700; + break; + + case MENU_CONTEXT_DEC_BKLASH_CORR: //1700: + //0x5b410: DEC Bklash Correction + bData_40003173 = 1; + bData_40003171 = 1; + bData_40003172 = 1; + bData_40003170 = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_ONE_STAR_ALIGN; //1100; + break; + + case MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM: //2100: + //0x5b448 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CONSTELLATION; //2200; + break; + + case MENU_CONTEXT_NAVIGATION_CONSTELLATION: //2200: + //0x5b468 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_FAMOUS_STAR; //2300; + break; + + case MENU_CONTEXT_NAVIGATION_FAMOUS_STAR: //2300: + //0x5b488 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_MESSIER_CAT; //2400; + break; + + case MENU_CONTEXT_NAVIGATION_MESSIER_CAT: //2400: + //0x5b4a8 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_NGC_CAT; //2500; + break; + + case MENU_CONTEXT_NAVIGATION_NGC_CAT: //2500: + //0x5b4c8 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_IC_CAT; //2600; + break; + + case MENU_CONTEXT_NAVIGATION_IC_CAT: //2600: + //0x5b4e8 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SH2_CAT; //2700; + break; + + case MENU_CONTEXT_NAVIGATION_SH2_CAT: //2700: + //0x5b508 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_BRIGHT_STAR; //2800; + break; + + case MENU_CONTEXT_NAVIGATION_BRIGHT_STAR: //2800: + //0x5b528 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SAO_CAT; //2900; + break; + + case MENU_CONTEXT_NAVIGATION_SAO_CAT: //2900: + //0x5b548 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case MENU_CONTEXT_NAVIGATION_CUST_OBJ: //2110: + //0x5b568 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_RA_DEC; //2120; + break; + + case MENU_CONTEXT_NAVIGATION_RA_DEC: //2120: + //0x5b588 + HandleLongListScroll(1, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_LAND; //2130; + break; + + case MENU_CONTEXT_NAVIGATION_CUST_LAND: //2130: + //0x5b5a8 + bData_40003177 = 1; + bData_40003175 = 1; + bData_40003176 = 1; + bData_40003174 = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM; //2100; + break; + + case MENU_CONTEXT_CURRENT_OBJECTS: //3100: + //0x5b5e0 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_OBJECT_RISE_SET; //3200; + break; + + case MENU_CONTEXT_OBJECT_RISE_SET: //3200: + //0x5b600 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_LUNAR_PHASE; //3300; + break; + + case MENU_CONTEXT_LUNAR_PHASE: //3300: + //0x5b620 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER; //3400; + break; + + case MENU_CONTEXT_TIMER: //3400: + //0x5b640 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_ALARM; //3500; + break; + + case MENU_CONTEXT_ALARM: //3500: + //0x5b660 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV; //3600; + break; + + case MENU_CONTEXT_EYEPIECE_FOV: //3600: + //0x5b680 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN; //3700; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN: //3700: + //0x5b6a0 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_DISPLAY_ILLUMINATION; //3800; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION: //3800: + //0x5b6c0 + HandleLongListScroll(1, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_PARK_POSITION; //3900; + break; + + case MENU_CONTEXT_PARK_POSITION: //3900: + //0x5b6e0 + bData_4000317b = 1; + bData_40003179 = 1; + bData_4000317a = 1; + bData_40003178 = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_CURRENT_OBJECTS; //3100; + break; + + case MENU_CONTEXT_TIME_DATE: //4100: + //0x5b718 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = 4200; + break; + + case 4200: + //0x5b738 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_SITE_SETTING; //4300; + break; + + case MENU_CONTEXT_SITE_SETTING: //4300: + //0x5b758 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = 4400; + break; + + case 4400: + //0x5b778 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_AZ_EQU; //4500; + break; + + case MENU_CONTEXT_AZ_EQU: //4500: + //0x5b798 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_TELESCOPE_MOUNT; //4600; + break; + + case MENU_CONTEXT_TELESCOPE_MOUNT: //4600: + //0x5b7b8 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE; //4700; + break; + + case MENU_CONTEXT_TRACKING_RATE: //4700: + //0x5b7d8 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_LANGUAGE; //4800; + break; + + case MENU_CONTEXT_LANGUAGE: //4800: + //0x5b7f8 + HandleLongListScroll(1, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_RESET; //4900; + break; + + case MENU_CONTEXT_RESET: //4900: + //0x5b818 + bData_4000317f = 1; + bData_4000317d = 1; + bData_4000317e = 1; + bData_4000317c = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE; //4100; + break; + + case MENU_CONTEXT_SYNC_ENSURE: //1402: + //0x5b850 + Data_40002c64_MenuContextId = MENU_CONTEXT_SYNC_CANCEL; //1403; + break; + + case MENU_CONTEXT_SYNC_CANCEL: //1403: + //0x5b864 + Data_40002c64_MenuContextId = MENU_CONTEXT_SYNC_ENSURE; //1402; + break; + + case 22011: + //0x5b878 + bData_40003182 = 1; + bData_40003180 = 1; + Data_40002c64_MenuContextId = 2201; + break; + + case 2301: + //0x5b8a0 + HandleLongListScroll(1, 23); + Data_40002c64_MenuContextId = 2302; + break; + + case 2302: + //0x5b8c0 + HandleLongListScroll(1, 23); + Data_40002c64_MenuContextId = 2303; + break; + + case 2303: + //0x5b8e0 + HandleLongListScroll(1, 23); + Data_40002c64_MenuContextId = 2304; + break; + + case 2304: + //0x5b900 + HandleLongListScroll(1, 23); + Data_40002c64_MenuContextId = 2305; + break; + + case 2305: + //0x5b920 + HandleLongListScroll(1, 23); + Data_40002c64_MenuContextId = 2306; + break; + + case 2306: + //0x5b940 + HandleLongListScroll(1, 23); + Data_40002c64_MenuContextId = 2307; + break; + + case 2307: + //0x5b960 + HandleLongListScroll(1, 23); + Data_40002c64_MenuContextId = 2308; + break; + + case 2308: + //0x5b980 + bData_40003186 = 1; + bData_40003184 = 1; + Data_40002c64_MenuContextId = 2301; + break; + + case 2501: + //0x5b9a8 + Data_40002c64_MenuContextId = 2502; + break; + + case 2502: + //0x5b9bc + Data_40002c64_MenuContextId = 2503; + break; + + case 2503: + //0x5b9d0 + Data_40002c64_MenuContextId = 2501; + break; + + case 2801: + //0x5b9e4 + Data_40002c64_MenuContextId = 2802; + break; + + case 2802: + //0x5b9f8 + Data_40002c64_MenuContextId = 2803; + break; + + case 2803: + //0x5ba0c + Data_40002c64_MenuContextId = 2804; + break; + + case 2804: + //0x5ba20 + Data_40002c64_MenuContextId = 2801; + break; + + case 21101: + //0x5ba34 + Data_40002c64_MenuContextId = 21102; + break; + + case 21102: + //0x5ba48 + Data_40002c64_MenuContextId = 21103; + break; + + case 21103: + //0x5ba5c + Data_40002c64_MenuContextId = 21101; + break; + + case 3601: + //0x5ba70 + Data_40002c64_MenuContextId = 3602; + break; + + case 3602: + //0x5ba84 + Data_40002c64_MenuContextId = 3601; + break; + + case 3801: + //0x5ba98 + Data_40002c64_MenuContextId = 3802; + break; + + case 3802: + //0x5baac + Data_40002c64_MenuContextId = 3801; + break; + + case MENU_CONTEXT_COUNTRY_CITY: //4301: + //0x5bbc0 + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOM_SITE; //4302; + break; + + case MENU_CONTEXT_CUSTOM_SITE: //4302: + //0x5bbd4 + Data_40002c64_MenuContextId = MENU_CONTEXT_COUNTRY_CITY; //4301; + break; + + case MENU_CONTEXT_TRACKING_RATE_STAR_SPEED: //4801: + //0x5bbe8: Tracking Rate -> "Star Speed" + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED; //4802; + break; + + case MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED: //4802: + //0x5bbfc -> "Solar Speed" + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_MOON_SPEED; //4803; + break; + + case MENU_CONTEXT_TRACKING_RATE_MOON_SPEED: //4803: + //0x5bc10 -> "Moon Speed" + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED; //4804; + break; + + case MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED: //4804: + //0x5bc24 -> "Customize Speed" + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED; //4805; + break; + + case MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED: //4805: + //0x5bc38 -> "Guiding Speed" + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_STAR_SPEED; //4801; + break; + + case MENU_CONTEXT_GUIDING_SPEED1: //48051: + //0x5bc4c + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED2; //48052; + break; + + case MENU_CONTEXT_GUIDING_SPEED2: //48052: + //0x5bc60 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED3; //48053; + break; + + case MENU_CONTEXT_GUIDING_SPEED3: //48053: + //0x5bc74 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED4; //48054; + break; + + case MENU_CONTEXT_GUIDING_SPEED4: //48054: + //0x5bc88 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED5; //48055; + break; + + case MENU_CONTEXT_GUIDING_SPEED5: //48055: + //0x5bc9c + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED6; //48056; + break; + + case MENU_CONTEXT_GUIDING_SPEED6: //48056: + //0x5bcb0 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED7; //48057; + break; + + case MENU_CONTEXT_GUIDING_SPEED7: //48057: + //0x5bcc4 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED8; //48058; + break; + + case MENU_CONTEXT_GUIDING_SPEED8: //48058: + //0x5bcd8 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED1; //48051; + break; + + case MENU_CONTEXT_MAIN: //0: + //0x5bcec + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x5bcf4 + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x5bcf8 + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x5bcfc + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x5bd00 + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x5bd04 + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x5bd08 + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x5bd0c + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x5bd10 + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x5bd14 + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x5bd18 + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x5bd1c + if (g_bLandTarget == 0) + { + //5bd2c + if ((Data_40004128.bTrackingActive != 0) && + (g_bSlewingStop != 1)) + { + //5bd4c + g_iSlewStepDecAxis = -1; + bData_40003201 = 0; + } + else + { + //0x5bd68 + if (bData_40002c1a == 1) + { + //5bd78 + SlewAxis(2, 2, g_eSlewRateIndex); + } + else + { + //0x5bd90 + SlewAxis(4, 2, g_eSlewRateIndex); + } + } + } + else + { + //0x5bda8 + if (bData_40002c1a == 1) + { + //5bdb8 + SlewAxis(2, 2, g_eSlewRateIndex); + } + else + { + //0x5bdd0 + SlewAxis(4, 2, g_eSlewRateIndex); + } + } + //->0x5ca8c + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN: //11201: + //0x5bde8 + dData_40002e00 = dData_40002df8; + if (bData_40002c1a == 1) + { + //5be0c + SlewAxis(2, 2, SLEW_RATE_8X); + bData_40002edd = 3; + } + else + { + //0x5be2c + SlewAxis(4, 2, SLEW_RATE_8X); + bData_40002edd = 1; + } + iBacklashCorrectionSlewing = 1; + bDecBacklashCorrectionDirection = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN; //11203; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + //0x5be6c + if (bDecBacklashCorrectionDirection == 2) + { + if (bData_40002c1a == 1) + { + //5be90 + SlewAxis(2, 2, SLEW_RATE_8X); + } + else + { + //0x5bea4 + SlewAxis(4, 2, SLEW_RATE_8X); + } + } + //5beb4 -> 0x5ca8c + break; + + case MENU_CONTEXT_SKY_TARGET: //45001: + //0x5beb8 + Data_40002c64_MenuContextId = MENU_CONTEXT_LAND_TARGET; //45002; + break; + + case MENU_CONTEXT_LAND_TARGET: //45002: + //0x5becc + Data_40002c64_MenuContextId = MENU_CONTEXT_SKY_TARGET; //45001; + break; + + case MENU_CONTEXT_MOUNT_AZ: //46001: + //0x5bee0 + Data_40002c64_MenuContextId = MENU_CONTEXT_MOUNT_EQU; //46002; + break; + + case MENU_CONTEXT_MOUNT_EQU: //46002: + //0x5bef4 + Data_40002c64_MenuContextId = MENU_CONTEXT_MOUNT_AZ; //46001; + break; + + case MENU_CONTEXT_ENGLISH: //49001: + //0x5bf08: Language -> English + Data_40002c64_MenuContextId = MENU_CONTEXT_GERMAN; //49002; + break; + + case MENU_CONTEXT_GERMAN: //49002: + //0x5bf1c + Data_40002c64_MenuContextId = MENU_CONTEXT_FRENCH; //49003; + break; + + case MENU_CONTEXT_FRENCH: //49003: + //0x5bf30 + Data_40002c64_MenuContextId = MENU_CONTEXT_ITALIAN; //49004; + break; + + case MENU_CONTEXT_ITALIAN: //49004: + //0x5bf44 + Data_40002c64_MenuContextId = MENU_CONTEXT_SPANISH; //49005; + break; + + case MENU_CONTEXT_SPANISH: //49005: + //0x5bf58 + Data_40002c64_MenuContextId = MENU_CONTEXT_ENGLISH; //49001; + break; + + case 21001: + //0x5bf6c + if ((bData_40003161 - 1) == bData_40002eb4) + { + bData_40002eb4 = 0; + } + else + { + bData_40002eb4++; + } + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION: //22001: + //0x5bfb4: Navigation -> Solar System + lcd_display_clear(); + case MENU_CONTEXT_SOLAR_SYSTEM_OBJ_RISE_SET_TIMES: //31001: + //0x5bfc0 + bData_40002eb5_SolarSystemObjectNr++; + if (bData_40002eb5_SolarSystemObjectNr > 9) + { + bData_40002eb5_SolarSystemObjectNr = 0; + } + break; + + case MENU_CONTEXT_CONSTELLATION_SELECTION: //24001: + //0x5bff4: Navigation - Constellation + lcd_display_clear(); + + bData_40002ece_ConstellationNr++; + if (bData_40002ece_ConstellationNr > 88) + { + bData_40002ece_ConstellationNr = 1; + } + break; + + case MENU_CONTEXT_FAMOUS_STAR_SELECTION: //25001: + //0x5c030 + lcd_display_clear(); + + bData_40002ed2_FamousStarNr++; + if (bData_40002ed2_FamousStarNr > 33) + { + bData_40002ed2_FamousStarNr = 1; + } + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x5c06c + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x5c074 + lcd_display_clear(); + + wData_40002eb8_MessierNr++; + if (wData_40002eb8_MessierNr > 110) + { + wData_40002eb8_MessierNr = 1; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x5c0b0 + lcd_display_clear(); + + wData_40002eba_NGCNr++; + if (wData_40002eba_NGCNr > 7840) + { + wData_40002eba_NGCNr = 1; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x5c0f4 + lcd_display_clear(); + + wData_40002ebc_ICNr++; + if (wData_40002ebc_ICNr > 5386) + { + wData_40002ebc_ICNr = 1; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x5c138 + lcd_display_clear(); + + wData_40002ebe_ShNr++; + if (wData_40002ebe_ShNr > 313) + { + wData_40002ebe_ShNr = 1; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x5c17c + lcd_display_clear(); + + wData_40002ec0_BrightStarNr++; + if (wData_40002ec0_BrightStarNr > 167) + { + wData_40002ec0_BrightStarNr = 1; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x5c1bc + lcd_display_clear(); + + Data_40002ec4_SAONr++; + if (Data_40002ec4_SAONr > 258997) + { + Data_40002ec4_SAONr = 1; + } + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x5c1fc + bCharacterInputPosition = 6; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT; //204; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x5c21c + bCharacterInputPosition = 5; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT; //205; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x5c23c + bCharacterInputPosition = 6; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT; //203; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x5c25c + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x5c264 + case 101: + //0x5c268 + switch (bData_4000319a_SkyLandTargetId) + { + case 1: + //0x5c2a4 + bData_4000319a_SkyLandTargetId = 4; + break; + + case 4: + //0x5c2b8 + bData_4000319a_SkyLandTargetId = 7; + break; + + case 7: + //0x5c2cc + bData_4000319a_SkyLandTargetId = 1; + break; + + case 2: + //0x5c2e0 + bData_4000319a_SkyLandTargetId = 5; + break; + + case 5: + //0x5c2f4 + bData_4000319a_SkyLandTargetId = 8; + break; + + case 8: + //0x5c308 + bData_4000319a_SkyLandTargetId = 2; + break; + + case 3: + //0x5c31c + bData_4000319a_SkyLandTargetId = 6; + break; + + case 6: + //0x5c330 + bData_4000319a_SkyLandTargetId = 9; + break; + + case 9: + //0x5c344 + bData_4000319a_SkyLandTargetId = 3; + break; + #if 0 + default: + //0x5c358 + break; + #endif + } + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + //0x5c360 + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_INPUT; //29002; + bCharacterInputPosition = 5; + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + //0x5c380 + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_INPUT; //29001; + bCharacterInputPosition = 6; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x5c3a0 + bCharacterInputPosition = 5; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT; //207; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x5c3c0 + bCharacterInputPosition = 5; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT; //208; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x5c3e0 + bCharacterInputPosition = 6; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT; //206; + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x5c400 + if (bDateTimeInputMode == 0) + { + bDateTimeInputMode = 1; + } + else + { + bDateTimeInputMode = 0; + } + bCharacterInputPosition = 1; + break; + + case 43021: + //0x5c440 + Data_40002c64_MenuContextId = 43022; + break; + + case 43022: + //0x5c454 + Data_40002c64_MenuContextId = 43023; + break; + + case 43023: + //0x5c468 + Data_40002c64_MenuContextId = 43024; + break; + + case 43024: + //0x5c47c + Data_40002c64_MenuContextId = 43021; + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x5c490 + if (bCurrentCustomSiteInputLine == 3) + { + bCurrentCustomSiteInputLine = 0; + bCharacterInputPosition = 7; + } + else + { + bCurrentCustomSiteInputLine++; + bCharacterInputPosition = 7; + } + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x5c4e4 + Data_40002c64_MenuContextId = MENU_CONTEXT_OTA_ZERO_SETUP; //47011; + if (bData_4000316d < 1) + { + bData_4000316d++; + } + else + { + bData_4000316d = 0; + } + if (bData_4000316d == 0) + { + bCharacterInputPosition = 5; + } + else + { + bCharacterInputPosition = 6; + } + break; + + case 33001: + //0x5c558: Curr. Lunar Phase + Data_40003164_LunarPhaseYear++; + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x5c674 + if (bData_40002c62_AlignmentStarMode != 0) + { + g_iSlewStepDecAxis = -1; + bData_40003201 = 0; + } + else + { + //0x5c6a4 + if (bData_40002c60_CurrentAlignStarIndex == numVisibleAlignmentStars) + { + bData_40002c60_CurrentAlignStarIndex = 1; + } + else + { + bData_40002c60_CurrentAlignStarIndex++; + } + } + + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x5c6e4 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT; //360022; + bCharacterInputPosition = 7; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x5c704 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT; //360021; + bCharacterInputPosition = 7; + break; + + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x5c724 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT; //370022; + bCharacterInputPosition = 7; + break; + + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_INPUT; //370023; + bCharacterInputPosition = 7; + //0x5c744 + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT; //370021; + bCharacterInputPosition = 7; + //0x5c764 + break; + + case 360111: + //0x5c784 + Data_40002c64_MenuContextId = 360112; + break; + + case 360112: + //0x5c798 + Data_40002c64_MenuContextId = 360113; + break; + + case 360113: + //0x5c7ac + Data_40002c64_MenuContextId = 360111; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL: //380011: + //0x5c7c0 + if (Data_40003248_CurrentDisplayPWM == 255) + { + setDisplayPWM(191); + Data_40003248_CurrentDisplayPWM = 191; + } + else if (Data_40003248_CurrentDisplayPWM == 191) + { + setDisplayPWM(127); + Data_40003248_CurrentDisplayPWM = 127; + } + else if (Data_40003248_CurrentDisplayPWM == 127) + { + setDisplayPWM(63); + Data_40003248_CurrentDisplayPWM = 63; + } + else + { + setDisplayPWM(0); + Data_40003248_CurrentDisplayPWM = 0; + } + break; + + case MENU_CONTEXT_COUNTRY_CITY_SELECTION: //43011: + //0x5c854 + lcd_display_clear(); + func_59dd0(); //->Next country + break; + + case 211001: + //0x5c864 + switch (bData_40003262) + { + case 0: + //0x5c88c + case 2: + //0x5c894 + if ((bData_40003258-1) == bData_4000325c) + { + bData_4000325c = 0; + } + else + { + bData_4000325c++; + } + //->0x5c934 + break; + + case 1: + //0x5c8d8 + if (bData_40003261 == 2) + { + bData_40003261 = 0; + bCharacterInputPosition = 7; + } + else + { + //0x5c908 + bData_40003261++; + bCharacterInputPosition = 7; + } + break; + + default: + break; + } + break; + + case 28001: + //0x5c93c + switch (bData_40003263) + { + case 0: + //0x5c96c + case 2: + //0x5c974 + if ((wData_40003256 - 1) == wData_4000325a) + { + wData_4000325a = 0; + } + else + { + wData_4000325a++; + } + break; + + case 1: + //0x5c9bc + case 3: + //0x5c9c4 + if (bData_40003260 == 2) + { + bData_40003260 = 0; + bCharacterInputPosition = 7; + } + else + { + bData_40003260++; + bCharacterInputPosition = 7; + } + break; + + default: + break; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_ON: //42001: + //0x5ca24 + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_OFF; //42002; + bDaylightSavingTime = 0; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_OFF: //42002: + //0x5ca54 + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_ON; //42001; + bDaylightSavingTime = 1; + } + break; + + default: + break; + } +} + diff --git a/applications/freertos_app/HandleEnterKey.c b/applications/freertos_app/HandleEnterKey.c new file mode 100644 index 0000000..bb0eed6 --- /dev/null +++ b/applications/freertos_app/HandleEnterKey.c @@ -0,0 +1,1656 @@ + + +/* 52898 - todo */ +void HandleEnterKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x52e68 + if (Data_40004128.bAlignmentComplete == 0) + { + //52e7c + ProcessNextAlignmentStar(); + } + else + { + //0x52e84 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + } + //->0x563b8 + break; + + case MENU_CONTEXT_MERIDIAN_FLIP: //3: + //0x52e94 + bData_40003210 = 0; + bData_40003211 = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case 101: + //0x52eb8 + lcd_display_clear(); + Data_40002c64_MenuContextId = 102; + break; + + case 102: + //0x52ed0 + switch (bData_40002e79_SkyLandTargetSeletion) + { + case 0: + //0x52ef0 + func_5218(bData_4000319a_SkyLandTargetId, &Data_40003f50); + + if (Data_40003f50.bData_0 == 1) + { + //52f14 + dData_40002cc8 = Data_40003f50.fData_12; + dData_40002d10 = Data_40003f50.fData_16; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = 10; + bData_40002f10_RecentTargetId = bData_4000319a_SkyLandTargetId; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + beep1(1); + + Data_40002c64_MenuContextId = 0; + } + //0x52fa0 -> 0x5315c + break; + + case 1: + //0x53038 + func_54e0(bData_4000319a_SkyLandTargetId, &Data_40003f64); + + fData_400034ac = Data_40003f64.fData_12; + fData_400034b0 = Data_40003f64.fData_16; + + if (Data_40003f64.fData_16 >= -15) + { + //53080 + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_400034aa = 1; + bData_40002f0d_RecentTargetType = 12; + bData_40002f10_RecentTargetId = bData_4000319a_SkyLandTargetId; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + beep1(1); + + Data_40002c64_MenuContextId = 0; + //->0x53150 + } + else + { + //0x530f4 + lcd_display_clear(); + beep1(1); + lcd_display_string(0, 3, 1, 22, " Target Out of Range "); + lcd_display_string(0, 5, 1, 22, "Altitude < -15 Degree "); + func_659c(2000); + lcd_display_clear(); + + Data_40002c64_MenuContextId = 101; + } + break; + + default: + break; + } + //->0x563b8 + break; + + case MENU_CONTEXT_RECENT_TARGETS: //1: + //0x53164 + bData_40002f14_RecentTargetCount = flash_get_recent_targets(Data_40002f15_RecentTargetTypeArray, + Data_4000359c_RecentTargetIdArray, + Data_400035bc); + + switch (Data_40002f15_RecentTargetTypeArray[bData_4000316e_FocusLineOn8LineDisplay - 1]) + { + case 1: + //0x531d4 + bData_40003176 = 1; + bData_40003174 = 1; + bData_40002eb5_SolarSystemObjectNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION; //22001; + //->0x53690 + break; + + case 2: + //0x5321c + bData_40003176 = 2; + bData_40003174 = 1; + bData_40002ece_ConstellationNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_CONSTELLATION_SELECTION; //24001; + //->0x53690 + break; + + case 3: + //0x53268 + bData_40003176 = 3; + bData_40003174 = 1; + bData_40002ed2_FamousStarNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_FAMOUS_STAR_SELECTION; //25001; + //->0x53690 + break; + + case 4: + //0x532b4 + bData_40003176 = 4; + bData_40003174 = 1; + wData_40002eb8_MessierNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002ec8_NavigationDirectInputNr = 0; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MESSIER_OBJECT_DETAILS; //23012; + //->0x53690 + break; + + case 5: + //0x5330c + bData_40003176 = 5; + bData_40003174 = 1; + wData_40002eba_NGCNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002ec8_NavigationDirectInputNr = 0; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_NGC_OBJECT_SELECTION; //23003; + //->0x53690 + break; + + case 6: + //0x53364 + bData_40003176 = 6; + bData_40003174 = 1; + wData_40002ebc_ICNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002ec8_NavigationDirectInputNr = 0; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_IC_OBJECT_SELECTION; //23004; + //->0x53690 + break; + + case 7: + //0x5345c + bData_40003176 = 7; + bData_40003174 = 1; + wData_40002ebe_ShNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002ec8_NavigationDirectInputNr = 0; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SH2_OBJECT_SELECTION; //23005; + //->0x53690 + break; + + case 8: + //0x534b4 + bData_40003176 = 8; + bData_40003174 = 1; + wData_40002ec0_BrightStarNr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002ec8_NavigationDirectInputNr = 0; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_BRIGHT_STAR_SELECTION; //23006; + //->0x53690 + break; + + case 9: + //0x5350c + bData_40003176 = 8; + bData_40003174 = 2; + Data_40002ec4_SAONr = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002ec8_NavigationDirectInputNr = 0; + + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SAO_OBJECT_SELECTION; //23007; + //->0x53690 + break; + + case 10: + //0x53564 + if (bData_40002e79_SkyLandTargetSeletion == 0) + { + //53578 + bData_4000319a_SkyLandTargetId = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002c64_MenuContextId = 101; + } + else + { + //0x535a4 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + break; + + case 11: + //0x535b4 + func_5218(10, &Data_40003f50); + + if (Data_40003f50.bData_0 == 111) + { + //535d4 + dData_40002cc8 = Data_40003f50.fData_12; + dData_40002d10 = Data_40003f50.fData_16; + bTrackingMode = 1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + } + //0x5361c + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case 12: + //0x5362c + if (bData_40002e79_SkyLandTargetSeletion == 1) + { + //53640 + bData_4000319a_SkyLandTargetId = + Data_4000359c_RecentTargetIdArray[bData_4000316e_FocusLineOn8LineDisplay - 1]; + Data_40002c64_MenuContextId = 101; + } + else + { + //0x5366c + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + break; + + default: + //0x5367c + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + } + //->0x563b8 + break; + + case MENU_CONTEXT_ALIGNMENT: //1000: + //0x53698 + bData_40003173 = 1; + bData_40003171 = 1; + bData_40003172 = 1; + bData_40003170 = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_ONE_STAR_ALIGN; //1100; + break; + + case MENU_CONTEXT_NAVIGATION: //2000: + //0x536d0 + bData_40003177 = 1; + bData_40003175 = 1; + bData_40003176 = 1; + bData_40003174 = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM; //2100; + break; + + case MENU_CONTEXT_UTILITIES: //3000: + //0x53708 + bData_4000317b = 1; + bData_40003179 = 1; + bData_4000317a = 1; + bData_40003178 = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_CURRENT_OBJECTS; //3100; + break; + + case MENU_CONTEXT_SETUP: //4000: + //0x53740 + bData_4000317f = 1; + bData_4000317d = 1; + bData_4000317e = 1; + bData_4000317c = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE; //4100; + break; + + case MENU_CONTEXT_EYEPIECE_FOV: //3600: + //0x53778: Eyepiece FOV + bCharacterInputPosition = 7; + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT; //370021; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN: //3700: + //0x53798: Eyepiece Magn. + bCharacterInputPosition = 7; + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT; //360021; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION: //3800: + //0x537b8: Display Illumination + Data_40002c64_MenuContextId = MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL; //380011; + //->0x563b8 + break; + + case MENU_CONTEXT_SITE_SETTING: //4300: + //537cc: Site Setting + Data_40002c64_MenuContextId = MENU_CONTEXT_COUNTRY_CITY; //4301; + break; + + case MENU_CONTEXT_TELESCOPE_MOUNT: //4600: + //0x537e0: Telescope Mount + Data_40002c64_MenuContextId = MENU_CONTEXT_OTA_ZERO_SETUP; //47011; //->"Please setup OTA zero" + bData_4000316d = 0; + bCharacterInputPosition = 5; + bData_400032a4_OTAZeroDataErrorCount = 0; + + flash_get_ota_zero_data(&fData_4000329c, &fData_400032a0); + + sprintf(Data_400028d7, "Azi:%03d", (unsigned short)fData_4000329c); + sprintf(Data_400028e1, "Alt: %02d", (unsigned short)fData_400032a0); + sprintf(Data_40002789, "Azi:%03d", (unsigned short)fData_4000329c); + sprintf(Data_40002792, "Alt: %02d", (unsigned short)fData_400032a0); + break; + + case MENU_CONTEXT_TRACKING_RATE: //4700: + //0x538b4: Tracking Rate + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_STAR_SPEED; //4801; + break; + + case MENU_CONTEXT_ONE_STAR_ALIGN: //1100: + //0x538c8: One Star Align + Data_40002c5c_AlignmentStarCount = 1; + bData_40002c60_CurrentAlignStarIndex = 1; + bData_40002c61 = 1; + bData_40002c62_AlignmentStarMode = 0; //Alignment Star Selection + + numVisibleAlignmentStars = GetCurrentAlignStars(get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, arAlignmentStarNames, Data_40003b2c); + + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT_STAR_CONTROL; //12001; + //->0x563b8 + break; + + case MENU_CONTEXT_TWO_STAR_ALIGN: //1200: + //0x53960: Two Star Align + Data_40002c5c_AlignmentStarCount = 2; + bData_40002c60_CurrentAlignStarIndex = 1; + bData_40002c61 = 1; + bData_40002c62_AlignmentStarMode = 0; + + numVisibleAlignmentStars = GetCurrentAlignStars(get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, arAlignmentStarNames, Data_40003b2c); + + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT_STAR_CONTROL; //12001; + //->0x563b8 + break; + + case MENU_CONTEXT_THREE_STAR_ALIGN: //1300: + //0x539fc: Three Star Align + Data_40002c5c_AlignmentStarCount = 3; + bData_40002c60_CurrentAlignStarIndex = 1; + bData_40002c61 = 1; + bData_40002c62_AlignmentStarMode = 0; + + numVisibleAlignmentStars = GetCurrentAlignStars(get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, arAlignmentStarNames, Data_40003b2c); + + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT_STAR_CONTROL; //12001; + //->0x563b8 + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x53b68 + bData_400034cd = 0; + bData_40003430 = 1; + + if (bData_40002c62_AlignmentStarMode == 0) + { + //53b94: Alignment Star Selection + switch (bData_40002c61) + { + case 1: + //0x53bb8 + numVisibleAlignmentStars = GetCurrentAlignStars(get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, arAlignmentStarNames, Data_40003b2c); + + Data_40004128.dFirstAlignmentStarRa = + Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2]; + Data_40004128.dFirstAlignmentStarDec = + Data_40004a68_CurrentAlignStarEquatorialCoord[1 + (bData_40002c60_CurrentAlignStarIndex - 1)*2]; + + switch (Data_40002c5c_AlignmentStarCount) + { + case 1: + //0x53c90 + StartOneStarAlignment(); + break; + + case 2: + //0x53c9c + StartTwoStarAlignment(); + break; + + case 3: + //0x53ca8 + StartThreeStarAlignment(); + break; + + default: + break; + } + //0x53cbc + bData_40002c61++; + Data_40002c5c_AlignmentStarCount--; + bData_40002c62_AlignmentStarMode = 1; //"Slewing to Target" + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + //->0x53f44 + break; + + case 2: + //0x53d04 + if (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/) + { + //53d18 + numVisibleAlignmentStars = GetCurrentAlignStars(get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, arAlignmentStarNames, Data_40003b2c); + + Data_40004128.dSecondAlignmentStarRa = + Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2]; + Data_40004128.dSecondAlignmentStarDec = + Data_40004a68_CurrentAlignStarEquatorialCoord[1 + (bData_40002c60_CurrentAlignStarIndex - 1)*2]; + + if (Data_40004128.bAlignmentComplete == 0) + { + ProcessNextAlignmentStar(); + } + //0x53ddc + bData_40002c61++; + Data_40002c5c_AlignmentStarCount--; + bData_40002c62_AlignmentStarMode = 1; //"Slewing to Target" + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + } + //0x53e1c -> 0x53f44 + break; + + case 3: + //0x53e20 + if (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/) + { + numVisibleAlignmentStars = GetCurrentAlignStars(get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, arAlignmentStarNames, Data_40003b2c); + + Data_40004128.dThirdAlignmentStarRa = + Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2]; + Data_40004128.dThirdAlignmentStarDec = + Data_40004a68_CurrentAlignStarEquatorialCoord[1 + (bData_40002c60_CurrentAlignStarIndex - 1)*2]; + + if (Data_40004128.bAlignmentComplete == 0) + { + ProcessNextAlignmentStar(); + } + //0x53ef8 + bData_40002c61++; + Data_40002c5c_AlignmentStarCount--; + bData_40002c62_AlignmentStarMode = 1; //"Slewing to Target" + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + } + //0x53f38 -> 0x53f44 + break; + + default: + //53f3c + break; + } + //53f44 -> 0x53f74 + } //if (bData_40002c62_AlignmentStarMode == 0) + else + { + //0x53f48 + if ((bData_400031e9 == 4) || (bData_400031e9 == 8)) + { + //0x53f68 + bData_40002c62_AlignmentStarMode = 0; //->(Next) Alignment Star Selection + } + } + //0x53f74 + if (Data_40002c5c_AlignmentStarCount != -1) + { + //53f84 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT_STAR_CONTROL; //12001; + } + //0x53f90 -> 0x563b8 + break; + + case MENU_CONTEXT_TARGET_SYNC: //1400: + //0x53f94: Target Sync + bData_400031eb = 0; + if (g_bTargetSyncOpen == FALSE) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_SYNC_OPEN; //1401; + } + else + { + Data_40002c64_MenuContextId = MENU_CONTEXT_SYNC_ENSURE; //1402; + } + break; + + case MENU_CONTEXT_SYNC_OPEN: //1401: + //0x53fd4 + g_bTargetSyncOpen = TRUE; + Data_40002c64_MenuContextId = 0; + + beep1(2); + break; + + case MENU_CONTEXT_SYNC_ENSURE: //1402: + //0x53ffc + dData_40003410 = dData_400033d8; + dData_40003418 = -dData_400033e0; + dData_40003420 = dData_400033d8; + dData_40003428 = dData_400033e0; + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + g_bTargetSyncOpen = 0; + + beep1(2); + break; + + case MENU_CONTEXT_SYNC_CANCEL: //1403: + //0x54064 + g_bTargetSyncOpen = 0; + Data_40002c64_MenuContextId = 0; + break; + + case MENU_CONTEXT_POLE_AXIS_DEV: //1500: + //0x54080: Pole-Axis Dev. + Data_40002c64_MenuContextId = MENU_CONTEXT_POLE_AXIS_DEV_INPUT; //18001; //->"Pole Axis Dev: " + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR: //1600: + //0x54094: RA Bklash Corr. + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11102; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x540a8 + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT; //11101; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + //0x540bc + if (fabs(dData_40002dc0_Azimuth - dRaBklashCorrStartAzimuth) > 5.0) + { + //540fc + fData_40002e90 = fabs((dData_40002dc0_Azimuth - dRaBklashCorrStartAzimuth - 360.0) * 3600.0); + //->0x541b0 + } + else + { + //0x54164 + fData_40002e90 = fabs((dData_40002dc0_Azimuth - dRaBklashCorrStartAzimuth) * 3600.0); + } + //0x541b0 + Data_40002e94 += fData_40002e90; + Data_40002e9c += 1; + iBacklashCorrectionSlewing = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_RESULT; //11104; + //->0x563b8 + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT: //11101: + //0x54200: RA Bklash Corr. - 2nd page + if (Data_40002e9c != 0) + { + //54218 + fData_40002e98 = Data_40002e94 / Data_40002e9c; + + func_52720(1); + } + //0x54244 + Data_40002e94 = 0; + fData_40002e90 = 0; + Data_40002e9c = 0; + Data_40002c64_MenuContextId = 11105; + break; + + case MENU_CONTEXT_DEC_BKLASH_CORR: //1700: + //0x54270: DEC Bklash Corr. + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11202; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x54284 + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN; //11201; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + //0x54298 + fData_40002ea0 = fabs((dData_40002df8 - dData_40002e00) * 3600.0); + fData_40002ea4 += fData_40002ea0; + fData_40002eac += 1; + iBacklashCorrectionSlewing = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_RESULT; //11204; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN: //11201: + //0x54338 + if (fData_40002eac != 0) + { + //54350 + fData_40002ea8 = fData_40002ea4 / fData_40002eac; + + func_52720(2); + } + //0x5437c + fData_40002ea4 = 0; + fData_40002ea0 = 0; + fData_40002eac = 0; + Data_40002c64_MenuContextId = 11205; + break; + + case MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM: //2100: + //0x543a8: Navigation -> Solar System + bData_40002eb5_SolarSystemObjectNr = 0; + lcd_display_clear(); + bData_40003432 = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION; //22001; + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION: //22001: + //0x543d8 + if (bData_40002eb5_SolarSystemObjectNr == 8/*Sun*/) + { + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SUN_WARNING; //22112; + + beep1(1); + } + else + { + //0x54408 + get_solar_system_object_data(bData_40002eb5_SolarSystemObjectNr, + &fData_40002cd0_ObjectRightAscension, + &fData_40002d18_ObjectDeclination); + + dData_40002cc8 = fData_40002cd0_ObjectRightAscension; + dData_40002d10 = fData_40002d18_ObjectDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_SOLAR_SYSTEM; //1; + bData_40002f10_RecentTargetId = bData_40002eb5_SolarSystemObjectNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING; //22111; + } + //->0x563b8 + break; + + case MENU_CONTEXT_SUN_WARNING: //22112: + //0x544a8 + get_solar_system_object_data(bData_40002eb5_SolarSystemObjectNr, + &fData_40002cd0_ObjectRightAscension, + &fData_40002d18_ObjectDeclination); + + dData_40002cc8 = fData_40002cd0_ObjectRightAscension; + dData_40002d10 = fData_40002d18_ObjectDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_SOLAR_SYSTEM; //1; + bData_40002f10_RecentTargetId = bData_40002eb5_SolarSystemObjectNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING; //22111; + break; + + case MENU_CONTEXT_NAVIGATION_CONSTELLATION: //2200: + //0x5454c: Navigation -> Constellation + bData_40002ece_ConstellationNr = 1; + lcd_display_clear(); + bData_40003432 = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_CONSTELLATION_SELECTION; //24001; + break; + + case MENU_CONTEXT_CONSTELLATION_SELECTION: //24001: + //0x5457c + flash_get_constellation_data(bData_40002ece_ConstellationNr, + &Data_40003dd4_FlashConstellationData); + + dData_40002cc8 = Data_40003dd4_FlashConstellationData.fRightAscension; + dData_40002d10 = Data_40003dd4_FlashConstellationData.fDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_CONSTELLATION; //2; + bData_40002f10_RecentTargetId = bData_40002ece_ConstellationNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_CONSTELLATION_TRACKING; //24002; + //->0x563b8 + break; + + case MENU_CONTEXT_NAVIGATION_FAMOUS_STAR: //2300: + //0x5461c: Navigation -> Famous Star + bData_40002ed2_FamousStarNr = 1; + lcd_display_clear(); + bData_40003432 = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_FAMOUS_STAR_SELECTION; //25001; + break; + + case MENU_CONTEXT_FAMOUS_STAR_SELECTION: //25001: + //0x5464c + flash_get_famous_star_data(bData_40002ed2_FamousStarNr, &Data_40003d94_FlashFamousStarData); + + dData_40002cc8 = Data_40003d94_FlashFamousStarData.fRightAscension; + dData_40002d10 = Data_40003d94_FlashFamousStarData.fDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_FAMOUS_STAR; //3; + bData_40002f10_RecentTargetId = bData_40002ed2_FamousStarNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_FAMOUS_STAR_TRACKING; //25002; + break; + + case MENU_CONTEXT_NAVIGATION_MESSIER_CAT: //2400: + //0x546ec + wData_40002eb8_MessierNr = 1; + Data_40002ec8_NavigationDirectInputNr = 0; + lcd_display_clear(); + bData_40003432 = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_MESSIER_OBJECT_DETAILS; //23012; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x54728 + lcd_display_clear(); + Data_40002c64_MenuContextId = MENU_CONTEXT_MESSIER_OBJECT_SELECTION; //23002; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x54740 + flash_get_messier_data((unsigned char)wData_40002eb8_MessierNr, + &Data_40003e08_FlashMessierData); + + dData_40002cc8 = Data_40003e08_FlashMessierData.fRightAscension; + dData_40002d10 = Data_40003e08_FlashMessierData.fDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_MESSIER; //4; + bData_40002f10_RecentTargetId = wData_40002eb8_MessierNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MESSIER_OBJECT_TRACKING; //23022; + break; + + case MENU_CONTEXT_NAVIGATION_NGC_CAT: //2500: + //0x548e4 + wData_40002eba_NGCNr = 1; + Data_40002ec8_NavigationDirectInputNr = 0; + bData_40003432 = 0; + lcd_display_clear(); + Data_40002c64_MenuContextId = MENU_CONTEXT_NGC_OBJECT_SELECTION; //23003; + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x5491c + flash_get_ngc_data(wData_40002eba_NGCNr, &Data_40003ee0_FlashNGCData); + + dData_40002cc8 = Data_40003ee0_FlashNGCData.fRightAscension; + dData_40002d10 = Data_40003ee0_FlashNGCData.fDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_NGC; //5; + bData_40002f10_RecentTargetId = wData_40002eba_NGCNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_NGC_OBJECT_TRACKING; //23013; + break; + + case MENU_CONTEXT_NAVIGATION_IC_CAT: //2600: + //0x549bc + wData_40002ebc_ICNr = 1; + Data_40002ec8_NavigationDirectInputNr = 0; + bData_40003432 = 0; + lcd_display_clear(); + Data_40002c64_MenuContextId = MENU_CONTEXT_IC_OBJECT_SELECTION; //23004; + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x549f4 + flash_get_ic_data(wData_40002ebc_ICNr, &Data_40003ec0_FlashICData); + + dData_40002cc8 = Data_40003ec0_FlashICData.fRightAscension; + dData_40002d10 = Data_40003ec0_FlashICData.fDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_IC; //6; + bData_40002f10_RecentTargetId = wData_40002ebc_ICNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_IC_OBJECT_TRACKING; //23014; + break; + + case MENU_CONTEXT_NAVIGATION_SH2_CAT: //2700: + //0x54a94 + wData_40002ebe_ShNr = 1; + Data_40002ec8_NavigationDirectInputNr = 0; + bData_40003432 = 0; + lcd_display_clear(); + Data_40002c64_MenuContextId = MENU_CONTEXT_SH2_OBJECT_SELECTION; //23005; + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x54acc + flash_get_sh2_data(wData_40002ebe_ShNr, &Data_40003350_FlashSh2Data); + + dData_40002cc8 = Data_40003350_FlashSh2Data.fRightAscension; + dData_40002d10 = Data_40003350_FlashSh2Data.fDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_SH2; //7; + bData_40002f10_RecentTargetId = wData_40002ebe_ShNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SH2_OBJECT_TRACKING; //23015; + break; + + case MENU_CONTEXT_NAVIGATION_BRIGHT_STAR: //2800: + //0x54b6c + wData_40002ec0_BrightStarNr = 1; + Data_40002ec8_NavigationDirectInputNr = 0; + bData_40003432 = 0; + lcd_display_clear(); + Data_40002c64_MenuContextId = MENU_CONTEXT_BRIGHT_STAR_SELECTION; //23006; + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x54ba4 + flash_get_bright_star_data((unsigned char)wData_40002ec0_BrightStarNr, &Data_40003ea0_FlashBrightStarData); + + dData_40002cc8 = Data_40003ea0_FlashBrightStarData.fRightAscension; + dData_40002d10 = Data_40003ea0_FlashBrightStarData.fDeclination; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_BRIGHT_STAR; //8; + bData_40002f10_RecentTargetId = wData_40002ec0_BrightStarNr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_BRIGHT_STAR_TRACKING; //23016; + break; + + case MENU_CONTEXT_NAVIGATION_SAO_CAT: //2900: + //0x54c48: SAO Catalogue + Data_40002ec4_SAONr = 1; + Data_40002ec8_NavigationDirectInputNr = 0; + bData_40003432 = 0; + lcd_display_clear(); + Data_40002c64_MenuContextId = MENU_CONTEXT_SAO_OBJECT_SELECTION; //23007; + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x54c80: SAO item + flash_get_sao_data(Data_40002ec4_SAONr, &Data_40003358_SAORecord); + + dData_40002cc8 = Data_40003358_SAORecord.ra; + dData_40002d10 = Data_40003358_SAORecord.dec; + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = MENU_RECENT_TARGET_SAO_CAT; //9; + bData_40002f10_RecentTargetId = Data_40002ec4_SAONr; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_SAO_OBJECT_TRACKING; //23017; + //->0x563b8 + break; + + case MENU_CONTEXT_NAVIGATION_CUST_OBJ: //2110: + //0x54d20: Customer Objects + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION; //201; + bData_4000319a_SkyLandTargetId = 1; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x54d40 + bCharacterInputPosition = 6; + PrepareCustomerSkyObjectInputData(); + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT; //203; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x54d64 + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x54d6c + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x54d70 + HandleCustomerSkyObjectInput(); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case MENU_CONTEXT_NAVIGATION_RA_DEC: //2120: + //0x54d84: Input RA/DEC + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_INPUT; //29001; + bCharacterInputPosition = 6; + PrepareCustomerSkyObjectInputData(); + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + //0x54da8 + HandleRectascensionDeclinationInput(); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + //0x54db4 + HandleRectascensionDeclinationInput(); + break; + + case MENU_CONTEXT_NAVIGATION_CUST_LAND: //2130: + //0x54dc0 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_LAND; //2130; + bData_4000319a_SkyLandTargetId = 1; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x54de0 + PrepareCustomerLandObjectInputData(); + bCharacterInputPosition = 6; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT; //206; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x54e04 + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x54e0c + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x54e10 + HandleCustomerLandObjectInput(); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_LAND; //2130; + break; + + case MENU_CONTEXT_SKY_LAND: //4400: + //0x54e24 +#ifdef V2_3 + Data_40002c64_MenuContextId = MENU_CONTEXT_SKY_LAND; //4400; +#else + Data_40002c64_MenuContextId = MENU_CONTEXT_SKY_TARGET; //45001; +#endif + break; + + case MENU_CONTEXT_SKY_TARGET: //45001: + //0x54e38 + bData_40002e79_SkyLandTargetSeletion = 0; + g_bLandTarget = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_SKY_LAND; //4400; + + Data_40003500.dwData = fabs((int) ((6.0 * dTrackingRate) / 15.04)); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x04); + uart1_write_byte(0x41); + + if (dTrackingRate > 0) + { + //54efc + uart1_write_byte(0x01); + } + else + { + //0x54f08 + uart1_write_byte(0x00); + } + //0x54f10 + uart1_write_byte(Data_40003500.bData[1]); + uart1_write_byte(Data_40003500.bData[0]); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x04); + uart1_write_byte(0x01); + + if (dTrackingRate > 0) + { + //54f68 + uart1_write_byte(0x00); + } + else + { + //0x54f74 + uart1_write_byte(0x01); + } + //0x54f7c + uart1_write_byte(Data_40003500.bData[1]); + uart1_write_byte(Data_40003500.bData[0]); + break; + + case MENU_CONTEXT_LAND_TARGET: //45002: + //0x54f98 + bData_40002e79_SkyLandTargetSeletion = 1; + g_bLandTarget = 1; + func_b4d0(); + Data_40002c64_MenuContextId = MENU_CONTEXT_SKY_LAND; //4400; + break; + + case MENU_CONTEXT_AZ_EQU: //4500: + //0x54fc4: AZ / EQ +#ifdef V2_3 + Data_40002c64_MenuContextId = MENU_CONTEXT_AZ_EQU; //4500; +#else + Data_40002c64_MenuContextId = MENU_CONTEXT_MOUNT_AZ; //46001; +#endif + break; + + case MENU_CONTEXT_MOUNT_AZ: //46001: + //0x54fd8 + bData_40002e7a_MountType = MENU_MOUNT_TYPE_AZ; //0; + Data_40002c64_MenuContextId = MENU_CONTEXT_AZ_EQU; //4500; + break; + + case MENU_CONTEXT_MOUNT_EQU: //46002: + //0x54ff8 + bData_40002e7a_MountType = MENU_MOUNT_TYPE_EQU; //1; + Data_40002c64_MenuContextId = MENU_CONTEXT_AZ_EQU; //4500; + break; + + case MENU_CONTEXT_LANGUAGE: //4800: + //0x55018 + Data_40002c64_MenuContextId = MENU_CONTEXT_ENGLISH; //49001; + break; + + case MENU_CONTEXT_ENGLISH: //49001: + //0x5502c + bData_40003196_CurrentLanguage = MENU_LANGUAGE_ENGLISH; //1; + flash_read(0xdcb, 0, 528, Data_400035bc); + Data_400035bc[0] = bData_40003196_CurrentLanguage; + flash_write(0xdcb, 0, 528, Data_400035bc); + Data_40002c64_MenuContextId = MENU_CONTEXT_LANGUAGE; //4800; + break; + + case MENU_CONTEXT_GERMAN: //49002: + //0x55084 + bData_40003196_CurrentLanguage = MENU_LANGUAGE_GERMAN; //2; + flash_read(0xdcb, 0, 528, Data_400035bc); + Data_400035bc[0] = bData_40003196_CurrentLanguage; + flash_write(0xdcb, 0, 528, Data_400035bc); + Data_40002c64_MenuContextId = MENU_CONTEXT_LANGUAGE; //4800; + break; + + case MENU_CONTEXT_FRENCH: //49003: + //0x550dc + bData_40003196_CurrentLanguage = MENU_LANGUAGE_FRENCH; //3; + flash_read(0xdcb, 0, 528, Data_400035bc); + Data_400035bc[0] = bData_40003196_CurrentLanguage; + flash_write(0xdcb, 0, 528, Data_400035bc); + Data_40002c64_MenuContextId = MENU_CONTEXT_LANGUAGE; //4800; + break; + + case MENU_CONTEXT_ITALIAN: //49004: + //0x55134 + bData_40003196_CurrentLanguage = MENU_LANGUAGE_ITALIAN; //4; + flash_read(0xdcb, 0, 528, Data_400035bc); + Data_400035bc[0] = bData_40003196_CurrentLanguage; + flash_write(0xdcb, 0, 528, Data_400035bc); + Data_40002c64_MenuContextId = MENU_CONTEXT_LANGUAGE; //4800; + break; + + case MENU_CONTEXT_SPANISH: //49005: + //0x5518c + bData_40003196_CurrentLanguage = MENU_LANGUAGE_SPANISH; //5; + flash_read(0xdcb, 0, 528, Data_400035bc); + Data_400035bc[0] = bData_40003196_CurrentLanguage; + flash_write(0xdcb, 0, 528, Data_400035bc); + Data_40002c64_MenuContextId = MENU_CONTEXT_LANGUAGE; //4800; + break; + + case MENU_CONTEXT_TRACKING_RATE_STAR_SPEED: //4801: + //0x551e4: Tracking Rate -> "Star Speed" + dTrackingRate = 0; + bData_40002e7c_TrackingRateType = MENU_TRACKING_RATE_STAR_SPEED; //0; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED: //4802: + //0x5521c: Tracking Rate -> "Solar Speed" + dTrackingRate = 0.000000298199444444444492059666153988; + bData_40002e7c_TrackingRateType = MENU_TRACKING_RATE_SOLAR_SPEED; //1; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_TRACKING_RATE_MOON_SPEED: //4803: + //0x55254: "Moon Speed" + dTrackingRate = 0.00000376886111111111134081550801123; + bData_40002e7c_TrackingRateType = MENU_TRACKING_RATE_MOON_SPEED; //2; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED: //4804: + //0x55288: "Customize Speed" + bCharacterInputPosition = 1; + sprintf(strTrackingRateCustInput, "+0%.2f\272\343\320\307\313\331 ", 1.0); + sprintf(strTrackingRateCustDisplay, "+0%.2f starspeed", 1.0); + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_INPUT; //48001; + break; + + case MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED: //4805: + //0x552d0: "Guiding Speed" + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED1; //48051; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x552e4 + bData_40002e7c_TrackingRateType = MENU_TRACKING_RATE_CUST_SPEED; //3; + dTrackingRate = (1 - atof(strTrackingRateCustInput)) * 0.37 / 3600.0; + + beep1(2); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED1: //48051: + //0x55364 + dGuidingSpeed = 0.125; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED2: //48052: + //0x55490 + dGuidingSpeed = 0.25; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED3: //48053: + //0x554bc + dGuidingSpeed = 0.375; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED4: //48054: + //0x554e8 + dGuidingSpeed = 0.5; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED5: //48055: + //0x55514 + dGuidingSpeed = 0.625; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED6: //48056: + //0x55540 + dGuidingSpeed = 0.75; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED7: //48057: + //0x5556c + dGuidingSpeed = 0.875; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_GUIDING_SPEED8: //48058: + //0x55598 + dGuidingSpeed = 1.0; + beep1(2); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_PARK_POSITION: //3900: + //0x555c4: Parkposition + func_75c4(); + bGotoParkPosition = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_CURRENT_OBJECTS: //3100: + //0x555e8: Current Objects + bData_40002eb5_SolarSystemObjectNr = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_SOLAR_SYSTEM_OBJ_RISE_SET_TIMES; //31001; + break; + + case MENU_CONTEXT_TIME_DATE: //4100: + //55608: Time and Date + get_rtc_date_time(); + + sprintf(Data_400037ec, "%04d-%02d-%02d", + Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40003150, "%02d:%02d:%02d", + bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + sprintf(Data_40002655, "%04d-%02d-%02d", + Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40002660, "%02d:%02d:%02d", + bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + + bCharacterInputPosition = 1; + bDateTimeInputMode = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE_INPUT; //41001; + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x556d8 + if (ValidateDateTimeSetRTC() == 1) + { + //556e8 + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_OFF; //42002; + } + else + { + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE; //4100; + } + beep1(1); + } + else + { + //0x55720 + get_rtc_date_time(); + + sprintf(Data_400037ec, "%04d-%02d-%02d", + Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40003150, "%02d:%02d:%02d", + bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + sprintf(Data_40002655, "%04d-%02d-%02d", + Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40002660, "%02d:%02d:%02d", + bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + + bCharacterInputPosition = 1; + bDateTimeInputMode = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE_INPUT; //41001; + } + //0x557e8 -> 0x563b8 + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING: //4200: + //0x55868 + if (bDaylightSavingTime == 0) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_OFF; //42002; + } + else + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_ON; //42001; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_ON: //42001: + //0x5589c + case MENU_CONTEXT_DAYLIGHT_SAVING_OFF: //42002: + //0x558a4 + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_COUNTRY_CITY; //4301; + } + else + { + beep1(1); + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING; //4200; + } + break; + + case MENU_CONTEXT_COUNTRY_CITY: //4301: + //0x558dc: Country & City + wData_40003250 = 1; + wData_40003252 = 0; + lcd_display_clear(); + Data_40002c64_MenuContextId = MENU_CONTEXT_COUNTRY_CITY_SELECTION; //43011; + break; + + case MENU_CONTEXT_COUNTRY_CITY_SELECTION: //43011: + //0x5590c + flash_get_site_data((unsigned short)(wData_40003250 + wData_40003252), &Data_40003f1c_FlashSiteData); + + dData_40002e28_SiteLongitude = Data_40003f1c_FlashSiteData.fLongitude; + dData_40002e48_SiteLatitude = Data_40003f1c_FlashSiteData.fLatitude; + Data_40002e54_Zone = Data_40003f1c_FlashSiteData.Zone; + Data_40004128.geographicLongitude = dData_40002e28_SiteLongitude; + Data_40004128.geographicLatitude = dData_40002e48_SiteLatitude; + Data_40004128.timeZone = Data_40002e54_Zone; + + beep1(2); + + if (bData_40002f1e_SetupLocalData == 1) + { + //559b8 + if (bData_40002c1a == 1) + { + bSystemInitialized = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + bData_40002f1e_SetupLocalData = 0; + } + else + { + //0x559e8 + Data_40002c64_MenuContextId = MENU_CONTEXT_OTA_ZERO_SETUP; //47011; + } + } + else + { + //0x559f8 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + //->0x563b8 + break; + + case MENU_CONTEXT_CUSTOM_SITE: //4302: + //0x55a08: Custom Site + bData_40002edc = 1; + bCurrentCustomSiteInputLine = 0; + bCharacterInputPosition = 7; + + flash_get_custom_site_data(arCustomSiteName, + &fCustomSiteLongitude, &fCustomSiteLatitude, + &iCustomSiteTimeZone); + + /*Name:*/ + strCustomSiteName[6] = arCustomSiteName[0]; + strCustomSiteName[7] = arCustomSiteName[1]; + strCustomSiteName[8] = arCustomSiteName[2]; + strCustomSiteName[9] = arCustomSiteName[3]; + strCustomSiteName[10] = arCustomSiteName[4]; + strCustomSiteName[11] = arCustomSiteName[5]; + strCustomSiteName[12] = arCustomSiteName[6]; + strCustomSiteName[13] = arCustomSiteName[7]; + + if (fCustomSiteLongitude > 0) + { + //55abc + sprintf(strCustomSiteLongitude, " Lon:E%03dd%02df ", + DEGREES_MINUTES_ABS(fCustomSiteLongitude)); + } + else + { + //0x55b4c + sprintf(strCustomSiteLongitude, " Lon:W%03dd%02df ", + DEGREES_MINUTES_ABS(fCustomSiteLongitude)); + } + //0x55bd8 + if (fCustomSiteLatitude > 0) + { + //55bec + sprintf(strCustomSiteLatitude, " Lat:N%02dd%02df ", + DEGREES_MINUTES_ABS(fCustomSiteLatitude)); + } + else + { + //0x55c7c + sprintf(strCustomSiteLatitude, " Lat:S%02dd%02df ", + DEGREES_MINUTES_ABS(fCustomSiteLatitude)); + } + //0x55d08 + if (iCustomSiteTimeZone > 0) + { + //55d18 + sprintf(strCustomSiteTimezone, " Zone:E%02d", abs(iCustomSiteTimeZone)); + } + else + { + //0x55d48 + sprintf(strCustomSiteTimezone, " Zone:W%02d", abs(iCustomSiteTimeZone)); + } + + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOM_SITE_INPUT; //43002; + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x55d84 + HandleCustomSiteData(); + break; + + case MENU_CONTEXT_RESET: //4900: + //0x55d90: Reset + Data_40002c64_MenuContextId = MENU_CONTEXT_RESET_CONFIRM; //100; + break; + + case MENU_CONTEXT_RESET_CONFIRM: //100: + //0x55da4: Reset -> Enter + HandleReset(); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: //Telescope Mount -> "Please setup OTA zero" + //0x55db0 + HandleOTAZeroData(); + break; + + case MENU_CONTEXT_OBJECT_RISE_SET: //3200: + //0x55dbc: Object Rise/Set + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_INPUT; //29001; + bCharacterInputPosition = 6; + PrepareCustomerSkyObjectInputData(); + bData_40003162 = 1; + break; + + case MENU_CONTEXT_RISE_SET_TIMES: //32001: + //0x55dec + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_INPUT; //29001; + break; + + case MENU_CONTEXT_LUNAR_PHASE: //3300: + //0x55e00 + Data_40002c64_MenuContextId = 33001; + func_50018(); + break; + + case MENU_CONTEXT_TIMER: //3400: + //0x55e18 + if (Data_40003214_UserTimerSeconds != 0) + { + Data_40002c64_MenuContextId = 34002; //->"Counting down:" + } + else + { + //0x55e3c + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER_SET; //34001; + bCharacterInputPosition = 1; + } + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x55e58 + if (bData_40003196_CurrentLanguage == 1) + { + //755e6c + Data_40003214_UserTimerSeconds = atoi(strEng00000s); + } + else + { + //0x55e80 + Data_40003214_UserTimerSeconds = atoi(Data_4000294a); + } + //0x55e90 + if (Data_40003214_UserTimerSeconds == 0) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER_SET; //34001; + } + else + { + //0x55eb0 + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER_COUNTING; //34002; + } + //0x55ebc -> 0x563b8 + break; + + case MENU_CONTEXT_TIMER_COUNTING: //34002: + //0x55ec0 + Data_40003214_UserTimerSeconds = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER_SET; //34001; + break; + + case MENU_CONTEXT_ALARM: //3500: + //0x55ee0 + if (bData_4000322c == 1) + { + //55ef4 + Data_40002c64_MenuContextId = 35002; + } + else + { + //0x55f04 + //-> "Input time:" + Data_40002c64_MenuContextId = MENU_CONTEXT_ALARM_INPUT; //35001; + bCharacterInputPosition = 1; + } + //->563b8 + break; + + case MENU_CONTEXT_ALARM_INPUT: //35001: + //0x55f20: Alarm start? + HandleAlarmInputData(); + break; + + case 35002: + //0x55f2c: Alarm stop? + bData_4000322c = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_ALARM_INPUT; //35001; + break; + + case 3601: + //0x55f4c + Data_40002c64_MenuContextId = 360011; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x55f60 + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x55f68 + fMainFocalLength = atoi(&strEyepieceFovMfInput[6]) * 1.0; + fSecondaryFocalLength = atoi(&strEyepieceFovSfInput[6]) * 1.0; + fEyepieceMagnification = fMainFocalLength / fSecondaryFocalLength; + + sprintf(strEyepieceMagnification, "Magnification = %.1f ", fEyepieceMagnification); + beep1(1); + + bCharacterInputPosition = 7; + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT; //360021; + break; + + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x56048 + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x56050 + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x56054 + fMainFocalLength = atoi(&strEyepieceFovMfInput[6]) * 1.0; + fSecondaryFocalLength = atoi(&strEyepieceFovSfInput[6]) * 1.0; + fEyepieceFOV = atoi(&strEyepieceFovInput[6]) * 1.0 + + atoi(&strEyepieceFovInput[9]) * 0.016666667; + fEyepieceMagnification = fMainFocalLength / fSecondaryFocalLength; + fFieldOfView = fEyepieceFOV / fEyepieceMagnification; + + sprintf(strEyepieceFOV, " FOV:%0.5f ", fFieldOfView); + beep1(1); + + bCharacterInputPosition = 7; + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT; //370021; + break; + + case 360023: + //0x562f8 + fMainFocalLength = atoi(&Data_40002474[6]); + fSecondaryFocalLength = atoi(&Data_40002481[6]); + fEyepieceMagnification = fMainFocalLength / fSecondaryFocalLength; + break; + + case 3801: + //0x5634c + Data_40002c64_MenuContextId = MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL; //380011; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL: //380011: + //0x56360 + HandleStarKey(); + break; + + case 3802: + //0x5636c + if (bData_40003194 == 0) + { + setDisplayPWM(0xFF); + bData_40003194 = 1; + } + else + { + setDisplayPWM(0x00); + bData_40003194 = 0; + } + break; + + default: + break; + } +} + diff --git a/applications/freertos_app/HandleHelpKey.c b/applications/freertos_app/HandleHelpKey.c new file mode 100644 index 0000000..3a4a4ce --- /dev/null +++ b/applications/freertos_app/HandleHelpKey.c @@ -0,0 +1,779 @@ + + +/* 60ed0 - todo */ +void HandleHelpKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case 0: + //0x611f8 + Data_40002c64_MenuContextId = 500; //Main Screen Help Pages + bHelpActive = 1; + + lcd_display_clear(); + + bData_40002c59_MainScreenHelpPage = 1; + //->0x61ec0 + break; + + case 1000: + //0x61228 + Data_40002c64_MenuContextId = 501; //Telescope align + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2000: + //0x6124c + Data_40002c64_MenuContextId = 502; //Target navigation + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3000: + //0x61270 + Data_40002c64_MenuContextId = 503; //Utilities Commands + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4000: + //0x61294 + Data_40002c64_MenuContextId = 504; //Parameter Setup + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 1100: //1000 = Telescope align + //0x612b8 + Data_40002c64_MenuContextId = 505; //One star align + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 1200: + //0x612dc + Data_40002c64_MenuContextId = 506; //Two stars align + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 1300: + //0x61300 + Data_40002c64_MenuContextId = 507; //Three star align + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 1400: + //0x61324 + Data_40002c64_MenuContextId = 508; //Target Sync + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 1500: + //0x61348 + Data_40002c64_MenuContextId = 509; //Pole-Axis Deviation + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 1600: + //0x6136c + Data_40002c64_MenuContextId = 510; //RA Bklash Correction + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 1700: + //0x61390 + Data_40002c64_MenuContextId = 511; //DEC Bklash Correction + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2100: //2000 = Target navigation + //0x613b4 + Data_40002c64_MenuContextId = 516; //Solar System + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2200: + //0x613d8 + Data_40002c64_MenuContextId = 517; //Constellation + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2300: + //0x613fc + Data_40002c64_MenuContextId = 518; //Famous Star + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2400: + //0x61420 + Data_40002c64_MenuContextId = 519; //Messier Catalogue + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2500: + //0x61444 + Data_40002c64_MenuContextId = 520; //NGC Deep Sky + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2600: + //0x61468 + Data_40002c64_MenuContextId = 521; //IC Deep Sky + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2700: + //0x6148c + Data_40002c64_MenuContextId = 522; //Sh2 Deep Sky + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2800: + //0x614b0 + Data_40002c64_MenuContextId = 523; //Bright Stars + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2900: + //0x614d4 + Data_40002c64_MenuContextId = 524; //SAO Star + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2110: + //0x614f8 + Data_40002c64_MenuContextId = 525; //User-def Object + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2120: + //0x6151c + Data_40002c64_MenuContextId = 526; //Specify Ra Dec + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 2130: + //0x61540 + Data_40002c64_MenuContextId = 527; //Landmarks + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3100: //3000 = Utilities Commands + //0x61564 + Data_40002c64_MenuContextId = 528; //Current Objects + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3200: + //0x61588 + Data_40002c64_MenuContextId = 529; //Object Rise/Set + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3300: + //0x615ac + Data_40002c64_MenuContextId = 530; //Lunar Phase + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3400: + //0x615d0 + Data_40002c64_MenuContextId = 531; //Timer + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3500: + //0x615f4 + Data_40002c64_MenuContextId = 532; //Alarm + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3600: + //0x61618 + Data_40002c64_MenuContextId = 533; //Field Angle Cal + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3700: + //0x6163c + Data_40002c64_MenuContextId = 534; //Magify Power Cal + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3800: + //0x61660 + Data_40002c64_MenuContextId = 535; //Illumination + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 3900: + //0x61684 + Data_40002c64_MenuContextId = 537; //Parkzen + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4100: + //0x616a8 + Data_40002c64_MenuContextId = 538; //Time and Date + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4200: + //0x616cc + Data_40002c64_MenuContextId = 539; //Daylight Saving + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4300: + //0x616f0 + Data_40002c64_MenuContextId = 540; //Site Setting + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4400: + //0x61714 + Data_40002c64_MenuContextId = 541; //Sky/ Land + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4500: + //0x61738 + Data_40002c64_MenuContextId = 542; //AZ/EQ + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4600: + //0x6175c + Data_40002c64_MenuContextId = 543; //Telescope Zero + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4700: + //0x61780 + Data_40002c64_MenuContextId = 544; //Tracking Rate + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4800: + //0x617a4 + Data_40002c64_MenuContextId = 545; //Language + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 4900: + //0x617c8 + Data_40002c64_MenuContextId = 546; //Reset + bHelpActive = 1; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 500: + //0x617ec + Data_40002c64_MenuContextId = 0; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 501: //0x1f5 + //0x6180c: Telescope align? + Data_40002c64_MenuContextId = 1000; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 502: + //0x61830: Target navigation? + Data_40002c64_MenuContextId = 2000; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 503: + //0x61854: Utilities Commands? + Data_40002c64_MenuContextId = 3000; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 504: //0x1f8 + //0x61878: Parameter Setup? + Data_40002c64_MenuContextId = 4000; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 505: + //0x6189c + Data_40002c64_MenuContextId = 1100; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 506: + //0x618c0 + Data_40002c64_MenuContextId = 1200; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 507: + //0x618e4 + Data_40002c64_MenuContextId = 1300; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 508: + //0x61908 + Data_40002c64_MenuContextId = 1400; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 509: //0x1fd + //0x6192c: Pole-Axis Deviation? + Data_40002c64_MenuContextId = 1500; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 510: + //0x61950 + Data_40002c64_MenuContextId = 1600; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 511: + //0x61974 + Data_40002c64_MenuContextId = 1700; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 516: + //0x61998 + Data_40002c64_MenuContextId = 2100; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 517: + //0x619bc + Data_40002c64_MenuContextId = 2200; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 518: + //0x619e0 + Data_40002c64_MenuContextId = 2300; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 519: + //0x61a04 + Data_40002c64_MenuContextId = 2400; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 520: + //0x61a28 + Data_40002c64_MenuContextId = 2500; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 521: + //0x61a4c + Data_40002c64_MenuContextId = 2600; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 522: + //0x61b60 + Data_40002c64_MenuContextId = 2700; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 523: + //0x61b84 + Data_40002c64_MenuContextId = 2800; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 524: //0x20c + //0x61ba8 + Data_40002c64_MenuContextId = 2900; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 525: + //0x61bcc + Data_40002c64_MenuContextId = 2110; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 526: + //0x61bf0 + Data_40002c64_MenuContextId = 2120; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 527: + //0x61c14 + Data_40002c64_MenuContextId = 2130; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 528: + //0x61c38 + Data_40002c64_MenuContextId = 3100; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 529: + //0x61c5c + Data_40002c64_MenuContextId = 3200; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 530: + //0x61c80 + Data_40002c64_MenuContextId = 3300; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 531: + //0x61ca4 + Data_40002c64_MenuContextId = 3400; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 532: + //0x61cc8 + Data_40002c64_MenuContextId = 3500; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 533: + //0x61cec + Data_40002c64_MenuContextId = 3600; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 534: + //0x61d10 + Data_40002c64_MenuContextId = 3700; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 535: + //0x61d34 + Data_40002c64_MenuContextId = 3800; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + #if 0 + case 536: + //0x61ec0 + break; + #endif + + case 537: + //0x61d58 + Data_40002c64_MenuContextId = 3900; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 538: + //0x61d7c + Data_40002c64_MenuContextId = 4100; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 539: + //0x61da0 + Data_40002c64_MenuContextId = 4200; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 540: + //0x61dc4 + Data_40002c64_MenuContextId = 4300; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 541: + //0x61de8 + Data_40002c64_MenuContextId = 4400; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 542: + //0x61e0c + Data_40002c64_MenuContextId = 4500; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 543: + //0x61e30 + Data_40002c64_MenuContextId = 4600; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 544: + //0x61e54 + Data_40002c64_MenuContextId = 4700; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 545: + //0x61e78 + Data_40002c64_MenuContextId = 4800; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + case 546: //0x222 + //0x61e9c + Data_40002c64_MenuContextId = 4900; + bHelpActive = 0; + + lcd_display_clear(); + //->0x61ec0 + break; + + #if 0 + default: + //0x61ec0 + break; + #endif + } +} + diff --git a/applications/freertos_app/HandleLeftKey.c b/applications/freertos_app/HandleLeftKey.c new file mode 100644 index 0000000..bcd558a --- /dev/null +++ b/applications/freertos_app/HandleLeftKey.c @@ -0,0 +1,1210 @@ + + +/* 583dc - todo */ +void func_583dc(void) +{ + switch (bData_40003263) + { + case 1: + //0x583f8 + case 3: + //0x58400 + switch (bData_40003260) + { + case 0: + //0x58424 + if (bCharacterInputPosition > 7) + { + bCharacterInputPosition--; + } + else + { + bCharacterInputPosition = 13; + } + break; + + case 1: + //0x58460 + switch (bCharacterInputPosition) + { + case 7: + //0x5849c + bCharacterInputPosition = 14; + break; + + case 8: + //0x584b0 + bCharacterInputPosition = 7; + break; + + case 10: + //0x584c4 + bCharacterInputPosition = 8; + break; + + case 11: + //0x584d8 + bCharacterInputPosition = 10; + break; + + case 13: + //0x584ec + bCharacterInputPosition = 11; + break; + + case 14: + //0x58500 + bCharacterInputPosition = 13; + break; + + default: + //0x58514 + break; + } //switch (bCharacterInputPosition) + //->0x565f4 + break; + + case 2: + //0x58524 + switch (bCharacterInputPosition) + { + case 7: + //0x58564 + bCharacterInputPosition = 15; + break; + + case 8: + //0x58578 + bCharacterInputPosition = 7; + break; + + case 9: + //0x5858c + bCharacterInputPosition = 8; + break; + + case 11: + //0x585a0 + bCharacterInputPosition = 9; + break; + + case 12: + //0x585b4 + bCharacterInputPosition = 11; + break; + + case 14: + //0x585c8 + bCharacterInputPosition = 12; + break; + + case 15: + //0x585dc + bCharacterInputPosition = 14; + break; + + default: + //0x585f0 + break; + } //switch (bCharacterInputPosition) + //-> + break; + + default: + //0x58600 + break; + } //switch (bData_40003260) + + break; + + default: + //0x58610 + break; + } //switch (bData_40003263) +} + +/* 58620 - todo */ +void func_58620(void) +{ + switch (bData_40003262) + { + case 1: + //58630 + switch (bData_40003261) + { + case 0: + //0x58658 + if (bCharacterInputPosition > 7) + { + bCharacterInputPosition--; + } + else + { + bCharacterInputPosition = 13; + } + //->0x56828 + break; + + case 1: + //0x58694 + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 15; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + case 9: + bCharacterInputPosition = 8; + break; + + case 11: + bCharacterInputPosition = 9; + break; + + case 12: + bCharacterInputPosition = 11; + break; + + case 14: + bCharacterInputPosition = 12; + break; + + case 15: + bCharacterInputPosition = 14; + break; + + default: + break; + } + break; + + case 2: + //0x58770 + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 14; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + case 10: + bCharacterInputPosition = 8; + break; + + case 11: + bCharacterInputPosition = 10; + break; + + case 13: + bCharacterInputPosition = 11; + break; + + case 14: + bCharacterInputPosition = 13; + break; + + default: + break; + } + break; + + default: + //0x58834 + break; + } //switch (bData_40003261) + break; + + default: + //0x58844 + break; + } //switch (bData_40003262) +} + +/* 58854 - todo */ +void HandlePreviousCity(void) +{ + switch (wData_40003250) + { + case 3: + //0x588f8 + if (wData_40003252 == 0) + { + wData_40003252 = 21; + } + else + { + wData_40003252--; + } + break; + + case 26: + //0x58934 + case 35: + //0x5893c + case 77: + //0x58940 + if (wData_40003252 == 0) + { + wData_40003252 = 2; + } + else + { + wData_40003252--; + } + break; + + case 40: + //0x58978 + case 48: + //0x58980 + if (wData_40003252 == 0) + { + wData_40003252 = 4; + } + else + { + wData_40003252--; + } + break; + + case 60: + //0x589b8 + case 90: + //0x589c0 + case 119: + //0x589c4 + case 150: + //0x589c8 + case 152: + //0x589cc + case 156: + //0x589d0 + if (wData_40003252 == 0) + { + wData_40003252 = 1; + } + else + { + wData_40003252--; + } + break; + + case 64: + //0x58a08 + case 134: + //0x58a10 + if (wData_40003252 == 0) + { + wData_40003252 = 8; + } + else + { + wData_40003252--; + } + break; + + case 82: + //0x58a48 + if (wData_40003252 == 0) + { + wData_40003252 = 6; + } + else + { + wData_40003252--; + } + break; + + case 99: + //0x58a84 + if (wData_40003252 == 0) + { + wData_40003252 = 5; + } + else + { + wData_40003252--; + } + break; + + default: + //0x58ac0 + wData_40003252 = 0; + break; + } +} + +/* 58adc - todo */ +void func_58adc(void) +{ + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 10; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + case 9: + bCharacterInputPosition = 8; + break; + + case 10: + bCharacterInputPosition = 9; + break; + + default: + break; + } +} + +/* 58b68 - todo */ +void func_58b68(void) +{ + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 12; + break; + + case 12: + bCharacterInputPosition = 11; + break; + + case 11: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 8; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + default: + break; + } +} + +/* 58c0c - todo */ +void func_58c0c(void) +{ + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 8; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + default: + break; + } +} + +/* 58c60 - todo */ +void func_58c60(void) +{ + switch (bCharacterInputPosition) + { + case 1: + bCharacterInputPosition = 8; + break; + + case 2: + bCharacterInputPosition = 1; + break; + + case 4: + bCharacterInputPosition = 2; + break; + + case 5: + bCharacterInputPosition = 4; + break; + + case 7: + bCharacterInputPosition = 5; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + default: + break; + } +} + +/* 58d20 - todo */ +void HandlePrevTimerInputPosition(void) +{ + switch (bCharacterInputPosition) + { + case 1: + bCharacterInputPosition = 5; + break; + + case 2: + bCharacterInputPosition = 1; + break; + + case 3: + bCharacterInputPosition = 2; + break; + + case 4: + bCharacterInputPosition = 3; + break; + + case 5: + bCharacterInputPosition = 4; + break; + + default: + break; + } +} + +/* 58dc0 - todo */ +void func_58dc0(void) +{ + switch (bData_4000316d) + { + case 0: + if (bCharacterInputPosition > 5) + { + bCharacterInputPosition--; + } + else + { + bCharacterInputPosition = 7; + } + break; + + case 1: + if (bCharacterInputPosition > 6) + { + bCharacterInputPosition--; + } + else + { + bCharacterInputPosition = 7; + } + break; + + default: + break; + } +} + +/* 58e64 - complete */ +void HandlePrevCustomSiteInputPosition(void) +{ + switch (bData_40002edc) + { + case 1: + case 3: + switch (bCurrentCustomSiteInputLine) + { + case 0: //Name + if (bCharacterInputPosition > 7) + { + bCharacterInputPosition--; + } + else + { + bCharacterInputPosition = 14; + } + break; + + case 1: //Longitude + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 13; + break; + + case 13: + bCharacterInputPosition = 12; + break; + + case 12: + bCharacterInputPosition = 10; + break; + + case 10: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 8; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + default: + break; + } + break; + + case 2: //Latitude + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 12; + break; + + case 12: + bCharacterInputPosition = 11; + break; + + case 11: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 8; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + default: + break; + } + break; + + case 3: //Time Zone + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 8; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + default: + break; + } + break; + + case 4: + switch (bCharacterInputPosition) + { + case 7: + bCharacterInputPosition = 10; + break; + + case 10: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 8; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + default: + break; + } + break; + + default: + break; + } + break; + + default: + break; + } +} + +/* 591b8 - todo */ +void HandlePrevDateTimeInputPosition(void) +{ + switch (bDateTimeInputMode) + { + case 0: + switch (bCharacterInputPosition) + { + case 1: + bCharacterInputPosition = 10; + break; + + case 10: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 7; + break; + + case 7: + bCharacterInputPosition = 6; + break; + + case 6: + bCharacterInputPosition = 4; + break; + + case 4: + bCharacterInputPosition = 3; + break; + + case 3: + bCharacterInputPosition = 2; + break; + + case 2: + bCharacterInputPosition = 1; + break; + + default: + break; + } + break; + + case 1: + switch (bCharacterInputPosition) + { + case 1: + bCharacterInputPosition = 8; + break; + + case 8: + bCharacterInputPosition = 7; + break; + + case 7: + bCharacterInputPosition = 5; + break; + + case 5: + bCharacterInputPosition = 4; + break; + + case 4: + bCharacterInputPosition = 2; + break; + + case 2: + bCharacterInputPosition = 1; + break; + + default: + break; + } + break; + + default: + break; + } +} + +/* 5939c - complete */ +void func_5939c(void) +{ + switch (bCharacterInputPosition) + { + case 1: + bCharacterInputPosition = 6; + break; + + case 6: + bCharacterInputPosition = 5; + break; + + case 5: + bCharacterInputPosition = 3; + break; + + case 3: + bCharacterInputPosition = 2; + break; + + case 2: + bCharacterInputPosition = 1; + break; + + default: + break; + } +} + +/* 59440 - complete */ +void func_59440(void) +{ + switch (bCharacterInputPosition) + { + case 5: + bCharacterInputPosition = 15; + break; + + case 15: + bCharacterInputPosition = 13; + break; + + case 13: + bCharacterInputPosition = 12; + break; + + case 12: + bCharacterInputPosition = 10; + break; + + case 10: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 7; + break; + + case 7: + bCharacterInputPosition = 6; + break; + + case 6: + bCharacterInputPosition = 5; + break; + + default: + break; + } +} + +/* 59534 - complete */ +void func_59534(void) +{ + switch (bCharacterInputPosition) + { + case 6: + bCharacterInputPosition = 15; + break; + + case 15: + bCharacterInputPosition = 13; + break; + + case 13: + bCharacterInputPosition = 12; + break; + + case 12: + bCharacterInputPosition = 10; + break; + + case 10: + bCharacterInputPosition = 9; + break; + + case 9: + bCharacterInputPosition = 7; + break; + + case 7: + bCharacterInputPosition = 6; + break; + + default: + break; + } +} + +/* 59610 - todo */ +void func_59610(void) +{ + switch (wData_40002eda) + { + case 1: + //0x5963c + wData_40002eda = 10; + break; + + case 10: + //0x59650 + wData_40002eda = 100; + break; + + case 100: + //0x59664 + wData_40002eda = 1000; + break; + + case 1000: + //0x59678 + wData_40002eda = 10000; + break; + + default: + //0x5968c + break; + } +} + +/* 5969c - todo */ +void HandleLeftKey(void) +{ + func_59610(); + + switch (Data_40002c64_MenuContextId) + { + case 29001: + //0x598c0 + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x598c8 + func_59534(); + break; + + case 29002: + //0x598d0 + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x598d8 + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x598dc + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x598e0 + func_59440(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x598e8 + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x598f0 + bCharacterInputPosition--; + if (bCharacterInputPosition < 6) + { + bCharacterInputPosition = 13; + } + break; + + case MENU_CONTEXT_MAIN: //0: + //0x59924 + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x5992c + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x59930 + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x59934 + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x59938 + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x5993c + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x59940 + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x59944 + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x59948 + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x5994c + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x59950 + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x59954 + if (g_bLandTarget == 0) + { + if ((Data_40004128.bTrackingActive != 0) && (g_bSlewingStop != 1)) + { + //59984 + g_iSlewStepRaAxis = -1; + bData_40003200 = 0; + //->0x59a1c + } + else + { + //0x599a0 + if (bData_40002c1a == 1) + { + //599b0 + SlewAxis(1, 3, g_eSlewRateIndex); + //->0x59a1c + } + else + { + //0x599c8 + SlewAxis(3, 3, g_eSlewRateIndex); + //->0x59a1c + } + } + } + else + { + //0x599e0 + if (bData_40002c1a == 1) + { + //599f0 + SlewAxis(1, 3, g_eSlewRateIndex); + } + else + { + //0x59a08 + SlewAxis(3, 3, g_eSlewRateIndex); + } + } + //-> 0x59dc4 + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x59a20 + if (bData_40002c62_AlignmentStarMode != 0) + { + //59a34 + g_iSlewStepRaAxis = -1; + bData_40003200 = 0; + } + //0x59a4c -> 0x59dc4 + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT: //11101: + //0x59a50 + dRaBklashCorrStartAzimuth = dData_40002dc0_Azimuth; + + if (bData_40002c1a == 1) + { + //59a74 + SlewAxis(1, 3, SLEW_RATE_8X); //3); + + bData_40002edd = 2; + } + else + { + //0x59a94 + SlewAxis(3, 3, SLEW_RATE_8X); //3); + + bData_40002edd = 0; + } + //0x59ab0 + iBacklashCorrectionSlewing = 1; + bRaBacklashCorrectionDirection = 2; + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT; //11103; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + //0x59ad8 + if (bRaBacklashCorrectionDirection == 1) + { + //Slewing Left when started Right + if (bData_40002c1a == 1) + { + //59afc + SlewAxis(1, 3, g_eSlewRateIndex); + } + else + { + //0x59b14 + SlewAxis(3, 3, g_eSlewRateIndex); + } + } + //0x59b28 -> 0x59dc4 + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x59b2c + func_5939c(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x59b38 + HandlePrevDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x59b44 + HandlePrevCustomSiteInputPosition(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x59b50 + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x59b58 + case 101: + //0x59b5c + switch (bData_4000319a_SkyLandTargetId) + { + case 1: + //0x59b98 + bData_4000319a_SkyLandTargetId = 3; + break; + + case 3: + //0x59bac + bData_4000319a_SkyLandTargetId = 2; + break; + + case 2: + //0x59bc0 + bData_4000319a_SkyLandTargetId = 1; + break; + + case 4: + //0x59bd4 + bData_4000319a_SkyLandTargetId = 6; + break; + + case 6: + //0x59be8 + bData_4000319a_SkyLandTargetId = 5; + break; + + case 5: + //0x59bfc + bData_4000319a_SkyLandTargetId = 4; + break; + + case 7: + //0x59c10 + bData_4000319a_SkyLandTargetId = 9; + break; + + case 9: + //0x59c24 + bData_4000319a_SkyLandTargetId = 8; + break; + + case 8: + //0x59c38 + bData_4000319a_SkyLandTargetId = 7; + break; + #if 0 + default: + //0x59c4c + break; + #endif + } + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x59c54 + func_58dc0(); + break; + + case 33001: + //0x59c60 + if (Data_40003168_LunarPhaseMonth > 0) + { + Data_40003168_LunarPhaseMonth--; + } + else + { + //0x59c8c + Data_40003168_LunarPhaseMonth = 12; + } + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x59c9c + HandlePrevTimerInputPosition(); + break; + + case MENU_CONTEXT_ALARM_INPUT: //35001: + //0x59ca8 + func_58c60(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x59cb4 + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x59cbc + func_58c0c(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x59cc4 + func_58b68(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x59cd0 + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x59cd8 + func_58adc(); + break; + + case MENU_CONTEXT_COUNTRY_CITY_SELECTION: //43011: + //0x59ce0 + lcd_display_clear(); + HandlePreviousCity(); + //break; + case 211001: + //0x59cf0 + switch (bData_40003262) + { + case 1: + //59d00 + func_58620(); + break; + + default: + break; + } + break; + + case 28001: + //0x59d1c + switch (bData_40003263) + { + case 1: + //0x59d3c + case 3: + //0x59d44 + func_583dc(); + break; + + default: + //0x59d4c + break; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_ON: //42001: + //0x59d5c + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_OFF; //42002; + bDaylightSavingTime = 0; + } + //0x59d88 + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_OFF: //42002: + //0x59d8c + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_ON; //42001; + bDaylightSavingTime = 1; + } + break; + + default: + //0x59dbc + break; + } +} + diff --git a/applications/freertos_app/HandleMinusKey.c b/applications/freertos_app/HandleMinusKey.c new file mode 100644 index 0000000..35fa277 --- /dev/null +++ b/applications/freertos_app/HandleMinusKey.c @@ -0,0 +1,1065 @@ + +//#include "menu.h" + +/* 5f230 - todo */ +void HandleMinusKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_RECENT_TARGETS: //1: + //0x5f9e0 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case 5000: + //0x5f9f4 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case 101: + //0x5fa08 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case 102: + //0x5fa1c + Data_40002c64_MenuContextId = 101; + break; + + case MENU_CONTEXT_MERIDIAN_FLIP: //3: + //0x5fa30 + bData_40003210 = 1; + bData_40003211 = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x5fa58: One / Two / Three Star Align + if (bData_40002c62_AlignmentStarMode != 0) + { + //5fa6c + Data_40004128.bAlignmentComplete = 1; + + StopSlewing(); + + bData_40002e8c = 0; + + lcd_display_string(0, 1, 1, 21, " "); + lcd_display_string(0, 2, 1, 21, " "); + lcd_display_string(0, 3, 1, 21, " "); + lcd_display_string(0, 4, 1, 21, "This Align Canceled "); + lcd_display_string(0, 5, 1, 21, " "); + lcd_display_string(0, 6, 1, 21, " "); + lcd_display_string(0, 7, 1, 21, " "); + lcd_display_string(0, 8, 1, 21, " "); + + func_659c(1000); + beep1(2); + func_659c(100); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + else + { + //0x5fb8c + switch (Data_40002c5c_AlignmentStarCount) + { + case 1: + //0x5fbb0 + Data_40002c64_MenuContextId = MENU_CONTEXT_ONE_STAR_ALIGN; //1100; + break; + + case 2: + //0x5fbc4 + Data_40002c64_MenuContextId = MENU_CONTEXT_TWO_STAR_ALIGN; //1200; + break; + + case 3: + //0x5fbd8 + Data_40002c64_MenuContextId = MENU_CONTEXT_THREE_STAR_ALIGN; //1300; + break; + + default: + //0x5fbec + break; + } + } + //->0x60d48 + break; + + case MENU_CONTEXT_ALIGNMENT: //1000: + //0x5fbfc + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + //->0x60d48 + break; + + case MENU_CONTEXT_NAVIGATION: //2000: + //0x5fc10 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_UTILITIES: //3000: + //0x5fc24 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_SETUP: //4000: + //0x5fc38 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_ONE_STAR_ALIGN: //1100: + //0x5fc4c + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + break; + + case MENU_CONTEXT_TWO_STAR_ALIGN: //1200: + //0x5fc60 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + break; + + case MENU_CONTEXT_THREE_STAR_ALIGN: //1300: + //0x5fc74 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + break; + + case MENU_CONTEXT_TARGET_SYNC: //1400: + //0x5fc88 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + break; + + case MENU_CONTEXT_POLE_AXIS_DEV: //1500: + //0x5fc9c + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR: //1600: + //0x5fcb0 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + break; + + case MENU_CONTEXT_DEC_BKLASH_CORR: //1700: + //0x5fcc4 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; //1000; + break; + + case MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM: //2100: + //0x5fcd8 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case MENU_CONTEXT_NAVIGATION_CONSTELLATION: //2200: + //0x5fcec + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2300: + //0x5fd00 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2400: + //0x5fd14 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2500: + //0x5fd28 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2600: + //0x5fd3c + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2700: + //0x5fd50 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2800: + //0x5fd64 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2900: + //0x5fd78 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case MENU_CONTEXT_NAVIGATION_CUST_OBJ: //2110: + //0x5fdd8 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case MENU_CONTEXT_NAVIGATION_RA_DEC: //2120: + //0x5fdec + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 2130: + //0x5fe00 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; //2000; + break; + + case 3100: + //0x5fe14 + Data_40002c64_MenuContextId = 3000; + break; + + case MENU_CONTEXT_OBJECT_RISE_SET: //3200: + //0x5fe28 + Data_40002c64_MenuContextId = 3000; + break; + + case 3300: + //0x5fe3c + Data_40002c64_MenuContextId = 3000; + break; + + case MENU_CONTEXT_TIMER: //3400: + //0x5fe50 + Data_40002c64_MenuContextId = 3000; + break; + + case 3500: + //0x5fe64 + Data_40002c64_MenuContextId = 3000; + break; + + case 3600: + //0x5fe78 + Data_40002c64_MenuContextId = 3000; + break; + + case 3700: + //0x5fe8c + Data_40002c64_MenuContextId = 3000; + break; + + case 3800: + //0x5fea0 + Data_40002c64_MenuContextId = 3000; + break; + + case 3900: + //0x5feb4 + Data_40002c64_MenuContextId = 3000; + break; + + case 4100: + //0x5fec8 + Data_40002c64_MenuContextId = 4000; + break; + + case 4200: + //0x5fedc: Daylight Saving + Data_40002c64_MenuContextId = 4000; + break; + + case 4300: + //0x5fef0 + Data_40002c64_MenuContextId = 4000; + break; + + case 4400: + //0x5ff04 + Data_40002c64_MenuContextId = 4000; + break; + + case 4500: + //0x5ff18 + Data_40002c64_MenuContextId = 4000; + break; + + case 4600: + //0x5ff2c + Data_40002c64_MenuContextId = 4000; + break; + + case 4700: + //0x5ff40 + Data_40002c64_MenuContextId = 4000; + break; + + case 4800: + //0x5ff54 + Data_40002c64_MenuContextId = 4000; + break; + + case 4900: + //0x5ff68 + Data_40002c64_MenuContextId = 4000; + break; + + case MENU_CONTEXT_SYNC_OPEN: //1401: + //0x5ff7c + g_bTargetSyncOpen = FALSE; + case MENU_CONTEXT_SYNC_ENSURE: //1402: + //0x5ff90 + case MENU_CONTEXT_SYNC_CANCEL: //1403: + //0x5ff94 + Data_40002c64_MenuContextId = MENU_CONTEXT_TARGET_SYNC; //1400; + break; + + case 2801: + //0x5ffa4 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case 2802: + //0x5ffb8 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case 2803: + //0x5ffcc + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case 2804: + //0x5ffe0 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case 21101: + //0x5fff4 + Data_40002c64_MenuContextId = 2130; + break; + + case 21102: + //0x60008 + Data_40002c64_MenuContextId = 2130; + break; + + case 21103: + //0x6001c + Data_40002c64_MenuContextId = 2130; + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x60030 + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER; //3400; + break; + + case MENU_CONTEXT_TIMER_COUNTING: //34002: + //0x60044 + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER; //3400; + break; + + case MENU_CONTEXT_ALARM_INPUT: //35001: + //0x60058 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALARM; //3500; + break; + + case 35002: + //0x6006c + Data_40002c64_MenuContextId = MENU_CONTEXT_ALARM; //3500; + break; + + case 360021: + //0x60080 + case 360022: + //0x60088 + Data_40002c64_MenuContextId = 3700; + break; + + case 370021: + //0x60098 + case 370022: + //0x600a0 + case 370023: + //0x600a4 + Data_40002c64_MenuContextId = 3600; + break; + + case 3602: + //0x600b4 + Data_40002c64_MenuContextId = 3600; + break; + + case 3801: + //0x600c8 + Data_40002c64_MenuContextId = 3800; + break; + + case 3802: + //0x600dc + Data_40002c64_MenuContextId = 3800; + break; + + case 4301: + //0x600f0 + case 4302: + //0x600f8 + if (bData_40002f1e_SetupLocalData == 0) + { + Data_40002c64_MenuContextId = 4300; + } + else + { + //0x60118 + Data_40002c64_MenuContextId = 42001; + } + break; + + case MENU_CONTEXT_TRACKING_RATE_STAR_SPEED: //4801: + //0x60128 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE; //4700; + break; + + case MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED: //4802: + //0x6013c + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE; //4700; + break; + + case MENU_CONTEXT_TRACKING_RATE_MOON_SPEED: //4803: + //0x60150 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE; //4700; + break; + + case MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED: //4804: + //0x60164 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE; //4700; + break; + + case MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED: //4805: + //0x60178 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE; //4700; + break; + + case 45001: + //0x6018c + Data_40002c64_MenuContextId = 4400; + break; + + case 45002: + //0x601a0 + Data_40002c64_MenuContextId = 4400; + break; + + case 46001: + //0x601b4 + Data_40002c64_MenuContextId = 4500; + break; + + case 46002: + //0x601c8 + Data_40002c64_MenuContextId = 4500; + break; + + case 18001: + //0x601dc + Data_40002c64_MenuContextId = 1500; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x601f0 + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR; //1600; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT: //11101: + //0x60204 + SlewStop(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11102; + iBacklashCorrectionSlewing = 0; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x60228 + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKLASH_CORR; //1700; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN: //11201: + //0x6023c + SlewStop(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11202; + iBacklashCorrectionSlewing = 0; + break; + + case 31001: + //0x60260 + Data_40002c64_MenuContextId = 3100; + break; + + case 26001: + //0x60274 + Data_40002c64_MenuContextId = 2600; + break; + + case 27001: + //0x60288 + Data_40002c64_MenuContextId = 2700; + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION: //22001: + //0x6029c + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM; //2100; + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x602b0 + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x602e0 + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION; //22001; + } + else + { + //0x60300 + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_SUN_WARNING: //22112: + //0x60328 + Data_40002c64_MenuContextId = MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION; //22001; + break; + + case MENU_CONTEXT_CONSTELLATION_SELECTION: //24001: + //0x6033c + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CONSTELLATION; //2200; + break; + + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x60350 + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //60380 + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_CONSTELLATION_SELECTION; //24001; + } + else + { + //0x603a0 + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_FAMOUS_STAR_SELECTION: //25001: + //0x603c8 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_FAMOUS_STAR; //2300; + break; + + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x603dc + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x6040c + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_FAMOUS_STAR_SELECTION; //25001; + } + else + { + //6042c + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x60454 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_MESSIER_CAT; //2400; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x60468 + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MESSIER_OBJECT_DETAILS; //23012; + break; + + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x60480 + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x604b0 + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_MESSIER_OBJECT_SELECTION; //23002; + } + else + { + //0x604d0 + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x604f8 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_NGC_CAT; //2500; + break; + + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x6050c + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x6053c + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_NGC_OBJECT_SELECTION; //23003; + } + else + { + //0x6055c + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x60584 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_IC_CAT; //2600; + break; + + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x60598 + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x605c8 + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_IC_OBJECT_SELECTION; //23004; + } + else + { + //0x605e8 + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x60610 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SH2_CAT; //2700; + break; + + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x60624 + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x60654 + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_SH2_OBJECT_SELECTION; //23005; + } + else + { + //0x60674 + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x6069c + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_BRIGHT_STAR; //2800; + break; + + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x606b0 + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x606e0 + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_BRIGHT_STAR_SELECTION; //23006; + } + else + { + //0x60700 + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x60728 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SAO_CAT; //2900; + break; + + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x6073c + bData_40003432 = 0; + + if ((bTrackingModeMenu == MENU_TRACKING_MODE_CANCEL/*5*/) || + (bTrackingModeMenu == 3)) + { + //0x6076c + lcd_display_clear(); + + Data_40004128.bTrackingRequest = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_SAO_OBJECT_SELECTION; //23007; + } + else + { + //0x6078c + bTrackingModeMenu = MENU_TRACKING_MODE_CANCEL; //5; + + StopSlewing(); + + bData_40002e8c = 0; + + beep1(2); + } + //->0x60d48 + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x607b4 + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x607c8 + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x607d0 + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x607d4 + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION; //201; + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + //0x607e4 + if (bData_40003162 == 0) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_RA_DEC; //2120; + } + else + { + //0x60808 + Data_40002c64_MenuContextId = MENU_CONTEXT_OBJECT_RISE_SET; //3200; + } + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + //0x60818 + if (bData_40003162 == 0) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_RA_DEC; //2120; + } + else + { + //0x6083c + Data_40002c64_MenuContextId = MENU_CONTEXT_OBJECT_RISE_SET; //3200; + } + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x6084c + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_LAND; //2130; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x60860 + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x60868 + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x6086c + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_SELECTION; //202; + break; + + case 360111: + //0x6087c + Data_40002c64_MenuContextId = 3601; + break; + + case 360112: + //0x60890 + Data_40002c64_MenuContextId = 3601; + break; + + case 360113: + //0x608a4 + Data_40002c64_MenuContextId = 3601; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL: //380011: + //0x608b8 + Data_40002c64_MenuContextId = MENU_CONTEXT_DISPLAY_ILLUMINATION; //3800; + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_ON: //42001: + //0x608cc + case MENU_CONTEXT_DAYLIGHT_SAVING_OFF: //42002: + //0x608d4 + if (bData_40002f1e_SetupLocalData == 0) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING; //4200; + } + else + { + //0x608f4 + get_rtc_date_time(); + + sprintf(Data_400037ec, "%04d-%02d-%02d", + Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40003150, "%02d:%02d:%02d", + bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + + sprintf(Data_40002655, "%04d-%02d-%02d", + Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40002660, "%02d:%02d:%02d", + bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + + bCharacterInputPosition = 1; + bDateTimeInputMode = 0; + + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE_INPUT; //41001; + } + //0x609bc -> 0x60d48 + break; + + case 211001: + //0x609c0 + switch (bData_40003262) + { + case 0: + //0x609e8 + Data_40002c64_MenuContextId = 21101; + break; + + case 1: + //0x609fc + Data_40002c64_MenuContextId = 21102; + break; + + case 2: + //0x60a10 + Data_40002c64_MenuContextId = 21103; + break; + + default: + //0x60a24 + break; + } + break; + + case 28001: + //0x60a34 + switch (bData_40003263) + { + case 0: + //0x60a64 + Data_40002c64_MenuContextId = 2801; + break; + + case 1: + //0x60a78 + Data_40002c64_MenuContextId = 2802; + break; + + case 2: + //0x60b8c + Data_40002c64_MenuContextId = 2803; + break; + + case 3: + //0x60ba0 + Data_40002c64_MenuContextId = 2804; + break; + + default: + //0x60bb4 + break; + + } + break; + + case 49001: + //0x60bc4 + Data_40002c64_MenuContextId = 4800; + break; + + case 49002: + //0x60bd8 + Data_40002c64_MenuContextId = 4800; + break; + + case 49003: + //0x60bec + Data_40002c64_MenuContextId = 4800; + break; + + case 49004: + //0x60c00 + Data_40002c64_MenuContextId = 4800; + break; + + case 49005: + //0x60c14 + Data_40002c64_MenuContextId = 4800; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x60c28 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED; //4804; + break; + + case MENU_CONTEXT_GUIDING_SPEED1: //48051: + //0x60c3c + case MENU_CONTEXT_GUIDING_SPEED2: //48052: + //0x60c44 + case MENU_CONTEXT_GUIDING_SPEED3: //48053: + //0x60c48 + case MENU_CONTEXT_GUIDING_SPEED4: //48054: + //0x60c4c + case MENU_CONTEXT_GUIDING_SPEED5: //48055: + //0x60c50 + case MENU_CONTEXT_GUIDING_SPEED6: //48056: + //0x60c54 + case MENU_CONTEXT_GUIDING_SPEED7: //48057: + //0x60c58 + case MENU_CONTEXT_GUIDING_SPEED8: //48058: + //0x60c5c + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED; //4805; + break; + + case 360011: //??? + //0x60c6c + Data_40002c64_MenuContextId = 3601; + break; + + case 41001: + //0x60c80 + if (bData_40002f1e_SetupLocalData == 0) + { + Data_40002c64_MenuContextId = 4100; + } + break; + + case 43011: + //0x60ca4 + Data_40002c64_MenuContextId = 4301; + break; + + case 43002: + //0x60cb8 + Data_40002c64_MenuContextId = 4302; + break; + + case MENU_CONTEXT_RESET_CONFIRM: //100: + //0x60ccc: Reset -> Cancel + Data_40002c64_MenuContextId = MENU_CONTEXT_RESET; //4900; + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x60ce0 + if (bData_40002f1e_SetupLocalData == 0) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_TELESCOPE_MOUNT; //4600; + } + else + { + //0x60d04 + Data_40002c64_MenuContextId = MENU_CONTEXT_COUNTRY_CITY; //4301; + } + break; + + case MENU_CONTEXT_RISE_SET_TIMES: //32001: + //0x60d14 + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_INPUT; //29001; + break; + + case 33001: + //0x60d28: Curr. Lunar Phase + Data_40002c64_MenuContextId = 3300; + break; + + default: + //60d3c + func_b4d0(); + break; + } +} + diff --git a/applications/freertos_app/HandleRightKey.c b/applications/freertos_app/HandleRightKey.c new file mode 100644 index 0000000..6708fbc --- /dev/null +++ b/applications/freertos_app/HandleRightKey.c @@ -0,0 +1,1276 @@ + + +/* 563c8 - todo */ +void func_563c8(void) +{ + switch (bData_40003263) + { + case 1: + //0x563e4 + case 3: + //0x563ec + switch (bData_40003260) + { + case 0: + //0x56410 + if (bCharacterInputPosition < 13) + { + //56424 + bCharacterInputPosition++; + } + else + { + //0x5643c + bCharacterInputPosition = 7; + } + //0x56448 -> 0x565f4 + break; + + case 1: + //0x5644c + switch (bCharacterInputPosition) + { + case 7: + //0x56488 + bCharacterInputPosition = 8; + break; + + case 8: + //0x5649c + bCharacterInputPosition = 10; + break; + + case 10: + //0x564b0 + bCharacterInputPosition = 11; + break; + + case 11: + //0x564c4 + bCharacterInputPosition = 13; + break; + + case 13: + //0x564d8 + bCharacterInputPosition = 14; + break; + + case 14: + //0x564ec + bCharacterInputPosition = 7; + break; + + default: + //0x56500 + break; + } //switch (bCharacterInputPosition) + //->0x565f4 + break; + + case 2: + //0x56510 + switch (bCharacterInputPosition) + { + case 7: + //0x56550 + bCharacterInputPosition = 8; + break; + + case 8: + //0x56564 + bCharacterInputPosition = 9; + break; + + case 9: + //0x56578 + bCharacterInputPosition = 11; + break; + + case 11: + //0x5658c + bCharacterInputPosition = 12; + break; + + case 12: + //0x565a0 + bCharacterInputPosition = 14; + break; + + case 14: + //0x565b4 + bCharacterInputPosition = 15; + break; + + case 15: + //0x565c8 + bCharacterInputPosition = 7; + break; + + default: + //0x565dc + break; + } //switch (bCharacterInputPosition) + //-> + break; + + default: + //0x565ec + break; + } //switch (bData_40003260) + + break; + + default: + //0x565fc + break; + } //switch (bData_40003263) +} + +/* 5660c - todo */ +void func_5660c(void) +{ + switch (bData_40003262) + { + case 1: + //5661c + switch (bData_40003261) + { + case 0: + //0x56644 + if (bCharacterInputPosition < 13) + { + bCharacterInputPosition++; + } + else + { + //0x56670 + bCharacterInputPosition = 7; + } + //->0x56828 + break; + + case 1: + //0x56680 + switch (bCharacterInputPosition) + { + case 7: + //0x566c0 + bCharacterInputPosition = 8; + break; + + case 8: + //0x566d4 + bCharacterInputPosition = 9; + break; + + case 9: + //0x566e8 + bCharacterInputPosition = 11; + break; + + case 11: + //0x566fc + bCharacterInputPosition = 12; + break; + + case 12: + //0x56710 + bCharacterInputPosition = 14; + break; + + case 14: + //0x56724 + bCharacterInputPosition = 15; + break; + + case 15: + //0x56738 + bCharacterInputPosition = 7; + break; + + default: + //0x5674c + break; + } + break; + + case 2: + //0x5675c + switch (bCharacterInputPosition) + { + case 7: + //0x56798 + bCharacterInputPosition = 8; + break; + + case 8: + //0x567ac + bCharacterInputPosition = 10; + break; + + case 10: + //0x567c0 + bCharacterInputPosition = 11; + break; + + case 11: + //0x567d4 + bCharacterInputPosition = 13; + break; + + case 13: + //0x567e8 + bCharacterInputPosition = 14; + break; + + case 14: + //0x567fc + bCharacterInputPosition = 7; + break; + + default: + //0x56810 + break; + } + break; + + default: + //0x56820 + break; + } //switch (bData_40003261) + break; + + default: + //0x56830 + break; + } //switch (bData_40003262) +} + +/* 56840 - complete */ +void HandleNextCity(void) +{ + switch (wData_40003250) + { + case 3: + //0x568e4 + wData_40003252++; + if (wData_40003252 > 21) + { + wData_40003252 = 0; + } + break; + + case 26: + //0x56920 + case 35: + //0x56928 + case 77: + //0x5692c + wData_40003252++; + if (wData_40003252 > 2) + { + wData_40003252 = 0; + } + break; + + case 40: + //0x56964 + case 48: + //0x5696c + wData_40003252++; + if (wData_40003252 > 4) + { + wData_40003252 = 0; + } + break; + + case 60: + //0x569a4 + case 90: + //0x569ac + case 119: + //0x569b0 + case 150: + //0x569b4 + case 152: + //0x569b8 + case 156: + //0x569bc + wData_40003252++; + if (wData_40003252 > 1) + { + wData_40003252 = 0; + } + break; + + case 64: + //0x569f4 + case 134: + //0x569fc + wData_40003252++; + if (wData_40003252 > 8) + { + wData_40003252 = 0; + } + break; + + case 82: + //0x56a34 + wData_40003252++; + if (wData_40003252 > 6) + { + wData_40003252 = 0; + } + break; + + case 99: + //0x56a70 + wData_40003252++; + if (wData_40003252 > 5) + { + wData_40003252 = 0; + } + break; + + default: + //0x56aac + wData_40003252 = 0; + break; + } +} + +/* 56ac8 - todo */ +void HandleNextMfInputPosition(void) +{ + switch (bCharacterInputPosition) + { + case 7: + //0x56af4 + bCharacterInputPosition = 8; + break; + + case 8: + //0x56b08 + bCharacterInputPosition = 9; + break; + + case 9: + //0x56b1c + bCharacterInputPosition = 10; + break; + + case 10: + //0x56b30 + bCharacterInputPosition = 7; + break; + + default: + //0x56b44 + break; + } +} + +/* 56b54 - todo */ +void HandleNextEyepieceFovInputPosition(void) +{ + switch (bCharacterInputPosition) + { + case 7: + //0x56b84 + bCharacterInputPosition = 8; + break; + + case 8: + //0x56b98 + bCharacterInputPosition = 9; + break; + + case 9: + //0x56bac + bCharacterInputPosition = 11; + break; + + case 11: + //0x56bc0 + bCharacterInputPosition = 12; + break; + + case 12: + //0x56bd4 + bCharacterInputPosition = 7; + break; + + default: + //0x56be8 + break; + } +} + +/* 56bf8 - todo */ +void HandleNextSfInputPosition(void) +{ + switch (bCharacterInputPosition) + { + case 7: + //0x56c14 + bCharacterInputPosition = 8; + break; + + case 8: + //0x56c28 + bCharacterInputPosition = 7; + break; + + default: + //0x56be8 + break; + } +} + +/* 56c4c - todo */ +void func_56c4c(void) +{ + switch (bCharacterInputPosition) + { + case 1: + //0x56c84 + bCharacterInputPosition = 2; + break; + + case 2: + //0x56c98 + bCharacterInputPosition = 4; + break; + + case 4: + //0x56cac + bCharacterInputPosition = 5; + break; + + case 5: + //0x56cc0 + bCharacterInputPosition = 7; + break; + + case 7: + //0x56cd4 + bCharacterInputPosition = 8; + break; + + case 8: + //0x56ce8 + bCharacterInputPosition = 1; + break; + + default: + //0x56cfc + break; + } +} + +/* 56d0c - todo */ +void HandleNextTimerInputPosition(void) +{ + switch (bCharacterInputPosition) + { + case 1: + //0x56d38 + bCharacterInputPosition = 2; + break; + + case 2: + //0x56d4c + bCharacterInputPosition = 3; + break; + + case 3: + //0x56d60 + bCharacterInputPosition = 4; + break; + + case 4: + //0x56d74 + bCharacterInputPosition = 5; + break; + + case 5: + //0x56d88 + bCharacterInputPosition = 1; + break; + + default: + break; + } +} + +/* 56dac - todo */ +void func_56dac(void) +{ + switch (bData_4000316d) + { + case 0: + //0x56dc8 + if (bCharacterInputPosition < 7) + { + bCharacterInputPosition++; + } + else + { + bCharacterInputPosition = 5; + } + break; + + case 1: + //0x56e04 + if (bCharacterInputPosition < 7) + { + bCharacterInputPosition++; + } + else + { + bCharacterInputPosition = 6; + } + break; + + default: + //0x56e40 + break; + } +} + +/* 56e50 - complete */ +void HandleNextCustomSiteInputPosition(void) +{ + switch (bData_40002edc) + { + case 1: + //0x56e6c + case 3: + //0x56e74 + switch (bCurrentCustomSiteInputLine) + { + case 0: + //0x56e9c: Name + if (bCharacterInputPosition < 14) + { + bCharacterInputPosition++; + } + else + { + bCharacterInputPosition = 7; + } + break; + + case 1: + //0x56ed8: Longitude + switch (bCharacterInputPosition) + { + case 7: + //0x56f10 + bCharacterInputPosition = 8; + break; + + case 8: + //0x56f24 + bCharacterInputPosition = 9; + break; + + case 9: + //0x56f38 + bCharacterInputPosition = 10; + break; + + case 10: + //0x56f4c + bCharacterInputPosition = 12; + break; + + case 12: + //0x56f60 + bCharacterInputPosition = 13; + break; + + case 13: + //0x56f74 + bCharacterInputPosition = 7; + break; + + default: + //0x56f88 + break; + } + break; + + case 2: + //0x56f98: Latitude + switch (bCharacterInputPosition) + { + case 7: + //0x56fcc + bCharacterInputPosition = 8; + break; + + case 8: + //0x56fe0 + bCharacterInputPosition = 9; + break; + + case 9: + //0x56ff4 + bCharacterInputPosition = 11; + break; + + case 11: + //0x57008 + bCharacterInputPosition = 12; + break; + + case 12: + //0x5701c + bCharacterInputPosition = 7; + break; + + default: + //0x57030 + break; + } + break; + + case 3: + //0x57040: Time Zone + switch (bCharacterInputPosition) + { + case 7: + //0x57068 + bCharacterInputPosition = 8; + break; + + case 8: + //0x5707c + bCharacterInputPosition = 9; + break; + + case 9: + //0x57090 + bCharacterInputPosition = 7; + break; + + default: + //0x570a4 + break; + } + break; + + case 4: + //0x570b4 + switch (bCharacterInputPosition) + { + case 7: + //0x570e4 + bCharacterInputPosition = 8; + break; + + case 8: + //0x570f8 + bCharacterInputPosition = 9; + break; + + case 9: + //0x5710c + bCharacterInputPosition = 10; + break; + + case 10: + //0x57120 + bCharacterInputPosition = 7; + break; + + default: + //0x57134 + break; + } + break; + + default: + //0x57144 + break; + } + break; + + default: + //0x57154 + break; + } +} + +/* 5718c - complete */ +void HandleNextDateTimeInputPosition(void) +{ + switch (bDateTimeInputMode) + { + case 0: + //0x571a8 + switch (bCharacterInputPosition) + { + case 1: + //0x571ec + bCharacterInputPosition = 2; + break; + + case 2: + //0x57200 + bCharacterInputPosition = 3; + break; + + case 3: + //0x57214 + bCharacterInputPosition = 4; + break; + + case 4: + //0x57228 + bCharacterInputPosition = 6; + break; + + case 6: + //0x5723c + bCharacterInputPosition = 7; + break; + + case 7: + //0x57250 + bCharacterInputPosition = 9; + break; + + case 9: + //0x57264 + bCharacterInputPosition = 10; + break; + + case 10: + //0x57278 + bCharacterInputPosition = 1; + break; + + default: + //0x5728c + break; + } + break; + + case 1: + //0x5729c + switch (bCharacterInputPosition) + { + case 1: + //0x572d8 + bCharacterInputPosition = 2; + break; + + case 2: + //0x572ec + bCharacterInputPosition = 4; + break; + + case 4: + //0x57300 + bCharacterInputPosition = 5; + break; + + case 5: + //0x57314 + bCharacterInputPosition = 7; + break; + + case 7: + //0x57328 + bCharacterInputPosition = 8; + break; + + case 8: + //0x5733c + bCharacterInputPosition = 1; + break; + + default: + //0x57350 + break; + } + break; + + default: + //0x57360 + break; + } +} + +/* 57370 - todo */ +void func_57370(void) +{ + switch (bCharacterInputPosition) + { + case 1: + //0x573a0 + bCharacterInputPosition = 2; + break; + + case 2: + //0x573b4 + bCharacterInputPosition = 3; + break; + + case 3: + //0x573c8 + bCharacterInputPosition = 5; + break; + + case 5: + //0x573dc + bCharacterInputPosition = 6; + break; + + case 6: + //0x573f0 + bCharacterInputPosition = 1; + break; + + default: + //0x57404 + break; + } +} + +#include "slew1.c" + +/* 57a4c - complete */ +void func_57a4c(void) +{ + switch (bCharacterInputPosition) + { + case 5: + //0x57a90 + bCharacterInputPosition = 6; + break; + + case 6: + //0x57aa4 + bCharacterInputPosition = 7; + break; + + case 7: + //0x57ab8 + bCharacterInputPosition = 9; + break; + + case 9: + //0x57acc + bCharacterInputPosition = 10; + break; + + case 10: + //0x57ae0 + bCharacterInputPosition = 12; + break; + + case 12: + //0x57af4 + bCharacterInputPosition = 13; + break; + + case 13: + //0x57b08 + bCharacterInputPosition = 15; + break; + + case 15: + //0x57b1c + bCharacterInputPosition = 5; + break; + + default: + //0x57b30 + break; + } +} + +/* 57b40 - complete */ +void func_57b40(void) +{ + switch (bCharacterInputPosition) + { + case 6: + //0x57b80 + bCharacterInputPosition = 7; + break; + + case 7: + //0x57b94 + bCharacterInputPosition = 9; + break; + + case 9: + //0x57ba8 + bCharacterInputPosition = 10; + break; + + case 10: + //0x57bbc + bCharacterInputPosition = 12; + break; + + case 12: + //0x57bd0 + bCharacterInputPosition = 13; + break; + + case 13: + //0x57be4 + bCharacterInputPosition = 15; + break; + + case 15: + //0x57bf8 + bCharacterInputPosition = 6; + break; + + default: + //0x57c0c + break; + } +} + +/* 57c1c - todo */ +void HandleRightKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case 29001: + //0x57e3c + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x57e44 + func_57b40(); + break; + + case 29002: + //0x57e4c + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x57e54 + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x57e58 + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x57e5c + func_57a4c(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x57e64 + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x57e6c + bCharacterInputPosition++; + if (bCharacterInputPosition > 13) + { + bCharacterInputPosition = 6; + } + //->0x583d0 + break; + + case MENU_CONTEXT_MAIN: //0: + //0x57ea0 + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x57ea8 + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x57eac + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x57eb0 + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x57eb4 + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x57eb8 + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x57ebc + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x57ec0 + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x57ec4 + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x57ec8 + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x57ecc + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x57ed0 + if (g_bLandTarget == 0) + { + //57ee0 + if ((Data_40004128.bTrackingActive != 0) && (g_bSlewingStop != 1)) + { + //57f00 + g_iSlewStepRaAxis = 1; + bData_40003200 = 0; + } + else + { + //0x57f1c + if (bData_40002c1a == 1) + { + //57f2c + SlewAxis(1, 4, g_eSlewRateIndex); + } + else + { + //0x57f44 + SlewAxis(3, 4, g_eSlewRateIndex); + } + } + } + else + { + //0x57f5c + if (bData_40002c1a == 1) + { + //57f6c + SlewAxis(1, 4, g_eSlewRateIndex); + } + else + { + //0x57f84 + SlewAxis(3, 4, g_eSlewRateIndex); + } + } + //0x57f98 -> 0x583d0 + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x57f9c + if (bData_40002c62_AlignmentStarMode != 0) + { + //57fb0 + g_iSlewStepRaAxis = 1; + bData_40003200 = 0; + } + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT: //11101: + //0x57fcc + dRaBklashCorrStartAzimuth = dData_40002dc0_Azimuth; + if (bData_40002c1a == 1) + { + //57ff0 + SlewAxis(1, 4, SLEW_RATE_8X); //3); + + bData_40002edd = 2; + } + else + { + //0x58010 + SlewAxis(3, 4, SLEW_RATE_8X); //3); + + bData_40002edd = 0; + } + //0x5802c + iBacklashCorrectionSlewing = 1; + bRaBacklashCorrectionDirection = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT; //11103; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + //0x58050 + if (bRaBacklashCorrectionDirection == 2) + { + //58064: Slewing Right when started Left + if (bData_40002c1a == 1) + { + //58074 + SlewAxis(1, 4, g_eSlewRateIndex); + } + else + { + //0x58120 + SlewAxis(3, 4, g_eSlewRateIndex); + } + } + //0x58134 + //break; //BUG: Fall through? + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x58138 + func_57370(); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x58140 + HandleNextDateTimeInputPosition(); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x5814c + HandleNextCustomSiteInputPosition(); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x58158 + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x58160 + case 101: + //0x58164 + switch (bData_4000319a_SkyLandTargetId) + { + case 1: + //0x581a0 + bData_4000319a_SkyLandTargetId = 2; + break; + + case 2: + //0x581b4 + bData_4000319a_SkyLandTargetId = 3; + break; + + case 3: + //0x581c8 + bData_4000319a_SkyLandTargetId = 1; + break; + + case 4: + //0x581dc + bData_4000319a_SkyLandTargetId = 5; + break; + + case 5: + //0x581f0 + bData_4000319a_SkyLandTargetId = 6; + break; + + case 6: + //0x58204 + bData_4000319a_SkyLandTargetId = 4; + break; + + case 7: + //0x58218 + bData_4000319a_SkyLandTargetId = 8; + break; + + case 8: + //0x5822c + bData_4000319a_SkyLandTargetId = 9; + break; + + case 9: + //0x58240 + bData_4000319a_SkyLandTargetId = 7; + break; + + #if 0 + default: + //0x58254 + break; + #endif + } + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x5825c + func_56dac(); + break; + + case 33001: + //0x58268 + if (Data_40003168_LunarPhaseMonth < 12) + { + Data_40003168_LunarPhaseMonth++; + } + else + { + Data_40003168_LunarPhaseMonth = 0; + } + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x582a4 + HandleNextTimerInputPosition(); + break; + + case MENU_CONTEXT_ALARM_INPUT: //35001: + //0x582b0 + func_56c4c(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x582bc + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x582c4 + HandleNextSfInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x582cc + HandleNextEyepieceFovInputPosition(); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x582d8 + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x582e0 + HandleNextMfInputPosition(); + break; + + case MENU_CONTEXT_COUNTRY_CITY_SELECTION: //43011: + //0x582e8 + lcd_display_clear(); + HandleNextCity(); + break; + + case 211001: + //0x582f8 + switch (bData_40003262) + { + case 1: + //5830c + func_5660c(); + break; + + default: + break; + } + break; + + case 28001: + //0x58328 + switch (bData_40003263) + { + case 1: + //0x58348 + case 3: + //0x58350 + func_563c8(); + break; + + default: + //0x59d4c + break; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_ON: //42001: + //0x58368 + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_OFF; //42002; + bDaylightSavingTime = 0; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_OFF: //42002: + //0x58398 + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_ON; //42001; + bDaylightSavingTime = 1; + } + break; + + default: + //0x583c8 + break; + } +} + diff --git a/applications/freertos_app/HandleUpKey.c b/applications/freertos_app/HandleUpKey.c new file mode 100644 index 0000000..e91a50f --- /dev/null +++ b/applications/freertos_app/HandleUpKey.c @@ -0,0 +1,1452 @@ + +//#include "menu.h" + +/* 5ca98 - complete */ +void func_5ca98(void) +{ + wData_40003252 = 0; + + switch (wData_40003250) + { + case 1: + //0x5cd64 + wData_40003250 = 170; + break; + + case 2: + //0x5cd78 + case 3: + //0x5cd80 + wData_40003250--; + break; + + case 25: + //0x5cd98 + wData_40003250 = 3; + break; + + case 26: + //0x5cdac + wData_40003250 = 25; + break; + + case 29: + //0x5cdc0 + wData_40003250 = 26; + break; + + case 30: + //0x5cdd4 + case 31: + //0x5cddc + case 32: + //0x5cde0 + case 33: + //0x5cde4 + case 34: + //0x5cde8 + case 35: + //0x5cdec + wData_40003250--; + break; + + case 38: + //0x5ce04 + wData_40003250 = 35; + break; + + case 39: + //0x5ce18 + case 40: + //0x5ce20 + wData_40003250--; + break; + + case 45: + //0x5ce38 + wData_40003250 = 40; + break; + + case 46: + //0x5ce4c + case 47: + //0x5ce54 + case 48: + //0x5ce58 + wData_40003250--; + break; + + case 53: + //0x5ce70 + wData_40003250 = 48; + break; + + case 54: + //0x5ce84 + case 55: + //0x5ce8c + case 56: + //0x5ce90 + case 57: + //0x5ce94 + case 58: + //0x5ce98 + case 59: + //0x5ce9c + case 60: + //0x5cea0 + wData_40003250--; + break; + + case 62: + //0x5ceb8 + wData_40003250 = 60; + break; + + case 63: + //0x5cecc + case 64: + //0x5ced4 + wData_40003250--; + break; + + case 73: + //0x5ceec + wData_40003250 = 64; + break; + + case 74: + //0x5cf00 + case 75: + //0x5cf08 + case 76: + //0x5cf0c + case 77: + //0x5cf10 + wData_40003250--; + break; + + case 80: + //0x5cf28 + wData_40003250 = 77; + break; + + case 81: + //0x5cf3c + case 82: + //0x5cf44 + wData_40003250--; + break; + + case 89: + //0x5cf5c + wData_40003250 = 82; + break; + + case 90: + //0x5cf70 + wData_40003250 = 89; + break; + + case 92: + //0x5cf84 + wData_40003250 = 90; + break; + + case 93: + //0x5cf98 + case 94: + //0x5cfa0 + case 95: + //0x5cfa4 + case 96: + //0x5cfa8 + case 97: + //0x5cfac + wData_40003250--; + break; + + case 99: + //0x5cfc4 + wData_40003250 = 98; + break; + + case 98: + //0x5cfd8 + wData_40003250 = 97; + break; + + case 105: + //0x5cfec + wData_40003250 = 99; + break; + + case 106: + //0x5d000 + case 107: + case 108: + case 109: + case 110: + case 111: + case 112: + case 113: + case 114: + case 115: + case 116: + case 117: + case 118: + case 119: + //0x5d038 + wData_40003250--; + break; + + case 121: + //0x5d050 + wData_40003250 = 119; + break; + + case 122: + //0x5d064 + case 123: + //0x5d06c + case 124: + case 125: + case 126: + case 127: + case 128: + case 129: + case 130: + case 131: + case 132: + case 133: + case 134: + //0x5d098 + wData_40003250--; + break; + + case 143: + //0x5d0b0 + wData_40003250 = 134; + break; + + case 144: + //0x5d0c4 + case 145: + //0x5d0cc + case 146: + case 147: + case 148: + case 149: + case 150: + //0x5d0e0 + wData_40003250--; + break; + + case 152: + //0x5d0f8 + wData_40003250 = 150; + break; + + case 154: + //0x5d10c + wData_40003250 = 152; + break; + + case 155: + //0x5d120 + wData_40003250 = 154; + break; + + case 156: + //0x5d134 + wData_40003250 = 155; + break; + + case 158: + //0x5d148 + wData_40003250 = 156; + break; + + case 159: + //0x5d15c + case 160: + //0x5d164 + case 161: + //0x5d168 + case 162: + case 163: + case 164: + case 165: + case 166: + case 167: + case 168: + case 169: + case 170: + //0x5d18c + wData_40003250--; + break; + } +} + +/* 5d1ac - todo */ +void HandleUpKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_RECENT_TARGETS: //1: + //0x5d8d4 + if (bData_4000316e_FocusLineOn8LineDisplay == 1) + { + //5d8e8 + bData_4000316e_FocusLineOn8LineDisplay = bData_40002f14_RecentTargetCount; + } + else + { + //0x5d8fc + bData_4000316e_FocusLineOn8LineDisplay--; + } + break; + + case 500: + //0x5d914: Main Screen Help Pages + lcd_display_clear(); + + if (bData_40002c59_MainScreenHelpPage == 1) + { + bData_40002c59_MainScreenHelpPage = 10; + } + else + { + bData_40002c59_MainScreenHelpPage--; + } + //->0x5f0b4 + break; + + case MENU_CONTEXT_ALIGNMENT: //1000: + //0x5d954 + Data_40002c64_MenuContextId = MENU_CONTEXT_SETUP; + break; + + case MENU_CONTEXT_NAVIGATION: //2000: + //0x5d968 + Data_40002c64_MenuContextId = MENU_CONTEXT_ALIGNMENT; + break; + + case MENU_CONTEXT_UTILITIES: //3000: + //0x5d97c + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION; + break; + + case MENU_CONTEXT_SETUP: //4000: + //0x5d990 + Data_40002c64_MenuContextId = MENU_CONTEXT_UTILITIES; + break; + + case MENU_CONTEXT_ONE_STAR_ALIGN: //1100: + //0x5d9a4 + bData_40003173 = 4; + bData_40003171 = 4; + bData_40003172 = 7; + bData_40003170 = 8; + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKLASH_CORR; + break; + + case MENU_CONTEXT_TWO_STAR_ALIGN: //1200: + //0x5d9e4 + HandleLongListScroll(0, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_ONE_STAR_ALIGN; //1100; + //->0x5f0b4 + break; + + case MENU_CONTEXT_THREE_STAR_ALIGN: //1300: + //0x5da04 + HandleLongListScroll(0, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_TWO_STAR_ALIGN; //1200; + break; + + case MENU_CONTEXT_TARGET_SYNC: //1400: + //0x5da24 + HandleLongListScroll(0, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_THREE_STAR_ALIGN; //1300; + break; + + case MENU_CONTEXT_POLE_AXIS_DEV: //1500: + //0x5da44 + HandleLongListScroll(0, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_TARGET_SYNC; //1400; + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR: //1600: + //0x5da64 + HandleLongListScroll(0, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_POLE_AXIS_DEV; //1500; + break; + + case MENU_CONTEXT_DEC_BKLASH_CORR: //1700: + //0x5da84 + HandleLongListScroll(0, 11); + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR; //1600; + break; + + case MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM: //2100: + //0x5daa4 + bData_40003177 = 4; + bData_40003175 = 9; + bData_40003176 = 8; + bData_40003174 = 5; + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_LAND; //2130 + break; + + case MENU_CONTEXT_NAVIGATION_CONSTELLATION: //2200: + //0x5dae8 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM; //2100; + break; + + case MENU_CONTEXT_NAVIGATION_FAMOUS_STAR: //2300: + //0x5db08 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CONSTELLATION; //2200; + break; + + case MENU_CONTEXT_NAVIGATION_MESSIER_CAT: //2400: + //0x5db28 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_FAMOUS_STAR; //2300; + break; + + case MENU_CONTEXT_NAVIGATION_NGC_CAT: //2500: + //0x5db48 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_MESSIER_CAT; //2400; + break; + + case MENU_CONTEXT_NAVIGATION_IC_CAT: //2600: + //0x5db68 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_NGC_CAT; //2500; + break; + + case MENU_CONTEXT_NAVIGATION_SH2_CAT: //2700: + //0x5db88 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_IC_CAT; //2600; + break; + + case MENU_CONTEXT_NAVIGATION_BRIGHT_STAR: //2800: + //0x5dba8 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SH2_CAT; //2700; + break; + + case MENU_CONTEXT_NAVIGATION_SAO_CAT: //2900: + //0x5dbc8 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_BRIGHT_STAR; //2800; + break; + + case MENU_CONTEXT_NAVIGATION_CUST_OBJ: //2110: + //0x5dbe8 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_SAO_CAT; //2900; + break; + + case MENU_CONTEXT_NAVIGATION_RA_DEC: //2120: + //0x5dc08 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_CUST_OBJ; //2110; + break; + + case MENU_CONTEXT_NAVIGATION_CUST_LAND: //2130: + //0x5dc28 + HandleLongListScroll(0, 12); + Data_40002c64_MenuContextId = MENU_CONTEXT_NAVIGATION_RA_DEC; //2120; + break; + + case MENU_CONTEXT_CURRENT_OBJECTS: //3100: + //0x5dc48 + bData_4000317b = 4; + bData_40003179 = 6; + bData_4000317a = 8; + bData_40003178 = 2; + Data_40002c64_MenuContextId = MENU_CONTEXT_PARK_POSITION; //3900; + break; + + case MENU_CONTEXT_OBJECT_RISE_SET: //3200: + //0x5dc8c + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_CURRENT_OBJECTS; //3100; + break; + + case MENU_CONTEXT_LUNAR_PHASE: //3300: + //0x5dcac + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_OBJECT_RISE_SET; //3200; + break; + + case MENU_CONTEXT_TIMER: //3400: + //0x5dccc + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_LUNAR_PHASE; //3300; + break; + + case MENU_CONTEXT_ALARM: //3500: + //0x5dcec + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_TIMER; //3400; + break; + + case MENU_CONTEXT_EYEPIECE_FOV: //3600: + //0x5dd0c + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_ALARM; //3500; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN: //3700: + //0x5dd2c + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION: //3800: + //0x5dd4c + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN; + break; + + case MENU_CONTEXT_PARK_POSITION: //3900: + //0x5dd6c + HandleLongListScroll(0, 13); + Data_40002c64_MenuContextId = MENU_CONTEXT_DISPLAY_ILLUMINATION; + break; + + case MENU_CONTEXT_TIME_DATE: //4100: + //0x5dd8c + bData_4000317f = 4; + bData_4000317d = 6; + bData_4000317e = 8; + bData_4000317c = 2; + Data_40002c64_MenuContextId = MENU_CONTEXT_RESET; + break; + + case 4200: + //0x5ddd0 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE; + break; + + case MENU_CONTEXT_SITE_SETTING: //4300: + //0x5ddf0 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = 4200; + break; + + case 4400: + //0x5de10 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_SITE_SETTING; + break; + + case MENU_CONTEXT_AZ_EQU: //4500: + //0x5de30 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = 4400; + break; + + case MENU_CONTEXT_TELESCOPE_MOUNT: //4600: + //0x5de50 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_AZ_EQU; + break; + + case MENU_CONTEXT_TRACKING_RATE: //4700: + //0x5de70 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_TELESCOPE_MOUNT; + break; + + case MENU_CONTEXT_LANGUAGE: //4800: + //0x5de90 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE; + break; + + case MENU_CONTEXT_RESET: //4900: + //0x5deb0 + HandleLongListScroll(0, 14); + Data_40002c64_MenuContextId = MENU_CONTEXT_LANGUAGE; //4800; + break; + + case MENU_CONTEXT_SYNC_ENSURE: //1402: + //0x5ded0 + Data_40002c64_MenuContextId = MENU_CONTEXT_SYNC_CANCEL; //1403; + break; + + case MENU_CONTEXT_SYNC_CANCEL: //1403: + //0x5dee4 + Data_40002c64_MenuContextId = MENU_CONTEXT_SYNC_ENSURE; //1402; + break; + + case 2301: + //0x5def8 + bData_40003182 = 8; + bData_40003180 = 1; + Data_40002c64_MenuContextId = 2308; + break; + + case 2302: + //0x5df24 + HandleLongListScroll(0, 23); + Data_40002c64_MenuContextId = 2301; + break; + + case 2303: + //0x5df44 + HandleLongListScroll(0, 23); + Data_40002c64_MenuContextId = 2302; + break; + + case 2304: + //0x5df64 + HandleLongListScroll(0, 23); + Data_40002c64_MenuContextId = 2303; + break; + + case 2305: + //0x5df84 + HandleLongListScroll(0, 23); + Data_40002c64_MenuContextId = 2304; + break; + + case 2306: + //0x5dfa4 + HandleLongListScroll(0, 23); + Data_40002c64_MenuContextId = 2305; + break; + + case 2307: + //0x5e0c4 + HandleLongListScroll(0, 23); + Data_40002c64_MenuContextId = 2306; + break; + + case 2308: + //0x5e0e4 + HandleLongListScroll(0, 23); + Data_40002c64_MenuContextId = 2307; + break; + + case 2501: + //0x5e104 + Data_40002c64_MenuContextId = 2503; + break; + + case 2502: + //0x5e118 + Data_40002c64_MenuContextId = 2501; + break; + + case 2503: + //0x5e12c + Data_40002c64_MenuContextId = 2502; + break; + + case 2801: + //0x5e140 + Data_40002c64_MenuContextId = 2804; + break; + + case 2802: + //0x5e154 + Data_40002c64_MenuContextId = 2801; + break; + + case 2803: + //0x5e168 + Data_40002c64_MenuContextId = 2802; + break; + + case 2804: + //0x5e17c + Data_40002c64_MenuContextId = 2803; + break; + + case 21101: + //0x5e190 + Data_40002c64_MenuContextId = 21103; + break; + + case 21102: + //0x5e1a4 + Data_40002c64_MenuContextId = 21101; + break; + + case 21103: + //0x5e1b8 + Data_40002c64_MenuContextId = 21102; + break; + + case 3601: + //0x5e1cc + Data_40002c64_MenuContextId = 3602; + break; + + case 3602: + //0x5e1e0 + Data_40002c64_MenuContextId = 3601; + break; + + case 3801: + //0x5e1f4 + Data_40002c64_MenuContextId = 3802; + break; + + case 3802: + //0x5e208 + Data_40002c64_MenuContextId = 3801; + break; + + case MENU_CONTEXT_COUNTRY_CITY: //4301: + //0x5e21c + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOM_SITE; //4302; + break; + + case MENU_CONTEXT_CUSTOM_SITE: //4302: + //0x5e230 + Data_40002c64_MenuContextId = MENU_CONTEXT_COUNTRY_CITY; //4301; + break; + + case MENU_CONTEXT_TRACKING_RATE_STAR_SPEED: //4801: + //0x5e244 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED; //4805; + break; + + case MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED: //4802: + //0x5e258 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_STAR_SPEED; //4801; + break; + + case MENU_CONTEXT_TRACKING_RATE_MOON_SPEED: //4803: + //0x5e26c + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED; //4802; + break; + + case MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED: //4804: + //0x5e280 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_MOON_SPEED; //4803; + break; + + case MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED: //4805: + //0x5e294 + Data_40002c64_MenuContextId = MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED; //4804; + break; + + case MENU_CONTEXT_GUIDING_SPEED1: //48051: + //0x5e2a8 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED8; //48058; + break; + + case MENU_CONTEXT_GUIDING_SPEED2: //48052: + //0x5e2bc + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED1; //48051; + break; + + case MENU_CONTEXT_GUIDING_SPEED3: //48053: + //0x5e2d0 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED2; //48052; + break; + + case MENU_CONTEXT_GUIDING_SPEED4: //48054: + //0x5e2e4 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED3; //48053; + break; + + case MENU_CONTEXT_GUIDING_SPEED5: //48055: + //0x5e2f8 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED4; //48054; + break; + + case MENU_CONTEXT_GUIDING_SPEED6: //48056: + //0x5e30c + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED5; //48055; + break; + + case MENU_CONTEXT_GUIDING_SPEED7: //48057: + //0x5e320 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED6; //48056; + break; + + case MENU_CONTEXT_GUIDING_SPEED8: //48058: + //0x5e334 + Data_40002c64_MenuContextId = MENU_CONTEXT_GUIDING_SPEED7; //48057; + break; + + case MENU_CONTEXT_MAIN: //0: + //0x5e348 + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x5e350 + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x5e354 + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x5e358 + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x5e35c + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x5e360 + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x5e364 + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x5e368 + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x5e36c + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x5e370 + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x5e374 + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x5e378 + if (g_bLandTarget == 0) + { + //5e388 + if ((Data_40004128.bTrackingActive != 0) && (g_bSlewingStop != 1)) + { + //5e3a8 + g_iSlewStepDecAxis = 1; + bData_40003201 = 0; + } + else + { + //0x5e3c4 + if (bData_40002c1a == 1) + { + //5e3d4 + SlewAxis(2, 1, g_eSlewRateIndex); + } + else + { + //0x5e3ec + SlewAxis(4, 1, g_eSlewRateIndex); + } + } + } + else + { + //0x5e404 + if (bData_40002c1a == 1) + { + //5e414 + SlewAxis(2, 1, g_eSlewRateIndex); + } + else + { + //0x5e42c + SlewAxis(4, 1, g_eSlewRateIndex); + } + } + //0x5e440 -> 0x5f0b4 + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN: //11201: + //0x5e444 + dData_40002e00 = dData_40002df8; + + if (bData_40002c1a == 1) + { + //5e468 + SlewAxis(2, 1, SLEW_RATE_8X); + + bData_40002edd = 3; + } + else + { + //0x5e488 + SlewAxis(4, 1, SLEW_RATE_8X); + + bData_40002edd = 1; + } + //0x5e4a4 + iBacklashCorrectionSlewing = 1; + bDecBacklashCorrectionDirection = 2; + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN; //11203; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + //0x5e4cc + if (bDecBacklashCorrectionDirection == 1) + { + //5e4e0 + if (bData_40002c1a == 1) + { + //5e414 + SlewAxis(2, 1, SLEW_RATE_8X); + } + else + { + //0x5e504 + SlewAxis(4, 1, SLEW_RATE_8X); + } + } + //0x5e514 + break; + + case MENU_CONTEXT_SKY_TARGET: //45001: + //0x5e518 + Data_40002c64_MenuContextId = MENU_CONTEXT_LAND_TARGET; //45002; + break; + + case MENU_CONTEXT_LAND_TARGET: //45002: + //0x5e52c + Data_40002c64_MenuContextId = MENU_CONTEXT_SKY_TARGET; //45001; + break; + + case 46001: + //0x5e540 + Data_40002c64_MenuContextId = 46002; + break; + + case 46002: + //0x5e554 + Data_40002c64_MenuContextId = 46001; + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + //0x5e568 + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_INPUT; //29002; + bCharacterInputPosition = 5; + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + //0x5e588 + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_INPUT; //29001; + bCharacterInputPosition = 6; + break; + + case MENU_CONTEXT_ENGLISH: //49001: + //0x5e5a8 + Data_40002c64_MenuContextId = MENU_CONTEXT_SPANISH; //49005; + break; + + case MENU_CONTEXT_SPANISH: //49005: + //0x5e5bc + Data_40002c64_MenuContextId = MENU_CONTEXT_ITALIAN; //49004; + break; + + case MENU_CONTEXT_ITALIAN: //49004: + //0x5e5d0 + Data_40002c64_MenuContextId = MENU_CONTEXT_FRENCH; //49003; + break; + + case MENU_CONTEXT_FRENCH: //49003: + //0x5e5e4 + Data_40002c64_MenuContextId = MENU_CONTEXT_GERMAN; //49002; + break; + + case MENU_CONTEXT_GERMAN: //49002: + //0x5e5f8 + Data_40002c64_MenuContextId = MENU_CONTEXT_ENGLISH; //49001; + break; + + case 21001: + //0x5e60c + if (bData_40002eb4 == 0) + { + bData_40002eb4 = bData_40003161 - 1; + } + else + { + bData_40002eb4--; + } + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION: //22001: + //0x5e650 + lcd_display_clear(); + //break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJ_RISE_SET_TIMES: //31001: + //0x5e65c + if (bData_40002eb5_SolarSystemObjectNr == 0) + { + bData_40002eb5_SolarSystemObjectNr = 9; + } + else + { + bData_40002eb5_SolarSystemObjectNr--; + } + break; + + case MENU_CONTEXT_CONSTELLATION_SELECTION: //24001: + //0x5e694 + lcd_display_clear(); + + bData_40002ece_ConstellationNr--; + if (bData_40002ece_ConstellationNr == 0) + { + bData_40002ece_ConstellationNr = 88; + } + break; + + case MENU_CONTEXT_FAMOUS_STAR_SELECTION: //25001: + //0x5e6d0 + lcd_display_clear(); + + bData_40002ed2_FamousStarNr--; + if (bData_40002ed2_FamousStarNr == 0) + { + bData_40002ed2_FamousStarNr = 33; + } + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x5e70c + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x5e714 + lcd_display_clear(); + + wData_40002eb8_MessierNr--; + if (wData_40002eb8_MessierNr == 0) + { + wData_40002eb8_MessierNr = 110; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x5e74c + lcd_display_clear(); + + wData_40002eba_NGCNr--; + if (wData_40002eba_NGCNr == 0) + { + wData_40002eba_NGCNr = 7840; + } + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x5e788 + lcd_display_clear(); + + wData_40002ebc_ICNr--; + if (wData_40002ebc_ICNr == 0) + { + wData_40002ebc_ICNr = 5386; + } + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x5e8c8 + lcd_display_clear(); + + wData_40002ebe_ShNr--; + if (wData_40002ebe_ShNr == 0) + { + wData_40002ebe_ShNr = 313; + } + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x5e904 + lcd_display_clear(); + + wData_40002ec0_BrightStarNr--; + if (wData_40002ec0_BrightStarNr == 0) + { + wData_40002ec0_BrightStarNr = 167; + } + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x5e940 + lcd_display_clear(); + + Data_40002ec4_SAONr--; + if (Data_40002ec4_SAONr == 0) + { + Data_40002ec4_SAONr = 258997; + } + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x5e97c + bCharacterInputPosition = 5; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT; //205; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x5e99c + bCharacterInputPosition = 6; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT; //204; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x5e9bc + bCharacterInputPosition = 6; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT; //203; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x5e9dc + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x5e9e4 + case 101: + //0x5e9e8 + switch (bData_4000319a_SkyLandTargetId) + { + case 1: + //0x5ea24 + bData_4000319a_SkyLandTargetId = 7; + break; + + case 7: + //0x5ea38 + bData_4000319a_SkyLandTargetId = 4; + break; + + case 4: + //0x5ea4c + bData_4000319a_SkyLandTargetId = 1; + break; + + case 2: + //0x5ea60 + bData_4000319a_SkyLandTargetId = 8; + break; + + case 8: + //0x5ea74 + bData_4000319a_SkyLandTargetId = 5; + break; + + case 5: + //0x5ea88 + bData_4000319a_SkyLandTargetId = 2; + break; + + case 3: + //0x5ea9c + bData_4000319a_SkyLandTargetId = 9; + break; + + case 9: + //0x5eab0 + bData_4000319a_SkyLandTargetId = 6; + break; + + case 6: + //0x5eac4 + bData_4000319a_SkyLandTargetId = 3; + break; + + #if 0 + default: + //0x5ead8 + break; + #endif + } + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x5eae0 + bCharacterInputPosition = 5; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT; //208; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x5eb00 + bCharacterInputPosition = 5; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT; //207; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x5eb20 + bCharacterInputPosition = 6; + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT; //206; + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x5eb40 + if (bDateTimeInputMode == 0) + { + //5eb54 + bDateTimeInputMode = 1; + } + else + { + //0x5eb64 + bDateTimeInputMode = 0; + } + //0x5eb70 + bCharacterInputPosition = 1; + break; + + case 43021: + //0x5eb80 + Data_40002c64_MenuContextId = 43024; + break; + + case 43022: + //0x5eb94 + Data_40002c64_MenuContextId = 43021; + break; + + case 43023: + //0x5eba8 + Data_40002c64_MenuContextId = 43022; + break; + + case 43024: + //0x5ebbc + Data_40002c64_MenuContextId = 43023; + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x5ebd0 + if (bCurrentCustomSiteInputLine == 0) + { + bCurrentCustomSiteInputLine = 3; + bCharacterInputPosition = 7; + } + else + { + //0x5ec00 + bCurrentCustomSiteInputLine--; + bCharacterInputPosition = 7; + } + //0x5ec20 + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x5ec24 + Data_40002c64_MenuContextId = MENU_CONTEXT_OTA_ZERO_SETUP; //47011; + if (bData_4000316d > 0) + { + //5ec44 + bData_4000316d--; + } + else + { + //0x5ec5c + bData_4000316d = 1; + } + //0x5ec68 + if (bData_4000316d == 0) + { + bCharacterInputPosition = 5; + } + else + { + //0x5ec88 + bCharacterInputPosition = 6; + } + //0x5ec94 + break; + + case 33001: + //0x5ec98 + Data_40003164_LunarPhaseYear--; + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x5ecb4 + if (bData_40002c62_AlignmentStarMode != 0) + { + g_iSlewStepDecAxis = 1; + bData_40003201 = 0; + } + else + { + if (bData_40002c60_CurrentAlignStarIndex == 1) + { + bData_40002c60_CurrentAlignStarIndex = numVisibleAlignmentStars; + } + else + { + bData_40002c60_CurrentAlignStarIndex--; + } + } + //->0x5f0b4 + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x5ed20 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT; //360022; + bCharacterInputPosition = 7; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x5ed40 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT; //360021; + bCharacterInputPosition = 7; + break; + + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x5ed60 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_INPUT; //370023; + bCharacterInputPosition = 7; + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x5ed80 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT; //370022; + bCharacterInputPosition = 7; + break; + + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x5eda0 + Data_40002c64_MenuContextId = MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT; //370021; + bCharacterInputPosition = 7; + break; + + case 360111: + //0x5edc0 + Data_40002c64_MenuContextId = 360113; + break; + + case 360112: + //0x5edd4 + Data_40002c64_MenuContextId = 360111; + break; + + case 360113: + //0x5ede8 + Data_40002c64_MenuContextId = 360112; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL: //380011: + //0x5edfc: Background light + if (Data_40003248_CurrentDisplayPWM == 0) + { + //5ee10 + setDisplayPWM(63); + Data_40003248_CurrentDisplayPWM = 63; + } + else if (Data_40003248_CurrentDisplayPWM == 63) + { + //5ee38 + setDisplayPWM(127); + Data_40003248_CurrentDisplayPWM = 127; + } + else if (Data_40003248_CurrentDisplayPWM == 127) + { + //5ee38 + setDisplayPWM(191); + Data_40003248_CurrentDisplayPWM = 191; + } + else + { + //0x5ee78 + setDisplayPWM(255); + Data_40003248_CurrentDisplayPWM = 255; + } + //->0x5f0b4 + break; + + case MENU_CONTEXT_COUNTRY_CITY_SELECTION: //43011: + //0x5ee90 + lcd_display_clear(); + func_5ca98(); //->Previous country + break; + + case 211001: + //0x5eea0 + switch (bData_40003262) + { + case 0: + //0x5eec8 + case 2: + //0x5eed0 + if (bData_4000325c == 0) + { + bData_4000325c = bData_40003258 - 1; + } + else + { + //0x5eef8 + bData_4000325c--; + } + break; + + case 1: + //0x5ef10 + if (bData_40003261 == 0) + { + bData_40003261 = 2; + bCharacterInputPosition = 7; + } + else + { + //0x5ef40 + bData_40003261--; + bCharacterInputPosition = 7; + } + //break; + + default: + //0x5ef64 + break; + } + break; + + case 28001: + //0x5ef70 + switch (bData_40003263) + { + case 0: + //0x5efa0 + case 2: + //0x5efa8 + if (wData_4000325a == 0) + { + wData_4000325a = wData_40003256 - 1; + } + else + { + wData_4000325a--; + } + break; + + case 1: + //0x5efe8 + case 3: + //0x5eff0 + if (bData_40003260 == 0) + { + bData_40003260 = 2; + bCharacterInputPosition = 7; + } + else + { + bData_40003260--; + bCharacterInputPosition = 7; + } + //break; + + default: + //0x5f040 + break; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_ON: //42001: + //0x5f04c + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_OFF; //42002; + bDaylightSavingTime = 0; + } + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_OFF: //42002: + //0x5f07c + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40002c64_MenuContextId = MENU_CONTEXT_DAYLIGHT_SAVING_ON; //42001; + bDaylightSavingTime = 1; + } + break; + + default: + //0x5f0ac + break; + } +} + diff --git a/applications/freertos_app/HelpScreen.c b/applications/freertos_app/HelpScreen.c new file mode 100644 index 0000000..c33ff01 --- /dev/null +++ b/applications/freertos_app/HelpScreen.c @@ -0,0 +1,489 @@ + +/* 1e228 - todo */ +void DisplayHelpScreen(void) +{ + if (Data_4000318c != Data_40003190) + { + Data_40003190 = Data_4000318c; + } + + switch (Data_40002c64_MenuContextId - 500) + { + case 0: + //0x1e328: 500 = Main Screen Help Pages + switch (bData_40002c59_MainScreenHelpPage) + { + case 1: + //0x1e36c + lcd_display_string(0, 1, 1, 21, "*Key: "); + lcd_display_string(0, 3, 1, 21, "Press the key to cha- "); + lcd_display_string(0, 5, 1, 21, "-nge LED illuminance. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x1eb90 + break; + + case 2: + //0x1e3e4 + lcd_display_string(0, 1, 1, 21, "Green Key: "); + lcd_display_string(0, 3, 1, 21, "Press the key to show "); + lcd_display_string(0, 5, 1, 21, "and select hitoric "); + lcd_display_string(0, 7, 1, 21, "target quickly. "); + //->0x1eb90 + break; + + case 3: + //0x1e580 + lcd_display_string(0, 1, 1, 21, "Red Key: "); + lcd_display_string(0, 3, 1, 21, "Show function menu "); + lcd_display_string(0, 5, 1, 21, "or Enter. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x1eb90 + break; + + case 4: + //0x1e5f8 + lcd_display_string(0, 1, 1, 21, "Yellow Key: "); + lcd_display_string(0, 3, 1, 21, "Press the key to stop "); + lcd_display_string(0, 5, 1, 21, "or abandon or quit. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x1eb90 + break; + + case 5: + //0x1e670 + lcd_display_string(0, 1, 1, 21, "Arrow Keys: "); + lcd_display_string(0, 3, 1, 21, "Slew the telescope "); + lcd_display_string(0, 5, 1, 21, "or Scroll in menu. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x1eb90 + break; + + case 6: + //0x1e6e8 + lcd_display_string(0, 1, 1, 21, "Number Keys: "); + lcd_display_string(0, 3, 1, 21, "Press to input digits "); + lcd_display_string(0, 5, 1, 21, "0 to 9, input letter "); + lcd_display_string(0, 7, 1, 21, "or Change slew speed. "); + //->0x1eb90 + break; + + case 7: + //0x1e89c + lcd_display_string(0, 1, 1, 21, "Stop Key: "); + lcd_display_string(0, 3, 1, 21, "Press to pause when "); + lcd_display_string(0, 5, 1, 21, "telescope in tracking, "); + lcd_display_string(0, 7, 1, 21, "moving or slewing. "); + //->0x1eb90 + break; + + case 8: + //0x1e914 + lcd_display_string(0, 1, 1, 21, "Help Key: "); + lcd_display_string(0, 3, 1, 21, "Show help file "); + lcd_display_string(0, 5, 1, 21, "can be used in all "); + lcd_display_string(0, 7, 1, 21, "levels menu. "); + //->0x1eb90 + break; + + case 9: + //0x1e98c + lcd_display_string(0, 1, 1, 21, "F+(1 to 9): "); + lcd_display_string(0, 3, 1, 21, "Show historic target "); + lcd_display_string(0, 5, 1, 21, " "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x1eb90 + break; + + case 10: + //0x1eb18 + lcd_display_string(0, 1, 1, 21, "F+0 "); + lcd_display_string(0, 3, 1, 21, "Open or close key "); + lcd_display_string(0, 5, 1, 21, "beep "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x1eb90 + break; + #if 0 + default: + //0x1eb90 + break; + #endif + } + //->0x20a50 + break; + + case 1: + //0x1eb98: 501 = Telescope Align + lcd_display_string(0, 1, 1, 21, "Telescope align: "); + lcd_display_string(0, 3, 1, 21, "Align Telescop point "); + lcd_display_string(0, 5, 1, 21, "Pole-axis aim and "); + lcd_display_string(0, 7, 1, 21, "correct Backlash. "); + //->0x20a50 + break; + + case 2: + //0x1ec10 + lcd_display_string(0, 1, 1, 21, "Target navigation: "); + lcd_display_string(0, 3, 1, 21, "Select Target from "); + lcd_display_string(0, 5, 1, 21, "database or input "); + lcd_display_string(0, 7, 1, 21, "data. "); + //->0x20a50 + break; + + case 3: + //0x1ed94 + lcd_display_string(0, 1, 1, 21, "Utilities Commands: "); + lcd_display_string(0, 3, 1, 21, "Some tools in common "); + lcd_display_string(0, 5, 1, 21, "use. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 4: + //0x1ee0c + lcd_display_string(0, 1, 1, 21, "Parameter Setup: "); + lcd_display_string(0, 3, 1, 21, "Setup some parameter "); + lcd_display_string(0, 5, 1, 21, "in system. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 5: + //0x1ee84 + lcd_display_string(0, 1, 1, 21, "One star align: "); + lcd_display_string(0, 3, 1, 21, "Select one star align"); + lcd_display_string(0, 5, 1, 21, "the telescope point "); + lcd_display_string(0, 7, 1, 21, "by hand. "); + //->0x20a50 + break; + + case 6: + //0x1f004 + lcd_display_string(0, 1, 1, 21, "Two stars align: "); + lcd_display_string(0, 3, 1, 21, "Select two star align"); + lcd_display_string(0, 5, 1, 21, "the telescope point "); + lcd_display_string(0, 7, 1, 21, "by hand. "); + //->0x20a50 + break; + + case 7: + //0x1f07c + lcd_display_string(0, 1, 1, 21, "Three star align: "); + lcd_display_string(0, 3, 1, 21, "Select three stars "); + lcd_display_string(0, 5, 1, 21, "align the telescope "); + lcd_display_string(0, 7, 1, 21, "point by hand. "); + //->0x20a50 + break; + + case 8: + //0x1f0f4 + lcd_display_string(0, 1, 1, 21, "Target Sync: "); + lcd_display_string(0, 3, 1, 21, "Synchronizing the "); + lcd_display_string(0, 5, 1, 21, "target parameter with "); + lcd_display_string(0, 7, 1, 21, "thetelescope point. "); + //->0x20a50 + break; + + case 9: + //0x1f16c + lcd_display_string(0, 1, 1, 21, "Pole-Axis Deviation: "); + lcd_display_string(0, 3, 1, 21, "Show the Pole-Axis "); + lcd_display_string(0, 5, 1, 21, "practice Deviation "); + lcd_display_string(0, 7, 1, 21, "through the align. "); + //->0x20a50 + break; + + case 10: + //0x1f344 + lcd_display_string(0, 1, 1, 21, "RA Bklash Correction: "); + lcd_display_string(0, 3, 1, 21, "Correct the backlash "); + lcd_display_string(0, 5, 1, 21, "in RA motor gear. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 11: + //0x1f3bc + lcd_display_string(0, 1, 1, 21, "DEC Bklash Correction: "); + lcd_display_string(0, 3, 1, 21, "Correct the backlash "); + lcd_display_string(0, 5, 1, 21, "in DED motor gear. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 16: + //0x1f434 + lcd_display_string(0, 1, 1, 21, "Solar System: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at Planet, Sun, "); + lcd_display_string(0, 7, 1, 21, "Moon. "); + //->0x20a50 + break; + + case 17: + //0x1f5c4 + lcd_display_string(0, 1, 1, 21, "Constellation: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at Constell- "); + lcd_display_string(0, 7, 1, 21, "ation. "); + //->0x20a50 + break; + + case 18: + //0x1f63c + lcd_display_string(0, 1, 1, 21, "Famous Star: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at all famous "); + lcd_display_string(0, 7, 1, 21, "stars. "); + //->0x20a50 + break; + + case 19: + //0x1f6b4 + lcd_display_string(0, 1, 1, 21, "Messier Catalogue: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at all stars in "); + lcd_display_string(0, 7, 1, 21, "Messier Catalogue. "); + //->0x20a50 + break; + + case 20: + //0x1f838 + lcd_display_string(0, 1, 1, 21, "NGC Deep Sky: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at all stars "); + lcd_display_string(0, 7, 1, 21, "in NGC deep sky. "); + //->0x20a50 + break; + + case 21: + //0x1f8b0 + lcd_display_string(0, 1, 1, 21, "IC Deep Sky: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at all stars "); + lcd_display_string(0, 7, 1, 21, "in IC deep sky. "); + //->0x20a50 + break; + + case 22: + //0x1f928 + lcd_display_string(0, 1, 1, 21, "Sh2 Deep Sky: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at all stars "); + lcd_display_string(0, 7, 1, 21, "in Sh2 Deep Sky. "); + //->0x20a50 + break; + + case 23: + //0x1f9a0 + lcd_display_string(0, 1, 1, 21, "Bright Stars: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at all stars "); + lcd_display_string(0, 7, 1, 21, "in Bright Stars. "); + //->0x20a50 + break; + + case 24: + //0x1fa18 + lcd_display_string(0, 1, 1, 21, "SAO Star: "); + lcd_display_string(0, 3, 1, 21, "Telescope can auto "); + lcd_display_string(0, 5, 1, 21, "point at all stars "); + lcd_display_string(0, 7, 1, 21, "in SAO Star. "); + //->0x20a50 + break; + + case 25: + //0x1fbb4 + lcd_display_string(0, 1, 1, 21, "User-def Object: "); + lcd_display_string(0, 3, 1, 21, "Input sky target "); + lcd_display_string(0, 5, 1, 21, "parameter and save it. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 26: + //0x1fc2c + lcd_display_string(0, 1, 1, 21, "Specify Ra Dec: "); + lcd_display_string(0, 3, 1, 21, "Input Target R.a and "); + lcd_display_string(0, 5, 1, 21, "Des ,then point to it. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 27: + //0x1fca4 + lcd_display_string(0, 1, 1, 21, "Landmarks: "); + lcd_display_string(0, 3, 1, 21, "Input land target "); + lcd_display_string(0, 5, 1, 21, "parameter and save it. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 28: + //0x1fd1c + lcd_display_string(0, 1, 1, 21, "Current Objects: "); + lcd_display_string(0, 3, 1, 21, "Give planet's,solar "); + lcd_display_string(0, 5, 1, 21, "and lunar rise, "); + lcd_display_string(0, 7, 1, 21, "transit and set time. "); + //->0x20a50 + break; + + case 29: + //0x1feec + lcd_display_string(0, 1, 1, 21, "Object Rise/Set: "); + lcd_display_string(0, 3, 1, 21, "calculate star rise, "); + lcd_display_string(0, 5, 1, 21, "transit and set time. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 30: + //0x1ff64 + lcd_display_string(0, 1, 1, 21, "Lunar Phase: "); + lcd_display_string(0, 3, 1, 21, "Show the lunar phase "); + lcd_display_string(0, 5, 1, 21, " "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 31: + //0x1ffdc + lcd_display_string(0, 1, 1, 21, "Timer: "); + lcd_display_string(0, 3, 1, 21, "Count down reminder "); + lcd_display_string(0, 5, 1, 21, " "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 32: + //0x20054 + lcd_display_string(0, 1, 1, 21, "Alarm: "); + lcd_display_string(0, 3, 1, 21, "Timeing alarm. "); + lcd_display_string(0, 5, 1, 21, " "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 33: + //0x200cc + lcd_display_string(0, 1, 1, 21, "Field Angle Cal: "); + lcd_display_string(0, 3, 1, 21, "Calculate the teles- "); + lcd_display_string(0, 5, 1, 21, "cope's field angel. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 34: + //0x2025c + lcd_display_string(0, 1, 1, 21, "Magify Power Cal: "); + lcd_display_string(0, 3, 1, 21, "Calculate the teles- "); + lcd_display_string(0, 5, 1, 21, "cope's magify power. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 35: + //0x202d4 + lcd_display_string(0, 1, 1, 21, "Illumination: "); + lcd_display_string(0, 3, 1, 21, "Set screen illumina- "); + lcd_display_string(0, 5, 1, 21, "tion. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 37: + //0x2034c + lcd_display_string(0, 1, 1, 21, "Parkzen: "); + lcd_display_string(0, 3, 1, 21, "Slew telescope to "); + lcd_display_string(0, 5, 1, 21, "Original Position. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 38: + //0x203c4 + lcd_display_string(0, 1, 1, 21, "Time and Date: "); + lcd_display_string(0, 3, 1, 21, "Set local time and "); + lcd_display_string(0, 5, 1, 21, "data for system. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 39: + //0x2055c + lcd_display_string(0, 1, 1, 21, "Daylight Saving: "); + lcd_display_string(0, 3, 1, 21, "Set Daylight Saving. "); + lcd_display_string(0, 5, 1, 21, " "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 40: + //0x205d4 + lcd_display_string(0, 1, 1, 21, "Site Setting: "); + lcd_display_string(0, 3, 1, 21, "Select local site "); + lcd_display_string(0, 5, 1, 21, "from database or "); + lcd_display_string(0, 7, 1, 21, "input data. "); + //->0x20a50 + break; + + case 41: + //0x2064c + lcd_display_string(0, 1, 1, 21, "Sky/ Land: "); + lcd_display_string(0, 3, 1, 21, "Select sky or land "); + lcd_display_string(0, 5, 1, 21, "mode "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 42: + //0x206c4 + lcd_display_string(0, 1, 1, 21, "AZ/EQ: "); + lcd_display_string(0, 3, 1, 21, "Set mount mode to be "); + lcd_display_string(0, 5, 1, 21, "AZ or EQ mode. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 43: + //0x20870 + lcd_display_string(0, 1, 1, 21, "Telescope Zero: "); + lcd_display_string(0, 3, 1, 21, "Set telescope Origin- "); + lcd_display_string(0, 5, 1, 21, "al Position. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 44: + //0x208e8 + lcd_display_string(0, 1, 1, 21, "Tracking Rate: "); + lcd_display_string(0, 3, 1, 21, "Set telescope track "); + lcd_display_string(0, 5, 1, 21, "speed. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 45: + //0x20960 + lcd_display_string(0, 1, 1, 21, "Language: "); + lcd_display_string(0, 3, 1, 21, "Select the menu "); + lcd_display_string(0, 5, 1, 21, "language. "); + lcd_display_string(0, 7, 1, 21, " "); + //->0x20a50 + break; + + case 46: + //0x209d8 + lcd_display_string(0, 1, 1, 21, "Reset: "); + lcd_display_string(0, 3, 1, 21, "All parameter resume "); + lcd_display_string(0, 5, 1, 21, "to the leave factory "); + lcd_display_string(0, 7, 1, 21, "state. "); + //->0x20a50 + break; + #if 0 + default: + //0x20a50 + break; + #endif + } +} + diff --git a/applications/freertos_app/Makefile b/applications/freertos_app/Makefile new file mode 100644 index 0000000..70ce953 --- /dev/null +++ b/applications/freertos_app/Makefile @@ -0,0 +1,71 @@ +################################################################################ +################################################################################ +## +## Makefile -- makefile for v2.3 +## +## Mandatory settings: +## +## o TOPDIR = the toplevel directory (using slashes as path separator) +## o TARGET = the machine qualifier to generate code for +## +################################################################################ +################################################################################ + +TOPDIR = ../.. +SUBDIR = applications/freertos_app + +include $(TOPDIR)/env/make/Makefile.config + +################################################################################ +# source files +################################################################################ + +SOURCES += main.c +SOURCES += uart.c +SOURCES += data.c +SOURCES += Startup.s + +################################################################################ +# define define user cc flags +################################################################################ + + + +################################################################################ +# define define user ld flags +################################################################################ + + + +################################################################################ +# define library used +################################################################################ + +LIBRARIES = FreeRTOS FreeRTOS_portable + +################################################################################ +# define target name +################################################################################ + +PROGRAM = freertos_app + +################################################################################ +# define user targets +################################################################################ + +default: install + +clean: clean-objects clean-program + +build: build-objects build-program build-elfdump-program build-intelhex-program + +install: build install-program install-intelhex-program + +headers: + +all: clean build install + + +include $(TOPDIR)/env/make/Makefile.rules + + diff --git a/applications/freertos_app/Startup.s b/applications/freertos_app/Startup.s new file mode 100644 index 0000000..531831e --- /dev/null +++ b/applications/freertos_app/Startup.s @@ -0,0 +1,429 @@ +;/*****************************************************************************/ +;/* STARTUP.S: Startup file for Philips LPC2000 */ +;/*****************************************************************************/ +;/* <<< Use Configuration Wizard in Context Menu >>> */ +;/*****************************************************************************/ +;/* This file is part of the uVision/ARM development tools. */ +;/* Copyright (c) 2005-2007 Keil Software. All rights reserved. */ +;/* This software may only be used under the terms of a valid, current, */ +;/* end user licence from KEIL for a compatible version of KEIL software */ +;/* development tools. Nothing else gives you the right to use this software. */ +;/*****************************************************************************/ + + +;/* +; * The STARTUP.S code is executed after CPU Reset. This file may be +; * translated with the following SET symbols. In uVision these SET +; * symbols are entered under Options - ASM - Define. +; * +; * REMAP: when set the startup code initializes the register MEMMAP +; * which overwrites the settings of the CPU configuration pins. The +; * startup and interrupt vectors are remapped from: +; * 0x00000000 default setting (not remapped) +; * 0x80000000 when EXTMEM_MODE is used +; * 0x40000000 when RAM_MODE is used +; * +; * EXTMEM_MODE: when set the device is configured for code execution +; * from external memory starting at address 0x80000000. +; * +; * RAM_MODE: when set the device is configured for code execution +; * from on-chip RAM starting at address 0x40000000. +; * +; * EXTERNAL_MODE: when set the PIN2SEL values are written that enable +; * the external BUS at startup. +; */ + + +; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs + +Mode_USR EQU 0x10 +Mode_FIQ EQU 0x11 +Mode_IRQ EQU 0x12 +Mode_SVC EQU 0x13 +Mode_ABT EQU 0x17 +Mode_UND EQU 0x1B +Mode_SYS EQU 0x1F + +I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled +F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled + + +;// Stack Configuration (Stack Sizes in Bytes) +;// Undefined Mode <0x0-0xFFFFFFFF:8> +;// Supervisor Mode <0x0-0xFFFFFFFF:8> +;// Abort Mode <0x0-0xFFFFFFFF:8> +;// Fast Interrupt Mode <0x0-0xFFFFFFFF:8> +;// Interrupt Mode <0x0-0xFFFFFFFF:8> +;// User/System Mode <0x0-0xFFFFFFFF:8> +;// + +UND_Stack_Size EQU 0x00000008 +SVC_Stack_Size EQU 0x00000300 +ABT_Stack_Size EQU 0x00000008 +FIQ_Stack_Size EQU 0x00000008 +IRQ_Stack_Size EQU 0x00000300 +USR_Stack_Size EQU 0x00000008 + +Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \ + FIQ_Stack_Size + IRQ_Stack_Size + USR_Stack_Size ) + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size + +;__initial_sp SPACE ISR_Stack_Size + +Stack_Top EQU Stack_Mem + Stack_Size + + +;// Heap Configuration +;// Heap Size (in Bytes) <0x0-0xFFFFFFFF> +;// + +Heap_Size EQU 0x00000000 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + +; VPBDIV definitions +VPBDIV EQU 0xE01FC100 ; VPBDIV Address + +;// VPBDIV Setup +;// Peripheral Bus Clock Rate +;// VPBDIV: VPB Clock +;// <0=> VPB Clock = CPU Clock / 4 +;// <1=> VPB Clock = CPU Clock +;// <2=> VPB Clock = CPU Clock / 2 +;// XCLKDIV: XCLK Pin +;// <0=> XCLK Pin = CPU Clock / 4 +;// <1=> XCLK Pin = CPU Clock +;// <2=> XCLK Pin = CPU Clock / 2 +;// +VPBDIV_SETUP EQU 0 +VPBDIV_Val EQU 0x00000000 + + +; Phase Locked Loop (PLL) definitions +PLL_BASE EQU 0xE01FC080 ; PLL Base Address +PLLCON_OFS EQU 0x00 ; PLL Control Offset +PLLCFG_OFS EQU 0x04 ; PLL Configuration Offset +PLLSTAT_OFS EQU 0x08 ; PLL Status Offset +PLLFEED_OFS EQU 0x0C ; PLL Feed Offset +PLLCON_PLLE EQU (1<<0) ; PLL Enable +PLLCON_PLLC EQU (1<<1) ; PLL Connect +PLLCFG_MSEL EQU (0x1F<<0) ; PLL Multiplier +PLLCFG_PSEL EQU (0x03<<5) ; PLL Divider +PLLSTAT_PLOCK EQU (1<<10) ; PLL Lock Status + +;// PLL Setup +;// MSEL: PLL Multiplier Selection +;// <1-32><#-1> +;// M Value +;// PSEL: PLL Divider Selection +;// <0=> 1 <1=> 2 <2=> 4 <3=> 8 +;// P Value +;// +PLL_SETUP EQU 1 +PLLCFG_Val EQU 0x00000024 + + +; Memory Accelerator Module (MAM) definitions +MAM_BASE EQU 0xE01FC000 ; MAM Base Address +MAMCR_OFS EQU 0x00 ; MAM Control Offset +MAMTIM_OFS EQU 0x04 ; MAM Timing Offset + +;// MAM Setup +;// MAM Control +;// <0=> Disabled +;// <1=> Partially Enabled +;// <2=> Fully Enabled +;// Mode +;// MAM Timing +;// <0=> Reserved <1=> 1 <2=> 2 <3=> 3 +;// <4=> 4 <5=> 5 <6=> 6 <7=> 7 +;// Fetch Cycles +;// +MAM_SETUP EQU 1 +MAMCR_Val EQU 0x00000002 +MAMTIM_Val EQU 0x00000004 + + +; External Memory Controller (EMC) definitions +EMC_BASE EQU 0xFFE00000 ; EMC Base Address +BCFG0_OFS EQU 0x00 ; BCFG0 Offset +BCFG1_OFS EQU 0x04 ; BCFG1 Offset +BCFG2_OFS EQU 0x08 ; BCFG2 Offset +BCFG3_OFS EQU 0x0C ; BCFG3 Offset + +;// External Memory Controller (EMC) +EMC_SETUP EQU 0 + +;// Bank Configuration 0 (BCFG0) +;// IDCY: Idle Cycles <0-15> +;// WST1: Wait States 1 <0-31> +;// WST2: Wait States 2 <0-31> +;// RBLE: Read Byte Lane Enable +;// WP: Write Protect +;// BM: Burst ROM +;// MW: Memory Width <0=> 8-bit <1=> 16-bit +;// <2=> 32-bit <3=> Reserved +;// +BCFG0_SETUP EQU 0 +BCFG0_Val EQU 0x0000FBEF + +;// Bank Configuration 1 (BCFG1) +;// IDCY: Idle Cycles <0-15> +;// WST1: Wait States 1 <0-31> +;// WST2: Wait States 2 <0-31> +;// RBLE: Read Byte Lane Enable +;// WP: Write Protect +;// BM: Burst ROM +;// MW: Memory Width <0=> 8-bit <1=> 16-bit +;// <2=> 32-bit <3=> Reserved +;// +BCFG1_SETUP EQU 0 +BCFG1_Val EQU 0x0000FBEF + +;// Bank Configuration 2 (BCFG2) +;// IDCY: Idle Cycles <0-15> +;// WST1: Wait States 1 <0-31> +;// WST2: Wait States 2 <0-31> +;// RBLE: Read Byte Lane Enable +;// WP: Write Protect +;// BM: Burst ROM +;// MW: Memory Width <0=> 8-bit <1=> 16-bit +;// <2=> 32-bit <3=> Reserved +;// +BCFG2_SETUP EQU 0 +BCFG2_Val EQU 0x0000FBEF + +;// Bank Configuration 3 (BCFG3) +;// IDCY: Idle Cycles <0-15> +;// WST1: Wait States 1 <0-31> +;// WST2: Wait States 2 <0-31> +;// RBLE: Read Byte Lane Enable +;// WP: Write Protect +;// BM: Burst ROM +;// MW: Memory Width <0=> 8-bit <1=> 16-bit +;// <2=> 32-bit <3=> Reserved +;// +BCFG3_SETUP EQU 0 +BCFG3_Val EQU 0x0000FBEF + +;// End of EMC + + +; External Memory Pins definitions +PINSEL2 EQU 0xE002C014 ; PINSEL2 Address +PINSEL2_Val EQU 0x0E6149E4 ; CS0..3, OE, WE, BLS0..3, + ; D0..31, A2..23, JTAG Pins + + + PRESERVE8 + + +; Area Definition and Entry Point +; Startup Code must be linked first at Address at which it expects to run. + + AREA RESET, CODE, READONLY + ARM + + +; Exception Vectors +; Mapped to Address 0. +; Absolute addressing mode must be used. +; Dummy Handlers are implemented as infinite loops which can be modified. + IMPORT vPortYieldProcessor + +Vectors LDR PC, Reset_Addr + LDR PC, Undef_Addr + LDR PC, SWI_Addr + LDR PC, PAbt_Addr + LDR PC, DAbt_Addr + NOP ; Reserved Vector +; LDR PC, IRQ_Addr + LDR PC, [PC, #-0x0FF0] ; Vector from VicVectAddr + LDR PC, FIQ_Addr + +Reset_Addr DCD Reset_Handler +Undef_Addr DCD Undef_Handler +SWI_Addr DCD vPortYieldProcessor +PAbt_Addr DCD PAbt_Handler +DAbt_Addr DCD DAbt_Handler + DCD 0 ; Reserved Address +IRQ_Addr DCD IRQ_Handler +FIQ_Addr DCD FIQ_Handler + +Undef_Handler B Undef_Handler +SWI_Handler B SWI_Handler +PAbt_Handler B PAbt_Handler +DAbt_Handler B DAbt_Handler +IRQ_Handler B IRQ_Handler +FIQ_Handler B FIQ_Handler + + +; Reset Handler + + EXPORT Reset_Handler +Reset_Handler + + +; Setup External Memory Pins + IF :DEF:EXTERNAL_MODE + LDR R0, =PINSEL2 + LDR R1, =PINSEL2_Val + STR R1, [R0] + ENDIF + + +; Setup External Memory Controller + IF EMC_SETUP <> 0 + LDR R0, =EMC_BASE + + IF BCFG0_SETUP <> 0 + LDR R1, =BCFG0_Val + STR R1, [R0, #BCFG0_OFS] + ENDIF + + IF BCFG1_SETUP <> 0 + LDR R1, =BCFG1_Val + STR R1, [R0, #BCFG1_OFS] + ENDIF + + IF BCFG2_SETUP <> 0 + LDR R1, =BCFG2_Val + STR R1, [R0, #BCFG2_OFS] + ENDIF + + IF BCFG3_SETUP <> 0 + LDR R1, =BCFG3_Val + STR R1, [R0, #BCFG3_OFS] + ENDIF + + ENDIF ; EMC_SETUP + + +; Setup VPBDIV + IF VPBDIV_SETUP <> 0 + LDR R0, =VPBDIV + LDR R1, =VPBDIV_Val + STR R1, [R0] + ENDIF + + +; Setup PLL + IF PLL_SETUP <> 0 + LDR R0, =PLL_BASE + MOV R1, #0xAA + MOV R2, #0x55 + +; Configure and Enable PLL + MOV R3, #PLLCFG_Val + STR R3, [R0, #PLLCFG_OFS] + MOV R3, #PLLCON_PLLE + STR R3, [R0, #PLLCON_OFS] + STR R1, [R0, #PLLFEED_OFS] + STR R2, [R0, #PLLFEED_OFS] + +; Wait until PLL Locked +PLL_Loop LDR R3, [R0, #PLLSTAT_OFS] + ANDS R3, R3, #PLLSTAT_PLOCK + BEQ PLL_Loop + +; Switch to PLL Clock + MOV R3, #(PLLCON_PLLE:OR:PLLCON_PLLC) + STR R3, [R0, #PLLCON_OFS] + STR R1, [R0, #PLLFEED_OFS] + STR R2, [R0, #PLLFEED_OFS] + ENDIF ; PLL_SETUP + + +; Setup MAM + IF MAM_SETUP <> 0 + LDR R0, =MAM_BASE + MOV R1, #MAMTIM_Val + STR R1, [R0, #MAMTIM_OFS] + MOV R1, #MAMCR_Val + STR R1, [R0, #MAMCR_OFS] + ENDIF ; MAM_SETUP + + +; Memory Mapping (when Interrupt Vectors are in RAM) +MEMMAP EQU 0xE01FC040 ; Memory Mapping Control + IF :DEF:REMAP + LDR R0, =MEMMAP + IF :DEF:EXTMEM_MODE + MOV R1, #3 + ELIF :DEF:RAM_MODE + MOV R1, #2 + ELSE + MOV R1, #1 + ENDIF + STR R1, [R0] + ENDIF + + +; Initialise Interrupt System +; ... + + +; Setup Stack for each mode + + LDR R0, =Stack_Top + +; Enter Undefined Instruction Mode and set its Stack Pointer + MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit + MOV SP, R0 + SUB R0, R0, #UND_Stack_Size + +; Enter Abort Mode and set its Stack Pointer + MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit + MOV SP, R0 + SUB R0, R0, #ABT_Stack_Size + +; Enter FIQ Mode and set its Stack Pointer + MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit + MOV SP, R0 + SUB R0, R0, #FIQ_Stack_Size + +; Enter IRQ Mode and set its Stack Pointer + MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit + MOV SP, R0 + SUB R0, R0, #IRQ_Stack_Size + +; Enter Supervisor Mode and set its Stack Pointer + MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit + MOV SP, R0 + SUB R0, R0, #SVC_Stack_Size + +; Enter the C code + + IMPORT __main + LDR R0, =__main + BX R0 + + + IF :DEF:__MICROLIB + + EXPORT __heap_base + EXPORT __heap_limit + + ELSE +; User Initial Stack & Heap + AREA |.text|, CODE, READONLY + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + IRQ_Stack_Size + USR_Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + ENDIF + + + END diff --git a/applications/freertos_app/align_stars.c b/applications/freertos_app/align_stars.c new file mode 100644 index 0000000..0e0e00a --- /dev/null +++ b/applications/freertos_app/align_stars.c @@ -0,0 +1,235 @@ + +unsigned char strAlignStarsNames[][10] = //40000000 +{ + "Sirius ", + "Canopus ", + "Vega ", + "Alpha Cen", + "Arcturus ", + "Capella ", + "Rigel ", + "Procyon ", + "Achernar ", + "Betelgeus", + "Altair ", + "Aldebaran", + "Spica ", + "Antares ", + "Fomalhaut", + "Deneb ", + "Regulus ", + "Mirfak ", + "Castor ", + "Alphard ", + "Polaris ", + "Alpheratz", + "Rasalhagu", + "Denebola ", + "Navi ", + "Suhail ", + "Mizar ", + "Albireo " +}; + +unsigned char Data_40000118[][22] = //40000118 +{ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", +}; + +/* 58ec - complete */ +unsigned char GetCurrentAlignStars(float r4, float r5, float* equatorialCoord, unsigned char strNames[][10], unsigned char sp304[][22]) +{ + int i; + unsigned char cnt; + unsigned char j; + + float ra[28]; + float dec[28]; + unsigned char visible[20]; //size?? + unsigned char k; + float sp16, sp12, sp8, sp4; + + ra[0] = 6.75850009918212890625; //Sirius - Alpha CMa + dec[0] = -16.7263050079345703125; + ra[1] = 6.40180301666259765625; //Canopus - Alpha Car + dec[1] = -52.69824981689453125; + ra[2] = 18.620929718017578125; //Vega - Alpha Lyr + dec[2] = 38.790943145751953125; + ra[3] = 14.6703472137451171875; // Rigil Kentaurus / Toliman - Alpa Cen + dec[3] = -60.875278472900390625; + ra[4] = 14.26785564422607421875; //Arcturus - Alpha Boo + dec[4] = 19.1384716033935546875; + ra[5] = 5.288404941558837890625; //Capella - Alpha Aur + dec[5] = 46.0066375732421875; + ra[6] = 5.248960971832275390625; //Rigel - Beta Ori + dec[6] = -8.18952846527099609375; + ra[7] = 7.662292003631591796875; //Procyon - Alpha CMi + dec[7] = 5.204332828521728515625; + ra[8] = 1.63397800922393798828125; //Achernar - Alpha Eri + dec[8] = -57.187053680419921875; + ra[9] = 5.09371089935302734375; //Betelgeuse - Alpa Ori + dec[9] = 7.410167217254638671875; + ra[10] = 19.8538360595703125; //Altair - Alpha Aql + dec[10] = 8.890472412109375; + ra[11] = 4.60669994354248046875; //Aldebaran - Alpha Tau + dec[11] = 16.52752685546875; + ra[12] = 13.4276142120361328125; //Spica - Alpha Vir + dec[12] = -11.2079448699951171875; + ra[13] = 16.49939727783203125; //Antares - Alpha Sco + dec[13] = -26.4533329010009765625; + ra[14] = 22.9691143035888671875; //Formalhaut - Alpha PsA + dec[14] = -29.5733890533447265625; + ra[15] = 20.6958770751953125; //Deneb - Alpha Cyg + dec[15] = 45.308834075927734375; + ra[16] = 10.14705562591552734375; //Regulus - Alpha Leo + dec[16] = 11.9264163970947265625; + ra[17] = 3.41538906097412109375; //Mirfak - Alpha Per + dec[17] = 49.890056610107421875; + ra[18] = 7.5854969024658203125; //Castor - Alpha Gem + dec[18] = 31.87105560302734375; + ra[19] = 9.46664142608642578125; //Alphard - Alpha Hya + dec[19] = -8.69580554962158203125; + ra[20] = 2.6790111064910888671875; //Polaris - Alpha UMi + dec[20] = 89.2981109619140625; + ra[21] = 0.1473419964313507080078125; //Sirrah / Alpheratz - Alpha And + dec[21] = 29.136417388916015625; + ra[22] = 17.5893688201904296875; //Rasalhagu - Alpha Oph + dec[22] = 12.55330562591552734375; + ra[23] = 11.82501697540283203125; //Denebola - Beta Leo + dec[23] = 14.52511119842529296875; + ra[24] = 0.953800022602081298828125; //Navi / Tsih / 27 Cas - Gamma Cas + dec[24] = 60.759693145751953125; + ra[25] = 9.13812732696533203125; //Suhail - Lambda Velorum + dec[25] = -43.468776702880859375; + ra[26] = 13.40486621856689453125; //Mizar - Zeta UMa + dec[26] = 54.884029388427734375; + ra[27] = 19.51886749267578125; //Albireo - Beta Cyg + dec[27] = 27.982250213623046875; + + if ((r4 >= 4) || (r4 <= 20)) + { + sp8 = r4 - 4; + sp4 = r4 + 4; + } + //5c10 + else if (r4 < 4) + { + sp8 = r4 + 24 - 4; + sp4 = r4 + 4; + } + else + { + sp8 = r4 - 4; + sp4 = r4 - 24 + 4; + } + //5c7c + if (r5 >= 0) + { + sp16 = r5 - 60; + sp12 = r5 + 60; + + if (sp12 > 90) + { + sp12 = 90; + } + } + else + { + //5cc8 + sp16 = r5 - 60; + sp12 = r5 + 60; + + if (sp16 < -90) + { + sp16 = -90; + } + } + //5d00 + i = 0; + cnt = 0; + for (; i < 28; i++) + { + //5d0c + if ((r4 >= 4) || (r4 <= 20)) + { + //5d2c + if ((ra[i] >= sp8) && (ra[i] <= sp4) && + (dec[i] >= sp16) && (dec[i] <= sp12)) + { + visible[cnt] = i; + cnt++; + } + } + else + { + //5d90 + if ((r4 <= 4) || (r4 >= 20)) + { + //5db0 + if (((ra[i] >= sp8) && (ra[i] <= 24)) || + ((ra[i] >= 0) && (ra[i] <= sp4))) + { + //5e00 + if ((dec[i] >= sp16) && (dec[i] <= sp12)) + { + //5e28 + visible[cnt] = i; + cnt++; + } + } + } + } + } + //5e44 + if (cnt > 0) + { + for (i = 0; i <= (cnt-1); i++) + { + //5e54 + *(equatorialCoord + i*2) = ra[ visible[i] ]; + *(equatorialCoord + i*2 + 1) = dec[ visible[i] ]; + + for (j = 0; j < 10; j++) + { + //5e8c + strNames[i][j] = strAlignStarsNames[visible[i]][j]; + } + //5ec0 + for (k = 0; k < 22; k++) + { + //5ecc + sp304[i][k] = Data_40000118[visible[i]][k]; + } + } + } + //5f2c + return cnt-1; +} + diff --git a/applications/freertos_app/alignment.c b/applications/freertos_app/alignment.c new file mode 100644 index 0000000..bea5807 --- /dev/null +++ b/applications/freertos_app/alignment.c @@ -0,0 +1,519 @@ + + +typedef struct +{ + double dData_0; //0 + double dData_8; //8 + double dData_16; //16 + double dData_24; //24 + double dData_32; //32 sp336; + double dData_40; //40 sp344; + double dData_48; //48 sp352; + double dData_56; //56 sp360; + double dData_64; //64 sp368; + double dData_72; //72 sp376; + double dData_80; //80 sp384; + double dData_88; //88 sp392; +} Struct_b7f4_1; + +/* b7f4 - todo */ +void func_b7f4(Struct_b7f4_1 a/*sp336*/, Struct_b7f4* r4/*sp400*/) +{ + double sp288 = 0.0174532925200000001153544104682; + double sp280; + double sp272; + double sp264; + double sp256; + double sp248; + double sp240; + double sp232; + double sp224; + double sp216; + double sp208; + double sp200; + double sp192; + double sp184; + double sp176; + double sp168; + double sp160; + double sp152; + double sp144; + double sp136; + double sp128; + double sp120; + double sp112; + double sp104; + double sp96; + double sp88; + double sp80; + double sp72; + double sp64; + double sp56; + double sp48; + + sp280 = a.dData_32/*sp336*/ * sp288; + sp272 = a.dData_40/*sp344*/ * sp288; + sp264 = a.dData_64/*sp368*/ * sp288; + sp256 = a.dData_72/*sp376*/ * sp288; + sp248 = a.dData_48; //sp352; + sp232 = a.dData_80; //sp384; + sp240 = a.dData_56; //sp360; + sp224 = a.dData_88; //sp392; + sp216 = 1.0; + sp208 = sin(sp280) * sin(sp272) / cos(sp272); + sp200 = cos(sp280) * sin(sp272) / cos(sp272); + sp192 = 1.0; + sp184 = sin(sp264) * sin(sp256) / cos(sp256); + sp176 = cos(sp264) * sin(sp256) / cos(sp256); + sp168 = 1.0; + sp160 = cos(sp280); + sp152 = sin(sp280) * -1.0; + sp144 = 1.0; + sp136 = cos(sp264); + sp128 = sin(sp264) * -1.0; + sp120 = sp232 - sp248; + sp112 = sp184 - sp208; + sp104 = sp176 - sp200; + sp96 = sp224 - sp240; + sp88 = sp136 - sp160; + sp80 = sp128 - sp152; + + sp56 = (sp120 * sp88 - sp112 * sp96) / (sp88 * sp104 - sp80 * sp112); + sp48 = (sp120 * sp80 - sp104 * sp96) / (sp80 * sp112 - sp88 * sp104); + sp72 = sp248 - sp208 * sp48 - sp200 * sp56; + sp64 = sp240 - sp160 * sp48 - sp152 * sp56; + + sp56 = 0.0; + sp48 = 0.0; + sp72 = a.dData_80; //sp384; + sp64 = a.dData_88; //sp392; + r4->dData_32 = sp72; + r4->dData_40 = sp64; + r4->dData_24 = sp56; + r4->dData_16 = sp48; + r4->dData_8 = 0.0; + r4->dData_0 = 0.0; +} + +/* be8c - todo */ +void func_be8c(Struct_b7f4_1 a/*sp304*/, Struct_b7f4* r4/*sp400*/) +{ + double sp288 = 0.0174532925200000001153544104682; + double sp280; + double sp272; + double sp264; + double sp256; + double sp248; + double sp240; + double sp232; + double sp224; + double sp216; + double sp208; + double sp200; + double sp192; + double sp184; + double sp176; + double sp168; + double sp160; + double sp152; + double sp144; + double sp136; + double sp128; + double sp120; + double sp112; + double sp104; + double sp96; + double sp88; + double sp80; + double sp72; + double sp64; + double sp56; + double sp48; + + sp280 = a.dData_0/*sp304*/ * sp288; + sp272 = a.dData_8/*sp312*/ * sp288; + sp264 = a.dData_32/*sp336*/ * sp288; + sp256 = a.dData_40/*sp344*/ * sp288; + sp248 = a.dData_16; //sp320; + sp232 = a.dData_48; //sp352; + sp240 = a.dData_24; //sp328; + sp224 = a.dData_56; //sp360; + sp216 = 1.0; + sp208 = sin(sp280) * sin(sp272) / cos(sp272); + sp200 = cos(sp280) * sin(sp272) / cos(sp272); + sp192 = 1.0; + sp184 = sin(sp264) * sin(sp256) / cos(sp256); + sp176 = cos(sp264) * sin(sp256) / cos(sp256); + sp168 = 1.0; + sp160 = cos(sp280); + sp152 = sin(sp280) * -1.0; + sp144 = 1.0; + sp136 = cos(sp264); + sp128 = sin(sp264) * -1.0; + sp120 = sp232 - sp248; + sp112 = sp184 - sp208; + sp104 = sp176 - sp200; + sp96 = sp224 - sp240; + sp88 = sp136 - sp160; + sp80 = sp128 - sp152; + + sp56 = (sp120 * sp88 - sp112 * sp96) / (sp88 * sp104 - sp80 * sp112); + sp48 = (sp120 * sp80 - sp104 * sp96) / (sp80 * sp112 - sp88 * sp104); + sp72 = sp248 - sp208 * sp48 - sp200 * sp56; + sp64 = sp240 - sp160 * sp48 - sp152 * sp56; + sp56 = 0.0; + sp48 = 0.0; + sp72 = a.dData_80; //sp384; + sp64 = a.dData_88; //sp392; + r4->dData_32 = sp72; + r4->dData_40 = sp64; + r4->dData_24 = sp56; + r4->dData_16 = sp48; + r4->dData_8 = 0.0; + r4->dData_0 = 0.0; +} + +/* c510 - todo */ +void func_c510(Struct_b7f4_1 a/*sp336*/, Struct_b7f4* ip/*sp96*/) +{ + ip->dData_32 = a.dData_16; //sp16 + ip->dData_40 = a.dData_24; //sp24; + ip->dData_24 = 0.0; + ip->dData_16 = 0.0; + ip->dData_8 = 0.0; + ip->dData_0 = 0.0; +} + +/* c57c - todo */ +void func_c57c(void) +{ + #if 0 + double sp136; + double sp144; + double sp152; + double sp160; + double sp168; + double sp176; + double sp184; + double sp192; + double sp200; + double sp208; + double sp216; + double sp224; + #else + Struct_b7f4_1 sp136; + #endif + Struct_b7f4 sp88; + + int r4 = 0; + + if (Data_40004128.alignmentStarIndex < Data_40004128.numAlignmentStars) + { + Data_40004128.bData_344 = 0; + Data_40004128.bData_345 = 0; + Data_40004128.Data_348 = 0; + + switch (Data_40004128.alignmentStarIndex) + { + case 0: + //c5d8 + Data_40004128.dObjRectascension = Data_40004128.dFirstAlignmentStarRa; + Data_40004128.dObjDeclination = Data_40004128.dFirstAlignmentStarDec; + break; + + case 1: + //c60c + Data_40004128.dObjRectascension = Data_40004128.dSecondAlignmentStarRa; + Data_40004128.dObjDeclination = Data_40004128.dSecondAlignmentStarDec; + break; + + case 2: + //c640 + Data_40004128.dObjRectascension = Data_40004128.dThirdAlignmentStarRa; + Data_40004128.dObjDeclination = Data_40004128.dThirdAlignmentStarDec; + break; + + default: + break; + } + //c678 + //c680 -> c8e8 + } + else + { + //c684 + r4 = Data_40004128.numAlignmentStars; + + sp136.dData_0 /*sp136*/ = Data_40004128.dData_424; + sp136.dData_8 /*sp144*/ = Data_40004128.dData_432; + sp136.dData_16 /*sp152*/ = Data_40004128.dData_440; + sp136.dData_24 /*sp160*/ = Data_40004128.dData_448; + sp136.dData_32 /*sp168*/ = Data_40004128.dData_456; + sp136.dData_40 /*sp176*/ = Data_40004128.dData_464; + sp136.dData_48 /*sp184*/ = Data_40004128.dData_472; + sp136.dData_56 /*sp192*/ = Data_40004128.dData_480; + sp136.dData_64 /*sp200*/ = Data_40004128.dData_488; + sp136.dData_72 /*sp208*/ = Data_40004128.dData_496; + sp136.dData_80 /*sp216*/ = Data_40004128.dData_504; + sp136.dData_88 /*sp224*/ = Data_40004128.dData_512; + + switch (r4) + { + case 1: + //c798 + func_c510(sp136, &sp88); + break; + + case 2: + //c7c4 + func_be8c(sp136, &sp88); + break; + + case 3: + //c7f0 + func_b7f4(sp136, &sp88); + break; + + default: + break; + } + //c81c + //c828 + Data_40004380.dData_32 = sp88.dData_32; //sp120 + Data_40004380.dData_40 = sp88.dData_40; //sp128 + Data_40004380.dData_8 = sp88.dData_8; //sp96 + Data_40004380.dData_0 = sp88.dData_0; //sp88 + Data_40004380.dData_24 = sp88.dData_24; //sp112 + Data_40004380.dData_16 = sp88.dData_16; //sp104 + + Data_40004128.bAlignmentComplete = 1; + + dData_400033d8 = 0.0; + dData_400033e0 = 0.0; + dData_40003420 = 0.0; + dData_40003428 = 0.0; + + bData_40003200 = 1; + bData_40003201 = 1; + } +} + +/* c8f4 - complete */ +void ProcessNextAlignmentStar(void) +{ + if ((Data_40004128.bAlignmentComplete == 0) && + (Data_40004128.dData_304 == 2.0) && + (Data_40004128.dData_312 == 2.0)) + { + //c940 + Data_40004128.alignmentStarIndex++; + + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + //c964 + switch (Data_40004128.alignmentStarIndex) + { + case 1: + //0xc988 + Data_40004128.dData_424 = 180.0 + Data_40004128.dData_112; + Data_40004128.dData_432 = 90.0 - Data_40004128.dData_120; + Data_40004128.dData_440 = Data_40004128.dOffsetRa; + Data_40004128.dData_448 = -1.0 * Data_40004128.dOffsetDec; + //->0xcb2c + break; + + case 2: + //0xca14 + Data_40004128.dData_456 = 180.0 + Data_40004128.dData_112; + Data_40004128.dData_464 = 90.0 - Data_40004128.dData_120; + Data_40004128.dData_472 = Data_40004128.dOffsetRa; + Data_40004128.dData_480 = -1.0 * Data_40004128.dOffsetDec; + //->0xcb2c + break; + + case 3: + //0xca9c + Data_40004128.dData_488 = 180.0 + Data_40004128.dData_112; + Data_40004128.dData_496 = 90.0 - Data_40004128.dData_120; + Data_40004128.dData_504 = Data_40004128.dOffsetRa; + Data_40004128.dData_512 = -1.0 * Data_40004128.dOffsetDec; + //->0xcb2c + break; + + default: + //0xcb24 + break; + } + //->0xcdc8 + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0xcb30 + switch (Data_40004128.alignmentStarIndex) + { + case 1: + //0xcb54 + Data_40004128.dData_424 = 180.0 + 15.0 * Data_40004128.dData_88; + if (Data_40004128.dData_424 > 360.0) + { + Data_40004128.dData_424 -= 360.0; + } + Data_40004128.dData_432 = Data_40004128.dObjDeclination; + Data_40004128.dData_440 = Data_40004128.dOffsetRa; + Data_40004128.dData_448 = -1.0 * Data_40004128.dOffsetDec; + //->0xcdc4 + break; + + case 2: + //0xcc20 + Data_40004128.dData_456 = 180.0 + 15.0 * Data_40004128.dData_88; + if (Data_40004128.dData_456 > 360.0) + { + Data_40004128.dData_456 -= 360.0; + } + Data_40004128.dData_464 = Data_40004128.dObjDeclination; + Data_40004128.dData_472 = Data_40004128.dOffsetRa; + Data_40004128.dData_480 = -1.0 * Data_40004128.dOffsetDec; + //->0xcdc4 + break; + + case 3: + //0xccec + Data_40004128.dData_488 = 180.0 + 15.0 * Data_40004128.dData_88; + if (Data_40004128.dData_488 > 360.0) + { + Data_40004128.dData_488 -= 360.0; + } + Data_40004128.dData_496 = Data_40004128.dObjDeclination; + Data_40004128.dData_504 = Data_40004128.dOffsetRa; + Data_40004128.dData_512 = -1.0 * Data_40004128.dOffsetDec; + //->0xcdc4 + break; + + default: + //0xcdbc + break; + } + } + } +} + +/* cdd0 - todo */ +void func_cdd0(void) +{ + unsigned char strStarNames[28][10]; + unsigned char sp16[28][22]; + + Data_40004128.numAlignmentStars = 2; + Data_40004128.bAlignmentComplete = 0; + Data_40004128.alignmentStarIndex = 0; + + numVisibleAlignmentStars = GetCurrentAlignStars( + get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), + Data_40004128.geographicLatitude, Data_40004a68_CurrentAlignStarEquatorialCoord, strStarNames, sp16); + + #if 0 + Data_40004128.dFirstAlignmentStarRa = Data_40004a68_CurrentAlignStarEquatorialCoord[0][0]; + Data_40004128.dFirstAlignmentStarDec = Data_40004a68_CurrentAlignStarEquatorialCoord[0][1]; + Data_40004128.dSecondAlignmentStarRa = Data_40004a68_CurrentAlignStarEquatorialCoord[1][0]; + Data_40004128.dSecondAlignmentStarDec = Data_40004a68_CurrentAlignStarEquatorialCoord[1][1]; + #else + Data_40004128.dFirstAlignmentStarRa = Data_40004a68_CurrentAlignStarEquatorialCoord[0]; + Data_40004128.dFirstAlignmentStarDec = Data_40004a68_CurrentAlignStarEquatorialCoord[1]; + Data_40004128.dSecondAlignmentStarRa = Data_40004a68_CurrentAlignStarEquatorialCoord[2]; + Data_40004128.dSecondAlignmentStarDec = Data_40004a68_CurrentAlignStarEquatorialCoord[3]; + #endif + + dData_400033d8 = 0.0; + dData_400033e0 = 0.0; + dData_40003410 = 0.0; + dData_40003418 = 0.0; + + Data_40004380.dData_0 = 0.0; + Data_40004380.dData_8 = 0.0; + Data_40004380.dData_16 = 0.0; + Data_40004380.dData_24 = 0.0; + Data_40004380.dData_32 = 0.0; + Data_40004380.dData_40 = 0.0; + + dData_400034e0 = dData_400034e8; + dData_400034f0 = dData_400034f8; + + func_75c4(); +} + +/* cf8c - todo */ +void StartOneStarAlignment(void) +{ + Data_40004128.numAlignmentStars = 1; + Data_40004128.bAlignmentComplete = 0; + Data_40004128.alignmentStarIndex = 0; + + dData_400033d8 = 0.0; + dData_400033e0 = 0.0; + dData_40003410 = 0.0; + dData_40003418 = 0.0; + + Data_40004380.dData_0 = 0.0; + Data_40004380.dData_8 = 0.0; + Data_40004380.dData_16 = 0.0; + Data_40004380.dData_24 = 0.0; + Data_40004380.dData_32 = 0.0; + Data_40004380.dData_40 = 0.0; + + dData_400034e0 = dData_400034e8; + dData_400034f0 = dData_400034f8; + + func_75c4(); +} + +/* d07c - todo */ +void StartTwoStarAlignment(void) +{ + Data_40004128.numAlignmentStars = 2; + Data_40004128.bAlignmentComplete = 0; + Data_40004128.alignmentStarIndex = 0; + + dData_400033d8 = 0.0; + dData_400033e0 = 0.0; + dData_40003410 = 0.0; + dData_40003418 = 0.0; + + Data_40004380.dData_0 = 0.0; + Data_40004380.dData_8 = 0.0; + Data_40004380.dData_16 = 0.0; + Data_40004380.dData_24 = 0.0; + Data_40004380.dData_32 = 0.0; + Data_40004380.dData_40 = 0.0; + + dData_400034e0 = dData_400034e8; + dData_400034f0 = dData_400034f8; + + func_75c4(); +} + +/* d16c - todo */ +void StartThreeStarAlignment(void) +{ + Data_40004128.numAlignmentStars = 3; + Data_40004128.bAlignmentComplete = 0; + Data_40004128.alignmentStarIndex = 0; + + dData_400033d8 = 0.0; + dData_400033e0 = 0.0; + dData_40003410 = 0.0; + dData_40003418 = 0.0; + + Data_40004380.dData_0 = 0.0; + Data_40004380.dData_8 = 0.0; + Data_40004380.dData_16 = 0.0; + Data_40004380.dData_24 = 0.0; + Data_40004380.dData_32 = 0.0; + Data_40004380.dData_40 = 0.0; + + dData_400034e0 = dData_400034e8; + dData_400034f0 = dData_400034f8; + + func_75c4(); +} + diff --git a/applications/freertos_app/ascom.c b/applications/freertos_app/ascom.c new file mode 100644 index 0000000..c2ee181 --- /dev/null +++ b/applications/freertos_app/ascom.c @@ -0,0 +1,291 @@ + +/* 6c848 - complete */ +unsigned char ProcessUart0ReceiverData(void) +{ + if (uart0ReceiveFlag == 1) + { + bAscomCmd = uart0ReceiveDataBuffer[0]; + +#ifdef OLIMEX_LPC2148 + { + static char buf[105]; + + snprintf(buf, 100, "ProcessUart0ReceiverData: bAscomCmd: 0x%x\n\r", bAscomCmd); + uart1_send((unsigned char*)buf, strlen(buf)); + } +#endif + + switch (bAscomCmd) + { + case 35: + //6c898: Goto + case 36: + //6c8a0: Sync + Data_40002c28.bData[0] = uart0ReceiveDataBuffer[1]; + Data_40002c28.bData[1] = uart0ReceiveDataBuffer[2]; + Data_40002c28.bData[2] = uart0ReceiveDataBuffer[3]; + Data_40002c28.bData[3] = uart0ReceiveDataBuffer[4]; + fData_40003510 = Data_40002c28.fData; + + Data_40002c28.bData[0] = uart0ReceiveDataBuffer[5]; + Data_40002c28.bData[1] = uart0ReceiveDataBuffer[6]; + Data_40002c28.bData[2] = uart0ReceiveDataBuffer[7]; + Data_40002c28.bData[3] = uart0ReceiveDataBuffer[8]; + fData_40003514 = Data_40002c28.fData; + //->6ca60 + break; + + case 37: + //6c92c: "Standort einstellen" + Data_40002c28.bData[0] = uart0ReceiveDataBuffer[1]; + Data_40002c28.bData[1] = uart0ReceiveDataBuffer[2]; + Data_40002c28.bData[2] = uart0ReceiveDataBuffer[3]; + Data_40002c28.bData[3] = uart0ReceiveDataBuffer[4]; + fData_40003518_ReceiveExternalSiteLongitude = Data_40002c28.fData; + + Data_40002c28.bData[0] = uart0ReceiveDataBuffer[5]; + Data_40002c28.bData[1] = uart0ReceiveDataBuffer[6]; + Data_40002c28.bData[2] = uart0ReceiveDataBuffer[7]; + Data_40002c28.bData[3] = uart0ReceiveDataBuffer[8]; + fData_4000351c_ReceiveExternalSiteLatitude = Data_40002c28.fData; + //->6ca60 + break; + + case 38: + //6c9bc: "Zeit einstellen" + Data_40003524_ReceiveExternalYear = uart0ReceiveDataBuffer[1] * 100 + + uart0ReceiveDataBuffer[2]; + bData_40003528_ReceiveExternalMonth = uart0ReceiveDataBuffer[3]; + bData_40003529_ReceiveExternalDay = uart0ReceiveDataBuffer[4]; + bData_4000352a_ReceiveExternalHours = uart0ReceiveDataBuffer[5]; + bData_4000352b_ReceiveExternalMinutes = uart0ReceiveDataBuffer[6]; + bData_4000352c_ReceiveExternalSeconds = uart0ReceiveDataBuffer[7]; + fData_40003520 = (float)uart0ReceiveDataBuffer[8] - 12; +#ifdef OLIMEX_LPC2148 + { + static char buf[105]; + + snprintf(buf, 100, "Date: %u-%u-%u\n\r", + Data_40003524_ReceiveExternalYear, + bData_40003528_ReceiveExternalMonth, + bData_40003529_ReceiveExternalDay); + uart1_send((unsigned char*)buf, strlen(buf)); + + snprintf(buf, 100, "Time: %u:%u:%u\n\r", + bData_4000352a_ReceiveExternalHours, + bData_4000352b_ReceiveExternalMinutes, + bData_4000352c_ReceiveExternalSeconds); + uart1_send((unsigned char*)buf, strlen(buf)); + + snprintf(buf, 100, "%d.%d\n\r", + (int)fData_40003520, + (fData_40003520 - (int)fData_40003520) * 1000); + uart1_send((unsigned char*)buf, strlen(buf)); + } +#endif + //->6ca60 + break; + + default: + //6ca58 + break; + } + + uart0ReceiveFlag = 0; + } //if (uart0ReceiveFlag == 1) + //6ca70 + return bAscomCmd; +} + +/* 6cb38 - complete */ +void ProcessAscomCommands(void) +{ + union + { + unsigned char bData[4]; + float fData; + } sp60, sp56; + unsigned char sp40[13]; + + sp40[0] = 0x55; + sp40[1] = 0xaa; + sp40[2] = 0x01; + sp40[3] = 0x09; + + bAscomCmd = ProcessUart0ReceiverData(); + + switch (bAscomCmd) + { + case 29: + //6cbd8: Abort Slew + StopSlewing(); + + bAscomCmd = 1; + //->6d044 + break; + + case 30: + //6cbf0: Park + func_75c4(); + + bGotoParkPosition = 1; + bAscomCmd = 1; + //->6d044 + break; + + case 31: + //6cc10: Get Site info + sp60.fData = dData_40002e28_SiteLongitude; + sp56.fData = dData_40002e48_SiteLatitude; + + sp40[4] = 0xfe; //Site information + sp40[5] = sp60.bData[0]; + sp40[6] = sp60.bData[1]; + sp40[7] = sp60.bData[2]; + sp40[8] = sp60.bData[3]; + sp40[9] = sp56.bData[0]; + sp40[10] = sp56.bData[1]; + sp40[11] = sp56.bData[2]; + sp40[12] = sp56.bData[3]; + + uart0_send(sp40, 13); + + bAscomCmd = 1; + //->6d044 + break; + + case 32: + //6cc98: Get DateTime + bAscomCmd = 1; + //->6d044 + break; + + case 33: + //6ccac: Get AlignmentMode + if (bData_40002c1a == 1) + { + //Alignment Mode Polar + sp40[4] = 0x50; + } + else if (bData_40002c1a == 2) + { + //Alignment Mode AltAz + sp40[4] = 0x41; + } + + uart0_send(sp40, 13); + + bAscomCmd = 1; + //->6d044 + break; + + case 34: + //6cd00: Disconnect + bAscomCmd = 0; + //->6d044 + break; + + case 35: + //6cd14: Goto + GotoEQCoordinates(fData_40003510, fData_40003514); + + dData_400031f0 = 0; + dData_400031f8 = 0; + bAscomCmd = 1; + //->6d044 + break; + + case 36: + //6cd7c: Sync + dData_40003410 = dData_400033d8; + dData_40003418 = -dData_400033e0; + dData_40003420 = dData_400033d8; + dData_40003428 = dData_400033e0; + bAscomCmd = 1; + //->6d044 + break; + + case 37: + //6cdd4: Set Site info + g_bSlewingStop = 1; + + StopSlewing(); + + dData_40002e28_SiteLongitude = fData_40003518_ReceiveExternalSiteLongitude; + dData_40002e48_SiteLatitude = fData_4000351c_ReceiveExternalSiteLatitude; + Data_40004128.geographicLongitude = fData_40003518_ReceiveExternalSiteLongitude; + Data_40004128.geographicLatitude = fData_4000351c_ReceiveExternalSiteLatitude; + bAscomCmd = 1; + //->6d044 + break; + + case 38: + //6ce50: Set DateTime + g_bSlewingStop = 1; + + StopSlewing(); + + Data_40002e54_Zone = fData_40003520; + Data_40004128.timeZone = fData_40003520; + + CCR = (1 << 4); //clock from the 32 kHz oscillator that�s connected to the RTCX1 and RTCX2 pins + YEAR = Data_40003524_ReceiveExternalYear; + MONTH = bData_40003528_ReceiveExternalMonth; + DOM = bData_40003529_ReceiveExternalDay; + HOUR = bData_4000352a_ReceiveExternalHours; + MIN = bData_4000352b_ReceiveExternalMinutes; + SEC = bData_4000352c_ReceiveExternalSeconds; + CCR = (1 << 4) | (1 << 0); //CLKEN = 1 + + bAscomCmd = 1; + //->6d044 + break; + + case 1: + //6cef8 + if (bData_4000352e > 2) + { + //6cf0c + if (bData_40002c1a == 2) + { + //6cf1c + double sp32, sp24; + convert_horizontal_to_equatorial(fData_40003508, fData_4000350c, &sp32, &sp24); + fData_40003508 = sp32; + fData_4000350c = sp24; + dData_40003448 = sp32; + dData_40003450 = sp24; + } + //6cfa8 + sp60.fData = fData_40003508; + sp56.fData = fData_4000350c; + + sp40[4] = 0xff; //Ra & Dec ---Tracked + sp40[5] = sp60.bData[0]; + sp40[6] = sp60.bData[1]; + sp40[7] = sp60.bData[2]; + sp40[8] = sp60.bData[3]; + sp40[9] = sp56.bData[0]; + sp40[10] = sp56.bData[1]; + sp40[11] = sp56.bData[2]; + sp40[12] = sp56.bData[3]; + + uart0_send(sp40, 13); + + bData_4000352e = 0; + //->6d038 + } + else + { + //6d024 + bData_4000352e++; + } + //6d038 -> 6d044 + break; + + default: + //6d03c + break; + } +} + diff --git a/applications/freertos_app/data.c b/applications/freertos_app/data.c new file mode 100644 index 0000000..233bec8 --- /dev/null +++ b/applications/freertos_app/data.c @@ -0,0 +1,687 @@ + +#include "my_types.h" +#include "data.h" + + +unsigned char sHwKeyQueue[8]; //40002bf8, size?? +unsigned char bHwKeyQueueReadPtr; //40002c00 +unsigned char bHwKeyQueueWritePtr; //40002c01 +unsigned char bData_40002c02; //40002c02 +unsigned char bData_40002c03; //40002c03 +unsigned char bHwKeyCode; //40002c04 +unsigned char bData_40002c05; //40002c05 +unsigned char bTimer10msCounter; //40002c06 +unsigned char bData_40002c07; //40002c07 +unsigned char bData_40002c08; //40002c08 +unsigned char bData_40002c09; //40002c09 +unsigned char bData_40002c0a_uart0ReceiveDataCount; //40002c0a +char uart0ReceiveFlag; //40002c0b +unsigned char bData_40002c0c_uart0ReceiveStep; //40002c0c +unsigned char Data_40002c0d_uart0ReceiveHeader[4]; //40002c0d +unsigned char uart0_bRxData; //40002c11 +unsigned char bData_40002c12_uart1ReceiveDataCount; //40002c12 +char bData_40002c13_uart1ReceiveComplete; //40002c13 +unsigned char bData_40002c14_uart1ReceiveStep; //40002c14 +unsigned char bData_40002c15_uart1ReceiveHeader[4]; //40002c15 +unsigned char uart1_bRxData; //40002c19 +unsigned char bData_40002c1a; //40002c1a // V2.2: 40002c1e +int Data_40002c1c; //40002c1c +int Data_40002c20; //40002c20 +Union_40002c24 Data_40002c24; //40002c24 +Union_40002c28 Data_40002c28; //40002c28 +int fill_40002c2c; //40002c2c +int fill_40002c30; //40002c30 +int fill_40002c34; //40002c34 +int fill_40002c38; //40002c38 +int fill_40002c3c; //40002c3c +int fill_40002c40; //40002c40 +int fill_40002c44; //40002c44 +int fill_40002c48; //40002c48 +int fill_40002c4c; //40002c4c +int fill_40002c50; //40002c50 +int fill_40002c54; //40002c54 +char bHelpActive; //40002c58 +unsigned char bData_40002c59_MainScreenHelpPage; //40002c59 +char bData_40002c5a; //40002c5a +int Data_40002c5c_AlignmentStarCount; //40002c5c +unsigned char bData_40002c60_CurrentAlignStarIndex; //40002c60 +unsigned char bData_40002c61; //40002c61 +unsigned char bData_40002c62_AlignmentStarMode; //40002c62 +int Data_40002c64_MenuContextId; //40002c64 +char bData_40002c68; //40002c68 +unsigned char bData_40002c69_KeyCode; //40002c69 +char bDaylightSavingTime; //40002c6a +double dObjectRiseTime; //40002c70 +double dObjectTransitTime; //40002c78 +double dObjectSetTime; //40002c80 +double dData_40002c88; //40002c88 +double dData_40002c90; //40002c90 +double dTrackingRate; //40002c98 +double dGuidingSpeed; //40002ca0 +double g_dPoleAxisDevEastWest; //40002ca8 +double g_dPoleAxisDevNorthSouth; //40002cb0 +int Data_40002cb8; //40002cb8 +int Data_40002cbc; //40002cbc +float fData_40002cc0; //40002cc0 +double dData_40002cc8; //40002cc8 +float fData_40002cd0_ObjectRightAscension; //40002cd0 +int fill_40002cd4; //40002cd0 +int Data_40002cd8_ObjectRightAscensionHours; //40002cd8 +int Data_40002cdc_ObjectRightAscensionMinutes; //40002cdc +float fData_40002ce0_ObjectRightAscensionSeconds; //40002ce0 +double g_dObjectRightAcension; //40002ce8 +int fill_40002cf0; //40002cf0 +int Data_40002cf4; //40002cf4 +int Data_40002cf8; //40002cf8 +float fData_40002cfc; //40002cfc +int Data_40002d00_ObjectDeclinationDegrees; //40002d00 +int Data_40002d04_ObjectDeclinationMinutes; //40002d04 +float fData_40002d08_ObjectDeclinationSeconds; //40002d08 +double dData_40002d10; //40002d10 +float fData_40002d18_ObjectDeclination; //40002d18 +int fill_40002d1c; //40002d1c +int Data_40002d20; //40002d20 +int Data_40002d24; //40002d24 +float fData_40002d28; //40002d28 +double dData_40002d30; //40002d30 +int fill_40002d38; //40002d38 +int fill_40002d3c; //40002d3c +int Data_40002d40; //40002d40 +int g_iObjectDeclinationSign; //40002d44 +int Data_40002d48; //40002d48 +int Data_40002d4c; //40002d4c +float fData_40002d50; //40002d50 +double dData_40002d58; //40002d58 +int fill_40002d60; //40002d60 +int fill_40002d64; //40002d64 +int Data_40002d68_OTARightAscensionHours; //40002d68 +int Data_40002d6c_OTARightAscensionMinutes; //40002d6c +float fData_40002d70_OTARightAscensionSeconds; //40002d70 +double dData_40002d78; //40002d78 +double g_dMotorPositionRaAxis; //40002d80 +char bData_40002d88; //40002d88 +int Data_40002d8c_OTADeclinationDegrees; //40002d8c +int Data_40002d90_OTADeclinationMinutes; //40002d90 +float fData_40002d94_OTADeclinationSeconds; //40002d94 +double dData_40002d98; //40002d98 +double g_dMotorPositionDecAxis; //40002da0 +char bData_40002da8; //40002da8 +int Data_40002dac; //40002dac +int Data_40002db0; //40002db0 +float fData_40002db4; //40002db4 +double g_dMotorPositionAziAxis; //40002db8 +double dData_40002dc0_Azimuth; //40002dc0 +double dRaBklashCorrStartAzimuth; //40002dc8 +double dData_40002dd0; //40002dd0 +int fill_40002dd8; //40002dd8 +int fill_40002ddc; //40002ddc +int Data_40002de0; //40002de0 +int Data_40002de4; //40002de4 +float fData_40002de8; //40002de8 +double g_dMotorPositionAltAxis; //40002df0 +double dData_40002df8; //40002df8 +double dData_40002e00; //40002e00 +double dData_40002e08; //40002e08 +int fill_40002e10; //40002e10 +int fill_40002e14; //40002e14 +int Data_40002e18_SiteLongitudeDegrees; //40002e18 +int Data_40002e1c_SiteLongitudeMinutes; //40002e1c +float fData_40002e20_SiteLongitudeSeconds; //40002e20 +double dData_40002e28_SiteLongitude; //40002e28 +float fCustomSiteLongitude; //40002e30 +int Data_40002e34; //40002e34 +int Data_40002e38_SiteLatitudeDegrees; //40002e38 +int Data_40002e3c_SiteLatitudeMinutes; //40002e3c +float fData_40002e40_SiteLatitudeSeconds; //40002e40 +int Data_40002e44; //40002e44 +double dData_40002e48_SiteLatitude; //40002e48 +float fCustomSiteLatitude; //40002e50 +int Data_40002e54_Zone; //40002e54 +int iCustomSiteTimeZone; //40002e58 +unsigned Data_40002e5c_Year; //40002e5c +unsigned char bData_40002e60_Month; //40002e60 +unsigned char bData_40002e61_Day; //40002e61 +unsigned char bData_40002e62_Hours; //40002e62 +unsigned char bData_40002e63_Minutes; //40002e63 +unsigned char bData_40002e64_Seconds; //40002e64 +unsigned short wRtcMilliSeconds; //40002e66 +int fill_40002e68; //40002e68 +int fill_40002e6c; //40002e6c +int fill_40002e70; //40002e70 +int fill_40002e74; //40002e74 +unsigned char bDateTimeInputMode; //40002e78 +unsigned char bData_40002e79_SkyLandTargetSeletion; //40002e79 +unsigned char bData_40002e7a_MountType; //40002e7a +unsigned char bData_40002e7b_GpsAvailable; //40002e7b +unsigned char bData_40002e7c_TrackingRateType; //40002e7c +unsigned char g_eSlewRateIndex; //40002e7d +char bData_40002e7e; //40002e7e +int Data_40002e80; //40002e80 +int Data_40002e84; //40002e84 +unsigned char bTrackingMode; //40002e88 +char g_bSlewingStop; //40002e89 +unsigned char bTrackingModeMenu; //40002e8a +char bData_40002e8b; //40002e8b +char bData_40002e8c; //40002e8c +float fData_40002e90; //40002e90 +float Data_40002e94; //40002e94 +float fData_40002e98; //40002e98 +float Data_40002e9c; //40002e9c +float fData_40002ea0; //40002ea0 +float fData_40002ea4; //40002ea4 +float fData_40002ea8; //40002ea8 +float fData_40002eac; //40002eac +int iBacklashCorrectionSlewing; //40002eb0 +unsigned char bData_40002eb4; //40002eb4 +unsigned char bData_40002eb5_SolarSystemObjectNr; //40002eb5 +unsigned short wData_40002eb6; //40002eb6 +unsigned short wData_40002eb8_MessierNr; //40002eb8 +unsigned short wData_40002eba_NGCNr; //40002eba +unsigned short wData_40002ebc_ICNr; //40002ebc +unsigned short wData_40002ebe_ShNr; //40002ebe +unsigned short wData_40002ec0_BrightStarNr; //40002ec0 +unsigned int Data_40002ec4_SAONr; //40002ec4 +unsigned int Data_40002ec8_NavigationDirectInputNr; //40002ec8 +unsigned short wData_40002ecc; //40002ecc +unsigned char bData_40002ece_ConstellationNr; //40002ece +unsigned short wData_40002ed0; //40002ed0 +unsigned char bData_40002ed2_FamousStarNr; //40002ed2 +unsigned short wData_40002ed4; //40002ed4 +unsigned short wData_40002ed6; //40002ed6 +unsigned short wData_40002ed8; //40002ed8 +unsigned short wData_40002eda; //40002eda +unsigned char bData_40002edc; //40002edc +unsigned char bData_40002edd; //40002edd +char bData_40002ede; //40002ede +char bData_40002edf; //40002edf +int fill_40002ee0; //40002ee0 +int fill_40002ee4; //40002ee4 +int fill_40002ee8; //40002ee8 +int fill_40002eec; //40002eec +int fill_40002ef0; //40002ef0 +unsigned short fill_40002ef4; //40002ef4 +char bData_40002ef6; //40002ef6 +char bData_40002ef7; //40002ef7 +int Data_40002ef8; //40002ef8 +float fData_40002efc; //40002efc +float fData_40002f00; //40002f00 +int Data_40002f04; //40002f04 +int Data_40002f08; //40002f08 +char bData_40002f0c; //40002f0c +unsigned char bData_40002f0d_RecentTargetType; //40002f0d +int bData_40002f10_RecentTargetId; //40002f10 +unsigned char bData_40002f14_RecentTargetCount; //40002f14 +unsigned char Data_40002f15_RecentTargetTypeArray[8]; //40002f15, size??? +unsigned char bData_40002f1d; //40002f1d +char bData_40002f1e_SetupLocalData; //40002f1e + +char* strTelescopeAlign; //40002f20 +char* strNavigation; //40002f24 +char* strUtilities; //40002f28 +char* strSetup; //40002f2c +char* strOneStarAlign; //40002f30 +char* strTwoStarAlign; //40002f34 +char* strThreeStarAlign; //40002f38 +char* strTargetSync; //40002f3c +char* strPoleAxisDev; //40002f40 +char* strRaBklashCorr; //40002f44 +char* strDecBklashCorr; //40002f48 +char* Data_40002f4c; //40002f4c +char* Data_40002f50; //40002f50 +char* Data_40002f54; //40002f54 +char* Data_40002f58; //40002f58 +char* strSolarSystem; //40002f5c +char* strConstellation; //40002f60 +char* strFamousStar; //40002f64 +char* Data_40002f68; //40002f68 +char* Data_40002f6c; //40002f6c +char* Data_40002f70; //40002f70 +char* Data_40002f74; //40002f74 +char* Data_40002f78; //40002f78 +char* Data_40002f7c; //40002f7c +char* Data_40002f80; //40002f80 +char* Data_40002f84; //40002f84 +char* Data_40002f88; //40002f88 +char* strCurrentObjects; //40002f8c +char* Data_40002f90; //40002f90 +char* Data_40002f94; //40002f94 +char* Data_40002f98; //40002f98 +char* Data_40002f9c; //40002f9c +char* Data_40002fa0; //40002fa0 +char* Data_40002fa4; //40002fa4 +char* Data_40002fa8; //40002fa8 +char* strParkposition; //40002fac +char* Data_40002fb0; //40002fb0 +char* strTimeAndDate; //40002fb4 +char* Data_40002fb8; //40002fb8 +char* Data_40002fbc; //40002fbc +char* Data_40002fc0; //40002fc0 +char* Data_40002fc4; //40002fc4 +char* strTelescopeMount; //40002fc8 +char* strTrackingRate; //40002fcc +char* Data_40002fd0; //40002fd0 +char* strReset; //40002fd4 +char* Data_40002fd8; //40002fd8 +char* Data_40002fdc; //40002fdc +char* Data_40002fe0; //40002fe0 +char* Data_40002fe4; //40002fe4 +char* Data_40002fe8; //40002fe8 +char* Data_40002fec; //40002fec +char* Data_40002ff0; //40002ff0 +char* Data_40002ff4; //40002ff4 +char* Data_40002ff8; //40002ff8 +char* Data_40002ffc; //40002ffc +char* Data_40003000; //40003000 +char* Data_40003004; //40003004 +char* Data_40003008; //40003008 +char* Data_4000300c; //4000300c +char* Data_40003010; //40003010 +char* Data_40003014; //40003014 +char* Data_40003018; //40003018 +char* Data_4000301c; //4000301c +char* Data_40003020; //40003020 +char* Data_40003024; //40003024 +char* strScientificName; //40003028 +char* strSAOCatalog; //4000302c +char* strHRCatalog; //40003030 +char* strSelect; //40003034 +char* strAdd; //40003038 +char* strDelete; //4000303c +char* strModify; //40003040 +char* Data_40003044; +char* Data_40003048; +char* Data_4000304c; +char* strEyeshot; //40003050 +char* strRatio; //40003054 +char* strBackBoard; //40003058 +char* strAccessory; //4000305c +char* strCountryAndCity; //40003060 +char* strCustomSite; //40003064 +char* Data_40003068; +char* Data_4000306c; +char* Data_40003070; +char* Data_40003074; +char* Data_40003078; +char* Data_4000307c; +char* Data_40003080; +char* Data_40003084; +char* strStarSpeed; //40003088 +char* strSolarSpeed; //4000308c +char* strMoonSpeed; //40003090 +char* Data_40003094; +char* Data_40003098; +char* strListAlignStars; //4000309c +char* strSlewingTo; //400030a0 +char* strAutoloadAlignStars; //400030a4 +char* Data_400030a8; +char* Data_400030ac; +char* Data_400030b0; +char* Data_400030b4; +char* Data_400030b8; +char* Data_400030bc; +char* strThereIsNoTele; //400030c0 +char* strScopeToConnectThis; //400030c4 +char* strControlTerminal; //400030c8 +char* strPleaseAimAtThe; //400030cc +char* strTelescopeToDistant; //400030d0 +char* strTargetThenPress; //400030d4 +char* strEnterKey; //400030d8 +char* Data_400030dc; +char* Data_400030e0; +char* Data_400030e4; +char* Data_400030e8; +char* Data_400030ec; +char* Data_400030f0; +char* Data_400030f4; +char* Data_400030f8; +char* Data_400030fc; +char* Data_40003100; +char* Data_40003104; +char* Data_40003108; +char* Data_4000310c; +char* Data_40003110; +char* Data_40003114; //40003114 +int fill_40003118; //40003118 +int fill_4000311c; //4000311c +int fill_40003120; //40003120 +int fill_40003124; //40003124 +int fill_40003128; //40003128 +int fill_4000312c; //4000312c +int fill_40003130; //40003130 +int fill_40003134; //40003134 +int fill_40003138; //40003138 +int fill_4000313c; //4000313c +char* Data_40003140; //40003140 +unsigned char bCurrentCustomSiteInputLine; //40003144 +int fill_40003148; //40003148 +char* Data_4000314c_SolarSystemObjectName; //4000314c +char Data_40003150[8]; //40003150, size?? +char fill_40003158; //40003158 +char arCustomSiteName[8]; //40003159, size?? +unsigned char bData_40003161; //40003161 +char bData_40003162; //40003162 +int Data_40003164_LunarPhaseYear; //40003164 +int Data_40003168_LunarPhaseMonth; //40003168 +char fill_4000316c; //4000316c +unsigned char bData_4000316d; //4000316d +unsigned char bData_4000316e_FocusLineOn8LineDisplay; //4000316e +unsigned char bData_4000316f_FocusLineOn4LineDisplay; //4000316f +unsigned char bData_40003170; //40003170 +unsigned char bData_40003171; //40003171 +unsigned char bData_40003172; //40003172 +unsigned char bData_40003173; //40003173 +unsigned char bData_40003174; //40003174 +unsigned char bData_40003175; //40003175 +unsigned char bData_40003176; //40003176 +unsigned char bData_40003177; //40003177 +unsigned char bData_40003178; //40003178 +unsigned char bData_40003179; //40003179 +unsigned char bData_4000317a; //4000317a +unsigned char bData_4000317b; //4000317b +unsigned char bData_4000317c; //4000317c +unsigned char bData_4000317d; //4000317d +unsigned char bData_4000317e; //4000317e +unsigned char bData_4000317f; //4000317f +unsigned char bData_40003180; //40003180 +char fill_40003181; //40003181 +unsigned char bData_40003182; //40003182 +char fill_40003183; //40003183 +unsigned char bData_40003184; //40003184 +char fill_40003185; //40003185 +unsigned char bData_40003186; //40003186 +char fill_40003187; //40003187 +char bRaBacklashCorrectionDirection; //40003188 +char bDecBacklashCorrectionDirection; //40003189 +unsigned char bCharacterInputPosition; //4000318a +int Data_4000318c; //4000318c +int Data_40003190; //40003190 +char bData_40003194; //40003194 +unsigned char bData_40003195; //40003195 +unsigned char bData_40003196_CurrentLanguage; //40003196 +unsigned char bData_40003197_DisplayLinesPerMenuLine; //40003197 +char bCapsLock; //40003198 +unsigned char bMapKeyToCharIndex; //40003199 +unsigned char bData_4000319a_SkyLandTargetId; //4000319a +char bData_4000319b; //4000319b +char g_bSingleSlewActive; //4000319c +char g_bCombinedSlewActive; //4000319d +Union_400031a0 Data_400031a0; //400031a0 +Union_400031a0 g_stCurrentSlewRampValue; //400031a4 +int Data_400031a8; //400031a8 +Union_400031a0 Data_400031ac; //400031ac +int fill_400031b0; //400031b0 +int g_iCurrentSlewRampIndex; //400031b4 +char g_bMaxSlewRampActive; //400031b8 +char bData_400031b9; //400031b9 +char bData_400031ba; //400031ba +char bData_400031bb; //400031bb +char bData_400031bc; //400031bc +char bData_400031bd; //400031bd +char bData_400031be; //400031be +unsigned char bData_400031bf; //400031bf +float fData_400031c0; //400031c0 +float fData_400031c4; //400031c4 +int fill_400031c8; //400031c8 +int fill_400031cc; //400031cc +int fill_400031d0; //400031d0 +int fill_400031d4; //400031d4 +int fill_400031d8; //400031d8 +int fill_400031dc; //400031dc +char bData_400031e0; //400031e0 +char bData_400031e1; //400031e1 +int Data_400031e4; //400031e4 +unsigned char bCustomerObjectNameChar; //400031e8 +char bData_400031e9; //400031e9 +char g_bTargetSyncOpen; //400031ea +char bData_400031eb; //400031eb +char bData_400031ec; //400031ec +char bSystemInitialized; //400031ed +double dData_400031f0; //400031f0 +double dData_400031f8; //400031f8 +char bData_40003200; //40003200 +char bData_40003201; //40003201 +int iMountAutoguideRa; //40003204 +int iMountAutoguideDec; //40003208 +int fill_4000320c; //4000320c +char bData_40003210; //40003210 +char bData_40003211; //40003211 +int Data_40003214_UserTimerSeconds; //40003214 +int fill_40003218; //40003218 +int fill_4000321c; //4000321c +int Data_40003220_AlarmHours; //40003220 +int Data_40003224_AlarmMinutes; //40003224 +int Data_40003228_AlarmSeconds; //40003228 +char bData_4000322c; //4000322c +char bData_4000322d_AlarmTimeElapsed; //4000322d +float fMainFocalLength; //40003230 +float fSecondaryFocalLength; //40003234 +float fEyepieceMagnification; //40003238 +float fEyepieceFOV; //4000323c +float fFieldOfView; //40003240 +int fill_40003244; //40003244 +int Data_40003248_CurrentDisplayPWM; //40003248 +int fill_4000324c; //4000324c +unsigned short wData_40003250; //40003250 +unsigned short wData_40003252; //40003252 +unsigned short fill_40003254; //40003254 +unsigned short wData_40003256; //40003256 +unsigned char bData_40003258; //40003258 +unsigned short wData_4000325a; //4000325a +unsigned char bData_4000325c; //4000325c +char fill_4000325d; //4000325d +char fill_4000325e; //4000325e +char fill_4000325f; //4000325f +unsigned char bData_40003260; //40003260 +unsigned char bData_40003261; //40003261 +unsigned char bData_40003262; //40003262 +unsigned char bData_40003263; //40003263 +char fill_40003264; //40003264 +unsigned char bData_40003265; //40003265 +int fill_40003268; //40003268 +int fill_4000326c; //4000326c +int fill_40003270; //40003270 +int fill_40003274; //40003274 +int fill_40003278; //40003278 +unsigned short fill_4000327c; //4000327c +char fill_4000327e; //4000327e +unsigned char Data_4000327f[8]; //4000327f, size??? +float fData_40003288; //40003288 +float fData_4000328c; //4000328c +Struct_40003290 Data_40003290; //40003290 +Struct_40003296 Data_40003296; //40003296 +float fData_4000329c; //4000329c +float fData_400032a0; //400032a0 +unsigned char bData_400032a4_OTAZeroDataErrorCount; //400032a4 +double fill_400032a8; //400032a8 +double dData_400032b0_SunRightAscension; //400032b0 +double dData_400032b8_SunDeclination; //400032b8 +double dData_400032c0_MoonRightAscension; //400032c0 +double dData_400032c8_MoonDeclination; //400032c8 +double dData_400032d0; //400032d0 +double dData_400032d8; //400032d8 +double dData_400032e0; //400032e0 +double dData_400032e8; //400032e8 +double dData_400032f0; //400032f0 +double dData_400032f8; //400032f8 +double dData_40003300; //40003300 +double dData_40003308; //40003308 +double dData_40003310; //40003310 +double dData_40003318; //40003318 +double dData_40003320; //40003320 +double dData_40003328; //40003328 +double dData_40003330; //40003330 +double dData_40003338; //40003338 +double dData_40003340; //40003340 +double dData_40003348; //40003348 +Struct_Sh2Data Data_40003350_FlashSh2Data; //40003350 +Struct_SAOData Data_40003358_SAORecord; //40003358 +char* Data_40003360; //40003360 +char* Data_40003364; //40003364 +unsigned char* Data_40003368; //40003368 +char* Data_4000336c; //4000336c +char* Data_40003370; //40003370 +char* Data_40003374; //40003374 +char* Data_40003378; //40003378 +char* Data_4000337c; //4000337c +char* Data_40003380; //40003380 +char* Data_40003384; //40003384 +char* Data_40003388; //40003388 +char* Data_4000338c; //4000338c +char* Data_40003390; //40003390 +char* Data_40003394; //40003394 +char* Data_40003398; //40003398 +char* Data_4000339c; //4000339c +char* Data_400033a0; //400033a0 +char* Data_400033a4; //400033a4 +char* Data_400033a8; //400033a8 +char* Data_400033ac; //400033ac +char* Data_400033b0; //400033b0 +char* Data_400033b4; //400033b4 +int fill_400033b8; //400033b8 +int fill_400033bc; //400033bc +int fill_400033c0; //400033c0 +int fill_400033c4; //400033c4 +Union_400033c8 Data_400033c8; //400033c8 +Union_400033cc Data_400033cc; //400033cc +double fill_400033d0; //400033d0 +double dData_400033d8; //400033d8 +double dData_400033e0; //400033e0 +double dData_400033e8; //400033e8 +double dData_400033f0; //400033f0 +double g_dSlewRateRaAxis; //400033f8 +double g_dSlewRateDecAxis; //40003400 +int g_iSlewStepRaAxis; //40003408 +int g_iSlewStepDecAxis; //4000340c +double dData_40003410; //40003410 +double dData_40003418; //40003418 +double dData_40003420; //40003420 +double dData_40003428; //40003428 +char bData_40003430; //40003430 +char bGotoParkPosition; //40003431 +char bData_40003432; //40003432 +double fill_40003438; //40003438 +double fill_40003440; //40003440 +double dData_40003448; //40003448 +double dData_40003450; //40003450 +double dData_40003458; //40003458 +double dData_40003460; //40003460 +double fill_40003468; //40003468 +double fill_40003470; //40003470 +double fill_40003478; //40003478 +double fill_40003480; //40003480 +int Data_40003488; //40003488 +int Data_4000348c; //4000348c +double dData_40003490; //40003490 +char bData_40003498; //40003498 +double dData_400034a0_SiderealTimeGreenwich0UT; //400034a0 +unsigned char numVisibleAlignmentStars; //400034a8 +char g_bLandTarget; //400034a9 +char bData_400034aa; //400034aa +float fData_400034ac; //400034ac +float fData_400034b0; //400034b0 +char bData_400034b4; //400034b4 +char bData_400034b5; //400034b5 +float fData_400034b8; //400034b8 +float fData_400034bc; //400034bc +float fData_400034c0; //400034c0 +float fData_400034c4; //400034c4 +float fData_400034c8; //400034c8 +char bData_400034cc; //400034cc +char bData_400034cd; //400034cd +double Data_400034d0; //400034d0 +double Data_400034d8; //400034d8 +double dData_400034e0; //400034e0 +double dData_400034e8; //400034e8 +double dData_400034f0; //400034f0 +double dData_400034f8; //400034f8 +Union_40003500 Data_40003500; //40003500 +unsigned char bData_40003504; //40003504 +char bData_40003505; //40003505 +float fData_40003508; //40003508 +float fData_4000350c; //4000350c +float fData_40003510; //40003510 +float fData_40003514; //40003514 +float fData_40003518_ReceiveExternalSiteLongitude; //40003518 +float fData_4000351c_ReceiveExternalSiteLatitude; //4000351c +float fData_40003520; //40003520 +int Data_40003524_ReceiveExternalYear; //40003524 +unsigned char bData_40003528_ReceiveExternalMonth; //40003528 +unsigned char bData_40003529_ReceiveExternalDay; //40003529 +unsigned char bData_4000352a_ReceiveExternalHours; //4000352a +unsigned char bData_4000352b_ReceiveExternalMinutes; //4000352b +unsigned char bData_4000352c_ReceiveExternalSeconds; //4000352c +unsigned char bAscomCmd; //4000352d +unsigned char bData_4000352e; //4000352e +int fill_40003530; //40003530 +int fill_40003534; //40003534 +int fill_40003538; //40003538 +int fill_4000353c; //4000353c +float fInitialCustomSiteLongitude; //40003540 +float fInitialCustomSiteLatitude; //40003544 +int iInitialCustomSiteTimezone; //40003548 +int fill_4000354c; //4000354c +int fill_40003550; //40003550 +int fill_40003554; //40003554 +int fill_40003558; //40003558 +int fill_4000355c; //4000355c +int fill_40003560; //40003560 +int fill_40003564; //40003564 +int fill_40003568; //40003568 +int fill_4000356c; //4000356c +int fill_40003570; //40003570 +int fill_40003574; //40003574 +int fill_40003578; //40003578 +int fill_4000357c; //4000357c +int fill_40003580; //40003580 +int fill_40003584; //40003584 +unsigned char uart0ReceiveDataBuffer[10]; //40003588 +unsigned char Data_40003592_uart1ReceiveDataBuffer[10]; //40003592 +int Data_4000359c_RecentTargetIdArray[8]; //4000359c, size?? +unsigned char Data_400035bc[528]; //400035bc +char strTrackingRateCustInput[16]; //400037cc +char strTrackingRateCustDisplay[16]; //400037dc +char Data_400037ec[12]; //400037ec, size??? +float Data_400037f8[60]; //400037f8, size??? +unsigned char Data_400038e8[30][10]; //400038e8, size??? +unsigned char arAlignmentStarNames[28][10]; //40003a14, size?? +unsigned char Data_40003b2c[28][22]; //40003b2c, size?? +Struct_FamousStarData Data_40003d94_FlashFamousStarData; //40003d94 +Struct_ConstellationData Data_40003dd4_FlashConstellationData; //40003dd4 +Struct_MessierData Data_40003e08_FlashMessierData; //40003e08 +Struct_BrightStarData Data_40003ea0_FlashBrightStarData; //40003ea0 +Struct_ICData Data_40003ec0_FlashICData; //40003ec0 +Struct_NGCData Data_40003ee0_FlashNGCData; //40003ee0 +Struct_SiteData Data_40003f1c_FlashSiteData; //40003f1c +Struct_5218 Data_40003f50; //40003f50 +Struct_54e0 Data_40003f64; //40003f64 +unsigned char Data_40003f78[24]; //40003f78 +unsigned char Data_40003f90[25]; //40003f90, size??? +char Data_40003fa9[21]; //40003fa9, size??? +char Data_40003fbe[21]; //40003fbe, size??? +char Data_40003fd3[21]; //40003fd3, size??? +char Data_40003fe8[21]; //40003fe8, size??? +char Data_40003ffd[21]; //40003ffd, size??? +char Data_40004012[21]; //40004012, size??? +char Data_40004027[21]; //40004027, size??? +char Data_4000403c[42]; //4000403c, size??? +char Data_40004066[42]; //40004066, size??? +char Data_40004090[42]; //40004090, size??? +char Data_400040ba[42]; //400040ba, size??? +char Data_400040e4[42]; //400040e4, size??? +/*unsigned*/ char Data_4000410e[21]; //4000410e, size??? +Struct_40004128 Data_40004128; //40004128 +Struct_40004380 Data_40004380; //40004380 +int fill_40004380_[430]; //4000438???? +#if 0 +float Data_40004a68_CurrentAlignStarEquatorialCoord[2][2]; //40004a68 +#else +float Data_40004a68_CurrentAlignStarEquatorialCoord[28]; //40004a68 +#endif +Struct_GeographicCoordinates Data_40004ad8; //40004ad8 +Struct_EquatorialCoordinates Data_40004ae8; //40004ae8 +Struct_HorizontalCoordinates Data_40004b08; //40004b08 +Struct_EquatorialCoordinates Data_40004b50; //40004b50 +Struct_HorizontalCoordinates Data_40004b70; //40004b70 +unsigned char arInitialCustomSiteName[160]; //40004bb8 size??? +unsigned char Data_40004c58[100]; //40004c58, size? + diff --git a/applications/freertos_app/data.h b/applications/freertos_app/data.h new file mode 100644 index 0000000..dfab5c3 --- /dev/null +++ b/applications/freertos_app/data.h @@ -0,0 +1,807 @@ + + +#define _PI_180 0.0174532925199444438613127772442 + +typedef union +{ + unsigned char bData[4]; + int dwData; +} Union_400033c8; //400033c8 + +typedef union +{ + unsigned char bData[4]; + int dwData; +} Union_400033cc; //400033cc + +typedef union +{ + unsigned char bData[2]; + unsigned short wData; +} Union_40002c24; + +typedef union +{ + unsigned char bData[4]; + int Data; + float fData; +} Union_40002c28; + +typedef union +{ + unsigned char bData[4]; + int Data; +} Union_400031a0; + +typedef union +{ + unsigned char bData[4]; + int dwData; +} Union_40003500; //40003500 + +typedef struct +{ + int Data_0; //0 + double dData_8; //8 + double dData_16; //16 + double dData_24; //24 + double dData_32; //32 + int Data_40; //40 + unsigned char bData_44; //44 + double geographicLongitude; //48 + double geographicLatitude; //56 + int timeZone; //64 + int Data_68; //68 + double dObjRectascension; //72 + double dObjDeclination; //80 + double dData_88; //88 + double dJulianDay; //96 + double dFractionalDay; //104 + double dData_112; //112 + double dData_120; //120 + double dObjPositionRaAxis; //128 + double dObjPositionDecAxis; //136 + double dObjHourAngleDisplay; //144 + double dObjDeclinationDisplay; //152 + double dTargetPositionRaAxis; //160 + double dTargetPositionDecAxis; //168 + double dData_176; //176 + double dData_184; //184 + double dData_192; //192 + double dData_200; //200 + double dMotorPositionRaAxis; //208 + double dMotorPositionDecAxis; //216 + double dRaPositionDelta; //224 + double dDecPositionDelta; //232 + double dData_240; //240 + double dData_248; //248 + double dData_256; //256 + double dData_264; //264 + double dData_272; //272 + double dData_280; //280 + double dData_288; //288 + double dData_296; //296 + double dData_304; //304 + double dData_312; //312 + int fill_320[2]; //320 + double dOffsetRa; //328 + double dOffsetDec; //336 + char bData_344; //344 + char bData_345; //345 + int Data_348; //348 + int alignmentPause; //352 + unsigned char bTrackingActive; //356 + unsigned char bTrackingRequest; //357 + unsigned char bData_358; //358 + int numAlignmentStars; //360 + unsigned char bAlignmentComplete; //364 + char bData_365; //365 + int Data_368; //368 + int alignmentStarIndex; //372 + double dFirstAlignmentStarRa; //376 + double dFirstAlignmentStarDec; //384 + double dSecondAlignmentStarRa; //392 + double dSecondAlignmentStarDec; //400 + double dThirdAlignmentStarRa; //408 + double dThirdAlignmentStarDec; //416 + double dData_424; //424 + double dData_432; //432 + double dData_440; //440 + double dData_448; //448 + double dData_456; //456 + double dData_464; //464 + double dData_472; //472 + double dData_480; //480 + double dData_488; //488 + double dData_496; //496 + double dData_504; //504 + double dData_512; //512 + double dData_520; //520 + double dData_528; //528 + double dData_536; //536 + double dData_544; //544 + double dData_552; //552 + double dData_560; //560 + double dData_568; //568 + double dData_576; //576 + double dAutoguideRa; //584 + double dAutoguideDec; //592 + +} Struct_40004128; + +typedef struct +{ + double dData_0; //0 + double dData_8; //8 + double dData_16; //16 + double dData_24; //24 + double dData_32; //32 + double dData_40; //40 + +} Struct_40004380; + +extern char strCustomerObjectRaAziInputForTracking[]; //400022f2 +extern char Data_40002302[]; //40002302 +extern char strEngTelescopeOneMX51[]; //40002387 +extern char Data_4000239a[]; //4000239a +extern char Data_40002474[]; //40002474 +extern char Data_40002481[]; //40002487 +extern char Data_4000248c[]; //4000248c +extern char Data_400024a1[]; //400024a1 +extern char Data_400024b5[]; //400024b5 +extern char Data_400024c9[]; //400024c9 +extern char Data_400024d6[]; //400024d6 +extern char Data_400024e1[]; //400024e1 +extern char Data_400024ef[]; //400024ef +extern char Data_40002504[]; //40002504 +extern unsigned char Data_4000251d[]; //4000251d +extern unsigned char Data_4000253d[]; //4000253d +extern unsigned char Data_4000255d[]; //4000255d +extern unsigned char Data_4000257e[]; //4000257e +extern unsigned char Data_4000258c[]; //4000258c +extern unsigned char Data_400025a0[]; //400025a0 +extern unsigned char Data_400025b5[]; //400025b5 +extern unsigned char Data_400025d9[]; //400025d9 +extern unsigned char Data_400025fe[]; //400025fe +extern unsigned char Data_40002625[]; //40002625 +extern unsigned char Data_40002634[]; //40002634 +extern unsigned char Data_40002644[]; //40002644 +extern char Data_40002655[]; //40002655 +extern char Data_40002660[]; //40002660 +extern unsigned char Data_400026c3[]; //400026c3 +extern unsigned char Data_400026db[]; //400026db +extern unsigned char Data_400026f3[]; //400026f3 +extern unsigned char Data_4000270a[]; //4000270a +extern unsigned char Data_4000271a[]; //4000271a +extern unsigned char Data_40002789[]; //40002789 +extern unsigned char Data_40002792[]; //40002792 +extern char strInputRaDec[]; //400027cf +extern unsigned char strCustomerObjectRaAziInputForStoring[]; //400027df +extern unsigned char strCustomerObjectDecAltInputForStoring[]; //400027ef +extern unsigned char strCustomerObjectNameInput[]; //400027ff +extern unsigned char strCustomSiteName[]; //40002827 +extern unsigned char strCustomSiteLongitude[]; //40002837 +extern unsigned char strCustomSiteLatitude[]; //40002847 +extern unsigned char strCustomSiteTimezone[]; //40002856 +extern unsigned char strCustomSiteAltitude[]; //40002861 +extern char strSkyTarget[]; //4000288e +extern char strLandTarget[]; //40002899 +extern char Data_400028a5[]; //400028a5 +extern char Data_400028b3[]; //400028b3 +extern char strEngPleaseSetupOtaZero[]; //400028c1 +extern unsigned char Data_400028d7[]; //400028d7 +extern unsigned char Data_400028e1[]; //400028e1 +extern char Data_400028eb[]; //400028eb +extern char Data_40002901[]; //40002901 +extern char strEngEnglish[]; //40002916 +extern char strEngGerman[]; //4000291e +extern char strEngFrench[]; //40002925 +extern char strEngItalian[]; //4000292c +extern char strEngSpanish[]; //40002934 +extern char Data_4000294a[]; //4000294a +extern char strEngSetTimer[]; //400029a1 +extern char strEng00000s[]; //400029ac +extern char Data_400029b3[]; //400029b3 +extern char strEngStartBack[]; //400029b4 +extern char strEngCountingDown[]; //400029ca +extern char strEngTimeRemain[]; //400029da +extern char strEngTimeRemain00000s[]; //400029e7 +extern char strEngStopBack[]; //400029ee +extern char Data_40002a3f[]; //40002a3f +extern char Data_40002a42[]; //40002a42 +extern char Data_40002a45[]; //40002a45 +extern char strEngCloseAlarm[]; //40002a62 +extern char strEngAlarmCloseBack[]; //40002a71 +extern char strEngInputTime[]; //40002a87 +extern char strEngAlarm21h34m23s[]; //40002a94 +extern char strEngAlarmOnBack[]; //40002a9e +extern char strEngBackgroundLight[]; //40002acb +extern char strEngPressUpDownKey[]; //40002adc +extern char Data_40002aee[]; //40002aee +extern char Data_40002aef[]; //40002aef +extern char Data_40002b70[]; //40002b70 +extern char Data_40002b80[]; //40002b80 +extern char Data_40002b8a[]; //40002b8a +extern char Data_40002b8b[]; //40002b8b +extern char Data_40002ba5[]; //40002ba5 +extern char Data_40002bb5[]; //40002bb5 +extern char Data_40002bc0[]; //40002bc0 +extern char Data_40002bc1[]; //40002bc1 +extern int Data_40002bc4_DayYear[]; //40002bc4 +extern unsigned char sHwKeyQueue[8]; //40002bf8, size?? +extern unsigned char bHwKeyQueueReadPtr; //40002c00 +extern unsigned char bHwKeyQueueWritePtr; //40002c01 +extern unsigned char bData_40002c02; //40002c02 +extern unsigned char bData_40002c03; //40002c03 +extern unsigned char bHwKeyCode; //40002c04 +extern unsigned char bData_40002c05; //40002c05 +extern unsigned char bTimer10msCounter; //40002c06 +extern unsigned char bData_40002c07; //40002c07 +extern unsigned char bData_40002c08; //40002c08 +extern unsigned char bData_40002c09; //40002c09 +extern unsigned char bData_40002c0a_uart0ReceiveDataCount; //40002c0a +extern char uart0ReceiveFlag; //40002c0b +extern unsigned char bData_40002c0c_uart0ReceiveStep; //40002c0c +extern unsigned char Data_40002c0d_uart0ReceiveHeader[4]; //40002c0d +extern unsigned char uart0_bRxData; //40002c11 +extern unsigned char bData_40002c12_uart1ReceiveDataCount; //40002c12 +extern char bData_40002c13_uart1ReceiveComplete; //40002c13 +extern unsigned char bData_40002c14_uart1ReceiveStep; //40002c14 +extern unsigned char bData_40002c15_uart1ReceiveHeader[4]; //40002c15 +extern unsigned char uart1_bRxData; //40002c19 +extern unsigned char bData_40002c1a; //40002c1a // V2.2: 40002c1e +extern int Data_40002c1c; //40002c1c +extern int Data_40002c20; //40002c20 +extern Union_40002c24 Data_40002c24; //40002c24 +extern Union_40002c28 Data_40002c28; //40002c28 +extern char bHelpActive; //40002c58 +extern unsigned char bData_40002c59_MainScreenHelpPage; //40002c59 +extern char bData_40002c5a; //40002c5a +extern int Data_40002c5c_AlignmentStarCount; //40002c5c +extern unsigned char bData_40002c60_CurrentAlignStarIndex; //40002c60 +extern unsigned char bData_40002c61; //40002c61 +extern unsigned char bData_40002c62_AlignmentStarMode; //40002c62 +extern int Data_40002c64_MenuContextId; //40002c64 +extern char bData_40002c68; //40002c68 +extern unsigned char bData_40002c69_KeyCode; //40002c69 +extern char bDaylightSavingTime; //40002c6a +extern double dObjectRiseTime; //40002c70 +extern double dObjectTransitTime; //40002c78 +extern double dObjectSetTime; //40002c80 +extern double dData_40002c88; //40002c88 +extern double dData_40002c90; //40002c90 +extern double dTrackingRate; //40002c98 +extern double dGuidingSpeed; //40002ca0 +extern double g_dPoleAxisDevEastWest; //40002ca8 +extern double g_dPoleAxisDevNorthSouth; //40002cb0 +extern int Data_40002cb8; //40002cb8 +extern int Data_40002cbc; //40002cbc +extern float fData_40002cc0; //40002cc0 +extern double dData_40002cc8; //40002cc8 +extern float fData_40002cd0_ObjectRightAscension; //40002cd0 +extern int Data_40002cd8_ObjectRightAscensionHours; //40002cd8 +extern int Data_40002cdc_ObjectRightAscensionMinutes; //40002cdc +extern float fData_40002ce0_ObjectRightAscensionSeconds; //40002ce0 +extern double g_dObjectRightAcension; //40002ce8 +extern int Data_40002cf4; //40002cf4 +extern int Data_40002cf8; //40002cf8 +extern float fData_40002cfc; //40002cfc +extern int Data_40002d00_ObjectDeclinationDegrees; //40002d00 +extern int Data_40002d04_ObjectDeclinationMinutes; //40002d04 +extern float fData_40002d08_ObjectDeclinationSeconds; //40002d08 +extern double dData_40002d10; //40002d10 +extern float fData_40002d18_ObjectDeclination; //40002d18 +extern int Data_40002d20; //40002d20 +extern int Data_40002d24; //40002d24 +extern float fData_40002d28; //40002d28 +extern double dData_40002d30; //40002d30 +extern int Data_40002d40; //40002d40 +extern int g_iObjectDeclinationSign; //40002d44 +extern int Data_40002d48; //40002d48 +extern int Data_40002d4c; //40002d4c +extern float fData_40002d50; //40002d50 +extern double dData_40002d58; //40002d58 +extern int Data_40002d68_OTARightAscensionHours; //40002d68 +extern int Data_40002d6c_OTARightAscensionMinutes; //40002d6c +extern float fData_40002d70_OTARightAscensionSeconds; //40002d70 +extern double dData_40002d78; //40002d78 +extern double g_dMotorPositionRaAxis; //40002d80 +extern char bData_40002d88; //40002d88 +extern int Data_40002d8c_OTADeclinationDegrees; //40002d8c +extern int Data_40002d90_OTADeclinationMinutes; //40002d90 +extern float fData_40002d94_OTADeclinationSeconds; //40002d94 +extern double dData_40002d98; //40002d98 +extern double g_dMotorPositionDecAxis; //40002da0 +extern char bData_40002da8; //40002da8 +extern int Data_40002dac; //40002dac +extern int Data_40002db0; //40002db0 +extern float fData_40002db4; //40002db4 +extern double g_dMotorPositionAziAxis; //40002db8 +extern double dData_40002dc0_Azimuth; //40002dc0 +extern double dRaBklashCorrStartAzimuth; //40002dc8 +extern double dData_40002dd0; //40002dd0 +extern int Data_40002de0; //40002de0 +extern int Data_40002de4; //40002de4 +extern float fData_40002de8; //40002de8 +extern double g_dMotorPositionAltAxis; //40002df0 +extern double dData_40002df8; //40002df8 +extern double dData_40002e00; //40002e00 +extern double dData_40002e08; //40002e08 +extern int Data_40002e18_SiteLongitudeDegrees; //40002e18 +extern int Data_40002e1c_SiteLongitudeMinutes; //40002e1c +extern float fData_40002e20_SiteLongitudeSeconds; //40002e20 +extern double dData_40002e28_SiteLongitude; //40002e28 +extern float fCustomSiteLongitude; //40002e30 +extern int Data_40002e34; //40002e34 +extern int Data_40002e38_SiteLatitudeDegrees; //40002e38 +extern int Data_40002e3c_SiteLatitudeMinutes; //40002e3c +extern float fData_40002e40_SiteLatitudeSeconds; //40002e40 +extern int Data_40002e44; //40002e44 +extern double dData_40002e48_SiteLatitude; //40002e48 +extern float fCustomSiteLatitude; //40002e50 +extern int Data_40002e54_Zone; //40002e54 +extern int iCustomSiteTimeZone; //40002e58 +extern unsigned Data_40002e5c_Year; //40002e5c +extern unsigned char bData_40002e60_Month; //40002e60 +extern unsigned char bData_40002e61_Day; //40002e61 +extern unsigned char bData_40002e62_Hours; //40002e62 +extern unsigned char bData_40002e63_Minutes; //40002e63 +extern unsigned char bData_40002e64_Seconds; //40002e64 +extern unsigned short wRtcMilliSeconds; //40002e66 +extern unsigned char bDateTimeInputMode; //40002e78 +extern unsigned char bData_40002e79_SkyLandTargetSeletion; //40002e79 +extern unsigned char bData_40002e7a_MountType; //40002e7a +extern unsigned char bData_40002e7b_GpsAvailable; //40002e7b +extern unsigned char bData_40002e7c_TrackingRateType; //40002e7c +extern unsigned char g_eSlewRateIndex; //40002e7d +extern char bData_40002e7e; //40002e7e +extern int Data_40002e80; //40002e80 +extern int Data_40002e84; //40002e84 +extern unsigned char bTrackingMode; //40002e88 +extern char g_bSlewingStop; //40002e89 +extern unsigned char bTrackingModeMenu; //40002e8a +extern char bData_40002e8b; //40002e8b +extern char bData_40002e8c; //40002e8c +extern float fData_40002e90; //40002e90 +extern float Data_40002e94; //40002e94 +extern float fData_40002e98; //40002e98 +extern float Data_40002e9c; //40002e9c +extern float fData_40002ea0; //40002ea0 +extern float fData_40002ea4; //40002ea4 +extern float fData_40002ea8; //40002ea8 +extern float fData_40002eac; //40002eac +extern int iBacklashCorrectionSlewing; //40002eb0 +extern unsigned char bData_40002eb4; //40002eb4 +extern unsigned char bData_40002eb5_SolarSystemObjectNr; //40002eb5 +extern unsigned short wData_40002eb6; //40002eb6 +extern unsigned short wData_40002eb8_MessierNr; //40002eb8 +extern unsigned short wData_40002eba_NGCNr; //40002eba +extern unsigned short wData_40002ebc_ICNr; //40002ebc +extern unsigned short wData_40002ebe_ShNr; //40002ebe +extern unsigned short wData_40002ec0_BrightStarNr; //40002ec0 +extern unsigned int Data_40002ec4_SAONr; //40002ec4 +extern unsigned int Data_40002ec8_NavigationDirectInputNr; //40002ec8 +extern unsigned short wData_40002ecc; //40002ecc +extern unsigned char bData_40002ece_ConstellationNr; //40002ece +extern unsigned short wData_40002ed0; //40002ed0 +extern unsigned char bData_40002ed2_FamousStarNr; //40002ed2 +extern unsigned short wData_40002ed4; //40002ed4 +extern unsigned short wData_40002ed6; //40002ed6 +extern unsigned short wData_40002ed8; //40002ed8 +extern unsigned short wData_40002eda; //40002eda +extern unsigned char bData_40002edc; //40002edc +extern unsigned char bData_40002edd; //40002edd +extern char bData_40002ede; //40002ede +extern char bData_40002edf; //40002edf +extern char bData_40002ef6; //40002ef6 +extern char bData_40002ef7; //40002ef7 +extern int Data_40002ef8; //40002ef8 +extern float fData_40002efc; //40002efc +extern float fData_40002f00; //40002f00 +extern int Data_40002f04; //40002f04 +extern int Data_40002f08; //40002f08 +extern char bData_40002f0c; //40002f0c +extern unsigned char bData_40002f0d_RecentTargetType; //40002f0d +extern int bData_40002f10_RecentTargetId; //40002f10 +extern unsigned char bData_40002f14_RecentTargetCount; //40002f14 +extern unsigned char Data_40002f15_RecentTargetTypeArray[]; //40002f15, size??? +extern unsigned char bData_40002f1d; //40002f1d +extern char bData_40002f1e_SetupLocalData; //40002f1e + +extern char* strTelescopeAlign; //40002f20 +extern char* strNavigation; //40002f24 +extern char* strUtilities; //40002f28 +extern char* strSetup; //40002f2c +extern char* strOneStarAlign; //40002f30 +extern char* strTwoStarAlign; //40002f34 +extern char* strThreeStarAlign; //40002f38 +extern char* strTargetSync; //40002f3c +extern char* strPoleAxisDev; //40002f40 +extern char* strRaBklashCorr; //40002f44 +extern char* strDecBklashCorr; //40002f48 +extern char* Data_40002f4c; //40002f4c +extern char* Data_40002f50; //40002f50 +extern char* Data_40002f54; //40002f54 +extern char* Data_40002f58; //40002f58 +extern char* strSolarSystem; //40002f5c +extern char* strConstellation; //40002f60 +extern char* strFamousStar; //40002f64 +extern char* Data_40002f68; //40002f68 +extern char* Data_40002f6c; //40002f6c +extern char* Data_40002f70; //40002f70 +extern char* Data_40002f74; //40002f74 +extern char* Data_40002f78; //40002f78 +extern char* Data_40002f7c; //40002f7c +extern char* Data_40002f80; //40002f80 +extern char* Data_40002f84; //40002f84 +extern char* Data_40002f88; //40002f88 +extern char* strCurrentObjects; //40002f8c +extern char* Data_40002f90; //40002f90 +extern char* Data_40002f94; //40002f94 +extern char* Data_40002f98; //40002f98 +extern char* Data_40002f9c; //40002f9c +extern char* Data_40002fa0; //40002fa0 +extern char* Data_40002fa4; //40002fa4 +extern char* Data_40002fa8; //40002fa8 +extern char* strParkposition; //40002fac +extern char* Data_40002fb0; //40002fb0 +extern char* strTimeAndDate; //40002fb4 +extern char* Data_40002fb8; //40002fb8 +extern char* Data_40002fbc; //40002fbc +extern char* Data_40002fc0; //40002fc0 +extern char* Data_40002fc4; //40002fc4 +extern char* strTelescopeMount; //40002fc8 +extern char* strTrackingRate; //40002fcc +extern char* Data_40002fd0; //40002fd0 +extern char* strReset; //40002fd4 +extern char* Data_40002fd8; //40002fd8 +extern char* Data_40002fdc; //40002fdc +extern char* Data_40002fe0; //40002fe0 +extern char* Data_40002fe4; //40002fe4 +extern char* Data_40002fe8; //40002fe8 +extern char* Data_40002fec; //40002fec +extern char* Data_40002ff0; //40002ff0 +extern char* Data_40002ff4; //40002ff4 +extern char* Data_40002ff8; //40002ff8 +extern char* Data_40002ffc; //40002ffc +extern char* Data_40003000; //40003000 +extern char* Data_40003004; //40003004 +extern char* Data_40003008; //40003008 +extern char* Data_4000300c; //4000300c +extern char* Data_40003010; //40003010 +extern char* Data_40003014; //40003014 +extern char* Data_40003018; //40003018 +extern char* Data_4000301c; //4000301c +extern char* Data_40003020; //40003020 +extern char* Data_40003024; //40003024 +extern char* strScientificName; //40003028 +extern char* strSAOCatalog; //4000302c +extern char* strHRCatalog; //40003030 +extern char* strSelect; //40003034 +extern char* strAdd; //40003038 +extern char* strDelete; //4000303c +extern char* strModify; //40003040 +extern char* Data_40003044; +extern char* Data_40003048; +extern char* Data_4000304c; +extern char* strEyeshot; //40003050 +extern char* strRatio; //40003054 +extern char* strBackBoard; //40003058 +extern char* strAccessory; //4000305c +extern char* strCountryAndCity; //40003060 +extern char* strCustomSite; //40003064 +extern char* Data_40003068; +extern char* Data_4000306c; +extern char* Data_40003070; +extern char* Data_40003074; +extern char* Data_40003078; +extern char* Data_4000307c; +extern char* Data_40003080; +extern char* Data_40003084; +extern char* strStarSpeed; //40003088 +extern char* strSolarSpeed; //4000308c +extern char* strMoonSpeed; //40003090 +extern char* Data_40003094; +extern char* Data_40003098; +extern char* strListAlignStars; //4000309c +extern char* strSlewingTo; //400030a0 +extern char* strAutoloadAlignStars; //400030a4 +extern char* Data_400030a8; +extern char* Data_400030ac; +extern char* Data_400030b0; +extern char* Data_400030b4; +extern char* Data_400030b8; +extern char* Data_400030bc; +extern char* strThereIsNoTele; //400030c0 +extern char* strScopeToConnectThis; //400030c4 +extern char* strControlTerminal; //400030c8 +extern char* strPleaseAimAtThe; //400030cc +extern char* strTelescopeToDistant; //400030d0 +extern char* strTargetThenPress; //400030d4 +extern char* strEnterKey; //400030d8 +extern char* Data_400030dc; +extern char* Data_400030e0; +extern char* Data_400030e4; +extern char* Data_400030e8; +extern char* Data_400030ec; +extern char* Data_400030f0; +extern char* Data_400030f4; +extern char* Data_400030f8; +extern char* Data_400030fc; +extern char* Data_40003100; +extern char* Data_40003104; +extern char* Data_40003108; +extern char* Data_4000310c; +extern char* Data_40003110; +extern char* Data_40003114; +extern char* Data_40003140; //40003140 +extern unsigned char bCurrentCustomSiteInputLine; //40003144 +extern char* Data_4000314c_SolarSystemObjectName; //4000314c +extern char Data_40003150[]; //40003150, size?? +extern char arCustomSiteName[]; //40003159, size?? +extern unsigned char bData_40003161; //40003161 +extern char bData_40003162; //40003162 +extern int Data_40003164_LunarPhaseYear; //40003164 +extern int Data_40003168_LunarPhaseMonth; //40003168 +extern unsigned char bData_4000316d; //4000316d +extern unsigned char bData_4000316e_FocusLineOn8LineDisplay; //4000316e +extern unsigned char bData_4000316f_FocusLineOn4LineDisplay; //4000316f +extern unsigned char bData_40003170; //40003170 +extern unsigned char bData_40003171; //40003171 +extern unsigned char bData_40003172; //40003172 +extern unsigned char bData_40003173; //40003173 +extern unsigned char bData_40003174; //40003174 +extern unsigned char bData_40003175; //40003175 +extern unsigned char bData_40003176; //40003176 +extern unsigned char bData_40003177; //40003177 +extern unsigned char bData_40003178; //40003178 +extern unsigned char bData_40003179; //40003179 +extern unsigned char bData_4000317a; //4000317a +extern unsigned char bData_4000317b; //4000317b +extern unsigned char bData_4000317c; //4000317c +extern unsigned char bData_4000317d; //4000317d +extern unsigned char bData_4000317e; //4000317e +extern unsigned char bData_4000317f; //4000317f +extern unsigned char bData_40003180; //40003180 +extern unsigned char bData_40003182; //40003182 +extern unsigned char bData_40003184; //40003184 +extern unsigned char bData_40003186; //40003186 +extern char bRaBacklashCorrectionDirection; //40003188 +extern char bDecBacklashCorrectionDirection; //40003189 +extern unsigned char bCharacterInputPosition; //4000318a +extern int Data_4000318c; //4000318c +extern int Data_40003190; //40003190 +extern char bData_40003194; //40003194 +extern unsigned char bData_40003195; //40003195 +extern unsigned char bData_40003196_CurrentLanguage; //40003196 +extern unsigned char bData_40003197_DisplayLinesPerMenuLine; //40003197 +extern char bCapsLock; //40003198 +extern unsigned char bMapKeyToCharIndex; //40003199 +extern unsigned char bData_4000319a_SkyLandTargetId; //4000319a +extern char bData_4000319b; //4000319b +extern char g_bSingleSlewActive; //4000319c +extern char g_bCombinedSlewActive; //4000319d +extern Union_400031a0 Data_400031a0; //400031a0 +extern Union_400031a0 g_stCurrentSlewRampValue; //400031a4 +extern int Data_400031a8; //400031a8 +extern Union_400031a0 Data_400031ac; //400031ac +extern int g_iCurrentSlewRampIndex; //400031b4 +extern char g_bMaxSlewRampActive; //400031b8 +extern char bData_400031b9; //400031b9 +extern char bData_400031ba; //400031ba +extern char bData_400031bb; //400031bb +extern char bData_400031bc; //400031bc +extern char bData_400031bd; //400031bd +extern char bData_400031be; //400031be +extern unsigned char bData_400031bf; //400031bf +extern float fData_400031c0; //400031c0 +extern float fData_400031c4; //400031c4 +extern char bData_400031e0; //400031e0 +extern char bData_400031e1; //400031e1 +extern int Data_400031e4; //400031e4 +extern unsigned char bCustomerObjectNameChar; //400031e8 +extern char bData_400031e9; //400031e9 +extern char g_bTargetSyncOpen; //400031ea +extern char bData_400031eb; //400031eb +extern char bData_400031ec; //400031ec +extern char bSystemInitialized; //400031ed +extern double dData_400031f0; //400031f0 +extern double dData_400031f8; //400031f8 +extern char bData_40003200; //40003200 +extern char bData_40003201; //40003201 +extern int iMountAutoguideRa; //40003204 +extern int iMountAutoguideDec; //40003208 +extern char bData_40003210; //40003210 +extern char bData_40003211; //40003211 +extern int Data_40003214_UserTimerSeconds; //40003214 +extern int Data_40003220_AlarmHours; //40003220 +extern int Data_40003224_AlarmMinutes; //40003224 +extern int Data_40003228_AlarmSeconds; //40003228 +extern char bData_4000322c; //4000322c +extern char bData_4000322d_AlarmTimeElapsed; //4000322d +extern float fMainFocalLength; //40003230 +extern float fSecondaryFocalLength; //40003234 +extern float fEyepieceMagnification; //40003238 +extern float fEyepieceFOV; //4000323c +extern float fFieldOfView; //40003240 +extern int Data_40003248_CurrentDisplayPWM; //40003248 +extern unsigned short wData_40003250; //40003250 +extern unsigned short wData_40003252; //40003252 +extern unsigned short wData_40003256; //40003256 +extern unsigned char bData_40003258; //40003258 +extern unsigned short wData_4000325a; //4000325a +extern unsigned char bData_4000325c; //4000325c +extern unsigned char bData_40003260; //40003260 +extern unsigned char bData_40003261; //40003261 +extern unsigned char bData_40003262; //40003262 +extern unsigned char bData_40003263; //40003263 +extern unsigned char bData_40003265; //40003265 +extern unsigned char Data_4000327f[]; //4000327f +extern float fData_40003288; //40003288 +extern float fData_4000328c; //4000328c +extern Struct_40003290 Data_40003290; //40003290 +extern Struct_40003296 Data_40003296; //40003296 +extern float fData_4000329c; //4000329c +extern float fData_400032a0; //400032a0 +extern unsigned char bData_400032a4_OTAZeroDataErrorCount; //400032a4 +extern double dData_400032b0_SunRightAscension; //400032b0 +extern double dData_400032b8_SunDeclination; //400032b8 +extern double dData_400032c0_MoonRightAscension; //400032c0 +extern double dData_400032c8_MoonDeclination; //400032c8 +extern double dData_400032d0; //400032d0 +extern double dData_400032d8; //400032d8 +extern double dData_400032e0; //400032e0 +extern double dData_400032e8; //400032e8 +extern double dData_400032f0; //400032f0 +extern double dData_400032f8; //400032f8 +extern double dData_40003300; //40003300 +extern double dData_40003308; //40003308 +extern double dData_40003310; //40003310 +extern double dData_40003318; //40003318 +extern double dData_40003320; //40003320 +extern double dData_40003328; //40003328 +extern double dData_40003330; //40003330 +extern double dData_40003338; //40003338 +extern double dData_40003340; //40003340 +extern double dData_40003348; //40003348 +extern Struct_Sh2Data Data_40003350_FlashSh2Data; //40003350 +extern Struct_SAOData Data_40003358_SAORecord; //40003358 +extern char* Data_40003360; //40003360 +extern char* Data_40003364; //40003364 +extern unsigned char* Data_40003368; //40003368 +extern char* Data_4000336c; //4000336c +extern char* Data_40003370; //40003370 +extern char* Data_40003374; //40003374 +extern char* Data_40003378; //40003378 +extern char* Data_4000337c; //4000337c +extern char* Data_40003380; //40003380 +extern char* Data_40003384; //40003384 +extern char* Data_40003388; //40003388 +extern char* Data_4000338c; //4000338c +extern char* Data_40003390; //40003390 +extern char* Data_40003394; //40003394 +extern char* Data_40003398; //40003398 +extern char* Data_4000339c; //4000339c +extern char* Data_400033a0; //400033a0 +extern char* Data_400033a4; //400033a4 +extern char* Data_400033a8; //400033a8 +extern char* Data_400033ac; //400033ac +extern char* Data_400033b0; //400033b0 +extern char* Data_400033b4; //400033b4 +extern Union_400033c8 Data_400033c8; //400033c8 +extern Union_400033cc Data_400033cc; //400033cc +extern double dData_400033d8; //400033d8 +extern double dData_400033e0; //400033e0 +extern double dData_400033e8; //400033e8 +extern double dData_400033f0; //400033f0 +extern double g_dSlewRateRaAxis; //400033f8 +extern double g_dSlewRateDecAxis; //40003400 +extern int g_iSlewStepRaAxis; //40003408 +extern int g_iSlewStepDecAxis; //4000340c +extern double dData_40003410; //40003410 +extern double dData_40003418; //40003418 +extern double dData_40003420; //40003420 +extern double dData_40003428; //40003428 +extern char bData_40003430; //40003430 +extern char bGotoParkPosition; //40003431 +extern char bData_40003432; //40003432 +extern double dData_40003448; //40003448 +extern double dData_40003450; //40003450 +extern double dData_40003458; //40003458 +extern double dData_40003460; //40003460 +extern int Data_40003488; //40003488 +extern int Data_4000348c; //4000348c +extern double dData_40003490; //40003490 +extern char bData_40003498; //40003498 +extern double dData_400034a0_SiderealTimeGreenwich0UT; //400034a0 +extern unsigned char numVisibleAlignmentStars; //400034a8 +extern char g_bLandTarget; //400034a9 +extern char bData_400034aa; //400034aa +extern float fData_400034ac; //400034ac +extern float fData_400034b0; //400034b0 +extern char bData_400034b4; //400034b4 +extern char bData_400034b5; //400034b5 +extern float fData_400034b8; //400034b8 +extern float fData_400034bc; //400034bc +extern float fData_400034c0; //400034c0 +extern float fData_400034c4; //400034c4 +extern float fData_400034c8; //400034c8 +extern char bData_400034cc; //400034cc +extern char bData_400034cd; //400034cd +extern double Data_400034d0; //400034d0 +extern double Data_400034d8; //400034d8 +extern double dData_400034e0; //400034e0 +extern double dData_400034e8; //400034e8 +extern double dData_400034f0; //400034f0 +extern double dData_400034f8; //400034f8 +extern Union_40003500 Data_40003500; //40003500 +extern unsigned char bData_40003504; //40003504 +extern char bData_40003505; //40003505 +extern float fData_40003508; //40003508 +extern float fData_4000350c; //4000350c +extern float fData_40003510; //40003510 +extern float fData_40003514; //40003514 +extern float fData_40003518_ReceiveExternalSiteLongitude; //40003518 +extern float fData_4000351c_ReceiveExternalSiteLatitude; //4000351c +extern float fData_40003520; //40003520 +extern int Data_40003524_ReceiveExternalYear; //40003524 +extern unsigned char bData_40003528_ReceiveExternalMonth; //40003528 +extern unsigned char bData_40003529_ReceiveExternalDay; //40003529 +extern unsigned char bData_4000352a_ReceiveExternalHours; //4000352a +extern unsigned char bData_4000352b_ReceiveExternalMinutes; //4000352b +extern unsigned char bData_4000352c_ReceiveExternalSeconds; //4000352c +extern unsigned char bAscomCmd; //4000352d +extern unsigned char bData_4000352e; //4000352e +extern float fInitialCustomSiteLongitude; //40003540 +extern float fInitialCustomSiteLatitude; //40003544 +extern int iInitialCustomSiteTimezone; //40003548 +extern unsigned char uart0ReceiveDataBuffer[]; //40003588 +extern unsigned char Data_40003592_uart1ReceiveDataBuffer[]; //40003592 +extern int Data_4000359c_RecentTargetIdArray[]; //4000359c +extern unsigned char Data_400035bc[]; //400035bc +extern char strTrackingRateCustInput[]; //400037cc +extern char strTrackingRateCustDisplay[]; //400037dc +extern char Data_400037ec[]; //400037ec +extern float Data_400037f8[]; //400037f8 +extern unsigned char Data_400038e8[][10]; //400038e8 +extern unsigned char arAlignmentStarNames[][10]; //40003a14, size?? +extern unsigned char Data_40003b2c[][22]; //40003b2c, size?? +extern Struct_FamousStarData Data_40003d94_FlashFamousStarData; //40003d94 +extern Struct_ConstellationData Data_40003dd4_FlashConstellationData; //40003dd4 +extern Struct_MessierData Data_40003e08_FlashMessierData; //40003e08 +extern Struct_BrightStarData Data_40003ea0_FlashBrightStarData; //40003ea0 +extern Struct_ICData Data_40003ec0_FlashICData; //40003ec0 +extern Struct_NGCData Data_40003ee0_FlashNGCData; //40003ee0 +extern Struct_SiteData Data_40003f1c_FlashSiteData; //40003f1c +extern Struct_5218 Data_40003f50; //40003f50 +extern Struct_54e0 Data_40003f64; //40003f64 +extern unsigned char Data_40003f78[]; //40003f78 +extern unsigned char Data_40003f90[]; //40003f90 +extern char Data_40003fa9[]; //40003fa9 +extern char Data_40003fbe[]; //40003fbe +extern char Data_40003fd3[]; //40003fd3 +extern char Data_40003fe8[]; //40003fe8 +extern char Data_40003ffd[]; //40003ffd +extern char Data_40004012[]; //40004012 +extern char Data_40004027[]; //40004027 +extern char Data_4000403c[]; //4000403c +extern char Data_40004066[]; //40004066 +extern char Data_40004090[]; //40004090 +extern char Data_400040ba[]; //400040ba +extern char Data_400040e4[]; //400040e4 +extern /*unsigned*/ char Data_4000410e[]; //4000410e +extern Struct_40004128 Data_40004128; //40004128 +extern Struct_40004380 Data_40004380; //40004380 +extern Struct_GeographicCoordinates Data_40004ad8; //40004ad8 +#if 0 +extern float Data_40004a68_CurrentAlignStarEquatorialCoord[][2]; //40004a68 +#else +extern float Data_40004a68_CurrentAlignStarEquatorialCoord[]; //40004a68 +#endif +extern Struct_EquatorialCoordinates Data_40004ae8; //40004ae8 +extern Struct_HorizontalCoordinates Data_40004b08; //40004b08 +extern Struct_EquatorialCoordinates Data_40004b50; //40004b50 +extern Struct_HorizontalCoordinates Data_40004b70; //40004b70 +extern unsigned char arInitialCustomSiteName[]; //40004bb8 +extern unsigned char Data_40004c58[]; //40004c58, size??? + diff --git a/applications/freertos_app/earth.c b/applications/freertos_app/earth.c new file mode 100644 index 0000000..7f8e6f1 --- /dev/null +++ b/applications/freertos_app/earth.c @@ -0,0 +1,89 @@ + +//For the following see: https://pymeeus.readthedocs.io/en/latest/Earth.html +//https://www.avrfreaks.net/forum/best-microcontroller-heavy-computation?page=all + +/* e11c - complete */ +double earth_heliocentric_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double L5 = 0.0; + double res = 0.0; + + L0 += 175347046 * cos(0.0 + a * 0.0); + L0 += 3341656 * cos(4.6692568 + a * 6283.07585); + L0 += 34894 * cos(4.6261 + a * 12566.1517); + L0 += 3497 * cos(2.7441 + a * 5753.3849); + L0 += 3418 * cos(2.8289 + a * 3.5231); + L0 += 3136 * cos(3.6277 + a * 77713.7715); + + L1 += 628331966747 * cos(0.0 + a * 0.0); + L1 += 206059 * cos(2.678235 + a * 6283.07585); + L1 += 4303 * cos(2.6351 + a * 12566.1517); + + L2 += 52919 * cos(0.0 + a * 0.0); + L2 += 8720 * cos(1.0721 + a * 6283.0758); + + res = (L0 + + L1 * a + + L2 * a*a + + L3 * a*a*a + + L4 * a*a*a*a + + L5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* e8fc - complete */ +double earth_heliocentric_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double res = 0.0; + + B0 += 280.0 * cos(3.199 + a * 84334.662); + B0 += 102.0 * cos(5.422 + a * 5507.553); + B0 += 80.0 * cos(3.88 + a * 5223.69); + B0 += 44.0 * cos(3.7 + a * 2352.87); + B0 += 32.0 * cos(4 + a * 1577.34); + + B1 += 9.0 * cos(3.9 + a * 5507.55); + B1 += 6.0 * cos(1.73 + a * 1577.34); //5223.69); //BUG!!! + + res = (B0 + B1 * a) / 100000000.0; + + return res; +} + +/* ecf8 - complete */ +double earth_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double R4 = 0.0; + double res = 0.0; + + R0 += 100013989 * cos(0.0 + a * 0.0); + R0 += 1670700 * cos(3.0984635 + a * 6283.07585); + R0 += 13956 * cos(3.05525 + a * 12566.1517); + R0 += 3084 * cos(5.1985 + a * 77713.7715); + + R1 += 103019 * cos(1.10749 + a * 6283.07585); + R1 += 1721 * cos(1.0644 + a * 12566.1517); + + R2 += 4359 * cos(5.7846 + a * 6283.0758); + + res = (R0 + + R1 * a + + R2 * a*a + + R3 * a*a*a + + R4 * a*a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/freertos_app/file_1f30.c b/applications/freertos_app/file_1f30.c new file mode 100644 index 0000000..9f2ea77 --- /dev/null +++ b/applications/freertos_app/file_1f30.c @@ -0,0 +1,5987 @@ + +#include +#include +#include +#include +#include +#include "my_types.h" +#include "data.h" +#include "menu.h" +#include "file_79080.c" +#include "macros.h" + +// configuration for the Atmel AT45DB161D device +#define FLASH_PAGE_BITS 10 +#define FLASH_PAGE_SIZE 528 + +// Dataflash commands +#define FLASH_CMD_BUF1_TO_MEM 0x83 +#define FLASH_CMD_BUF1_WRITE 0x84 +#define FLASH_CMD_CONT_ARRAY_READ 0xE8 + +#define GPIO_FLASH_CS (1 << 24) //P1.24 +#define ENABLE_FLASH_CS (IO1CLR = GPIO_FLASH_CS) +#define DISABLE_FLASH_CS (IO1SET = GPIO_FLASH_CS) + +#define GPIO_FONTROM_CS (1 << 25) //P1.25 +#define ENABLE_FONTROM_CS (IO1CLR = GPIO_FONTROM_CS) +#define DISABLE_FONTROM_CS (IO1SET = GPIO_FONTROM_CS) + +#define GPIO_LCD_CS (1 << 10) //P0.10 +#define ENABLE_LCD_CS (IOCLR0 |= GPIO_LCD_CS) +#define DISABLE_LCD_CS (IOSET0 |= GPIO_LCD_CS) + +#define GPIO_LCD_SCLK (1 << 12) //P0.12 +#define LCD_SCLK_LO (IO0CLR |= GPIO_LCD_SCLK) +#define LCD_SCLK_HI (IO0SET |= GPIO_LCD_SCLK) + +#define GPIO_LCD_SID (1 << 15) //P0.15 +#define LCD_SID_LO (IO0CLR |= GPIO_LCD_SID) +#define LCD_SID_HI (IO0SET |= GPIO_LCD_SID) + +#define GPIO_LCD_RS (1 << 23) //P1.23 +#define LCD_RS_CONTROL (IO1CLR |= GPIO_LCD_RS) +#define LCD_RS_DATA (IO1SET |= GPIO_LCD_RS) + +// LCD Display commands +#define ST7565_CMD_DISPLAY_ON 0xAF +#define ST7565_CMD_SET_PAGE 0xB0 +#define ST7565_CMD_SET_COLUMN_UPPER 0x10 +#define ST7565_CMD_SET_COLUMN_LOWER 0x00 +#define ST7565_CMD_SET_BIAS_9 0xA2 +#define ST7565_CMD_INTERNAL_RESET 0xE2 +#define ST7565_CMD_SET_VOLUME_FIRST 0x81 +#define ST7565_CMD_SET_DISP_NORMAL 0xA6 +#define ST7565_CMD_SET_ALLPTS_NORMAL 0xA4 +#define ST7565_CMD_SET_COM_REVERSE 0xC8 + + +/* 224 - complete */ +void lcd_write_data(unsigned char a) +{ + unsigned char i; + + ENABLE_LCD_CS; + LCD_RS_DATA; + + for (i = 0; i < 8; i++) + { + LCD_SCLK_LO; + if (a & 0x80) + { + LCD_SID_HI; + } + else + { + LCD_SID_LO; + } + + a <<= 1; + + LCD_SCLK_HI; + } + + DISABLE_LCD_CS; +} + +/* 2dc - complete */ +void lcd_write_command(unsigned char a) +{ + unsigned char i; + + ENABLE_LCD_CS; + LCD_RS_CONTROL; + + for (i = 0; i < 8; i++) + { + LCD_SCLK_LO; + if (a & 0x80) + { + LCD_SID_HI; + } + else + { + LCD_SID_LO; + } + + a <<= 1; + + LCD_SCLK_HI; + } + + DISABLE_LCD_CS; +} + +/* 394 - complete */ +void lcd_display_clear(void) +{ + int i, j; + for (i = 0; i < 8; i++) + { + lcd_write_command((i & 0xff) | ST7565_CMD_SET_PAGE); + lcd_write_command(ST7565_CMD_SET_COLUMN_LOWER); + lcd_write_command(ST7565_CMD_SET_COLUMN_UPPER); + + for (j = 133; j > 0; j--) + { + lcd_write_data(0); + } + } +} + +/* 3ec - complete */ +void lcd_display_configure(void) +{ + lcd_write_command(ST7565_CMD_INTERNAL_RESET); + lcd_write_command(ST7565_CMD_SET_BIAS_9); + lcd_write_command(0x26); + lcd_write_command(0x2f); + lcd_write_command(ST7565_CMD_SET_VOLUME_FIRST); + lcd_write_command(0x80); + lcd_write_command(ST7565_CMD_SET_DISP_NORMAL); + lcd_write_command(ST7565_CMD_SET_ALLPTS_NORMAL); + lcd_write_command(ST7565_CMD_SET_COM_REVERSE); + lcd_write_command(ST7565_CMD_DISPLAY_ON); + lcd_write_command(0x60); + + lcd_display_clear(); + + //LED Backlight + PWMPR = 0; //Prescaler + PWMMCR = 2; //Match Control: Reset on PWMMR0 + PWMPCR = (1 << 13); //PWM5 output enabled + PWMMR0 = 11059; //Match Register 0 -> 1000Hz + PWMMR5 = 0; + PWMMR2 = 0; + PWMLER = (1 << 5) | (1 << 0); + PWMTCR = 0x02; //Timer Counter Reset + PWMTCR = 0x01 | 0x08; //Timer Counter Enable & PWM Enable +} + +/* 49c - complete */ +void setDisplayPWM(int a) +{ + if (a == 0) + { + PWMMR5 = 0; + } + else + { + PWMMR5 = (PWMMR0 * a) / 0xFF; + } + + PWMLER = (1 << 5) | (1 << 0); +} + +/* 4ec - complete */ +void func_4ec(int a) +{ + if (a == 0) + { + PWMMR5 = 0; + } + else + { + PWMMR2 = (PWMMR0 * a) / 0xFF; + } + + PWMLER = (1 << 5) | (1 << 0); +} + +/* 53c - complete */ +void lcd_display_brightness(unsigned char a) +{ + a = a / 2 + 80; + lcd_write_command(ST7565_CMD_SET_VOLUME_FIRST); + lcd_write_command(a); +} + +/* 570 - complete */ +int func_570(unsigned int a) +{ + unsigned short r2 = 0; + unsigned short ip = 0x43f; + unsigned short lr = 0x21f; + unsigned short r3; + do + { + r3 = lr; + if (a > Data_79080[lr]) + { + r2 = lr; + } + else if (a < Data_79080[lr]) + { + ip = lr; + } + else + { + return lr; + } + + lr = (r2 + ip) / 2; + } + while (lr != r3); + + return 0x21a; +} + +/* 5ec - complete */ +void spi0_init(void) +{ + //SPI Clock Counter Register: PCLK / 8 + S0SPCCR = 8; + + //SPI Control Register: MSTR + S0SPCR = (1 << 5); +} + +/* 604 - complete */ +unsigned char spi0_write_read_byte(unsigned char a) +{ + S0SPDR = a; + while (!(S0SPSR & 0x80)) {} + return S0SPDR; +} + + +/* 634 - complete */ +void lcd_display_character(int inv, int row, unsigned char col, const unsigned char* d) +{ +#ifndef OLIMEX_LPC2148 + char i, j, sl; + unsigned char bitmap[6]; //sp4 + unsigned char sp[4]; //sp + + if ((d[0] >= 0x20) && (d[0] <= 0x7e)) + { + ((unsigned int*)sp)[0] = 0x00188bd8 + ((d[0] - 0x20) << 3); + } + else + { + ((unsigned int*)sp)[0] = 0; + } + + sp[3] = 0x0b; + + lcd_write_command(((col - 1) * 6 + 1) & 0x0f); + lcd_write_command(((((col - 1) * 6 + 1) & 0xf0) >> 4) | ST7565_CMD_SET_COLUMN_UPPER); + lcd_write_command(((row - 1) & 0x0f) | ST7565_CMD_SET_PAGE); + + ENABLE_FONTROM_CS; + + for (i = 3; i >= 0; i--) + { + spi0_write_read_byte(sp[i]); + } + + for (i = 0; i < 8; i++) + { + sl = spi0_write_read_byte(0); + + for (j = 0; j < 6; j++) + { + if (sl & (0x80 >> j)) + { + bitmap[j] |= (1 << i); + } + else + { + bitmap[j] &= ~(1 << i); + } + } + } + + for (i = 0; i < 6; i++) + { + if (inv == 0) + { + lcd_write_data(bitmap[i]); + } + else + { + lcd_write_data(~bitmap[i]); + } + } + + DISABLE_FONTROM_CS; +#endif +} + +/* 7e8 - complete */ +void lcd_display_string(int a, unsigned char b, unsigned char c, unsigned char d, const unsigned char* e) +{ + unsigned char i; + + if ((c + d) > 22) + { + d = 22 - c; + } + + for (i = 0; i < d; i++) + { + if (e[i]) + { + lcd_display_character(a, b, c + i, &e[i]); + } + else + { + break; + } + } +} + +/* 864 - complete */ +void lcd_display_bitmap(int inv, int row, int col, unsigned char* bitmap) +{ + unsigned char i; + + // Column Address Set + lcd_write_command(((((col - 1) * 6 + 1) & 0x0f) >> 0) | ST7565_CMD_SET_COLUMN_LOWER); + lcd_write_command(((((col - 1) * 6 + 1) & 0xf0) >> 4) | ST7565_CMD_SET_COLUMN_UPPER); + + // Page Address Set + lcd_write_command(((row - 1) & 0x0f) | ST7565_CMD_SET_PAGE); + + if (inv == 0) + { + for (i = 0; i < 6; i++) + { + lcd_write_data(bitmap[i]); + } + } + else + { + for (i = 0; i < 6; i++) + { + lcd_write_data(~bitmap[i]); + } + } +} + +/* 91c - todo */ +unsigned char func_91c(int r4, int r5, int r6, int r7, char* sp76) +{ +#ifndef OLIMEX_LPC2148 + unsigned char sp24[16]; + union + { + unsigned char b[4]; + unsigned int d; + } sp20; + char sp16; + unsigned char r8; + unsigned char r9 = 0; + unsigned char sl; + char fp; + unsigned char sp12; + char sp8; + char sp4 = 0; + unsigned short sp; + + while ((sp = ((unsigned short*)sp76)[sp4]) != 0) + { + sp16 = 2; + sl = 8; + + if ((sp >= 0x20) && (sp <= 0x7F)) + { + sp20.d = 0x001883d8 + ((sp - 0x20) << 4); + } + else if ((sp >= 0xaca1) && (sp <= 0xacdf)) + { + sp20.d = 0x0018d878 + ((sp - 0xaca0) << 4); + } + else if ((sp >= 0xa0) && (sp < 0x218)) + { + sp20.d = 0x0018ab58 + ((sp - 0xa0) << 4); + } + else if ((sp >= 0x370) && (sp < 0x3d0)) + { + sp20.d = 0x0018c2d8 + ((sp - 0x370) << 4); + } + else if ((sp >= 0x400) && (sp <= 0x4f9)) + { + sp20.d = 0x0018c8d8 + ((sp - 0x400) << 4); + } + else + { + sp16 = 3; + + if ((sp >= 0x600) && (sp <= 0x6f9)) + { + sp20.d = 0x001a2f36 + ((sp - 0x600)*34); + } + else if ((sp >= 0xb000) && (sp <= 0xb1f1)) + { + sp20.d = 0x001a506a + ((sp - 0xb000)*34); + } + else + { + sp16 = 1; + sl = 16; + + if ((sp >= 0x3400) && (sp <= 0x4db5)) + { + sp20.d = 0x000a76b8 + ((sp - 0x3400) << 5); + } + else if ((sp >= 0x4e00) && (sp <= 0x9fa5)) + { + sp20.d = 0x000a76b8 + ((sp - 0x344a) << 5); + } + else if ((sp >= 0xff00) && (sp <= 0xff5e)) + { + if (sp == 0xff00) + { + sp20.d = 0x000b2554; + } + else + { + sp20.d = 0x000a76b8 + ((sp - 0x8fc9) << 5); + } + } + else if (((sp >= 0xa1) && (sp <= 0x33d5)) || + ((sp >= 0xe76c) && (sp <= 0xffe5))) + { + sp20.d = 0x000d6b80 + (func_570(sp) << 5) + 0x000a76b8; + } + else + { + break; + } + } + } + + sp20.b[3] = 0x0b; + + ENABLE_FONTROM_CS; + + for (sp8 = 3; sp8 >= 0; sp8--) + { + spi0_write_read_byte(sp20.b[sp8]); + } + + spi0_write_read_byte(0); + + if (sp16 == 3) + { + spi0_write_read_byte(0); + sl = spi0_write_read_byte(0); + } + + if ((r7 - r6) < (r9 + sl)) + { + break; + } + + sp12 = r6 + r9; + r9 += sl; + + if (sl > 8) + { + for (sp8 = 0; sp8 < 16; sp8++) + { + r8 = spi0_write_read_byte(0); + + for (fp = 0; fp < 8; fp++) + { + if (r8 & (0x80 >> fp)) + { + sp24[fp + ((sp8%2)*8)] |= (1 << (sp8/2)); //??? + } + else + { + sp24[fp + ((sp8%2)*8)] &= ~(1 << (sp8/2)); //??? + } + } + } + } + else + { + for (sp8 = 0; sp8 < 8; sp8++) + { + r8 = spi0_write_read_byte(0); + + for (fp = 0; fp < 8; fp++) + { + if (r8 & (0x80 >> fp)) + { + sp24[fp] |= (1 << sp8); + } + else + { + sp24[fp] &= ~(1 << sp8); + } + } + } + } + + lcd_write_command((sp12 + 1) & 0x0f); + lcd_write_command((((sp12 + 1) & 0xf0) >> 4) | ST7565_CMD_SET_COLUMN_UPPER); + lcd_write_command((((r5 - 1) << 1) & 0x0f) | ST7565_CMD_SET_PAGE); + + for (sp8 = 0; sp8 < sl; sp8++) + { + if (r4 == 0) + { + lcd_write_data(sp24[sp8]); + } + else + { + lcd_write_data(~sp24[sp8]); + } + } + + if (sl > 8) + { + for (sp8 = 0; sp8 < 16; sp8++) + { + r8 = spi0_write_read_byte(0); + + for (fp = 0; fp < 8; fp++) + { + if (r8 & (0x80 >> fp)) + { + sp24[fp + ((sp8%2)*8)] |= (1 << (sp8/2)); //??? + } + else + { + sp24[fp + ((sp8%2)*8)] &= ~(1 << (sp8/2)); //??? + } + } + } + } + else + { + for (sp8 = 0; sp8 < 8; sp8++) + { + r8 = spi0_write_read_byte(0); + + for (fp = 0; fp < 8; fp++) + { + if (r8 & (0x80 >> fp)) + { + sp24[fp] |= (1 << sp8); + } + else + { + sp24[fp] &= ~(1 << sp8); + } + } + } + } + + lcd_write_command((sp12 + 1) & 0x0f); + lcd_write_command((((sp12 + 1) & 0xf0) >> 4) | ST7565_CMD_SET_COLUMN_UPPER); + lcd_write_command(((((r5 - 1) << 1) + 1) & 0x0f) | ST7565_CMD_SET_PAGE); + + for (sp8 = 0; sp8 < sl; sp8++) + { + if (r4 == 0) + { + lcd_write_data(sp24[sp8]); + } + else + { + lcd_write_data(~sp24[sp8]); + } + } + + sp4++; + + DISABLE_FONTROM_CS; + } //while ((sp = ((unsigned short*)sp76)[sp4]) != 0) + + DISABLE_FONTROM_CS; + + return r6 + r9; +#endif +} + +/* 11d8 - complete */ +unsigned char get_hw_key_code(void) +{ + if (bHwKeyQueueReadPtr == bHwKeyQueueWritePtr) + { + return bHwKeyCode; + } + else + { + return sHwKeyQueue[bHwKeyQueueReadPtr]; + } +} + +/* 1210 - complete */ +void ack_hw_key(void) +{ + if (bHwKeyQueueReadPtr == bHwKeyQueueWritePtr) + { + bHwKeyCode |= 0x80; + } + else + { + bHwKeyQueueReadPtr = (bHwKeyQueueReadPtr + 1) % 8; + } +} + +/* 1268 - complete */ +void read_key_matrix(void) +{ + unsigned char row, col, i, r3, ip, lr; + unsigned int r4; + + r3 = 0; + col = 0; + row = 0; + ip = 0; + + for (i = 0; i < 4; i++) + { + // Write Value 1 on Column GPIO lines: P1.16, P1.17, P1.18, P1.19 + IO1SET = (1 << 16) | (1 << 17) | (1 << 18) | (1 << 19); + + // Output: P1.22, P1.23, P1.24, P1.25 + IO1DIR = (1 << 22) | (1 << 23) | (1 << 24) | (1 << 25); + + // Output: P1.16 + i + IO1DIR |= ((1 << 19) >> i); // 19 / 18 / 17 / 16 + + // Write Value 0 on Column GPIO lines: P1.16 + i + IO1CLR = (1 << 19) >> i; + + // Read Row GPIO lines: P0.22, P0.25, P0.28, P0.29, P0.30 + if ((IO0PIN & ((1 << 22) | (1 << 25) | (1 << 28) | (1 << 29) | (1 << 30))) ^ + ((1 << 22) | (1 << 25) | (1 << 28) | (1 << 29) | (1 << 30))) + { + r4 = IO0PIN; + if ((r4 & (1 << 22)) == 0) + { + row = 1; + lr = col; + col = i; + r3++; + ip++; + } + + if ((r4 & (1 << 25)) == 0) + { + row = 2; + col = i; + r3++; + } + + if ((r4 & (1 << 28)) == 0) + { + row = 3; + col = i; + r3++; + } + + if ((r4 & (1 << 29)) == 0) + { + row = 4; + col = i; + r3++; + } + + if ((r4 & (1 << 30)) == 0) + { + row = 5; + col = i; + r3++; + } + } + } //for (i = 0; i < 4; i++) + + if (r3 == 0) + { + //No Key + lr = 0; + } + else if (r3 == 1) + { + //Single Key + lr = col * 5 + row; + } + else if ((r3 == 2) && (ip == 2)) + { + //Two Keys (First Row) + switch (lr) + { + case 0: + if (col == 1) + { + lr = 21; + } + else if (col == 3) + { + lr = 22; + } + else + { + lr = 0; + } + break; + + case 1: + if (col == 2) + { + lr = 23; + } + else + { + lr = 0; + } + break; + + case 2: + if (col == 3) + { + lr = 24; + } + else + { + lr = 0; + } + break; + + default: + break; + } + } + else + { + lr = 0; + } + + if (lr != 0) + { + if ((bHwKeyCode & 0x1f) == lr) + { + if (bData_40002c02 > 9) + { + //Valid + bHwKeyCode |= 0x20; + } + + if (bData_40002c02 > 0xc0) + { + //Long Press + bHwKeyCode |= 0x40; + } + + if (bData_40002c02 < 0xff) + { + bData_40002c02++; + } + } + else if ((bHwKeyCode & 0x1f) >= 21) + { + switch (bHwKeyCode & 0x1f) + { + case 21: + if ((lr == 1) || (lr == 6)) + { + bHwKeyCode = (bHwKeyCode & 0xe0) | lr; + } + break; + + case 22: + if ((lr == 1) || (lr == 16)) + { + bHwKeyCode = (bHwKeyCode & 0xe0) | lr; + } + break; + + case 23: + if ((lr == 11) || (lr == 6)) + { + bHwKeyCode = (bHwKeyCode & 0xe0) | lr; + } + break; + + case 24: + if ((lr == 11) || (lr == 16)) + { + bHwKeyCode = (bHwKeyCode & 0xe0) | lr; + } + break; + + default: + break; + } + } + else if (ip == 2) + { + if (bData_40002c05 == lr) + { + if (bData_40002c03 > 9) + { + bHwKeyCode = (bHwKeyCode & 0xe0) | lr; + } + + if (bData_40002c03 < 0xff) + { + bData_40002c03++; + } + } + else + { + bData_40002c05 = 0; + + switch (bHwKeyCode & 0x1f) + { + case 1: + if ((lr == 21) || (lr == 22)) + { + bData_40002c05 = lr; + } + break; + + case 6: + if ((lr == 21) || (lr == 23)) + { + bData_40002c05 = lr; + } + break; + + case 11: + if ((lr == 23) || (lr == 24)) + { + bData_40002c05 = lr; + } + break; + + case 16: + if ((lr == 22) || (lr == 24)) + { + bData_40002c05 = lr; + } + break; + + default: + break; + } + } + } + else + { + bHwKeyCode = lr; + bData_40002c05 = 0; + bData_40002c03 = 0; + bData_40002c02 = 0; + } + } //if (lr != 0) + else + { + if ((bHwKeyCode & 0x20) && ((bHwKeyCode & 0x80) == 0)) + { + if (((bHwKeyQueueWritePtr + 1) % 8) != bHwKeyQueueReadPtr) + { + sHwKeyQueue[bHwKeyQueueWritePtr] = bHwKeyCode; + bHwKeyQueueWritePtr = (bHwKeyQueueWritePtr + 1) % 8; + } + } + + bHwKeyCode = 0; + bData_40002c02 = 0; + } +} + +/* 17d0 - complete */ +void func_17d0(void) +{ + bData_40002c02 = 0; + bHwKeyQueueWritePtr = 0; + bHwKeyQueueReadPtr = 0; + bHwKeyCode = 0; +} + +/* 17f8 - complete */ +#if 0 +#ifdef __GNUC__ +void timer_isr(void) __attribute__ ((interrupt ("IRQ"))); +void timer_isr(void) +#else +void timer_isr(void) __irq +#endif +#else +void timer_isr(void) +#endif +{ + read_key_matrix(); + + if (bData_40002c08 == 0) + { + IO1SET = (1 << 22); +#ifdef OLIMEX_LPC2148 + // Set LED1 + IOSET0 = (1 << 10); +#endif + + bData_40002c07 = 0; + } + else if (bData_40002c09 == 0) + { + IO1CLR = (1 << 22); +#ifdef OLIMEX_LPC2148 + // Clear LED1 + IOCLR0 = (1 << 10); +#endif + + bData_40002c07 = 0; + } + else if (bData_40002c07 <= bData_40002c08) + { + IO1CLR = (1 << 22); +#ifdef OLIMEX_LPC2148 + // Clear LED1 + IOCLR0 = (1 << 10); +#endif + + bData_40002c07++; + } + else if (bData_40002c07 <= bData_40002c09) + { + IO1SET = (1 << 22); +#ifdef OLIMEX_LPC2148 + // Set LED1 + IOSET0 = (1 << 10); +#endif + + bData_40002c07++; + } + else if (bData_40002c08 >= bData_40002c09) + { + IO1SET = (1 << 22); +#ifdef OLIMEX_LPC2148 + // Set LED1 + IOSET0 = (1 << 10); +#endif + + bData_40002c07 = 0; + bData_40002c08 = 0; + } + else + { + bData_40002c07 = 0; + } + + bTimer10msCounter++; + + if (Data_40003214_UserTimerSeconds != 0) + { + bData_40003265--; + if (bData_40003265 == 0) + { + bData_40003265 = 100; + + Data_40003214_UserTimerSeconds--; + if (Data_40003214_UserTimerSeconds == 0) + { + bData_40002c08 = 160; + bData_40002c09 = bData_40002c08 - 1; + } + } + } + +#if 0 + T0IR = 1; //Reset MR0 Interrupt + VICVectAddr = 0; +#endif +} + +/* 19cc - complete */ +#ifdef __GNUC__ +void rtc_isr(void) __attribute__ ((interrupt ("IRQ"))); +void rtc_isr(void) +#else +void rtc_isr(void) __irq +#endif +{ + // Clear the RTC Interrupt Location Register regarding.. + ILR = (1 << 0) // increment, + | (1 << 1); // Alarm. + + bTimer10msCounter = 0; + +#ifdef OLIMEX_LPC2148 + { + // Blinking LED2 + static int flag = 0; + if (flag) + { + IOSET0 = (1 << 11); + flag = 0; + } + else + { + IOCLR0 = (1 << 11); + flag = 1; + } + } +#endif + + VICVectAddr = 0; +} + +//#include "uart.c" + +#ifdef __GNUC__ +//void delay_loop(unsigned int a) __attribute__((optimize(-O0))); +#endif + +/* 2254 - complete */ +void delay_loop(unsigned int a) +{ +#ifdef __GNUC__ + volatile unsigned int b; +#else + unsigned int b; +#endif + for ( ; a > 1; a--) + { + for (b = 0x0000ffff; b > 1; b--) + { + } + } +} + +#ifdef USE_USB +#include "usb.c" +#endif + +#if 0 +#include "LPCUSB/usbinit.c" +#include "LPCUSB/usbhw_lpc.c" +#include "LPCUSB/usbcontrol.c" +#include "LPCUSB/usbstdreq.c" +#endif + +#ifdef OLIMEX_LPC2148 +#include "ssp.c" +#include "mmc.c" +#endif + +/* 227c - complete */ +void lpc_interrupt_init(void) +{ + //Timer0 + // Prescale Register + T0PR = 0; + // Match Control Register + T0MCR = 3; + // Match Register 0 + T0MR0 = 110592; // 100Hz / 10ms + // Timer Control Register + T0TCR = 3; + T0TCR = 1; + + VICIntSelect = 0; + + // Slot 0 has the highest priority and slot 15 the lowest + + VICVectCntl0 = (1 << 5) | 4; // TIMER0 -> Slot 0 + VICVectAddr0 = (unsigned int) timer_isr; + VICIntEnable = (1 << 4); // Enable TIMER0 + + VICVectCntl3 = (1 << 5) | 13; // RTC -> Slot 3 + VICVectAddr3 = (unsigned int) rtc_isr; + VICIntEnable = (1 << 13); // Enable RTC + + // Counter Increment Interrupt Register + CIIR = (1 << 0); //an increment of the Second value generates an interrupt + + // Clear the RTC Interrupt Location Register regarding... + ILR = (1 << 0) // increment, + | (1 << 1); // Alarm. + + // Clock Control Register + CCR = (1 << 4) | (1 << 0); //CLKEN + CLKSRC (from Oscillator) + +#if 0 + VICVectCntl1 = (1 << 5) | 6; // UART0 -> Slot 1 + VICVectCntl2 = (1 << 5) | 7; // UART1 -> Slot 2 + + VICIntEnable = (1 << 7); // Enable UART1 + VICIntEnable = (1 << 6); // Enable UART0 +#endif +} + +/* 2328 - complete */ +void lpc_hw_init(void) +{ + // Enable the PLL + PLL0CON = 0x01; + + // Setting peripheral Clock (pclk) to System Clock (cclk) / 4 + VPBDIV = 0; + +#ifdef OLIMEX_LPC2148 + // Setup the PLL to multiply the 12 MHz XTAL input... + PLL0CFG = 0x03 //by 4 + | (1 << 5); //divide by 2. +#else + // Setup the PLL to multiply the 11.0592 MHz XTAL input... + PLL0CFG = 0x03 //by 4, + | (1 << 5); //divide by 2. CCLK = 44.2368 MHz / Fcco = 176,9472 +#endif + PLL0FEED = 0xaa; + PLL0FEED = 0x55; + + // Wait for the PLL to lock to set frequency + while (!(PLL0STAT & 0x400)) {} + + // Connect the PLL as the clock source + PLL0CON = 0x01 | 0x02; + PLL0FEED = 0xaa; + PLL0FEED = 0x55; + + MAMCR = 2; + MAMTIM = 3; + + PINSEL0 = //0x00059505 = 00 00 00 00 00 00 01 01 10 01 01 01 00 00 01 01 + (1 << 0) | // P0.0 = TXD (UART0) + (1 << 2) | // P0.1 = RXD (UART0) + (0 << 4) | // P0.2 = GPIO Port 0.2 + (0 << 6) | // P0.3 = GPIO Port 0.3 + (1 << 8) | // P0.4 = SCK0 (SPI0) + (1 <<10) | // P0.5 = MISO0 (SPI0) + (1 <<12) | // P0.6 = MOSI0 (SPI0) + (2 <<14) | // P0.7 = PWM2 -> EXTLIGHT (Handset Pin 6: AUXO) + (1 <<16) | // P0.8 = TXD (UART1) + (1 <<18) | // P0.9 = RxD (UART1) + (0 <<20) | // P0.10 = GPIO Port 0.10 -> LCD CS + (0 <<22) | // P0.11 = GPIO Port 0.11 + (0 <<24) | // P0.12 = GPIO Port 0.12 -> LCD SCLK + (0 <<26) | // P0.13 = GPIO Port 0.13 + (0 <<28) | // P0.14 = GPIO Port 0.14 + (0 <<30); // P0.15 = GPIO Port 0.15 -> LCD Data (on DB7) + PINSEL1 = //0x800046a8 = 10 00 00 00 00 00 00 00 01 00 01 10 10 10 10 00 + (0 << 0) | // P0.16 = GPIO Port 0.16 + (2 << 2) | // P0.17 = SCK1 (SSP) + (2 << 4) | // P0.18 = MISO1 (SSP) + (2 << 6) | // P0.19 = MOSI1 (SSP) + (2 << 8) | // P0.20 = SSEL1 (SSP) + (1 <<10) | // P0.21 = PWM5 -> LCD Light + (0 <<12) | // P0.22 = GPIO Port 0.22 + (1 <<14) | // P0.23 = VBUS + (0 <<16) | // P0.24 = Reserved + (0 <<18) | // P0.25 = GPIO Port 0.25 + (0 <<20) | // P0.26 = Reserved + (0 <<22) | // P0.27 = Reserved + (0 <<24) | // P0.28 = GPIO Port 0.28 + (0 <<26) | // P0.29 = GPIO Port 0.29 + (0 <<28) | // P0.30 = GPIO Port 0.30 + (2 <<30); // P0.31 = CONNECT + PINSEL2 = //0x00000004 = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 + (0 << 0) | // Reserved + (1 << 2) | // Pins P1.36-26 are used as a Debug port. + (0 << 3); // Pins P1.25-16 are used as GPIO pins. + + IO0DIR = //0x0001b480 = 00 00 00 00 00 00 00 01 10 11 01 00 10 00 00 00 + (0 << 2) | // P0.2 = In + (0 << 3) | // P0.3 = In + (1 << 7) | // P0.7 = Out +#ifdef OLIMEX_LPC2148 + (1 <<10) | // P0.10 = Out -> LED1 + (1 <<11) | // P0.11 = Out -> LED2 +#else + (1 <<10) | // P0.10 = Out -> LCD CS + (0 <<11) | // P0.11 = In +#endif + (1 <<12) | // P0.12 = Out -> LCD SCLK + (1 <<13) | // P0.13 = Out -> double LED torch + (0 <<14) | // P0.14 = In + (1 <<15) | // P0.15 = Out -> LCD Data (on DB7) + (1 <<16) | // P0.16 = Out -> single LED torch + (0 <<22) | // P0.22 = In -> Key Matrix Row 1 + (0 <<25) | // P0.25 = In -> Key Matrix Row 2 + (0 <<28) | // P0.28 = In -> Key Matrix Row 3 + (0 <<29) | // P0.29 = In -> Key Matrix Row 4 + (0 <<30); // P0.30 = In -> Key Matrix Row 5 + IO1DIR = //0x03cf0000 = 00 00 00 11 11 00 11 11 00 00 00 00 00 00 00 00 + (1 <<16) | // P1.16 = Out -> Key Matrix Column D + (1 <<17) | // P1.17 = Out -> Key Matrix Column C + (1 <<18) | // P1.18 = Out -> Key Matrix Column B + (1 <<19) | // P1.19 = Out -> Key Matrix Column A + (0 <<20) | // P1.20 = In + (0 <<21) | // P1.21 = In -> EXTINT (Handset Pin 3: AUXI) + (1 <<22) | // P1.22 = Out -> Buzzer + (1 <<23) | // P1.23 = Out -> LCD RS (A0 Pin Command/Data) + (1 <<24) | // P1.24 = Out -> Chip Select for SPI Flash + (1 <<25); // P1.25 = Out -> Chip Select for SPI Font ROM + IO1SET = 1 << 22; //0x00400000; P1.22 = High + IO0SET = 1 << 13; //0x00002000; P0.13 = High + IO0CLR = 1 << 16; //0x00010000; P0.16 = Low + IO1SET = 1 << 24; //0x01000000; P1.24 = High + IO1SET = 1 << 25; //0x02000000; P1.25 = High + + spi0_init(); +#ifdef OLIMEX_LPC2148 + ssp_init(); +#endif + + lcd_display_configure(); + lcd_display_clear(); + lcd_display_brightness(0x80); + setDisplayPWM(0xff); + + func_17d0(); + + bData_40002c08 = 0x10; + bData_40002c09 = 0x10; + bData_40002c07 = 0x00; + +#if 0 + lpc_interrupt_init(); +#endif +} + + +/* 243c - complete */ +void flash_read(unsigned int PageAdr, int b, int Count, unsigned char* Data) +{ +#ifndef OLIMEX_LPC2148 + unsigned short i = 0; + + ENABLE_FLASH_CS; + + spi0_write_read_byte(FLASH_CMD_CONT_ARRAY_READ); + spi0_write_read_byte(PageAdr >> (16 - FLASH_PAGE_BITS)); + spi0_write_read_byte(PageAdr << (FLASH_PAGE_BITS - 8)); + + while (i < (b+5 + Count)) + { + if (i < (b+5)) + { + spi0_write_read_byte(0); + } + else + { + Data[i - (b+5)] = spi0_write_read_byte(0); + } + + i++; + } + + DISABLE_FLASH_CS; +#endif +} + +/* 24d4 - complete */ +void flash_write(int PageAdr, unsigned short BufAdr, int Count, unsigned char* Data) +{ +#ifndef OLIMEX_LPC2148 + unsigned short i; + ENABLE_FLASH_CS; + + spi0_write_read_byte(FLASH_CMD_BUF1_WRITE); + spi0_write_read_byte(0x00); + spi0_write_read_byte(BufAdr >> 8); + spi0_write_read_byte(BufAdr & 0xFF); + + for (i = 0; i < Count; i++) + { + spi0_write_read_byte(Data[i]); + } + + DISABLE_FLASH_CS; + ENABLE_FLASH_CS; + + if (PageAdr < 0x1000) + { + spi0_write_read_byte(FLASH_CMD_BUF1_TO_MEM); + spi0_write_read_byte(PageAdr >> (16 - FLASH_PAGE_BITS)); + spi0_write_read_byte(PageAdr << (FLASH_PAGE_BITS - 8)); + spi0_write_read_byte(0); + } + + DISABLE_FLASH_CS; + + delay_loop(5); +#endif +} + +/* 258c - complete */ +void flash_write_cust_sky_target(int a, unsigned char* b) +{ + unsigned char sp[FLASH_PAGE_SIZE]; + unsigned char i = 0; + b[0] = 1; + + flash_read((0x37 << 6) | 5, 0, sizeof(sp), sp); + + for (i = 0; i < 24; i++) + { + sp[(a - 1)*24 + i] = b[i]; + } + + flash_write((0x37 << 6) | 5, 0, sizeof(sp), sp); +} + +/* 260c - complete */ +void flash_write_cust_land_target(int a, unsigned char* b) +{ + unsigned char sp[FLASH_PAGE_SIZE]; + unsigned char i = 0; + b[0] = 1; + + flash_read((0x37 << 6) | 6, 0, sizeof(sp), sp); + + for (i = 0; i < 25; i++) + { + sp[25*(a - 1) + i] = b[i]; + } + + flash_write((0x37 << 6) | 6, 0, sizeof(sp), sp); +} + +/* 268c - complete */ +void flash_write_recent_target(unsigned char targetType, unsigned int targetId) +{ + unsigned char oldType; + unsigned int oldId; + unsigned char buf[57]; + + flash_read((0x37 << 6) | 7, 0, sizeof(buf), buf); + + oldType = buf[1]; + oldId = ((buf[2] - '0') * 100000) + + (((buf[3] - '0') * 10000)) + + (((buf[4] - '0') * 1000)) + + (((buf[5] - '0') * 100)) + + (((buf[6] - '0') * 10)) + + (buf[7] - '0'); + + if ((targetType == oldType) && (oldId == targetId)) + { + oldType = 0; + } + else + { + buf[0]++; + if (buf[0] > 8) + { + buf[0] = 8; + } + + flash_write((0x37 << 6) | 7, 0, sizeof(buf[0]), buf); + flash_write((0x37 << 6) | 7, 8, sizeof(buf) - sizeof(buf[0]), &buf[1]); + buf[1] = targetType; + flash_write((0x37 << 6) | 7, 1, sizeof(buf[1]), &buf[1]); + sprintf(buf, "%06d", targetId); + flash_write((0x37 << 6) | 7, 2, 6, &buf[0]); + } +} + +/* 27c4 - complete */ +void flash_get_ota_zero_data(float* a, float* b) +{ + unsigned char buf[5]; + + flash_read((0x37 << 6) | 9, 0, sizeof(buf), buf); + + *a = (buf[0] - '0') * 100.0 + (buf[1] - '0') * 10.0 + buf[2] - '0'; + *b = (buf[3] - '0') * 10.0 + buf[4] - '0'; +} + +/* 2910 - complete */ +void flash_write_ota_zero_data(int a, int b) +{ + unsigned char buf[5]; + sprintf(buf, "%03d%02d", a, b); + flash_write((0x37 << 6) | 9, 0, sizeof(buf), buf); +} + +/* 29b0 - complete */ +void flash_write_custom_site_data(unsigned char* name, unsigned char* lon, unsigned char* lat, unsigned char* tz) +{ + flash_write((0x37 << 6) | 10, 10, 8, name); + flash_write((0x37 << 6) | 10, 18, 6, lon); + flash_write((0x37 << 6) | 10, 24, 5, lat); + flash_write((0x37 << 6) | 10, 29, 3, tz); +} + +/* 2a1c - complete */ +void flash_get_custom_site_data(unsigned char* pName, + float* pLongitude, float* pLatitude, int* pTimeZone) +{ + unsigned char buf[22]; + unsigned char i = 0; + + flash_read((0x37 << 6) | 10, 10, sizeof(buf), buf); + + for (i = 0; i < 8; i++) + { + pName[i] = buf[i]; + } + + *pLongitude = (buf[9] - '0') * 100.0 + (buf[10] - '0') * 10.0 + buf[11] - '0' + + ((buf[12] - '0') * 10.0 + buf[13] - '0') / 60.0; + + if (buf[8] == 'W') + { + *pLongitude *= -1.0; + } + + *pLatitude = (buf[15] - '0') * 10.0 + buf[16] - '0' + + ((buf[17] - '0') * 10.0 + buf[18] - '0') / 60.0; + + if (buf[14] == 'S') + { + *pLatitude *= -1.0; + } + + *pTimeZone = (buf[20] - '0') * 10.0 + buf[21] - '0'; + + if (buf[19] == 'W') + { + *pTimeZone *= -1.0; + } +} + +/* 2df8 - complete */ +void func_2df8(int a, int b, int c, int d, unsigned char* e) +{ + unsigned char buf[528]; + unsigned char i = 0; + + flash_read(b, 0, sizeof(buf), buf); + + for (i = 0; i < d; i++) + { + buf[d * (a % (528 / d)) + c + i] = e[i]; + } + + flash_write(b, 0, sizeof(buf), buf); +} + +/* 2e94 - todo */ +void func_2e94(unsigned short a) +{ + unsigned char buf[528]; + + if (a > 500) + { + return; + } + + Data_40002c24.wData = a; + + flash_read(0xFFF, 0, sizeof(buf), buf); + + buf[4] = Data_40002c24.bData[0]; + buf[5] = Data_40002c24.bData[1]; + + flash_write(0xFFF, 0, sizeof(buf), buf); +} + +/* 2f00 - todo */ +unsigned short func_2f00(void) +{ + flash_read(0xFFF, 0x04, 2, Data_40002c24.bData); + + if (Data_40002c24.wData > 500) + { + func_2e94(0); + return 0; + } + + return Data_40002c24.wData; +} + +/* 2f48 - todo */ +void func_2f48(int a, unsigned char* b) +{ + func_2df8(a, 0xfde, 0, 16, b); +} + +/* 2f74 - todo */ +int func_2f74(int a, int* b, int* c, int* d, int* e) +{ + unsigned char buf[16]; + unsigned char i; + unsigned short sl; + unsigned short fp; + + sl = func_2f00(); + + if ((sl == 0) || ((sl-1) < a)) + { + return 0; + } + + fp = 16 * (a % 33); + + flash_read((unsigned short)(0xfde + (a / 33)), fp, sizeof(buf), buf); + + for (i = 0; i < 4; i++) + { + Data_40002c28.bData[i] = buf[i]; + } + + *b = Data_40002c28.Data; + + for (i = 0; i < 4; i++) + { + Data_40002c28.bData[i] = buf[i + 4]; + } + + *c = Data_40002c28.Data; + + for (i = 0; i < 4; i++) + { + Data_40002c28.bData[i] = buf[i + 8]; + } + + *d = Data_40002c28.Data; + + for (i = 0; i < 4; i++) + { + Data_40002c28.bData[i] = buf[i + 12]; + } + + *e = Data_40002c28.Data; + + return 1; +} + +/* 30e4 - todo */ +int func_30e4(unsigned char* a, int b, int c, int d, int e) +{ + unsigned char buf[16]; + unsigned char i; + unsigned short sl; + + sl = func_2f00(); + + if (a[0] == 0) + { + if (sl != 0) + { + func_2e94(0); + sl = 0; + } + a[0] = 1; + } + + if (sl >= 500) + { + return 0; + } + + Data_40002c28.Data = b; + + for (i = 0; i < 4; i++) + { + buf[i] = Data_40002c28.bData[i]; + } + + Data_40002c28.Data = c; + + for (i = 0; i < 4; i++) + { + buf[i + 4] = Data_40002c28.bData[i]; + } + + Data_40002c28.Data = d; + + for (i = 0; i < 4; i++) + { + buf[i + 8] = Data_40002c28.bData[i]; + } + + Data_40002c28.Data = e; + + for (i = 0; i < 4; i++) + { + buf[i + 12] = Data_40002c28.bData[i]; + } + + func_2f48(sl, buf); + + func_2e94(sl + 1); + + return 1; +} + +/* 3230 - todo */ +void func_3230(unsigned char* a, float* b, float* c) +{ + a = a; +} + +/* 3238 - complete */ +void func_3238(unsigned short a) +{ + unsigned char buf[528]; + + if (a > 66) + { + return; + } + + Data_40002c24.wData = a; + + flash_read(0xfff, 0, sizeof(buf), buf); + + buf[8] = Data_40002c24.bData[0]; + buf[9] = Data_40002c24.bData[1]; + + flash_write(0xfff, 0, sizeof(buf), buf); +} + +/* 32a4 - todo */ +int func_32a4(void) +{ + flash_read(0xfff, 0x08, 2, Data_40002c24.bData); + + if (Data_40002c24.wData > 66) + { + func_3238(0); + return 0; + } + + return Data_40002c24.wData; +} + +/* 32ec - complete */ +void func_32ec(unsigned short a) +{ + unsigned char buf[528]; + + if (a > 65) + { + return; + } + + Data_40002c24.wData = a; + + flash_read(0xfff, 0, sizeof(buf), buf); + + buf[10] = Data_40002c24.bData[0]; + buf[11] = Data_40002c24.bData[1]; + + flash_write(0xfff, 0, sizeof(buf), buf); +} + +/* 3358 - todo */ +int func_3358(void) +{ + flash_read(0xfff, 0x0a, 2, Data_40002c24.bData); + + if (Data_40002c24.wData > 65) + { + func_32ec(0); + return 0; + } + + return Data_40002c24.wData; +} + +/* 33a0 - todo */ +void func_33a0(int a, unsigned char* b) +{ + func_2df8(a, 0, 0, 8, b); +} + +/* 33cc - todo */ +int func_33cc(unsigned short a, int* b, int* c) +{ + unsigned char buf[8]; + unsigned char i; + int r8, r9; + unsigned short sl; + unsigned short fp; + + r8 = func_32a4(); + r9 = func_3358(); + + if ((r8 == 0) || ((r8-1) < a)) + { + return 0; + } + + if (r9 < a) + { + a = r9 + 66 - a; + } + else + { + a = r9 - a; + } + + sl = 8 * (a % 66); + fp = a / 66; + + flash_read(fp, sl, sizeof(buf), buf); + + for (i = 0; i < 4; i++) + { + Data_40002c28.bData[i] = buf[i]; + } + + *b = Data_40002c28.Data; + + for (i = 0; i < 4; i++) + { + Data_40002c28.bData[i] = buf[i+4]; + } + + *c = Data_40002c28.Data; + + return 1; +} + +#include "object_database.c" + +/* 4dd0 - todo */ +int func_4dd0(int a, Struct_4dd0* b) +{ + unsigned char buf[20]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 640)) + { + return 0; + } + + r6 = (a - 1) / 26; + r7 = ((a - 1) % 26) * 20; + + flash_read((unsigned short)(0xd9e + r6), r7, sizeof(buf), buf); + + for (i = 0; i < 8; i++) + { + b->bData_0[i-0] = buf[i]; + } + + b->bData_0[8] = 0; + b->bData_0[9] = 0; + + for (i = 8; i < 16; i++) + { + b->bData_10[i-8] = buf[i]; + } + + b->bData_10[8] = 0; + b->bData_10[9] = 0; + + b->fData_20 = buf[16] + buf[17] / 100.0; + b->fData_24 = buf[18] + buf[19] / 100.0; + + return 1; +} + +/* 4f5c - todo */ +int flash_get_site_data(int a, Struct_SiteData* b) +{ + unsigned char buf[40]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 170)) + { + return 0; + } + + r6 = (a - 1) / 13; + r7 = ((a - 1) % 13) * 40; + + flash_read((unsigned short)(0xdb7 + r6), r7, sizeof(buf), buf); + + for (i = 0; i < 18; i++) + { + b->cCountry[i-0] = buf[i]; + } + + b->cCountry[18] = ' '; + b->cCountry[19] = 0; + + for (i = 18; i < 34; i++) + { + b->cCity[i-18] = buf[i]; + } + + b->cCity[16] = ' '; + b->cCity[17] = 0; + + if (buf[34] >= 0x80) + { + b->fLongitude = ((0x80 - buf[34]) * 100) - buf[35] - buf[36] / 60.0; + } + else + { + b->fLongitude = (buf[34] * 100) + buf[35] + buf[36] / 60.0; + } + + if (buf[37] >= 0x80) + { + b->fLatitude = (0x80 - buf[37]) - buf[38] / 60.0; + } + else + { + b->fLatitude = buf[37] + buf[38] / 60.0; + } + + if (buf[39] > 0x80) + { + b->Zone = 0x80 - buf[39]; + } + else + { + b->Zone = buf[39]; + } + + return 1; +} + +/* 5218 - complete */ +int func_5218(int a, Struct_5218* b) +{ + unsigned char sp104[22 * 24]; + unsigned char sp80[24]; + unsigned char i; + + if ((a == 0) && (a > 10)) + { + return 0; + } + + flash_read(0xdc5, 0, sizeof(sp104), sp104); + + for (i = 0; i < 24; i++) + { + sp80[i] = sp104[(a - 1) * 24 + i]; + } + + b->bData_0 = sp80[0]; + + for (i = 1; i < 9; i++) + { + b->bData_1[i-1] = sp80[i]; + } + + b->fData_12 = sp80[9] * 10 + sp80[10] + + (sp80[11] * 10 + sp80[12]) / 60.0 + + (sp80[13] * 10 + sp80[14] + sp80[15] / 10.0) / 3600.0; + + b->fData_16 = sp80[17] * 10 + sp80[18] + + (sp80[19] * 10 + sp80[20]) / 60.0 + + (sp80[21] * 10 + sp80[22] + sp80[23] / 10.0) / 3600.0; + + if (sp80[16] == '-') + { + b->fData_16 *= -1.0; + } + + return 1; +} + +/* 54e0 - complete */ +int func_54e0(int a, Struct_54e0* b) +{ + unsigned char sp108[528]; + unsigned char sp80[25]; + unsigned char i; + + if ((a == 0) && (a > 9)) + { + return 0; + } + + flash_read(0xdc6, 0, sizeof(sp108), sp108); + + for (i = 0; i < 25; i++) + { + sp80[i] = sp108[(a - 1) * 25 + i]; + } + + b->bData_0 = sp80[0]; + + for (i = 1; i < 9; i++) + { + b->bData_1[i-1] = sp80[i]; + } + + b->fData_12 = sp80[9] * 100 + sp80[10] * 10 + sp80[11] + + (sp80[12] * 10 + sp80[13]) / 60.0 + + (sp80[14] * 10 + sp80[15] + sp80[16] / 10.0) / 3600.0; + + b->fData_16 = sp80[18] * 10 + sp80[19] + + (sp80[20] * 10 + sp80[21]) / 60.0 + + (sp80[22] * 10 + sp80[23] + sp80[24] / 10.0) / 3600.0; + + if (sp80[17] == '-') + { + b->fData_16 *= -1.0; + } + + return 1; +} + +/* 57b8 - complete */ +unsigned char flash_get_recent_targets(unsigned char* targetTypes, int* targetIds, void* c) +{ + unsigned char buf[57]; + unsigned char i; + unsigned char count; + + flash_read((0x37 << 6) | 7, 0, sizeof(buf), buf); + + count = buf[0]; + for (i = 0; i < count; i++) + { + targetTypes[i] = buf[1 + i*7]; + } + + for (i = 0; i < count; i++) + { + targetIds[i] = + (buf[2 + i*7] - '0') * 100000 + + (buf[3 + i*7] - '0') * 10000 + + (buf[4 + i*7] - '0') * 1000 + + (buf[5 + i*7] - '0') * 100 + + (buf[6 + i*7] - '0') * 10 + + (buf[7 + i*7] - '0'); + } + + c = buf; + return buf[0]; +} + +#include "align_stars.c" + +/* 5f40 - todo */ +void initialize_variables(void) +{ + bData_40002f1e_SetupLocalData = 1; + bHelpActive = 0; + bData_40002c5a = 0; + bData_40002c68 = 0; + bDaylightSavingTime = 0; + dTrackingRate = 0.0; + bData_40002e7c_TrackingRateType = 0; + dGuidingSpeed = 1.0; + g_dPoleAxisDevEastWest = 0.235; + g_dPoleAxisDevNorthSouth = 0.326; + dData_40002c88 = 0.0; + dData_40002c90 = 0.0; + + //Rectascension + Data_40002cb8 = 11; + Data_40002cbc = 41; + fData_40002cc0 = 12.6; + + //Declination + Data_40002d40 = 1; + Data_40002cf4 = 55; + Data_40002cf8 = 11; + fData_40002cfc = 1.9; + + Data_40002d20 = 1; + Data_40002d24 = 3; + fData_40002d28 = 5.9; + + Data_40002d48 = 6; + Data_40002d4c = 3; + fData_40002d50 = 5.8; + + Data_40002d68_OTARightAscensionHours = 2; + Data_40002d6c_OTARightAscensionMinutes = 3; + fData_40002d70_OTARightAscensionSeconds = 2.3; + Data_40002d8c_OTADeclinationDegrees = 5; + Data_40002d90_OTADeclinationMinutes = 2; + fData_40002d94_OTADeclinationSeconds = 5.6; + Data_40002dac = 8; + Data_40002db0 = 2; + fData_40002db4 = 5.8; + Data_40002de0 = 3; + Data_40002de4 = 6; + fData_40002de8 = 2.5; + Data_40002e18_SiteLongitudeDegrees = 12; + Data_40002e1c_SiteLongitudeMinutes = 7; + fData_40002e20_SiteLongitudeSeconds = 1.3; + Data_40002e34 = 1; + Data_40002e38_SiteLatitudeDegrees = 5; + Data_40002e3c_SiteLatitudeMinutes = 1; + fData_40002e40_SiteLatitudeSeconds = 8.9; + Data_40002e44 = 1; + Data_40002e54_Zone = 8; + Data_40002e5c_Year = 2010; + bData_40002e60_Month = 8; + bData_40002e61_Day = 28; + bData_40002e62_Hours = 18; + bData_40002e63_Minutes = 18; + bData_40002e64_Seconds = 18; + bData_40002e79_SkyLandTargetSeletion = 0; + bData_40002e7a_MountType = MENU_MOUNT_TYPE_AZ; //0; + bData_40002e7b_GpsAvailable = 0; + g_eSlewRateIndex = SLEW_RATE_64X; //5; + bData_40002e7e = 0; + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + g_bSlewingStop = 1; + bData_40002e8b = 0; + bData_40002e8c = 0; + fData_40002e90 = 0; + fData_40002e98 = 23.8; + Data_40002e9c = 0; + Data_40002e94 = 0; + fData_40002ea0 = 0; + fData_40002ea8 = 23.8; + fData_40002eac = 0; + fData_40002ea4 = 0; + iBacklashCorrectionSlewing = 0; + bData_40002eb4 = 0; + bData_40002eb5_SolarSystemObjectNr = 0; + wData_40002eb6 = 0; + wData_40002eb8_MessierNr = 0; + wData_40002eba_NGCNr = 0; + wData_40002ebc_ICNr = 0; + wData_40002ebe_ShNr = 0; + wData_40002ec0_BrightStarNr = 0; + Data_40002ec4_SAONr = 0; + wData_40002ecc = 0; + bData_40002ece_ConstellationNr = 1; + wData_40002ed0 = 0; + bData_40002ed2_FamousStarNr = 0; + wData_40002ed4 = 0; + wData_40002ed6 = 0; + wData_40002ed8 = 0; + wData_40002eda = 1; + bData_40002ede = 1; + bData_40002edf = 1; + bData_40002ef7 = 0; + Data_40002f04 = 0; + Data_40002f08 = 0; + bData_40002f0c = 0; + bData_40002f0d_RecentTargetType = 0; + bData_40002f10_RecentTargetId = 0; +} + +/* 6518 - complete */ +void get_rtc_date_time(void) +{ + unsigned int r0 = CTIME0; + unsigned int r1 = CTIME1; + + Data_40002e5c_Year = (r1 >> 16) & 0x0fff; + bData_40002e60_Month = (r1 >> 8) & 0x0f; + bData_40002e61_Day = r1 & 0x1f; //Day + bData_40002e62_Hours = (r0 >> 16) & 0x1f; + bData_40002e63_Minutes = (r0 >> 8) & 0x3f; + bData_40002e64_Seconds = r0 & 0x3f; //Seconds + wRtcMilliSeconds = bTimer10msCounter * 10; +} + +#ifdef __GNUC__ +//void func_659c(unsigned short a) __attribute__((optimize(-O0))); +#endif + +/* 659c - complete */ +void func_659c(unsigned short a) +{ +#ifdef __GNUC__ + volatile unsigned short b; +#else + unsigned short b; +#endif + for (; a > 1; a--) + { + for (b = 10000; b > 1; b--) + { + } + } +} + +/* 65d4 - todo */ +void func_65d4(double sp40, double sp48) +{ +// double sp48; +// double sp40; + + if (bData_40002c1a == 1) + { + #if 0 + Data_40004128.dData_8 = 0.0754242657290017382010205437837; + Data_40004128.dData_16 = 0.0754242657290017382010205437837; + Data_40004128.dData_24 = 0.000109484484490649148667393286694; + Data_40004128.dData_32 = 0.000109484484490649148667393286694; + #else + Data_40004128.dData_8 = Data_40004128.dData_16 = 0.0754242657290017382010205437837; + Data_40004128.dData_24 = Data_40004128.dData_32 = 0.000109484484490649148667393286694; + #endif + } + //6634 + if (bData_40002e8b == 0) //Always "0" + { + if (((Data_40004128.dData_176 > 0) && + ((Data_40004128.dMotorPositionRaAxis - Data_40004128.dTargetPositionRaAxis) > 0.005)) || + ((Data_40004128.dData_176 < 0) && + ((Data_40004128.dMotorPositionRaAxis - Data_40004128.dTargetPositionRaAxis) < -0.005))) + { + //66e4 + if (bData_40002c1a == 1) + { + //66f4 + Data_400033c8.dwData = (Data_40004128.dTargetPositionRaAxis - 0.0 * Data_40004128.dData_176 / 3600.0) * + 256 / Data_40004128.dData_24; + //->6818 + } + else + { + //6788 + Data_400033c8.dwData = (Data_40004128.dTargetPositionRaAxis - 0.6 * Data_40004128.dData_176 / 3600.0) * + 256 / Data_40004128.dData_24; + } + //6818 + Data_400033cc.dwData = sp40 * 1.0 / Data_40004128.dData_8; + //->6a44 + } + else + { + //6860 + if (bData_40002c1a == 1) + { + //6870 + Data_400033c8.dwData = (Data_40004128.dTargetPositionRaAxis + 0.0 * Data_40004128.dData_176 / 3600.0) * + 256 / Data_40004128.dData_24; + //->6a00 + } + else + { + //6970 + Data_400033c8.dwData = (Data_40004128.dTargetPositionRaAxis + 0.6 * Data_40004128.dData_176 / 3600.0) * + 256 / Data_40004128.dData_24; + } + //6a00 + Data_400033cc.dwData = sp40 * 1.0 / Data_40004128.dData_8; + } + //6a44 + if (bData_40002c1a == 2) + { + //6a54 + if (Data_400033cc.dwData > 980) + { + Data_400033cc.dwData = 980; + } + //->6a90 + } + else + { + //6a74 + if (Data_400033cc.dwData > 2000) + { + Data_400033cc.dwData = 2000; + } + } + //6a90 + if (Data_40004128.alignmentPause == 1) + { + Data_400033cc.dwData = 0; + } + //6aac + if (bData_40002c1a == 1) + { + //6abc + if (Data_40004128.dData_304 == 2) + { + //6ad8 + if (g_iSlewStepRaAxis == 0) + { + Data_400033cc.dwData = 5; + } + //6af4 + if ((iMountAutoguideRa != 0) || (Data_40003488 != 0)) + { + Data_400033cc.dwData = abs(2*((iMountAutoguideRa + 6 * Data_40003488)) + 6); + + if (iMountAutoguideRa == 1) + { + Data_400033cc.dwData = 12; + } + } + //6b68 + } + //6b68 + if (g_iSlewStepRaAxis != 0) + { + switch (g_eSlewRateIndex) + { + case SLEW_RATE_1X: //1: + //->6bb4 + Data_400033cc.dwData = 2*g_iSlewStepRaAxis + 6; + break; + + case SLEW_RATE_2X: //2: + //->6bd4 + Data_400033cc.dwData = 16; + break; + + case SLEW_RATE_8X: //3: + //->6be8 + Data_400033cc.dwData = 60; + break; + + case SLEW_RATE_16X: //4: + //->6bfc + Data_400033cc.dwData = 240; + break; + + case SLEW_RATE_64X: //5: + //->6c10 + Data_400033cc.dwData = 460; + break; + + case SLEW_RATE_128X: //6: + //->6c24 + Data_400033cc.dwData = 640; + break; + + case SLEW_RATE_256X: //7: + //->6c38 + Data_400033cc.dwData = 2000; + + if (Data_400033cc.dwData <= Data_40002e80) + { + Data_40002e80 = Data_400033cc.dwData; + } + else + { + Data_40002e80 += 400; + } + Data_400033cc.dwData = Data_40002e80; + break; + + case SLEW_RATE_512X: //8: + //->6c9c + Data_400033cc.dwData = 3200; + + if (Data_400033cc.dwData <= Data_40002e80) + { + Data_40002e80 = Data_400033cc.dwData; + } + else + { + Data_40002e80 += 640; + } + Data_400033cc.dwData = Data_40002e80; + break; + + case SLEW_RATE_MAX: //9: + //->6d00 + Data_400033cc.dwData = 4800; + + if (Data_400033cc.dwData <= Data_40002e80) + { + Data_40002e80 = Data_400033cc.dwData; + } + else + { + Data_40002e80 += 800; + } + Data_400033cc.dwData = Data_40002e80; + break; + + #if 0 + default: + //->6d64 + break; + #endif + } + //6d64 + } //if (g_iSlewStepRaAxis != 0) + //6d68 + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(1 + 2 + 3); + uart1_write_byte(0x02); //Send RA? + uart1_write_byte(Data_400033cc.bData[1]); + uart1_write_byte(Data_400033cc.bData[0]); + uart1_write_byte(Data_400033c8.bData[3]); + uart1_write_byte(Data_400033c8.bData[2]); + uart1_write_byte(Data_400033c8.bData[1]); + //->6f6c + } //if (bData_40002c1a == 1) + else + { + //6dec + if (g_iSlewStepRaAxis != 0) + { + switch (g_eSlewRateIndex) + { + case SLEW_RATE_1X: //1: + //->6e38 + Data_400033cc.dwData = 8; + break; + + case SLEW_RATE_2X: //2: + //->6e4c + Data_400033cc.dwData = 16; + break; + + case SLEW_RATE_8X: //3: + //->6e60 + Data_400033cc.dwData = 32; + break; + + case SLEW_RATE_16X: //4: + //->6e74 + Data_400033cc.dwData = 64; + break; + + case SLEW_RATE_64X: //5: + //->6e88 + Data_400033cc.dwData = 100; + break; + + case SLEW_RATE_128X: //6: + //->6e9c + Data_400033cc.dwData = 200; + break; + + case SLEW_RATE_256X: //7: + //->6eb0 + Data_400033cc.dwData = 400; + break; + + case SLEW_RATE_512X: //8: + //->6ec4 + Data_400033cc.dwData = 600; + //break; //-> BUG?? + + case SLEW_RATE_MAX: //9: + //->6ed8 + Data_400033cc.dwData = 980; + break; + + #if 0 + default: + //->6ee8 + break; + #endif + } + } //if (g_iSlewStepRaAxis != 0) + //6eec + if (Data_400033cc.dwData > 980) + { + Data_400033cc.dwData = 980; + } + //6f08 + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x06); + uart1_write_byte(0x42); + uart1_write_byte(Data_400033cc.bData[1]); + uart1_write_byte(Data_400033cc.bData[0]); + uart1_write_byte(Data_400033c8.bData[3]); + uart1_write_byte(Data_400033c8.bData[2]); + uart1_write_byte(Data_400033c8.bData[1]); + } + //6f6c + if (bData_40002c1a == 1) + { + Data_400033c8.dwData = (0.0 * Data_40004128.dData_184 / 3600.0 + Data_40004128.dTargetPositionDecAxis) * + 256 / Data_40004128.dData_32; + //->70a0 + } + else + { + //7010 + Data_400033c8.dwData = (1.0 * Data_40004128.dData_184 / 3600.0 + Data_40004128.dTargetPositionDecAxis) * + 256 / Data_40004128.dData_32; + } + //70a0 + Data_400033cc.dwData = 1.0 * sp48 / Data_40004128.dData_16; + + if (bData_40002c1a == 2) + { + if (Data_400033cc.dwData > 980) + { + Data_400033cc.dwData = 980; + } + } + else + { + //7114 + if (Data_400033cc.dwData > 2000) + { + Data_400033cc.dwData = 2000; + } + } + //7130 + if (Data_40004128.alignmentPause == 1) + { + Data_400033cc.dwData = 0; + } + + func_659c(20); + //7154 + if (bData_40002c1a == 1) + { + //7164 + if ((Data_40004128.dData_312 == 2) && (Data_4000348c != 0)) + { + Data_400033cc.dwData = 32; + } + //719c + if (g_iSlewStepDecAxis != 0) + { + switch (g_eSlewRateIndex) + { + case SLEW_RATE_1X: //1: + //->71e8 + Data_400033cc.dwData = 4; + break; + + case SLEW_RATE_2X: //2: + //->71fc + Data_400033cc.dwData = 16; + break; + + case SLEW_RATE_8X: //3: + //->7210 + Data_400033cc.dwData = 60; + break; + + case SLEW_RATE_16X: //4: + //->7224 + Data_400033cc.dwData = 240; + break; + + case SLEW_RATE_64X: //5: + //->7238 + Data_400033cc.dwData = 460; + break; + + case SLEW_RATE_128X: //6: + //->724c + Data_400033cc.dwData = 640; + break; + + case SLEW_RATE_256X: //7: + //->7260 + Data_400033cc.dwData = 2000; + + if (Data_400033cc.dwData <= Data_40002e84) + { + Data_40002e84 = Data_400033cc.dwData; + } + else + { + Data_40002e84 += 400; + } + Data_400033cc.dwData = Data_40002e84; + break; + + case SLEW_RATE_512X: //8: + //->72c4 + Data_400033cc.dwData = 3200; + + if (Data_400033cc.dwData <= Data_40002e84) + { + Data_40002e84 = Data_400033cc.dwData; + } + else + { + Data_40002e84 += 640; + } + Data_400033cc.dwData = Data_40002e84; + break; + + case SLEW_RATE_MAX: //9: + //->7328 + Data_400033cc.dwData = 4800; + + if (Data_400033cc.dwData <= Data_40002e84) + { + Data_40002e84 = Data_400033cc.dwData; + } + else + { + Data_40002e84 += 800; + } + Data_400033cc.dwData = Data_40002e84; + break; + + #if 0 + default: + //->738c + break; + #endif + } + } + //7390 + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(1 + 2 + 3); + uart1_write_byte(0x22); //Send DEC? + uart1_write_byte(Data_400033cc.bData[1]); + uart1_write_byte(Data_400033cc.bData[0]); + uart1_write_byte(Data_400033c8.bData[3]); + uart1_write_byte(Data_400033c8.bData[2]); + uart1_write_byte(Data_400033c8.bData[1]); + //->757c + } //if (bData_40002c1a == 1) + else + { + //73f8 + if (g_iSlewStepDecAxis != 0) + { + switch (g_eSlewRateIndex) + { + case SLEW_RATE_1X: //1: + //->7444 + Data_400033cc.dwData = 5; + break; + + case SLEW_RATE_2X: //2: + //->0x7458 + Data_400033cc.dwData = 13; + break; + + case SLEW_RATE_8X: //3: + //->0x746c + Data_400033cc.dwData = 50; + break; + + case SLEW_RATE_16X: //4: + //->0x7480 + Data_400033cc.dwData = 85; + break; + + case SLEW_RATE_64X: //5: + //->0x7494 + Data_400033cc.dwData = 150; + break; + + case SLEW_RATE_128X: //6: + //->74a8 + Data_400033cc.dwData = 220; + break; + + case SLEW_RATE_256X: //7: + //->0x74bc + Data_400033cc.dwData = 500; + break; + + case SLEW_RATE_512X: //8: + //->0x74d0 + Data_400033cc.dwData = 800; + break; + + case SLEW_RATE_MAX: //9: + //->0x74e4 + Data_400033cc.dwData = 980; + break; + + #if 0 + default: + //->74f8 + break; + #endif + } + } + //74fc + if (Data_400033cc.dwData > 980) + { + Data_400033cc.dwData = 980; + } + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x06); + uart1_write_byte(0x62); + uart1_write_byte(Data_400033cc.bData[1]); + uart1_write_byte(Data_400033cc.bData[0]); + uart1_write_byte(Data_400033c8.bData[3]); + uart1_write_byte(Data_400033c8.bData[2]); + uart1_write_byte(Data_400033c8.bData[1]); + } + //757c + func_659c(10); + } //if (bData_40002e8b == 0) +} + +/* 7590 - complete */ +void func_7590(void) +{ + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0xff); +} + +/* 75c4 - todo */ +void func_75c4(void) +{ + func_7590(); + + Data_40004128.bTrackingRequest = 1; + bGotoParkPosition = 0; + bData_40002e8c = 0; + Data_40004128.dData_312 = 0.0; + Data_40004128.dData_304 = 0.0; + Data_40004128.alignmentPause = 0; + Data_40004128.dData_264 = 0.0; + Data_40004128.dData_256 = 0.0; + g_bSlewingStop = 0; +} + +/* 7654 - todo */ +double func_7654(int a, int b, double sp64, double sp88, double sp96) +{ + double sp48, sp40, sp32; + double sp24, sp16, sp8, sp; + + switch (a) + { + case 1: + //0x7680 + sp24 = 6.0; + sp16 = 18.0; + sp8 = 6.0; + sp = 9.0; + break; + + case 2: + //0x76c4 + sp24 = 2.0; + sp16 = 1.0; + sp8 = 6.0; + sp = 9.0; + break; + + case 3: + //0x7708 + break; + + default: + break; + } + + switch (b) + { + case 1: + //0x7730 + sp40 = sp88 * sp24; + if (sp96 < 0.0) + { + sp40 *= -1; + } + //7784 + if (sp40 > 10.0) + { + sp40 = 10.0; + } + //77ac + if (sp40 < -10.0) + { + sp40 = -10.0; + } + //77d4 + sp32 = sp64; + Data_40004128.dData_240 = sp32; + //->78d0 + break; + + case 2: + //0x77fc + sp40 = sp88 * sp16; + if (sp96 < 0.0) + { + sp40 *= -1; + } + //0x7850 + if (sp40 > 10.0) + { + sp40 = 10.0; + } + //7878 + if (sp40 < -10.0) + { + sp40 = -10.0; + } + //78a0 + sp32 = sp64; + Data_40004128.dData_248 = sp32; + //->78d0 + break; + + default: + break; + } + //78d0 + sp48 = sp40 + sp32; + + return sp48; +} + +/* 7950 - todo */ +void beep1(int a) +{ + bData_40002c08 = a << 5; + bData_40002c09 = bData_40002c08 - 1; +} + +/* 7978 - todo */ +void func_7978(Struct_7978 sp, double* sp272, double* sp276) +{ + double sp200; + double sp192; + double RAD = 0.0174532922222222219854614877477; //sp184 + double sp176; + double sp168; + double sp160; + double sp152; + double sp144; + double sp136; + double sp128; + double sp120; + + sp200 = /*360/24*/15.0 * *sp272 + 180.0; + if (sp200 > 360.0) + { + sp200 -= 360.0; + } + + sp200 *= RAD; + sp192 = *sp276 * RAD; + sp160 = sp.dData_32; //sp256; + sp152 = sp.dData_40; //sp264; + sp144 = sp.dData_8; //sp232; + sp136 = sp.dData_0; //sp224; + sp128 = sp.dData_24; //sp248; + sp120 = sp.dData_16; //sp240; + + sp176 = sp160 - sp144 / cos(sp192) + + tan(sp192) * sp136 + + tan(sp192) * sp120 * sin(sp200) + + tan(sp192) * sp128 * cos(sp200); + sp168 = cos(sp200) * sp120 + sp152 - sin(sp200) * sp128; + + *sp272 += (sp176 / 15.0); + while (*sp272 > 24) + { + *sp272 -= 24; + } + + while (*sp272 < 0) + { + *sp272 += 24; + } + + *sp276 += sp168; +} + +/* 7d1c - complete */ +void get_date_time(Struct_DateTime* a) +{ + unsigned int r1 = CTIME0; + unsigned int r2 = CTIME1; + + a->wYear = (r2 >> 16) & 0xFFF; + a->bMonth = (r2 >> 8) & 0x0F; + a->bDay = r2 & 0x1F; + a->bHours = (r1 >> 16) & 0x1F; + a->bMinutes = (r1 >> 8) & 0x3F; + a->bSeconds = r1 & 0x3F; + a->wMilliSeconds = bTimer10msCounter * 10; + + if (bDaylightSavingTime != 0) + { + if (a->bHours >= 1) + { + a->bHours--; + } + else + { + a->bHours = 23; + a->bDay--; + if (a->bDay == 0) + { + //Number of days of previous month + switch (a->bMonth) + { + case 1: a->bDay = 31; break; + case 2: a->bDay = 31; break; + case 3: a->bDay = 28; break; + case 4: a->bDay = 31; break; + case 5: a->bDay = 30; break; + case 6: a->bDay = 31; break; + case 7: a->bDay = 30; break; + case 8: a->bDay = 31; break; + case 9: a->bDay = 31; break; + case 10: a->bDay = 30; break; + case 11: a->bDay = 31; break; + case 12: a->bDay = 30; break; + default: break; + } + + a->bMonth--; + if (a->bMonth == 0) + { + a->bMonth += 12; + a->wYear--; + } + } + } + } //if (bDaylightSavingTime != 0) +} + +/* 7f30 - complete */ +double get_local_sidereal_time(int a, int unused, double longitude/*sp192*/) +{ + double JD; //sp176; + double T; //sp168; + double theta0; //sp160; + double theta; //sp152; + Struct_DateTime localDateTime; //sp140 + Struct_DateTime tempLocalDateTime; //sp128 + Struct_DateTime GreenwichDateTime; //sp116 + double A; //sp104; + double B; //sp96; + double hours; //sp88; + double pi = 3.1415927; //sp80 + + get_date_time(&localDateTime); + + switch (a) + { + case 1: + //0x7f6c + tempLocalDateTime = localDateTime; + GreenwichDateTime = tempLocalDateTime; + if ((tempLocalDateTime.bHours - Data_40004128.timeZone) < 0) + { + //Greenwich has still previous day + GreenwichDateTime.bHours = GreenwichDateTime.bHours - Data_40004128.timeZone + 24; + GreenwichDateTime.bDay--; + if (GreenwichDateTime.bDay < 1) + { + //7fd4 + switch (GreenwichDateTime.bMonth) + { + case 1: + GreenwichDateTime.bDay = 31; + GreenwichDateTime.bMonth = 12; + GreenwichDateTime.wYear--; + break; + case 2: + GreenwichDateTime.bDay = 31; + GreenwichDateTime.bMonth = 1; + break; + case 3: + GreenwichDateTime.bDay = 28; + GreenwichDateTime.bMonth = 2; + break; + case 4: + GreenwichDateTime.bDay = 31; + GreenwichDateTime.bMonth = 3; + break; + case 5: + GreenwichDateTime.bDay = 30; + GreenwichDateTime.bMonth = 4; + break; + case 6: + GreenwichDateTime.bDay = 31; + GreenwichDateTime.bMonth = 5; + break; + case 7: + GreenwichDateTime.bDay = 30; + GreenwichDateTime.bMonth = 6; + break; + case 8: + GreenwichDateTime.bDay = 31; + GreenwichDateTime.bMonth = 7; + break; + case 9: + GreenwichDateTime.bDay = 31; + GreenwichDateTime.bMonth = 8; + //break; //Bug: Missing break! + + case 10: + GreenwichDateTime.bDay = 30; + GreenwichDateTime.bMonth = 9; + break; + case 11: + GreenwichDateTime.bDay = 31; + GreenwichDateTime.bMonth = 10; + break; + case 12: + GreenwichDateTime.bDay = 30; + GreenwichDateTime.bMonth = 11; + break; + default: /*->8148*/ break; + } + //8150 -> 83b0 + } + //83b0 + } //if ((tempLocalDateTime.bHours - Data_40004128.timeZone) < 0) + else + { + //8154: Greenwich has already next day + if ((tempLocalDateTime.bHours - Data_40004128.timeZone) > 24) + { + GreenwichDateTime.bHours = GreenwichDateTime.bHours - Data_40004128.timeZone - 24; + GreenwichDateTime.bDay++; + switch (GreenwichDateTime.bMonth) + { + case 1: + if (GreenwichDateTime.bDay > 31) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 2; + } + break; + case 2: + if (GreenwichDateTime.bDay > 28) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 3; + } + //break; //Bug: missing break! + + case 3: + if (GreenwichDateTime.bDay > 31) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 4; + } + //break; //Bug: missing break! + + case 4: + if (GreenwichDateTime.bDay > 30) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 5; + } + break; + case 5: + if (GreenwichDateTime.bDay > 31) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 6; + } + break; + case 6: + if (GreenwichDateTime.bDay > 30) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 7; + } + break; + case 7: + if (GreenwichDateTime.bDay > 31) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 8; + } + break; + case 8: + if (GreenwichDateTime.bDay > 31) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 9; + } + break; + case 9: + if (GreenwichDateTime.bDay > 30) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 10; + } + //break; //Bug: Missing break! + + case 10: + if (GreenwichDateTime.bDay > 31) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 11; + } + break; + case 11: + if (GreenwichDateTime.bDay > 30) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 12; + } + break; + case 12: + if (GreenwichDateTime.bDay > 31) + { + GreenwichDateTime.bDay = 1; + GreenwichDateTime.bMonth = 1; + GreenwichDateTime.wYear++; + } + break; + default: /*->8390*/ break; + } + //8398 -> 83b0 + } + else + { + //839c + GreenwichDateTime.bHours = tempLocalDateTime.bHours - Data_40004128.timeZone; + } + } + //83b0 -> 83d4 + break; + + case 2: + //0x83b4 + GreenwichDateTime = localDateTime; + break; + + default: + //0x83cc + break; + } + //83d4 + if (GreenwichDateTime.bMonth < 3) + { + GreenwichDateTime.wYear--; + GreenwichDateTime.bMonth += 12; + } + //8404 + A = (int)(GreenwichDateTime.wYear * 1.0 / 100.0); + B = 2.0 - A + (int)(A * 1.0 / 4.0); + + hours = (GreenwichDateTime.bHours + GreenwichDateTime.bMinutes / 60.0 + + GreenwichDateTime.bSeconds / 3600.0 + + GreenwichDateTime.wMilliSeconds / 3600000.0) / 24.0; + + Data_40004128.dFractionalDay = hours; + + JD = (int)((GreenwichDateTime.wYear + 4716) * 365.25) + + (int)((GreenwichDateTime.bMonth + 1) * 30.6001) + + GreenwichDateTime.bDay + hours + B - 1524.5; + + Data_40004128.dJulianDay = JD; + + //http://www.geoastro.de/elevaz/basics/meeus.htm + //-> compute sidereal time at Greenwich (according to: Jean Meeus: Astronomical Algorithms) + T = (JD - 2451545.0) / 36525.0; + + theta0 = 280.46061837 + 360.98564736629 * (JD - 2451545.0) + + 0.000387993 * T*T - T*T*T / 38710000.0; + //883c + while (theta0 > 360.0) + { + theta0 -= 360.0; + } + + while (theta0 < 0.0) + { + theta0 += 360.0; + } + //888c + JD = (int)((GreenwichDateTime.wYear + 4716) * 365.25) + + (int)((GreenwichDateTime.bMonth + 1) * 30.6001) + + GreenwichDateTime.bDay + B - 1524.5; + + T = (JD - 2451545.0) / 36525.0; + + dData_400034a0_SiderealTimeGreenwich0UT = 280.46061837 + 360.98564736629 * (JD - 2451545.0) + + 0.000387993 * T*T - T*T*T / 38710000.0; + + while (dData_400034a0_SiderealTimeGreenwich0UT > 360.0) + { + dData_400034a0_SiderealTimeGreenwich0UT -= 360.0; + } + + while (dData_400034a0_SiderealTimeGreenwich0UT < 0.0) + { + dData_400034a0_SiderealTimeGreenwich0UT += 360.0; + } + //8acc + dData_400034a0_SiderealTimeGreenwich0UT /= 15; + + theta = longitude + theta0; + + while (theta > 360.0) + { + theta -= 360.0; + } + + while (theta < 0.0) + { + theta += 360.0; + } + + theta /= 15.0; //conversion to hours + + return theta; +} + +/* 8ba4 - complete */ +void convert_equatorial_to_horizontal(Struct_GeographicCoordinates geo/*sp176*/, + Struct_EquatorialCoordinates equ/*sp208*/, + int r4, int r5, + Struct_HorizontalCoordinates* hor/*r6*/) +{ + double pi = 3.14159265359; + double longitude = geo.dLongitude; //sp176; + double phi = geo.dLatitude/*sp184*/; //Geographic latitude / sp152 + double alpha = equ.dRA; //Right ascension / sp208 + double delta = equ.dDec; //Declination / sp216 + double tau; //Local hour angle / sp128 + double Theta; //Local sidereal time / sp120 + double z; //Zenith distance / sp112 + double A; //Azimuth / sp104 + double sp96; + double sp88; + + Theta = get_local_sidereal_time(r4, r5, longitude); + + tau = Theta - alpha; + while (tau >= 24) + { + tau -= 24; + } + + while (tau < 0) + { + tau += 24; + } + //8cac + tau = tau * pi * 15.0 / 180.0; + phi = phi * pi / 180.0; + delta = delta * pi / 180.0; + + z = acos(sin(phi) * sin(delta) + cos(phi) * cos(delta) * cos(tau)); + A = acos((sin(phi) * cos(delta) * cos(tau) - cos(phi) * sin(delta)) / sin(z)); + + if (tau > pi) + { + A = -1 * A; + } + //8f38 + sp96 = (sin(phi) * sin(z) + cos(z) * cos(A) * cos(phi)) / sin(z) * 15.04; //15.041067? + sp88 = cos(phi) * 15.04 * sin(A); + +#define _180_PI 57.29577951308232 + + hor->dData_0 = A * _180_PI; + hor->dAzimuth = A * _180_PI + 180.0; + hor->dData_32 = sp96; + hor->dZenithDistance = z * _180_PI; + hor->dAltitude = 90.0 - z * _180_PI; + hor->dData_40 = sp88; + hor->dData_48 = -sp88; +} + +/* 9178 - todo */ +void func_9178(void) +{ + Struct_GeographicCoordinates geoCoord; //sp256; + Struct_EquatorialCoordinates equCoord; //sp224; + Struct_HorizontalCoordinates horCoord; //sp152; + Struct_7978 sp104; + double sp96; + double sp88; + double theta; //Local sidereal time //sp80; + double H; //Local hour angle //sp72; + double sp64; + double sp56; + double sp48; + + if (Data_40004128.bTrackingRequest != 0) + { + if (bGotoParkPosition == 0) + { + //91a0 + /*sp256*/geoCoord.dLongitude = Data_40004128.geographicLongitude; + /*sp264*/geoCoord.dLatitude = Data_40004128.geographicLatitude; + Data_40004128.bTrackingActive = 1; + + switch (Data_40004128.Data_68) //Always "1" + { + case 1: + //91e4 + Data_40004128.dObjRectascension += dTrackingRate; + if (Data_40004128.dObjRectascension >= 24) + { + Data_40004128.dObjRectascension -= 24; + } + //924c + if (Data_40004128.dObjRectascension < 0) + { + Data_40004128.dObjRectascension += 24; + } + //928c + /*sp224*/equCoord.dRA = Data_40004128.dObjRectascension; + /*sp224*/equCoord.dDec = Data_40004128.dObjDeclination; + break; + + default: + break; + } + //92c0 + theta = get_local_sidereal_time(Data_40004128.Data_40, Data_40004128.bData_44, + Data_40004128.geographicLongitude); + + fData_400034c8 = theta; + + convert_equatorial_to_horizontal(geoCoord/*sp256*/, + equCoord/*sp224*/, + Data_40004128.Data_40, + Data_40004128.bData_44, + &horCoord/*sp152*/); + + //Compute the local hour angle + H = theta - /*sp224*/equCoord.dRA; + + while (H >= 24) + { + H -= 24; + } + + while (H < 0) + { + H += 24; + } + + sp64 = H; + sp56 = Data_40004128.dObjDeclination; + sp104.dData_32 = Data_40004380.dData_32; + sp104.dData_40 = Data_40004380.dData_40; + sp104.dData_8 = Data_40004380.dData_8; + sp104.dData_0 = Data_40004380.dData_0; + sp104.dData_24 = Data_40004380.dData_24; + sp104.dData_16 = Data_40004380.dData_16; + + dData_40003458 = H; + dData_40003460 = Data_40004128.dObjDeclination; + + func_7978(sp104, &dData_40003458, &dData_40003460); + + sp64 = dData_40003458; + sp56 = dData_40003460; + + fData_400034c0 = sp64 - H; + fData_400034c4 = sp56 - Data_40004128.dObjDeclination; + + if (bData_400034cc == 1) + { + //9548 + sp64 = dData_40003458 - fData_400034c0; + sp56 = dData_40003460 - fData_400034c4; + } + //95a0 + Data_40004128.dData_112 = sp64 * 15.0; + Data_40004128.dData_88 = sp64; + Data_40004128.dObjHourAngleDisplay = H; + Data_40004128.dObjDeclinationDisplay = Data_40004128.dObjDeclination; + + if (bData_40002c1a == 1) + { + //9608 + if (/*sp264*/geoCoord.dLatitude >= 0) + { + //9620 + if (sp64 >= 12) + { + //9638 + Data_40004128.dData_112 -= 180; + } + //965c + Data_40004128.dData_112 -= 90; + Data_40004128.dData_120 = 90 - sp56; + + if (sp64 < 12) + { + //96b8 + Data_40004128.dData_120 = -1 * Data_40004128.dData_120; + } + //97b4 + } //if (/*sp264*/geoCoord.dLatitude >= 0) + else + { + //96e0 + if (sp64 >= 12) + { + //9638 + Data_40004128.dData_112 -= 180; + } + //971c + Data_40004128.dData_112 = 90 - 1.0 * Data_40004128.dData_112; + Data_40004128.dData_120 = -90.0 - sp56; + + if (sp64 < 12) + { + //9790 + Data_40004128.dData_120 = -1 * Data_40004128.dData_120; + } + //97b4 + } + //97b4 + Data_40004128.dData_176 = 3.6; + Data_40004128.dData_184 = 2.1; + } //if (bData_40002c1a == 1) + //97dc + if (bData_40002c1a == 2) + { + //97ec + if (/*sp264*/geoCoord.dLatitude >= 0) + { + //9804: User on Northern Hemisphere + Data_40004128.dData_112 += 180; + + if (Data_40004128.dData_112 > 360) + { + Data_40004128.dData_112 -= 360; + } + //9868 + Data_40004128.dData_120 = 90 - sp56; + //->9934 + } //if (/*sp264*/geoCoord.dLatitude >= 0) + else + { + //988c: User on Southern Hemisphere + Data_40004128.dData_112 += 180; + + if (Data_40004128.dData_112 > 360) + { + Data_40004128.dData_112 -= 360; + } + //98f0 + Data_40004128.dData_112 = -1 * Data_40004128.dData_112; + Data_40004128.dData_120 = 90 + sp56; + } + //9934 + Data_40004128.dData_176 = 3.6; + Data_40004128.dData_184 = 3.0; + } //if (bData_40002c1a == 2) + //9958 + Data_40004128.dObjPositionRaAxis = Data_40004128.dData_112; + Data_40004128.dObjPositionDecAxis = Data_40004128.dData_120; + Data_40004128.dOffsetRa = dData_400033d8; + Data_40004128.dOffsetDec = -1 * dData_400033e0; + Data_40004128.dTargetPositionRaAxis = Data_40004128.dObjPositionRaAxis + Data_40004128.dOffsetRa + Data_40004128.dAutoguideRa; + + if (Data_40004128.dMotorPositionDecAxis >= 0) + { + //9a68 + Data_40004128.dTargetPositionDecAxis = Data_40004128.dObjPositionDecAxis + Data_40004128.dOffsetDec + Data_40004128.dAutoguideDec; + //->9b78 + } + else + { + //9aac + Data_40004128.dTargetPositionDecAxis = Data_40004128.dObjPositionDecAxis - Data_40004128.dOffsetDec - Data_40004128.dAutoguideDec; + } + //->9b78 + } //if (bGotoParkPosition == 0) + else + { + //9af0: Set values for Park/Home Position + Data_40004128.dData_112 = -180.0; + Data_40004128.dData_120 = 90.0; + Data_40004128.dObjPositionRaAxis = 0.0; + Data_40004128.dObjPositionDecAxis = 0.0; + Data_40004128.dTargetPositionRaAxis = 0.0; + Data_40004128.dTargetPositionDecAxis = 0.0; + Data_40004128.dData_176 = 3.6; + Data_40004128.dData_184 = 3.0; + } + //9b78 + Data_40004128.dRaPositionDelta = Data_40004128.dTargetPositionRaAxis - Data_40004128.dMotorPositionRaAxis; + Data_40004128.dDecPositionDelta = Data_40004128.dTargetPositionDecAxis - Data_40004128.dMotorPositionDecAxis; + +#if 0//def UART0_DEBUG + { + static char buf[100]; + + snprintf(buf, sizeof(buf)-1, "== Menu=0x%x ==\n\r", Data_40002c64_MenuContextId); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dObjRectascension=%f / .dObjDeclination=%f\n\r", + Data_40004128.dObjRectascension, Data_40004128.dObjDeclination); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dObjPositionRaAxis=%f / .dObjPositionDecAxis=%f\n\r", + Data_40004128.dObjPositionRaAxis, Data_40004128.dObjPositionDecAxis); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dOffsetRa=%f / .dOffsetDec=%f\n\r", + Data_40004128.dOffsetRa, Data_40004128.dOffsetDec); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dTargetPositionRaAxis=%f / .dTargetPositionDecAxis=%f\n\r", + Data_40004128.dTargetPositionRaAxis, Data_40004128.dTargetPositionDecAxis); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dMotorPositionRaAxis=%f / .dMotorPositionDecAxis=%f\n\r", + Data_40004128.dMotorPositionRaAxis, Data_40004128.dMotorPositionDecAxis); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dRaPositionDelta=%f / .dDecPositionDelta=%f\n\r", + Data_40004128.dRaPositionDelta, Data_40004128.dDecPositionDelta); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dData_256=%f / .dData_264=%f\n\r", + Data_40004128.dData_256, Data_40004128.dData_264); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dData_304=%f / .dData_312=%f\n\r", + Data_40004128.dData_304, Data_40004128.dData_312); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dData_240=%f / .dData_248=%f\n\r", + Data_40004128.dData_240, Data_40004128.dData_248); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "Data_40004128.dData_176=%f / .dData_184=%f\n\r", + Data_40004128.dData_176, Data_40004128.dData_184); + uart0_send(buf, strlen(buf)); + + } +#endif + + if (Data_40004128.dData_304 == 0) + { + if (Data_40004128.dData_256 > 400.0) + { + //9bf8 + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) + 400; + } + else + { + //9c30 + Data_40004128.dData_256 += 10; + } + } + //9c54 + if (Data_40004128.dData_312 == 0) + { + if (Data_40004128.dData_264 > 400.0) + { + //9c8c + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + 400; + } + else + { + //9cc4 + Data_40004128.dData_264 += 10; + } + } + //9ce8 + if (fabs(Data_40004128.dRaPositionDelta) > 0.11) + { + //9d14 + if (Data_40004128.dData_304 == 2) + { + Data_40004128.dData_304 = 0; + + if (g_eSlewRateIndex > SLEW_RATE_128X/*6*/) + { + bData_40003498 = 1; + } + } + } + //9d60 + if (fabs(Data_40004128.dDecPositionDelta) > 0.11) + { + if (Data_40004128.dData_312 == 2) + { + Data_40004128.dData_312 = 0; + + if (g_eSlewRateIndex > SLEW_RATE_128X/*6*/) + { + bData_40003498 = 1; + } + } + } + //9dd8 + if ((fabs(Data_40004128.dRaPositionDelta) > 10.0) || + (fabs(Data_40004128.dDecPositionDelta) > 5.0)) + { + //9e30 + bData_40003498 = 1; + } + //9e3c + if (fabs(Data_40004128.dRaPositionDelta) <= 15) + { + if ((Data_40004128.dData_304 == 0) || + (Data_40004128.dData_304 == 1)) + { + //9ed8 + Data_40004128.dData_304 = 1; + + if (Data_40004128.dData_256 > 180.0) + { + //9f08 + Data_40004128.dData_256 -= 10.0; + //->9f88 + } + else + { + //9f30 + if (Data_40004128.dData_256 < 180.0) + { + //9f08 + Data_40004128.dData_256 += 10.0; + //->9f88 + } + else + { + //9f74 + Data_40004128.dData_256 = 180.0; + } + } + //9f88 + if (fabs(Data_40004128.dRaPositionDelta) <= 10.0) + { + //9fb4 + if (Data_40004128.dData_256 < 150.0) + { + //9fd0 + Data_40004128.dData_256 += 10; + //->a02c + } + else + { + //9ff8 + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) + 150.0; + } + } + //a02c + if (fabs(Data_40004128.dRaPositionDelta) <= 5.0) + { + //a058 + if (Data_40004128.dData_256 < 120.0) + { + //a074 + Data_40004128.dData_256 += 10.0; + } + else + { + //a09c + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) + 120.0; + } + } + //a0d0 + if (fabs(Data_40004128.dRaPositionDelta) <= 3.0) + { + //a0fc + if (Data_40004128.dData_256 < 80.0) + { + //a118 + Data_40004128.dData_256 += 10.0; + } + else + { + //a140 + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) + 80.0; + } + } + //a174 + if (fabs(Data_40004128.dRaPositionDelta) <= 1.0) + { + //a1a0 + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) + 50.0; + } + //a1d4 + if (fabs(Data_40004128.dRaPositionDelta) <= 0.1) + { + //a200 + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) + 10.0; + } + //a234 + if (fabs(Data_40004128.dRaPositionDelta) <= 0.01) + { + //a260 + Data_40004128.dData_304 = 2.0; + } + //a274 + } + //a274 + } //if (fabs(Data_40004128.dRaPositionDelta) <= 15) + //a274 + if (fabs(Data_40004128.dDecPositionDelta) <= 15.0) + { + //a2a0 + if ((Data_40004128.dData_312 == 0.0) || + (Data_40004128.dData_312 == 1.0)) + { + //a2d8 + Data_40004128.dData_312 = 1.0; + + if (Data_40004128.dData_264 > 180.0) + { + //a308 + Data_40004128.dData_264 -= 10.0; + //->a3c0 + } + else + { + //a368 + if (Data_40004128.dData_264 < 180.0) + { + Data_40004128.dData_264 += 10.0; + } + else + { + //a3ac + Data_40004128.dData_264 = 180.0; + } + } + //a3c0 + if (fabs(Data_40004128.dDecPositionDelta) <= 10.0) + { + //a3ec + if (Data_40004128.dData_264 < 150.0) + { + //a408 + Data_40004128.dData_264 += 10.0; + } + else + { + //a430 + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + 150.0; + } + } + //a464 + if (fabs(Data_40004128.dDecPositionDelta) <= 5.0) + { + //a490 + if (Data_40004128.dData_264 < 120.0) + { + //a4ac + Data_40004128.dData_264 += 10.0; + } + else + { + //a4d4 + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + 120.0; + } + } + //a508 + if (fabs(Data_40004128.dDecPositionDelta) <= 3.0) + { + //a534 + if (Data_40004128.dData_264 < 80.0) + { + //a550 + Data_40004128.dData_264 += 10.0; + } + else + { + //a578 + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + 80.0; + } + } + //a5ac + if (fabs(Data_40004128.dDecPositionDelta) <= 1.0) + { + //a5d8 + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + 50.0; + } + //a60c + if (fabs(Data_40004128.dDecPositionDelta) <= 0.1) + { + //a638 + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + 20.0; + } + //a66c + if (fabs(Data_40004128.dDecPositionDelta) <= 0.05) + { + //a698 + Data_40004128.dData_312 = 2.0; + } + } + //a6ac + } //if (fabs(Data_40004128.dDecPositionDelta) <= 15.0) + //a6ac + if ((Data_40004128.dData_304 == 2.0) && + (Data_40004128.dData_312 == 2.0)) + { + //a6e4 + bData_40002e8c = 1; + + if (bData_40003498 != 0) + { + beep1(1); + } + + bData_40003498 = 0; + bTrackingMode = MENU_TRACKING_MODE_TRACKING; //2; + //->a730 + } + else + { + //a724 + bTrackingMode = MENU_TRACKING_MODE_POINTING; //1; + } + //a730 + if ((Data_40004128.dData_304 == 2.0) && + (Data_40004128.dData_312 == 2.0) && + (bGotoParkPosition != 0)) + { + Data_40004128.bTrackingRequest = 0; + Data_40004128.bTrackingActive = 0; + bData_40002e8c = 0; + + beep1(1); + + bTrackingMode = 100; + } + //a7a4 + if (Data_40004128.dData_304 == 2.0) + { + //a7c0 + sp96 = func_7654(2, 1, + Data_40004128.dData_240, Data_40004128.dRaPositionDelta, Data_40004128.dData_176); + } + //a804 + if (Data_40004128.dData_312 == 2.0) + { + //a820 + sp88 = func_7654(Data_40004128.Data_0, 2, + Data_40004128.dData_248, Data_40004128.dDecPositionDelta, Data_40004128.dData_184); + } + //a864 + if (Data_40004128.dData_304 == 2.0) + { + if (g_iSlewStepRaAxis == 0) + { + //a890 + sp48 = 100000.0 * sp96 * sp96 * sp96 * sp96 * sp96 * sp96 - 0.05; + + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) / 9.5 + sp48; + //->aa9c + } + else + { + //a9ac + sp48 = 100000.0 * sp96 * sp96 * sp96 * sp96 * sp96 * sp96 - 0.05; + + Data_40004128.dData_256 = fabs(Data_40004128.dData_176) / 9.5 + fabs(sp48); + } + //aa9c + if (Data_40004128.dData_256 < 0) + { + Data_40004128.dData_256 = 0; + } + } + //aacc + if (Data_40004128.dData_312 == 2.0) + { + //aae8 + if (g_iSlewStepDecAxis == 0) + { + //aaf8 + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + sp88; + //->ab70 + } + else + { + //ab2c + Data_40004128.dData_264 = fabs(Data_40004128.dData_184) + fabs(sp88); + } + //ab70 + if (Data_40004128.dData_264 < 0) + { + Data_40004128.dData_264 = 0; + } + } + //aba0 + if (/*sp176*/horCoord.dAltitude >= 0) + { + //abb8 + if (bGotoParkPosition == 0) + { + //abc8 + func_65d4(Data_40004128.dData_256, Data_40004128.dData_264); + //->ac38 + } + else + { + //abe4 + func_65d4(Data_40004128.dData_256, Data_40004128.dData_264); + //->ac38 + } + } //if (horCoord.dAltitude >= 0) + else + { + //ac00: Under Horizon + func_65d4(0.0, 0.0); + + Data_40004128.bTrackingRequest = 0; + Data_40004128.bTrackingActive = 0; + Data_40004128.bData_358 = 1; + bTrackingMode = MENU_TRACKING_MODE_UNDER_HORIZON; //3; + } + //ac38 + if (bGotoParkPosition == 0) + { + //ac48 + if ((dData_40003490 == Data_40004128.dMotorPositionDecAxis) && + (Data_40004128.dData_312 != 2.0)) + { + //ac80 + func_75c4(); + } + //ac84 + dData_40003490 = Data_40004128.dMotorPositionDecAxis; + } + //accc + } //if (Data_40004128.bTrackingRequest != 0) + else + { + //ac9c + if (Data_40004128.bTrackingActive != 0) + { + func_65d4(0.0, 0.0); + + Data_40004128.bTrackingActive = 0; + } + } + //accc +} + +/* acd8 - complete */ +void func_acd8(void) +{ + /* empty */ +} + +/* acdc - complete */ +void convert_horizontal_to_equatorial(double azimuth/*sp144*/, double altitude/*sp152*/, /*sp176*/double* pRA, double* pDec) +{ + double pi_180 = _PI_180; //sp136 + double H; //Local hour angle //sp128 + double theta; //Local sidereal time //sp120 + double phi; //Geographic latitude //sp112 + + if (azimuth < 0.0003) + { + azimuth = 0.0003; + } + //ad24 + if (altitude < 0.0003) + { + altitude = 0.0003; + } + //ad4c + theta = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude); + + phi = Data_40004128.geographicLatitude; + azimuth -= 180.0; + + H = atan(sin(azimuth * pi_180) / + (cos(azimuth * pi_180) * sin(phi * pi_180) + tan(altitude * pi_180) * cos(phi * pi_180))); + + //Convert to hours + H = H / pi_180 / 15.0; + + if (altitude > phi) + { + if (H < 0) + { + H = 24.0 + H; + //af34 -> b00c + } + else + { + //af38 -> b00c + H = H; + } + } + else + { + //af3c + if (H < 0) + { + if (azimuth < 0) + { + //af6c + H += 24.0; + //->b00c + } + else + { + //af8c + H += 12.0; + //->b00c + } + } + else + { + //afac + if (azimuth < 0) + { + H += 12.0; + //->b00c + } + else + { + //b008 + H = H; + } + } + } + //b00c + *pRA = theta - H; + + if (*pRA > 24.0) + { + *pRA -= 24.0; + } + //b044 + if (*pRA < 0.0) + { + *pRA += 24.0; + } + //b06c + *pDec = asin(sin(phi * pi_180) * sin(altitude * pi_180) - cos(phi * pi_180) * cos(altitude * pi_180) * cos(azimuth * pi_180)); + *pDec /= pi_180; //convert to degrees +} + +/* b1a8 - todo */ +void func_b1a8(Struct_b1a8 a/*sp216*/, double *r4/*sp264*/) +{ + double sp200; + double sp192; + double sp184 = 0.0174532922222222219854614877477; + double sp176; + double sp168; + double sp160; + double sp152; + double sp144; + double sp136; + double sp128; + double sp120; + + sp200 = (r4[0] + 180.0) * sp184; + sp192 = (90.0 - r4[1]) * sp184; + sp160 = a.dData_32; //sp248; + sp152 = a.dData_40; //sp256; + sp144 = a.dData_8; //sp224; + sp136 = a.dData_0; //sp216 + sp128 = a.dData_24; //sp240; + sp120 = a.dData_16; //sp232; + + sp176 = sp160 - sp144 / cos(sp192) + + tan(sp192) * sp136 + + tan(sp192) * sp120 * sin(sp200) + + tan(sp192) * sp128 * cos(sp200); + sp168 = cos(sp200) * sp120 + sp152 - sin(sp200) * sp128; + + r4[2] = r4[0] + sp176; + r4[3] = r4[1] - sp168; +} + +/* b484 - todo */ +void func_b484(double* a, double* b) +{ + *a = Data_40004128.dObjPositionRaAxis - 0.0028; + *b = Data_40004128.dObjPositionDecAxis - 0.0028; +} + +/* b4d0 - todo */ +void func_b4d0(void) +{ + Data_40004128.bTrackingRequest = 0; + dData_40003490 = 10000.0; +} + +/* b4f0 - todo */ +void StopSlewing(void) +{ + Data_40004128.bTrackingRequest = 0; + Data_40004128.dData_312 = 0.0; + Data_40004128.dData_304 = 0.0; + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0x00); + + Data_40004128.alignmentPause = 1; + Data_40004128.dData_264 = 0.0; + Data_40004128.dData_256 = 0.0; +} + +/* b594 - todo */ +void ResumeSlewing(void) +{ + Data_40004128.bTrackingRequest = 1; + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0xFF); + + Data_40004128.alignmentPause = 0; + Data_40004128.dData_264 = 0.0; + Data_40004128.dData_256 = 0.0; + + g_eSlewRateIndex = SLEW_RATE_8X; //3; + bData_40003200 = 1; + bData_40003201 = 1; + + Data_40004128.dAutoguideRa = 0.0; + Data_40004128.dAutoguideDec = 0.0; +} + +/* b64c - complete */ +void GotoEQCoordinates(double ra, double dec) +{ + Data_40004128.dObjRectascension = ra; + Data_40004128.dObjDeclination = dec; + + bData_400034b5 = 1; + fData_400034b8 = ra; //unused? + fData_400034bc = dec; //unused? + bData_400034b4 = 1; + bData_40003430 = 1; + + Data_40004128.bData_344 = 0; + Data_40004128.bData_345 = 0; + Data_40004128.Data_348 = 0; + + dData_400033d8 = dData_40003420; + dData_400033e0 = dData_40003428; + bData_40003498 = 1; + bData_400034aa = 0; + + func_75c4(); + + bData_400034cc = 0; + g_eSlewRateIndex = SLEW_RATE_8X; //3; + bData_40003200 = 1; + bData_40003201 = 1; + + Data_40004128.dAutoguideRa = 0.0; + Data_40004128.dAutoguideDec = 0.0; + + bData_40003210 = 0; + bData_40003211 = 0; +} + +/* b7c8 - todo */ +void func_b7c8(double a, double b) +{ + Data_40004128.geographicLongitude = a; + Data_40004128.geographicLatitude = b; +} + + +#include "alignment.c" + + +typedef struct +{ + double fill_0[13]; +} Struct_d2bc; + +/* d2bc - todo */ +void func_d2bc(Struct_d2bc a, int b) +{ +} + +/* d2cc - todo */ +void func_d2cc(void) +{ + Data_40004128.Data_0 = 1; + Data_40004128.Data_40 = 1; + Data_40004128.bData_44 = 0; + + Data_40004128.dData_8 = 0.22701751051996060803972454778; + Data_40004128.dData_16 = 0.165215023456907555976513890528; + Data_40004128.dData_24 = 0.000330464898018532459832846681635; + Data_40004128.dData_32 = 0.000240500240500240509066917637959; + Data_40004128.geographicLongitude = 102.7944; + Data_40004128.geographicLatitude = 25.027777; + + Data_40004128.timeZone = 8; + Data_40004128.Data_68 = 1; + + Data_40004128.dObjRectascension = 4.4993833; + Data_40004128.dObjDeclination = -26.4534166669999990517680998892; + + Data_40004128.dData_240 = 0.0; + Data_40004128.dData_248 = 0.0; + + Data_40004128.dData_272 = 500.0; + Data_40004128.dData_280 = 160.0; + Data_40004128.dData_288 = 100.0; + Data_40004128.dData_296 = 50.0; + Data_40004128.dData_304 = 0.0; + Data_40004128.dData_312 = 0.0; + + Data_40004128.bTrackingActive = 0; + Data_40004128.bTrackingRequest = 0; + Data_40004128.bData_358 = 0; + Data_40004128.bData_344 = 0; + Data_40004128.bData_345 = 0; + Data_40004128.Data_348 = 0; + Data_40004128.alignmentPause = 0; + Data_40004128.numAlignmentStars = 0; + Data_40004128.bAlignmentComplete = 1; + Data_40004128.bData_365 = 0; + Data_40004128.Data_368 = 0; + Data_40004128.alignmentStarIndex = 0; + + Data_40004128.dFirstAlignmentStarRa = 12.0; + Data_40004128.dFirstAlignmentStarDec = -16.0; + + Data_40004128.dSecondAlignmentStarRa = 10.0; + Data_40004128.dSecondAlignmentStarDec = 0.0; + + Data_40004128.dThirdAlignmentStarRa = 16.0; + Data_40004128.dThirdAlignmentStarDec = 10.0; + + Data_40004128.dData_520 = 0.0; + Data_40004128.dData_528 = 0.0; + Data_40004128.dData_536 = 0.0; + Data_40004128.dData_544 = 0.0; + Data_40004128.dData_552 = 10.0; + Data_40004128.dData_560 = 0.0; + Data_40004128.dData_568 = 0.0; + Data_40004128.dData_576 = 0.0; + Data_40004128.dObjHourAngleDisplay = 0.0; + Data_40004128.dObjDeclinationDisplay = 0.0; + + g_bLandTarget = 0; + + Data_40004380.dData_32 = 0.0; + Data_40004380.dData_40 = 0.0; + Data_40004380.dData_8 = 0.0; + Data_40004380.dData_0 = 0.0; + Data_40004380.dData_24 = 0.0; + Data_40004380.dData_16 = 0.0; + + bData_400034b5 = 0; + + dData_400033d8 = 0.0; + dData_400033e0 = 0.0; + dData_400033e8 = 0.0; + dData_400033f0 = 0.0; + + dData_40003420 = 0.0; + dData_40003428 = 0.0; + + bData_400034cd = 0; + bData_400034b4 = 0; + bData_40003430 = 0; + + Data_40004128.dAutoguideRa = 0.0; + Data_40004128.dAutoguideDec = 0.0; + + Data_40003488 = 0; + Data_4000348c = 0; +} + +/* d784 - todo */ +void func_d784(int a) +{ + bData_40002c08 = a << 1; + bData_40002c09 = bData_40002c08 - 1; +} + +/* d7ac - todo */ +double get_object_visibility_time(int a, + double rightAscension, double declination, + double geoLongitude, double geoLatitude, int timeZone) +{ + double sp168; + double sp160; + double sp152; + double sp144; + double sp136; + double sp128; + double sp120; + + rightAscension *= 15.0; + + sp136 = 0.00273043357646934187199505572607; + sp128 = 0.00273790925583078815358506474809; + + sp120 = fabs(acos((cos(1.58068652588952995863280648337) - + sin(geoLatitude * 0.0174532925199399994997673246644) * + sin(declination * 0.0174532925199399994997673246644)) / + (cos(geoLatitude * 0.0174532925199399994997673246644) * + cos(declination * 0.0174532925199399994997673246644)))) * 3.81971863420548984890956489835; + + if (a == 1) + { + //d930: Rise + sp152 = rightAscension / 15.0 - sp120; + } + //0xd960 + if (a == 2) + { + //d968: Transit + sp152 = rightAscension / 15.0; + } + //0xd984 + if (a == 3) + { + //d98c: Set + sp152 = rightAscension / 15.0 + sp120; + } + //0xd9bc + sp144 = dData_400034a0_SiderealTimeGreenwich0UT - geoLongitude / 15.0 * sp128; + //->0xda24 + while ((sp152 - sp144) < 0.0) + { + //da08 + sp152 += 24.0; + } + //->0xda74 + while ((sp152 - sp144) > 24.0) + { + //da58 + sp152 -= 24.0; + } + //daa4 + sp160 = (sp152 - sp144) * (1.0 - sp136); + sp168 = Data_40004128.timeZone - geoLongitude / 15.0 + sp160; + //->dbb8 + while (sp168 <= 0.0) + { + //db9c + sp168 += 24.0; + } + //->0xdbf0 + while (sp168 >= 24.0) + { + //dbd4 + sp168 -= 24.0; + } + + return sp168; +} + +/* dc1c - todo */ +void func_dc1c(void) +{ +} + +/* dc20 - todo */ +void lcd_display_lunar_phase(unsigned char row, unsigned char col, unsigned char idx) +{ + int i; + char bitmap[8][32] = + { + { + 0xe0, 0x18, 0x04, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x02, 0x04, 0x18, 0xe0, + 0x07, 0x18, 0x20, 0x40, 0x00, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x00, 0x40, 0x20, 0x18, 0x07, + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, + 0x03, 0x07, 0x1f, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, + 0xc0, 0xe0, 0xf8, 0x7f, 0x7f, 0x3f, 0x1f, 0x07, + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x1f, 0x07, + }, + { + 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xfc, 0xfe, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, + 0x00, 0x00, 0x00, 0x03, 0x0f, 0x3f, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x1f, 0x07, + }, + { + 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xfc, 0xe0, + 0x07, 0x1f, 0x3f, 0x7f, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x1f, 0x07, + }, + { + 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, + 0xff, 0xfe, 0xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, + 0x07, 0x1f, 0x3f, 0x7f, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0x7f, 0x3f, 0x0f, 0x03, 0x00, 0x00, 0x00, + }, + { + 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0x1f, 0x3f, 0x7f, 0x7f, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + { + 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0x1f, 0x07, 0x03, + 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0x1f, 0x3f, 0x7f, 0x7f, 0xf8, 0xe0, 0xc0, + 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + } + }; + + lcd_write_command(((col - 1) * 6 + 2) & 0x0F); + lcd_write_command(((((col - 1) * 6 + 2) & 0xF0) >> 4) | ST7565_CMD_SET_COLUMN_UPPER); + lcd_write_command(((row - 1) & 0x0F) | ST7565_CMD_SET_PAGE); + + for (i = 0; i < 16; i++) + { + lcd_write_data(bitmap[idx][i]); + } + + lcd_write_command(((col - 1) * 6 + 2) & 0x0F); + lcd_write_command(((((col - 1) * 6 + 2) & 0xF0) >> 4) | ST7565_CMD_SET_COLUMN_UPPER); + lcd_write_command((row & 0x0F) | ST7565_CMD_SET_PAGE); + + for (i = 0; i < 16; i++) + { + lcd_write_data(bitmap[idx][i+16]); + } +} + +/* dd28 - complete */ +char is_leap_year(int y) +{ + if (!(y % 4) && (!(y % 400) || (y % 100))) + { + return 1; + } + + return 0; +} + +/* dd84 - complete */ +int get_days_of_month(int year, int month) +{ + int days = 31; + switch (month - 2) + { + case 2: + //0xddcc + case 4: + //0xddd4 + case 7: + //0xddd8 + case 9: + //0xdddc + days = 30; + break; + + case 0: + //0xdde4 + if (is_leap_year(year) == 1) + { + days = 29; + } + else + { + days = 28; + } + break; + } + + return days; +} + +/* de18 - todo */ +int get_lunar_phase(int year, int month, int day) +{ + //Computes the moon phase index as a value from 0 to 7 + //See: https://github.com/sighrobot/Moon/blob/master/src/com/abe/moon/MoonPhase.java + + int phase; + int cent; //Number of century + int epact; //Epact (Date of Full Moon) + int diy; //Day in the year + int golden; //Golden number of year + + if ((month < 0) || (month > 12)) + { + month = 0; + } + + diy = Data_40002bc4_DayYear[month] + day; + + if (month > 2) + { + //de50 + if (!(year % 4) && (!(year % 400) || (year % 100))) + { + diy++; + } + } + //0xde94 + cent = year / 100 + 1; + golden = year % 19 + 1; + + #if 0 + X = (3 * C / 4) - 12; + Z = ((8 * C + 5) / 25 - 5; + E = (11 * G + 20 + Z - X) % 30; + #else + epact = ((8 * cent + 5) / 25 + (golden * 11 + 20) - 5 - ((cent * 3) / 4 - 12)) % 30; + #endif + + if (epact <= 0) + { + epact += 30; + } + //0xdf18 + if (((epact == 25) && (golden > 11)) || (epact == 24)) + { + //0xdf38 + epact++; + } + //0xdf44 + phase = ((11 + (epact + diy) * 6) % 177 / 22) & 0x07; + return phase; +} + +/* df84 - todo */ +void lcd_display_lunar_phase_screen(int year, int month) +{ + int day; + int phaseIndex; + int phaseIndexPrevious = -1; + int row = 2; + int col = 1; + unsigned char dayDigits[][2] = + { + {'0', '1'}, + {'0', '2'}, + {'0', '3'}, + {'0', '4'}, + {'0', '5'}, + {'0', '6'}, + {'0', '7'}, + {'0', '8'}, + {'0', '9'}, + {'1', '0'}, + {'1', '1'}, + {'1', '2'}, + {'1', '3'}, + {'1', '4'}, + {'1', '5'}, + {'1', '6'}, + {'1', '7'}, + {'1', '8'}, + {'1', '9'}, + {'2', '0'}, + {'2', '1'}, + {'2', '2'}, + {'2', '3'}, + {'2', '4'}, + {'2', '5'}, + {'2', '6'}, + {'2', '7'}, + {'2', '8'}, + {'2', '9'}, + {'3', '0'}, + {'3', '1'}, + }; + unsigned char year_month[7]; + + year_month[0] = year / 1000 + '0'; + year_month[1] = (year % 1000) / 100 + '0'; + year_month[2] = (year % 100) / 10 + '0'; + year_month[3] = (year % 100) % 10 + '0'; + year_month[4] = '-'; + year_month[5] = month / 10 + '0'; + year_month[6] = month % 10 + '0'; + + lcd_display_string(0, 1, 8, 7, year_month); + + for (day = 1; day <= get_days_of_month(year, month); day++) + { + //0xe084 + phaseIndex = get_lunar_phase(year, month, day); + if (phaseIndex == phaseIndexPrevious) + { + continue; + } + + phaseIndexPrevious = phaseIndex; + + lcd_display_lunar_phase(row, col, phaseIndex); + lcd_display_string(0, row + 2, col, 2, dayDigits[day-1]); + + col += 4; + + if (col > 20) + { + col -= 20; + row += 3; + } + } +} + +#include "earth.c" +#include "mercury.c" +#include "venus.c" +#include "mars.c" +#include "jupiter.c" +#include "saturn.c" +#include "uranus.c" +#include "neptun.c" +#include "pluto.c" + +/* 1af1c - todo */ +double func_1af1c(double a) +{ + //->0x1af80 + while (1) + { + //0x1af24 + if (a > 360.0) + { + //1af38 + a -= 360.0; + } + else if (a < 0.0) + { + //1af64 + a += 360.0; + } + else + { + //0x1af7c -> 0x1af84 + break; + } + } + //1af88 + return a; +} + +/* 1afc0 - complete */ +void transform_ecliptical_to_equatorial_coordinates(double Lambda, double Beta, double Epsilon, double* pAlpha, double* pDelta) +{ + double Pi = 3.1415927; + double Alpha; + double Delta; + int r6; + + Lambda = Lambda * Pi / 180.0; + Beta = Beta * Pi / 180.0; + Epsilon = Epsilon * Pi / 180.0; + + Alpha = atan((sin(Lambda) * cos(Epsilon) - (tan(Beta) * sin(Epsilon))) / cos(Lambda)); + + Alpha = Alpha * 180.0 / Pi; + + Delta = asin(sin(Beta) * cos(Epsilon) + cos(Beta) * sin(Epsilon) * sin(Lambda)); + + Delta = Delta * 180.0 / Pi; + Lambda = Lambda * 180.0 / Pi; + + if ((Lambda > 0.0) && (Lambda <= 90.0)) + { + //1b2b4 + r6 = 1; + } + //0x1b2b8 + if ((Lambda > 90.0) && (Lambda <= 180.0)) + { + //1b2e8 + r6 = 2; + } + //0x1b2ec + if ((Lambda > 180.0) && (Lambda <= 270.0)) + { + //1b31c + r6 = 3; + } + //0x1b320 + if ((Lambda > 270.0) && (Lambda <= 360.0)) + { + //1b350 + r6 = 4; + } + //0x1b354 + switch (r6) + { + case 1: + //0x1b378 + if (Alpha < 0) + { + Alpha = -1.0 * Alpha; + } + //->0x1b4d0 + break; + + case 2: + //0x1b3b4 + if (Alpha >= 0) + { + //1b3d0 + Alpha = 180.0 - Alpha; + } + else + { + //0x1b3f0 + Alpha = 180.0 + Alpha; + } + //0x1b40c -> 0x1b4d0 + break; + + case 3: + //0x1b410 + if (Alpha >= 0) + { + //1b42c + Alpha = 180.0 + Alpha; + } + else + { + //0x1b44c + Alpha = 180.0 - Alpha; + } + //1b468 -> 0x1b4d0 + break; + + case 4: + //0x1b46c + if (Alpha >= 0) + { + //1b488 + Alpha = 360.0 - Alpha; + } + else + { + //0x1b4a8 + Alpha = 360.0 + Alpha; + } + break; + + default: + //0x1b4c8 + break; + } + //1b4d4 + Alpha /= 15.0; + *pAlpha = Alpha; + *pDelta = Delta; +} + +/* 1b528 - todo */ +void calculate_solar_system_object_equatorial_coordinates(int a, double* pAlpha, double* pDelta) +{ + double Tau; //sp536 + double T; //sp528 + double Lrad = 0.0; /*sp520*/ //Planet's Ecliptic Longitude in Radians + double Brad = 0.0; /*sp512*/ //Planet's Ecliptic Latitude in Radians + double R = 0.0; /*sp504*/ //Planet's Radius Vector + double L; /*sp496*/ //Planet's Ecliptic Longitude in Degrees + double B; /*sp488*/ //Planet's Ecliptic Latitude in Degrees + double L0rad; //sp480; //Earth Ecliptic Longitude in Radians + double B0rad; //sp472; //Earth Ecliptic Latitude in Radians + double R0; //sp464; //Earth Radius Vector + double L0; //sp456; //Earth Ecliptic Longitude in Degrees + double B0; //sp448; //Earth Ecliptic Latitude in Degrees + double x; /*sp440*/ + double y; /*sp432*/ + double z; /*sp424*/ + double Epsilon; /*sp416*/ //Obliquity of the Ecliptic + double Lambda = 0.0; /*sp408*/ + double Beta; ///*sp400*/ + double Alpha; //sp392; //Right Ascension + double Delta; //sp384; //Declination + double JD; //sp376; //Julian Day + double sp368; + double sp360; + double sp352; + double x0; //sp344; + double y0; //sp336; + double z0; //sp328; + double sp320; + double AlphaPlutoRadians; //sp312; + double DeltaPlutoRadians; //sp304; + double AlphaPluto; //sp296; + double DeltaPluto; //sp288; + double lp = 0.0; /*sp280*/ //Moon mean longitude + double d = 0.0; /*sp272*/ //Moon mean elongation + double m = 0.0; /*sp264*/ //Sun mean anomaly + double mp = 0.0; /*sp256*/ //Moon mean anomaly + double f = 0.0; /*sp248*/ //Moon arg of latitude + double a1 = 0.0; /*sp240*/ + double a2 = 0.0; /*sp232*/ + double a3 = 0.0; /*sp224*/ + double e = 0.0; /*sp216*/ + double sl = 0.0; /*sp208*/ + double sb = 0.0; /*sp200*/ + + /*sp192 =*/ get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude); + + JD/*sp376*/ = Data_40004128.dJulianDay; + Tau = (JD - 2451545.0) / 365250.0; + T = 10.0 * Tau; + + switch (a - 2) + { + case 0: //Mercury + //0x1b6dc + Lrad = mercury_ecliptic_longitude(Tau); + Brad = mercury_ecliptic_latitude(Tau); + R = mercury_radius_vector(Tau); + //->0x1b8c0 + break; + + case 1: //Venus + //0x1b720 + Lrad = venus_ecliptic_longitude(Tau); + Brad = venus_ecliptic_latitude(Tau); + R = venus_radius_vector(Tau); + //->0x1b8c0 + break; + + case 2: //Mars + //0x1b764 + Lrad = mars_ecliptic_longitude(Tau); + Brad = mars_ecliptic_latitude(Tau); + R = mars_radius_vector(Tau); + //->0x1b8c0 + break; + + case 3: //Jupiter + //0x1b7a8 + Lrad = jupiter_ecliptic_longitude(Tau); + Brad = jupiter_ecliptic_latitude(Tau); + R = jupiter_radius_vector(Tau); + //->0x1b8c0 + break; + + case 4: //Saturn + //0x1b7ec + Lrad = saturn_ecliptic_longitude(Tau); + Brad = saturn_ecliptic_latitude(Tau); + R = saturn_radius_vector(Tau); + //->0x1b8c0 + break; + + case 5: //Uranus + //0x1b830 + Lrad = uranus_ecliptic_longitude(Tau); + Brad = uranus_ecliptic_latitude(Tau); + R = uranus_radius_vector(Tau); + //->0x1b8c0 + break; + + case 6: //Neptune + //0x1b874 + Lrad = neptune_ecliptic_longitude(Tau); + Brad = neptune_ecliptic_latitude(Tau); + R = neptune_radius_vector(Tau); + //->0x1b8c0 + break; + + default: + //0x1b8b8 + break; + } + //1b8c4: Radians to Degrees + L = Lrad / 3.1415927 * 180.0; + B = Brad / 3.1415927 * 180.0; + + L0rad/*sp480*/ = earth_heliocentric_longitude(Tau); + B0rad/*sp472*/ = earth_heliocentric_latitude(Tau); + R0 = earth_radius_vector(Tau); + + //Radians to Degrees + L0 = L0rad/*sp480*/ * 57.295779513; + B0 = B0rad/*sp472*/ * 57.295779513; + //->0x1ba40 + while (1) + { + //0x1b9cc + if (L < 0.0) + { + L += 360.0; + //->0x1ba40 + } + //0x1ba04 + else if (L > 360.0) + { + L -= 360.0; + //->0x1ba40 + } + else + { + //0x1ba3c -> 0x1ba44 + break; + } + } + //0x1ba48 -> 0x1bac0 + while (1) + { + //0x1ba4c + if (L0 < 0.0) + { + L0 += 360.0; + //->0x1bac0 + } + //0x1ba84 + else if (L0 > 360.0) + { + L0 -= 360.0; + //->0x1bac0 + } + else + { + //0x1babc -> 0x1bac4 + break; + } + } + //1bac8: get rectangular coords of planets + x = R * cos(B / 180.0 * 3.1415927) * cos(L / 180.0 * 3.1415927) - + R0 * cos(B0 / 180.0 * 3.1415927) * cos(L0 / 180.0 * 3.1415927); + //1bc2c + y = R * cos(B / 180.0 * 3.1415927) * sin(L / 180.0 * 3.1415927) - + R0 * cos(B0 / 180.0 * 3.1415927) * sin(L0 / 180.0 * 3.1415927); + //1bd90: get geocentric longitude lambda + z = R * sin(B / 180.0 * 3.1415927) - + R0 * sin(B0 / 180.0 * 3.1415927); + //1be4c + Lambda = atan(y / x); //??? + + if (x < 0) + { + //1be84 + Lambda += 3.1415927; + } + //0x1bea0: get geocentric latitude, beta + Beta = atan(z / sqrt(x * x + y * y)); + //1bf20 + Lambda = Lambda / 3.1415927 * 180.0; + //1bf54 -> 0x1bfcc + while (1) + { + //0x1bf58 + if (Lambda < 0.0) + { + Lambda += 360.0; + //->0x1bfcc + } + //0x1bf90 + else if (Lambda > 360.0) + { + Lambda -= 360.0; + //->0x1bfcc + } + else + { + //0x1bfc8 -> 0x1bfd0 + break; + } + } + //1bfd4 + Beta = Beta / 3.1415927 * 180.0; + //1c008 + Epsilon = 23.4392911111111104105475533288 - + 46.8150 * T / 3600.0 - + 0.00059 * T * T / 3600.0 + + 0.001813 * T * T * T / 3600.0; + //1c120 + if (a == 1) //Sun + { + //1c128 + Lambda = L0 + 180.0; + //->0x1c164 + while (Lambda >= 360.0) + { + //0x1c148 + Lambda -= 360.0; + } + //1c17c + if (Lambda < 0) + { + //1c194 + Lambda += 360.0; + } + //0x1c1b0 + Beta = 1.0 * B0; + } + //0x1c1cc + if (a == 9) //Pluto + { + //1c1d4 + sp368 = pluto_ecliptic_longitude(T); + sp360 = pluto_ecliptic_latitude(T); + sp352 = pluto_radius_vector(T); + + Lambda = L0; + //->0x1c240 + while (Lambda >= 360.0) + { + //0x1c224 + Lambda -= 360.0; + } + //1c258 + if (Lambda < 0.0) + { + Lambda += 360.0; + } + //0x1c28c + Beta = -1.0 * B0; + + x0 = -1.0 * R0 * cos(Beta / 180.0 * 3.1415927) * + cos(Lambda / 180.0 * 3.1415927); + + y0 = -1.0 * R0 * cos(Beta / 180.0 * 3.1415927) * + sin(Lambda / 180.0 * 3.1415927); + + z0 = -1.0 * R0 * sin(Beta / 180.0 * 3.1415927); + + x0 = 0.00000044036 * y0 + x0 - 0.000000190919 * z0; + + y0 = -0.000000479966 * x0 + + 0.917482137087 * y0 - + 0.3977776982902/*BUG?*/ * z0; + + z0 = 0.397776982902 * y0 + 0.917482137087 * z0; + + x = cos(sp368 / 180.0 * 3.1415927) * sp352 * + cos(sp360 / 180.0 * 3.1415927); + + y = (sin(sp368 / 180.0 * 3.1415927) * + cos(sp360 / 180.0 * 3.1415927) * 0.917482062 - + sin(sp360 / 180.0 * 3.1415927) * 0.397777156) * sp352; + + z = (sin(sp368 / 180.0 * 3.1415927) * + cos(sp360 / 180.0 * 3.1415927) * 0.397777156 + + sin(sp360 / 180.0 * 3.1415927) * 0.917482062) * sp352; + + sp320 = sqrt((x0 + x) * (x0 + x) + + (y0 + y) * (y0 + y) + + (z0 + z) * (z0 + z)); + + AlphaPlutoRadians = atan((y0 + y) / (x0 + x)); + + if ((x0 + x) > 0) + { + //1cadc + AlphaPlutoRadians += 3.1415927; + } + //0x1caf8 + + DeltaPlutoRadians = asin((z0 + z) / sp320); + + AlphaPluto = AlphaPlutoRadians / 3.1415927 * 180.0; + + DeltaPluto = DeltaPlutoRadians / 3.1415927 * 180.0; + AlphaPluto += 180.0; + + if (AlphaPluto > 360.0) + { + //1cbd0 + AlphaPluto -= 360.0; + } + //0x1cbec + } //if (a == 9) //Pluto + //0x1cbec + if (a == 10) //Moon + { + //See: https://github.com/openhab/openhab1-addons/blob/master/bundles/binding/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/calc/MoonCalc.java + + //1cbf4 + lp = 218.3164591 + 481267.88134236 * T - + 0.0013268 * T * T + T * T * T / 538841.0 - T * T * T * T / 65194000.0; + lp = func_1af1c(lp); + + d = 297.8502042 + 445267.1115168 * T - + 0.00163 * T * T + T * T * T / 545868.0 - T * T * T * T / 113065000.0; + d = func_1af1c(d); + + m = 357.5291092 + 35999.0502909 * T - + 0.0001536 * T * T + T * T * T / 24490000.0; + m = func_1af1c(m); + + mp = 134.9634114 + 477198.8676313 * T - + 0.008997 * T * T + T * T * T / 69699.0 - T * T * T * T / 14712000.0; + mp = func_1af1c(mp); + //1d164 + f = 93.2720993 + 483202.0175273 * T - + 0.0034029 * T * T - T * T * T / 3526000 + T * T * T * T / 863310000; + f = func_1af1c(f); + //1d2bc + a1 = 119.75 + 131.849 * T; + a1 = func_1af1c(a1); + + a2 = 53.09 + 479264.29 * T; + a2 = func_1af1c(a2); + + a3 = 313.45 + 481266.484 * T; + a3 = func_1af1c(a3); + //1d394 + e = 1.0 - 0.002516 * T - 0.0000074 * T * T; + + sl = sin(/*0 * d*/ mp * 0.01745329252) * 6288774.0 + + sin((2 * d - mp) * 0.01745329252) * 1274027.0 + + sin(2 * d * /*0 * mp*/ 0.01745329252) * 658314.0 + + sin(/*0 * d*/ 2 * mp * 0.01745329252) * 213628.0; + + sl += sin(m * 0.01745329252) * -185116.0 - + sin(2 * f * 0.01745329252) * 114332.0 + + sin((2 * d - 2 * mp) * 0.01745329252) * 58793.0 + + sin((2 * d - m - mp) * 0.01745329252) * 57066.0; + + sl += sin((2 * d + mp) * 0.01745329252) * 53322.0 + + sin((2 * d - m) * 0.01745329252) * 45758.0 - + sin((m - mp) * 0.01745329252) * 40923.0 - + sin(d * 0.01745329252) * 34720.0; + + sl += sin((m + mp) * 0.01745329252) * -30383.0 + + sin((2 * d - 2 * f) * 0.01745329252) * 15327.0 - + sin((2 * f + mp) * 0.01745329252) * 12528.0 + + //sin((2 * f - mp) * 0.01745329252) * 10980.0; + sin((mp - 2 * f) * 0.01745329252) * 10980.0; //->BUG? + + sb = sin(f * 0.01745329252) * 5128122.0 + + sin((mp + f) * 0.01745329252) * 280602.0 + + sin((mp - f) * 0.01745329252) * 277693.0 + + sin((2 * d - f) * 0.01745329252) * 173237.0; + + sb += sin((2 * d - mp + f) * 0.01745329252) * 55413.0 + + sin((2 * d - mp - f) * 0.01745329252) * 46271.0 + + sin((2 * d + f) * 0.01745329252) * 32573.0 + + sin((2 * mp + f) * 0.01745329252) * 17198.0; + + Lambda = sl / 1000000 + lp; + Lambda = func_1af1c(Lambda); + + Beta = sb / 1000000; + Beta = func_1af1c(Beta); + } //if (a == 10) //Moon + //0x1e0bc + transform_ecliptical_to_equatorial_coordinates(Lambda, Beta, Epsilon, &Alpha, &Delta); + + *pAlpha = Alpha; + *pDelta = Delta; + + if (a == 9) //Pluto + { + //1e14c + *pAlpha = AlphaPluto / 15.0; + *pDelta = DeltaPluto; + } +} + +/* 1e17c - todo */ +void get_all_solar_system_object_equatorial_coordinates(void) +{ + calculate_solar_system_object_equatorial_coordinates(1, &dData_400032b0_SunRightAscension, &dData_400032b8_SunDeclination); //Sun + calculate_solar_system_object_equatorial_coordinates(2, &dData_400032d0, &dData_400032d8); //Mercury + calculate_solar_system_object_equatorial_coordinates(3, &dData_400032e0, &dData_400032e8); //Venus + calculate_solar_system_object_equatorial_coordinates(4, &dData_400032f0, &dData_400032f8); //Mars + calculate_solar_system_object_equatorial_coordinates(5, &dData_40003300, &dData_40003308); //Jupiter + calculate_solar_system_object_equatorial_coordinates(6, &dData_40003310, &dData_40003318); //Saturn + calculate_solar_system_object_equatorial_coordinates(7, &dData_40003320, &dData_40003328); //Uranus + calculate_solar_system_object_equatorial_coordinates(8, &dData_40003330, &dData_40003338); //Neptune + calculate_solar_system_object_equatorial_coordinates(9, &dData_40003340, &dData_40003348); //Pluto + calculate_solar_system_object_equatorial_coordinates(10, &dData_400032c0_MoonRightAscension, &dData_400032c8_MoonDeclination); //Moon +} + +#include "HelpScreen.c" + +/* 20b94 - todo */ +void DisplayMainScreen(void) +{ + lcd_display_string(0, 1, 1, strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 1, 14, strlen(Data_40003364), (unsigned char*)Data_40003364); + + if (g_bTargetSyncOpen == TRUE) + { + if (bData_400031eb == 0) + { + //20c18 + lcd_display_string(0, 2, 1, 22, ">>>>synchronizing<<<<"); + + bData_400031eb = 1; + } + else + { + //0x20c44 + lcd_display_string(0, 2, 1, 22, " "); + + bData_400031eb = 0; + } + } + else + { + //0x20c70 + lcd_display_string(0, 2, 1, 22, " "); + } + //0x20c8c + lcd_display_string(0, 3, 1, strlen(Data_40003370), Data_40003370); + lcd_display_string(0, 3, 6, 9, Data_40003374); + lcd_display_string(0, 3, 16, 2, Data_40003374 + 10); + lcd_display_string(0, 3, 19, 2, Data_40003374 + 13); + + lcd_display_bitmap(0, 3, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 3, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 3, 21, (unsigned char*)cBitmapSecond); + + if (abs(Data_40002e18_SiteLongitudeDegrees) < 100) + { + lcd_display_string(0, 3, 12, 1, " "); + } + + if (abs(Data_40002e18_SiteLongitudeDegrees) < 10) + { + lcd_display_string(0, 3, 13, 1, " "); + } + + if (abs(Data_40002e1c_SiteLongitudeMinutes) < 10) + { + lcd_display_string(0, 3, 16, 1, " "); + } + + if (abs(fData_40002e20_SiteLongitudeSeconds) < 10) + { + lcd_display_string(0, 3, 19, 1, " "); + } + + lcd_display_string(0, 4, 1, strlen(Data_40003378), Data_40003378); + lcd_display_string(0, 4, 6, 9, Data_4000337c); + lcd_display_string(0, 4, 16, 2, Data_4000337c + 10); + lcd_display_string(0, 4, 19, 2, Data_4000337c + 13); + + lcd_display_bitmap(0, 4, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 4, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 4, 21, (unsigned char*)cBitmapSecond); + + if (abs(Data_40002e38_SiteLatitudeDegrees) < 100) + { + lcd_display_string(0, 4, 12, 1, " "); + } + + if (abs(Data_40002e38_SiteLatitudeDegrees) < 10) + { + lcd_display_string(0, 4, 13, 1, " "); + } + + if (abs(Data_40002e3c_SiteLatitudeMinutes) < 10) + { + lcd_display_string(0, 4, 16, 1, " "); + } + + if (abs(fData_40002e40_SiteLatitudeSeconds) < 10) + { + lcd_display_string(0, 4, 19, 1, " "); + } + + lcd_display_string(0, 5, 1, strlen(Data_40003380), Data_40003380); + lcd_display_string(0, 5, 6, 9, Data_40003384); + lcd_display_string(0, 5, 16, 2, Data_40003384 + 10); + lcd_display_string(0, 5, 19, 2, Data_40003384 + 13); + + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + //21138 + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + + if (abs(Data_40002d20) < 100) + { + lcd_display_string(0, 5, 12, 1, " "); + } + + if (abs(Data_40002d20) < 10) + { + lcd_display_string(0, 5, 13, 1, " "); + } + + if (abs(Data_40002d24) < 10) + { + lcd_display_string(0, 5, 16, 1, " "); + } + + if (abs(fData_40002d28) < 10) + { + lcd_display_string(0, 5, 19, 1, " "); + } + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0x2127c + lcd_display_string(0, 5, 15, 1, "h"); + lcd_display_string(0, 5, 18, 1, "m"); + lcd_display_string(0, 5, 21, 1, "s"); + + if (Data_40002cd8_ObjectRightAscensionHours < 100) + { + lcd_display_string(0, 5, 12, 1, " "); + } + + if (Data_40002cd8_ObjectRightAscensionHours < 10) + { + lcd_display_string(0, 5, 13, 1, " "); + } + + if (Data_40002cdc_ObjectRightAscensionMinutes < 10) + { + lcd_display_string(0, 5, 16, 1, " "); + } + + if (fData_40002ce0_ObjectRightAscensionSeconds < 10) + { + lcd_display_string(0, 5, 19, 1, " "); + } + } + //0x213c8 + lcd_display_string(0, 6, 1, strlen(Data_40003388), Data_40003388); + lcd_display_string(0, 6, 6, 9, Data_4000338c); + lcd_display_string(0, 6, 16, 2, Data_4000338c + 10); + lcd_display_string(0, 6, 19, 2, Data_4000338c + 13); + + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + //214ac + if (abs(Data_40002d48) < 10) + { + lcd_display_string(0, 6, 13, 1, " "); + } + + if (abs(Data_40002d4c) < 10) + { + lcd_display_string(0, 6, 16, 1, " "); + } + + if (abs(fData_40002d50) < 10) + { + lcd_display_string(0, 6, 19, 1, " "); + } + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0x21574 + if (abs(Data_40002d00_ObjectDeclinationDegrees) < 10) + { + lcd_display_string(0, 6, 13, 1, " "); + } + + if (abs(Data_40002d04_ObjectDeclinationMinutes) < 10) + { + lcd_display_string(0, 6, 16, 1, " "); + } + + if (abs(fData_40002d08_ObjectDeclinationSeconds) < 10) + { + lcd_display_string(0, 6, 19, 1, " "); + } + } + //0x21638 + lcd_display_string(0, 7, 1, strlen(Data_40003390), Data_40003390); + lcd_display_string(0, 7, 6, 9, Data_40003394); + lcd_display_string(0, 7, 16, 2, Data_40003394 + 10); + lcd_display_string(0, 7, 19, 2, Data_40003394 + 13); + + if ((bData_400034b4 == 1) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING)) //2)) + { + //216f0 + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + + if (abs(Data_40002d20) < 100) + { + lcd_display_string(0, 7, 12, 1, " "); + } + + if (abs(Data_40002d20) < 10) + { + lcd_display_string(0, 7, 13, 1, " "); + } + + if (abs(Data_40002d24) < 10) + { + lcd_display_string(0, 7, 16, 1, " "); + } + + if (abs(fData_40002d28) < 10) + { + lcd_display_string(0, 7, 19, 1, " "); + } + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0x21844 + lcd_display_string(0, 7, 15, 1, "h"); + lcd_display_string(0, 7, 18, 1, "m"); + lcd_display_string(0, 7, 21, 1, "s"); + + if (Data_40002cd8_ObjectRightAscensionHours < 100) + { + lcd_display_string(0, 7, 12, 1, " "); + } + + if (Data_40002cd8_ObjectRightAscensionHours < 10) + { + lcd_display_string(0, 7, 13, 1, " "); + } + + if (Data_40002cdc_ObjectRightAscensionMinutes < 10) + { + lcd_display_string(0, 7, 16, 1, " "); + } + + if (fData_40002ce0_ObjectRightAscensionSeconds < 10) + { + lcd_display_string(0, 7, 19, 1, " "); + } + } + } + else + { + //0x21950 + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + //21960 + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + + if (abs(Data_40002dac) < 100) + { + lcd_display_string(0, 7, 12, 1, " "); + } + + if (abs(Data_40002dac) < 10) + { + lcd_display_string(0, 7, 13, 1, " "); + } + + if (abs(Data_40002db0) < 10) + { + lcd_display_string(0, 7, 16, 1, " "); + } + + if (abs(fData_40002db4) < 10) + { + lcd_display_string(0, 7, 19, 1, " "); + } + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0x21aec + lcd_display_string(0, 7, 15, 1, "h"); + lcd_display_string(0, 7, 18, 1, "m"); + lcd_display_string(0, 7, 21, 1, "s"); + + if (Data_40002d68_OTARightAscensionHours < 100) + { + lcd_display_string(0, 7, 12, 1, " "); + } + + if (Data_40002d68_OTARightAscensionHours < 10) + { + lcd_display_string(0, 7, 13, 1, " "); + } + + if (Data_40002d6c_OTARightAscensionMinutes < 10) + { + lcd_display_string(0, 7, 16, 1, " "); + } + + if (fData_40002d70_OTARightAscensionSeconds < 10) + { + lcd_display_string(0, 7, 19, 1, " "); + } + } + } + //0x21bf4 + lcd_display_string(0, 8, 1, strlen(Data_40003398), Data_40003398); + lcd_display_string(0, 8, 6, 9, Data_4000339c); + lcd_display_string(0, 8, 16, 2, Data_4000339c + 10); + lcd_display_string(0, 8, 19, 2, Data_4000339c + 13); + + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + + if ((bData_400034b4 == 1) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING)) //2)) + { + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + if (abs(Data_40002d48) < 10) + { + lcd_display_string(0, 8, 13, 1, " "); + } + + if (abs(Data_40002d4c) < 10) + { + lcd_display_string(0, 8, 16, 1, " "); + } + + if (abs(fData_40002d50) < 10) + { + lcd_display_string(0, 8, 19, 1, " "); + } + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0x21dc0 + if (abs(Data_40002d00_ObjectDeclinationDegrees) < 10) + { + lcd_display_string(0, 8, 13, 1, " "); + } + + if (abs(Data_40002d04_ObjectDeclinationMinutes) < 10) + { + lcd_display_string(0, 8, 16, 1, " "); + } + + if (abs(fData_40002d08_ObjectDeclinationSeconds) < 10) + { + lcd_display_string(0, 8, 19, 1, " "); + } + } + } + else + { + //0x21e88 + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + if (abs(Data_40002de0) < 10) + { + lcd_display_string(0, 8, 13, 1, " "); + } + + if (abs(Data_40002de4) < 10) + { + lcd_display_string(0, 8, 16, 1, " "); + } + + if (abs(fData_40002de8) < 10) + { + lcd_display_string(0, 8, 19, 1, " "); + } + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //0x21f60 + if (abs(Data_40002d8c_OTADeclinationDegrees) < 10) + { + lcd_display_string(0, 8, 13, 1, " "); + } + + if (abs(Data_40002d90_OTADeclinationMinutes) < 10) + { + lcd_display_string(0, 8, 16, 1, " "); + } + + if (abs(fData_40002d94_OTADeclinationSeconds) < 10) + { + lcd_display_string(0, 8, 19, 1, " "); + } + } + } +} + +char Data_40000380[10] = " "; //40000380, size??? +char Data_4000038a[10] = " "; //4000038a, size??? +char Data_40000394[10] = " "; //40000394, size??? +char Data_4000039e[10] = " "; //4000039e, size??? +char Data_400003a8[10] = " "; //400003a8, size??? +char Data_400003b2[8] = " "; //400003b2, size??? +char Data_400003ba[8] = " "; //400003ba, size??? +char Data_400003c2[8] = " "; //400003c2, size??? +char Data_400003ca[10] = " "; //400003ca, size??? +char Data_400003d4[10] = " "; //400003d4, size??? + +/* 22060 - todo */ +void get_solar_system_object_data(int a, float* pRightAscension, float* pDeclination) +{ + switch (a) + { + case 0: + //0x220a4 + *pRightAscension = dData_400032d0; + *pDeclination = dData_400032d8; + Data_4000314c_SolarSystemObjectName = "Mercury "; + Data_40003140 = Data_40000380; + //->0x22450 + break; + + case 1: + //0x220e4 + *pRightAscension = dData_400032e0; + *pDeclination = dData_400032e8; + Data_4000314c_SolarSystemObjectName = "Venus "; + Data_40003140 = Data_4000038a; + //->0x22450 + break; + + case 2: + //0x22124 + *pRightAscension = dData_400032f0; + *pDeclination = dData_400032f8; + Data_4000314c_SolarSystemObjectName = "Mars "; + Data_40003140 = Data_40000394; + //->0x22450 + break; + + case 3: + //0x22164 + *pRightAscension = dData_40003300; + *pDeclination = dData_40003308; + Data_4000314c_SolarSystemObjectName = "Jupiter "; + Data_40003140 = Data_4000039e; + //->0x22450 + break; + + case 4: + //0x221a4 + *pRightAscension = dData_40003310; + *pDeclination = dData_40003318; + Data_4000314c_SolarSystemObjectName = "Saturn "; + Data_40003140 = Data_400003a8; + //->0x22450 + break; + + case 5: + //0x221e4 + *pRightAscension = dData_40003320; + *pDeclination = dData_40003328; + Data_4000314c_SolarSystemObjectName = "Uranus "; + Data_40003140 = Data_400003b2; + //->0x22450 + break; + + case 6: + //0x22224 + *pRightAscension = dData_40003330; + *pDeclination = dData_40003338; + Data_4000314c_SolarSystemObjectName = "Neptune "; + Data_40003140 = Data_400003ba; + //->0x22450 + break; + + case 7: + //0x22388 + *pRightAscension = dData_40003340; + *pDeclination = dData_40003348; + Data_4000314c_SolarSystemObjectName = "Pluto "; + Data_40003140 = Data_400003c2; + //->0x22450 + break; + + case 8: + //0x223c8 + *pRightAscension = dData_400032b0_SunRightAscension; + *pDeclination = dData_400032b8_SunDeclination; + Data_4000314c_SolarSystemObjectName = "Sun "; + Data_40003140 = Data_400003ca; + //->0x22450 + break; + + case 9: + //0x22408 + *pRightAscension = dData_400032c0_MoonRightAscension; + *pDeclination = dData_400032c8_MoonDeclination; + Data_4000314c_SolarSystemObjectName = "Moon "; + Data_40003140 = Data_400003d4; + //->0x22450 + break; + + default: + //0x22448 + break; + } +} + +#include "func_23130.c" + +/* 24574 - todo */ +void PrepareMainScreenItems(void) +{ + dData_40002e28_SiteLongitude = Data_40004128.geographicLongitude; + dData_40002e48_SiteLatitude = Data_40004128.geographicLatitude; + Data_40002e54_Zone = Data_40004128.timeZone; + + Data_40002e18_SiteLongitudeDegrees = dData_40002e28_SiteLongitude; + Data_40002e1c_SiteLongitudeMinutes = (dData_40002e28_SiteLongitude - Data_40002e18_SiteLongitudeDegrees) * 60.0; + fData_40002e20_SiteLongitudeSeconds = (dData_40002e28_SiteLongitude * 60.0 - Data_40002e18_SiteLongitudeDegrees * 60.0 - Data_40002e1c_SiteLongitudeMinutes) * 60.0; + + Data_40002e38_SiteLatitudeDegrees = dData_40002e48_SiteLatitude; + Data_40002e3c_SiteLatitudeMinutes = (dData_40002e48_SiteLatitude - Data_40002e38_SiteLatitudeDegrees) * 60.0; + fData_40002e40_SiteLatitudeSeconds = (dData_40002e48_SiteLatitude * 60.0 - Data_40002e38_SiteLatitudeDegrees * 60.0 - Data_40002e3c_SiteLatitudeMinutes) * 60.0; + + sprintf(Data_40003fa9, "%04d-%02d-%02d", + Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + Data_40003360 = Data_40003fa9; + + sprintf(Data_40003fbe, "%02d:%02d:%02d", + bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + Data_40003364 = Data_40003fbe; + + switch (bData_40002e79_SkyLandTargetSeletion) + { + case 0: + //0x24950 + Data_40003370 = "Sky "; + break; + + case 1: + //0x24964 + Data_40003370 = "Land"; + break; + + default: + //0x24978 + break; + } + //24984 + if (dData_40002e28_SiteLongitude < 0) + { + //2499c + sprintf(Data_40004012, "Site:W%03d?%02d'%02d^", + abs(Data_40002e18_SiteLongitudeDegrees), + abs(Data_40002e1c_SiteLongitudeMinutes), + abs(fData_40002e20_SiteLongitudeSeconds) & 0xff); + } + else + { + //0x24a14 + sprintf(Data_40004012, "Site:E%03d?%02d'%02d^", + abs(Data_40002e18_SiteLongitudeDegrees), + abs(Data_40002e1c_SiteLongitudeMinutes), + abs(fData_40002e20_SiteLongitudeSeconds) & 0xff); + } + //0x24a88 + Data_40003374 = Data_40004012; + + switch (bData_40002e7a_MountType) + { + case MENU_MOUNT_TYPE_AZ: //0: + //0x24ab0 + Data_40003378 = "AZ"; + break; + + case MENU_MOUNT_TYPE_EQU: //1: + //0x24ac4 + Data_40003378 = "EQ"; + break; + + default: + //0x24ad8 + break; + } + //0x24ae0 + if (dData_40002e48_SiteLatitude < 0) + { + //24afc + sprintf(Data_4000403c, " S%03d?%02d'%02d^", + abs(Data_40002e38_SiteLatitudeDegrees), + abs(Data_40002e3c_SiteLatitudeMinutes), + abs(fData_40002e40_SiteLatitudeSeconds) & 0xff); + } + else + { + //0x24b74 + sprintf(Data_4000403c, " N%03d?%02d'%02d^", + abs(Data_40002e38_SiteLatitudeDegrees), + abs(Data_40002e3c_SiteLatitudeMinutes), + abs(fData_40002e40_SiteLatitudeSeconds) & 0xff); + } + //0x24be8 + Data_4000337c = Data_4000403c; + + switch (bData_40002e7b_GpsAvailable) + { + case 0: + //0x24c10 + Data_40003380 = " "; + break; + + case 1: + //0x24c24 + Data_40003380 = "GPS!"; + break; + + default: + //0x24ce4 + break; + } + + switch (bData_40002e7a_MountType) + { + case MENU_MOUNT_TYPE_AZ: //0: + //0x24d0c + sprintf(Data_40004066, " OBJ: %03d?%02d'%02.0f^", + abs(Data_40002d20), abs(Data_40002d24), fabs(fData_40002d28)); + break; + + case MENU_MOUNT_TYPE_EQU: //1: + //0x24d88 + sprintf(Data_40004066, " OBJ: %03dh%02dm%02ds", + Data_40002cd8_ObjectRightAscensionHours, + Data_40002cdc_ObjectRightAscensionMinutes, + (unsigned int)fData_40002ce0_ObjectRightAscensionSeconds & 0xFF); + break; + + default: + //0x24dc0 + break; + } + //24dcc + Data_40003384 = Data_40004066; + + switch (bData_40002e7c_TrackingRateType) + { + case MENU_TRACKING_RATE_STAR_SPEED: //0: + //0x24e04 + Data_40003388 = "Cel"; + break; + + case MENU_TRACKING_RATE_SOLAR_SPEED: //1: + //0x24e18 + Data_40003388 = "Sun"; + break; + + case MENU_TRACKING_RATE_MOON_SPEED: //2: + //0x24e2c + Data_40003388 = "Lun"; + break; + + case MENU_TRACKING_RATE_CUST_SPEED: //3: + //0x24e40 + Data_40003388 = "Def"; + break; + + default: + //0x24e54 + break; + } + //24e60 + switch (bData_40002e7a_MountType) + { + case MENU_MOUNT_TYPE_AZ: //0: + //0x24e7c + if (Data_40004128.dData_120 > 90) + { + //24e9c + sprintf(Data_40004090, " -%02d?%02d'%02d^", + abs(Data_40002d48), abs(Data_40002d4c), abs(fData_40002d50)); + } + else + { + //0x24f10 + sprintf(Data_40004090, " +%02d?%02d'%02d^", + abs(Data_40002d48), abs(Data_40002d4c), abs(fData_40002d50)); + } + //->0x25048 + break; + + case MENU_MOUNT_TYPE_EQU: //1: + //0x24f84 + if (g_iObjectDeclinationSign == -1) + { + //24f98 + sprintf(Data_40004090, " -%02d?%02d'%02d^", + abs(Data_40002d00_ObjectDeclinationDegrees), + abs(Data_40002d04_ObjectDeclinationMinutes), + abs(fData_40002d08_ObjectDeclinationSeconds)); + } + else + { + //0x2500c + sprintf(Data_40004090, " +%02d?%02d'%02d^", + Data_40002d00_ObjectDeclinationDegrees, + Data_40002d04_ObjectDeclinationMinutes, + ((unsigned int)fData_40002d08_ObjectDeclinationSeconds) & 0xff); + } + break; + + default: + //0x25040 + break; + } + //2504c + Data_4000338c = Data_40004090; + //25058 + switch (g_eSlewRateIndex) + { + case SLEW_RATE_1X: //1: + //0x25158 + Data_40003390 = "1X "; + break; + + case SLEW_RATE_2X: //2: + //0x2516c + Data_40003390 = "2X "; + break; + + case SLEW_RATE_8X: //3: + //0x25180 + Data_40003390 = "8X "; + break; + + case SLEW_RATE_16X: //4: + //0x25194 + Data_40003390 = "16X "; + break; + + case SLEW_RATE_64X: //5: + //0x251a8 + Data_40003390 = "64X "; + break; + + case SLEW_RATE_128X: //6: + //0x251bc + Data_40003390 = "128X"; + break; + + case SLEW_RATE_256X: //7: + //0x251d0 + Data_40003390 = "256X"; + break; + + case SLEW_RATE_512X: //8: + //0x251e4 + Data_40003390 = "512X"; + break; + + case SLEW_RATE_MAX: //9: + //0x251f8 + Data_40003390 = "Max "; + break; + + default: + //0x2520c + break; + } + //25218 + switch (bData_40002e7a_MountType) + { + case MENU_MOUNT_TYPE_AZ: //0: + //0x25234 + sprintf(Data_400040ba, " OTA: %03d?%02d'%02d^", + abs(Data_40002dac), abs(Data_40002db0), abs(fData_40002db4) & 0xff); + break; + + case MENU_MOUNT_TYPE_EQU: //1: + //0x252b0 + sprintf(Data_400040ba, " OTA: %03dh%02dm%02ds", + Data_40002d68_OTARightAscensionHours, + Data_40002d6c_OTARightAscensionMinutes, + abs(fData_40002d70_OTARightAscensionSeconds) & 0xff); + break; + + default: + //0x252fc + break; + } + //0x25304 + Data_40003394 = Data_400040ba; + + switch (bData_40002e7a_MountType) + { + case MENU_MOUNT_TYPE_AZ: //0: + //0x25330 + if ((fabs(Data_40004128.dMotorPositionDecAxis) > 90) || + (dData_40002df8 < 0)) + { + //0x25378 + sprintf(Data_400040e4, " -%02d?%02d'%02d^", + abs(Data_40002de0), abs(Data_40002de4), abs(fData_40002de8) & 0xFF); + } + else + { + //0x253f0 + sprintf(Data_400040e4, " +%02d?%02d'%02d^", + abs(Data_40002de0), abs(Data_40002de4), abs(fData_40002de8) & 0xFF); + } + break; + + case MENU_MOUNT_TYPE_EQU: //1: + //0x25518 + if (dData_40002d98 < 0) + { + //25534 + sprintf(Data_400040e4, " -%02d?%02d'%02d ", + abs(Data_40002d8c_OTADeclinationDegrees), + abs(Data_40002d90_OTADeclinationMinutes), + abs(fData_40002d94_OTADeclinationSeconds) & 0xFF); + } + else + { + //0x255ac + sprintf(Data_400040e4, " +%02d?%02d'%02d ", + abs(Data_40002d8c_OTADeclinationDegrees), + abs(Data_40002d90_OTADeclinationMinutes), + abs(fData_40002d94_OTADeclinationSeconds) & 0xFF); + } + break; + + default: + //0x25624 + break; + } + //0x2562c + Data_4000339c = Data_400040e4; + + switch (bTrackingMode) + { + case MENU_TRACKING_MODE_STOP: //0: + //0x25678 + case 100: + //0x25680 + Data_40003398 = "Stop"; + break; + + case MENU_TRACKING_MODE_POINTING: //1: + //0x25690 + Data_40003398 = "Poin"; + break; + + case MENU_TRACKING_MODE_TRACKING: //2: + //0x256a4 + Data_40003398 = "Trac"; + break; + + case MENU_TRACKING_MODE_UNDER_HORIZON: //3: + //0x256b8 + Data_40003398 = "UdHn"; + break; + + default: + //0x256cc + Data_40003398 = "Slew"; + break; + } + + if ((bData_400034b4 == 1) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING)) //2)) + { + Data_40003394 = Data_40004066; + Data_4000339c = Data_40004090; + Data_400040ba[1] = 'O'; + Data_400040ba[2] = 'T'; + Data_400040ba[3] = 'A'; + Data_40003394 = Data_400040ba; + Data_4000339c = Data_400040e4; + } +} + +#include "language.c" +#include "func_27844.c" +#include "func_3d72c.c" + + diff --git a/applications/freertos_app/file_5099c.c b/applications/freertos_app/file_5099c.c new file mode 100644 index 0000000..7a6b572 --- /dev/null +++ b/applications/freertos_app/file_5099c.c @@ -0,0 +1,61 @@ + +#if 0 +#include +#include "my_types.h" +#include "data.h" + +extern void func_2df8(int a, int b, int c, int d, unsigned char* e); +extern void initialize_variables(void); +#endif + + +/* 5099c - todo */ +void func_5099c(void) +{ + initialize_variables(); + + bData_4000316e_FocusLineOn8LineDisplay = 0; + Data_4000318c = 0; + Data_40003190 = 1; + bData_40003194 = 0; + bData_40003196_CurrentLanguage = MENU_LANGUAGE_ENGLISH; //1; + g_bSingleSlewActive = 0; + g_bCombinedSlewActive = 0; + bCapsLock = 0; + bMapKeyToCharIndex = 0; + bData_40002c1a = 0; + bGotoParkPosition = 0; + bData_40003210 = 0; + bData_40003211 = 0; + bData_400031bf = 0x42; + bData_400031be = 0; + fData_400031c0 = 10.6; + fData_400031c4 = 63.25; + bData_400031e0 = 1; + bRaBacklashCorrectionDirection = 0; + bDecBacklashCorrectionDirection = 0; + bData_40003195 = 0; + bData_400031e1 = 0; + bData_400032a4_OTAZeroDataErrorCount = 0; + bData_4000319b = 0; + bData_400031e9 = 0; + g_bMaxSlewRampActive = 0; + bData_400031b9 = 0; + Data_40002e80 = 0; + Data_40002e84 = 0; + bData_4000322d_AlarmTimeElapsed = 0; + g_bTargetSyncOpen = 0; + bData_400031eb = 0; + bData_400031ec = 1; + bSystemInitialized = 1; + dData_400031f0 = 0.0; + dData_400031f8 = 0.0; + bData_40003200 = 0; + bData_40003201 = 0; + iMountAutoguideRa = 0; + iMountAutoguideDec = 0; + bData_40002d88 = 0; + bData_40002da8 = 0; +} + + diff --git a/applications/freertos_app/file_79080.c b/applications/freertos_app/file_79080.c new file mode 100644 index 0000000..7fc8de2 --- /dev/null +++ b/applications/freertos_app/file_79080.c @@ -0,0 +1,1018 @@ + +const unsigned char cBitmapDegree[] = //7906c +{ + 0x00, 0x06, 0x09, 0x09, 0x06, 0x00, +}; + +const unsigned char cBitmapSecond[] = //79072 +{ + 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x00 +}; + +const unsigned char cBitmapMinute[] = //79078 +{ + 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +const unsigned int Data_79080[/*0x440*/] = +{ + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + 0x00000101, + 0x00000113, + 0x0000011b, + 0x0000012b, + 0x00000144, + 0x00000148, + 0x0000014d, + 0x00000152, + 0x00000153, + 0x00000160, + 0x00000161, + 0x0000016b, + 0x00000178, + 0x00000192, + 0x000001ce, + 0x000001d0, + 0x000001d2, + 0x000001d4, + 0x000001d6, + 0x000001d8, + 0x000001da, + 0x000001dc, + 0x00000251, + 0x00000261, + 0x000002c6, + 0x000002c7, + 0x000002c9, + 0x000002ca, + 0x000002cb, + 0x000002d9, + 0x000002dc, + 0x00000391, + 0x00000392, + 0x00000393, + 0x00000394, + 0x00000395, + 0x00000396, + 0x00000397, + 0x00000398, + 0x00000399, + 0x0000039a, + 0x0000039b, + 0x0000039c, + 0x0000039d, + 0x0000039e, + 0x0000039f, + 0x000003a0, + 0x000003a1, + 0x000003a3, + 0x000003a4, + 0x000003a5, + 0x000003a6, + 0x000003a7, + 0x000003a8, + 0x000003a9, + 0x000003b1, + 0x000003b2, + 0x000003b3, + 0x000003b4, + 0x000003b5, + 0x000003b6, + 0x000003b7, + 0x000003b8, + 0x000003b9, + 0x000003ba, + 0x000003bb, + 0x000003bc, + 0x000003bd, + 0x000003be, + 0x000003bf, + 0x000003c0, + 0x000003c1, + 0x000003c3, + 0x000003c4, + 0x000003c5, + 0x000003c6, + 0x000003c7, + 0x000003c8, + 0x000003c9, + 0x00000401, + 0x00000410, + 0x00000411, + 0x00000412, + 0x00000413, + 0x00000414, + 0x00000415, + 0x00000416, + 0x00000417, + 0x00000418, + 0x00000419, + 0x0000041a, + 0x0000041b, + 0x0000041c, + 0x0000041d, + 0x0000041e, + 0x0000041f, + 0x00000420, + 0x00000421, + 0x00000422, + 0x00000423, + 0x00000424, + 0x00000425, + 0x00000426, + 0x00000427, + 0x00000428, + 0x00000429, + 0x0000042a, + 0x0000042b, + 0x0000042c, + 0x0000042d, + 0x0000042e, + 0x0000042f, + 0x00000430, + 0x00000431, + 0x00000432, + 0x00000433, + 0x00000434, + 0x00000435, + 0x00000436, + 0x00000437, + 0x00000438, + 0x00000439, + 0x0000043a, + 0x0000043b, + 0x0000043c, + 0x0000043d, + 0x0000043e, + 0x0000043f, + 0x00000440, + 0x00000441, + 0x00000442, + 0x00000443, + 0x00000444, + 0x00000445, + 0x00000446, + 0x00000447, + 0x00000448, + 0x00000449, + 0x0000044a, + 0x0000044b, + 0x0000044c, + 0x0000044d, + 0x0000044e, + 0x0000044f, + 0x00000451, + 0x00002010, + 0x00002013, + 0x00002014, + 0x00002015, + 0x00002016, + 0x00002018, + 0x00002019, + 0x0000201a, + 0x0000201c, + 0x0000201d, + 0x0000201e, + 0x00002020, + 0x00002021, + 0x00002022, + 0x00002025, + 0x00002026, + 0x00002030, + 0x00002032, + 0x00002033, + 0x00002035, + 0x00002039, + 0x0000203a, + 0x0000203b, + 0x000020ac, + 0x00002103, + 0x00002105, + 0x00002109, + 0x00002116, + 0x00002121, + 0x00002122, + 0x00002160, + 0x00002161, + 0x00002162, + 0x00002163, + 0x00002164, + 0x00002165, + 0x00002166, + 0x00002167, + 0x00002168, + 0x00002169, + 0x0000216a, + 0x0000216b, + 0x00002170, + 0x00002171, + 0x00002172, + 0x00002173, + 0x00002174, + 0x00002175, + 0x00002176, + 0x00002177, + 0x00002178, + 0x00002179, + 0x00002190, + 0x00002191, + 0x00002192, + 0x00002193, + 0x00002196, + 0x00002197, + 0x00002198, + 0x00002199, + 0x00002208, + 0x0000220f, + 0x00002211, + 0x00002215, + 0x0000221a, + 0x0000221d, + 0x0000221e, + 0x0000221f, + 0x00002220, + 0x00002223, + 0x00002225, + 0x00002227, + 0x00002228, + 0x00002229, + 0x0000222a, + 0x0000222b, + 0x0000222e, + 0x00002234, + 0x00002235, + 0x00002236, + 0x00002237, + 0x0000223d, + 0x00002248, + 0x0000224c, + 0x00002252, + 0x00002260, + 0x00002261, + 0x00002264, + 0x00002265, + 0x00002266, + 0x00002267, + 0x0000226e, + 0x0000226f, + 0x00002295, + 0x00002299, + 0x000022a5, + 0x000022bf, + 0x00002312, + 0x00002460, + 0x00002461, + 0x00002462, + 0x00002463, + 0x00002464, + 0x00002465, + 0x00002466, + 0x00002467, + 0x00002468, + 0x00002469, + 0x00002474, + 0x00002475, + 0x00002476, + 0x00002477, + 0x00002478, + 0x00002479, + 0x0000247a, + 0x0000247b, + 0x0000247c, + 0x0000247d, + 0x0000247e, + 0x0000247f, + 0x00002480, + 0x00002481, + 0x00002482, + 0x00002483, + 0x00002484, + 0x00002485, + 0x00002486, + 0x00002487, + 0x00002488, + 0x00002489, + 0x0000248a, + 0x0000248b, + 0x0000248c, + 0x0000248d, + 0x0000248e, + 0x0000248f, + 0x00002490, + 0x00002491, + 0x00002492, + 0x00002493, + 0x00002494, + 0x00002495, + 0x00002496, + 0x00002497, + 0x00002498, + 0x00002499, + 0x0000249a, + 0x0000249b, + 0x00002500, + 0x00002501, + 0x00002502, + 0x00002503, + 0x00002504, + 0x00002505, + 0x00002506, + 0x00002507, + 0x00002508, + 0x00002509, + 0x0000250a, + 0x0000250b, + 0x0000250c, + 0x0000250d, + 0x0000250e, + 0x0000250f, + 0x00002510, + 0x00002511, + 0x00002512, + 0x00002513, + 0x00002514, + 0x00002515, + 0x00002516, + 0x00002517, + 0x00002518, + 0x00002519, + 0x0000251a, + 0x0000251b, + 0x0000251c, + 0x0000251d, + 0x0000251e, + 0x0000251f, + 0x00002520, + 0x00002521, + 0x00002522, + 0x00002523, + 0x00002524, + 0x00002525, + 0x00002526, + 0x00002527, + 0x00002528, + 0x00002529, + 0x0000252a, + 0x0000252b, + 0x0000252c, + 0x0000252d, + 0x0000252e, + 0x0000252f, + 0x00002530, + 0x00002531, + 0x00002532, + 0x00002533, + 0x00002534, + 0x00002535, + 0x00002536, + 0x00002537, + 0x00002538, + 0x00002539, + 0x0000253a, + 0x0000253b, + 0x0000253c, + 0x0000253d, + 0x0000253e, + 0x0000253f, + 0x00002540, + 0x00002541, + 0x00002542, + 0x00002543, + 0x00002544, + 0x00002545, + 0x00002546, + 0x00002547, + 0x00002548, + 0x00002549, + 0x0000254a, + 0x0000254b, + 0x00002550, + 0x00002551, + 0x00002552, + 0x00002553, + 0x00002554, + 0x00002555, + 0x00002556, + 0x00002557, + 0x00002558, + 0x00002559, + 0x0000255a, + 0x0000255b, + 0x0000255c, + 0x0000255d, + 0x0000255e, + 0x0000255f, + 0x00002560, + 0x00002561, + 0x00002562, + 0x00002563, + 0x00002564, + 0x00002565, + 0x00002566, + 0x00002567, + 0x00002568, + 0x00002569, + 0x0000256a, + 0x0000256b, + 0x0000256c, + 0x0000256d, + 0x0000256e, + 0x0000256f, + 0x00002570, + 0x00002571, + 0x00002572, + 0x00002573, + 0x00002581, + 0x00002582, + 0x00002583, + 0x00002584, + 0x00002585, + 0x00002586, + 0x00002587, + 0x00002588, + 0x00002589, + 0x0000258a, + 0x0000258b, + 0x0000258c, + 0x0000258d, + 0x0000258e, + 0x0000258f, + 0x00002593, + 0x00002594, + 0x00002595, + 0x000025a0, + 0x000025a1, + 0x000025b2, + 0x000025b3, + 0x000025bc, + 0x000025bd, + 0x000025c6, + 0x000025c7, + 0x000025cb, + 0x000025ce, + 0x000025cf, + 0x000025e2, + 0x000025e3, + 0x000025e4, + 0x000025e5, + 0x00002605, + 0x00002606, + 0x00002609, + 0x00002640, + 0x00002642, + 0x00003000, + 0x00003001, + 0x00003002, + 0x00003003, + 0x00003005, + 0x00003006, + 0x00003007, + 0x00003008, + 0x00003009, + 0x0000300a, + 0x0000300b, + 0x0000300c, + 0x0000300d, + 0x0000300e, + 0x0000300f, + 0x00003010, + 0x00003011, + 0x00003012, + 0x00003013, + 0x00003014, + 0x00003015, + 0x00003016, + 0x00003017, + 0x0000301d, + 0x0000301e, + 0x00003021, + 0x00003022, + 0x00003023, + 0x00003024, + 0x00003025, + 0x00003026, + 0x00003027, + 0x00003028, + 0x00003029, + 0x0000303e, + 0x00003041, + 0x00003042, + 0x00003043, + 0x00003044, + 0x00003045, + 0x00003046, + 0x00003047, + 0x00003048, + 0x00003049, + 0x0000304a, + 0x0000304b, + 0x0000304c, + 0x0000304d, + 0x0000304e, + 0x0000304f, + 0x00003050, + 0x00003051, + 0x00003052, + 0x00003053, + 0x00003054, + 0x00003055, + 0x00003056, + 0x00003057, + 0x00003058, + 0x00003059, + 0x0000305a, + 0x0000305b, + 0x0000305c, + 0x0000305d, + 0x0000305e, + 0x0000305f, + 0x00003060, + 0x00003061, + 0x00003062, + 0x00003063, + 0x00003064, + 0x00003065, + 0x00003066, + 0x00003067, + 0x00003068, + 0x00003069, + 0x0000306a, + 0x0000306b, + 0x0000306c, + 0x0000306d, + 0x0000306e, + 0x0000306f, + 0x00003070, + 0x00003071, + 0x00003072, + 0x00003073, + 0x00003074, + 0x00003075, + 0x00003076, + 0x00003077, + 0x00003078, + 0x00003079, + 0x0000307a, + 0x0000307b, + 0x0000307c, + 0x0000307d, + 0x0000307e, + 0x0000307f, + 0x00003080, + 0x00003081, + 0x00003082, + 0x00003083, + 0x00003084, + 0x00003085, + 0x00003086, + 0x00003087, + 0x00003088, + 0x00003089, + 0x0000308a, + 0x0000308b, + 0x0000308c, + 0x0000308d, + 0x0000308e, + 0x0000308f, + 0x00003090, + 0x00003091, + 0x00003092, + 0x00003093, + 0x0000309b, + 0x0000309c, + 0x0000309d, + 0x0000309e, + 0x000030a1, + 0x000030a2, + 0x000030a3, + 0x000030a4, + 0x000030a5, + 0x000030a6, + 0x000030a7, + 0x000030a8, + 0x000030a9, + 0x000030aa, + 0x000030ab, + 0x000030ac, + 0x000030ad, + 0x000030ae, + 0x000030af, + 0x000030b0, + 0x000030b1, + 0x000030b2, + 0x000030b3, + 0x000030b4, + 0x000030b5, + 0x000030b6, + 0x000030b7, + 0x000030b8, + 0x000030b9, + 0x000030ba, + 0x000030bb, + 0x000030bc, + 0x000030bd, + 0x000030be, + 0x000030bf, + 0x000030c0, + 0x000030c1, + 0x000030c2, + 0x000030c3, + 0x000030c4, + 0x000030c5, + 0x000030c6, + 0x000030c7, + 0x000030c8, + 0x000030c9, + 0x000030ca, + 0x000030cb, + 0x000030cc, + 0x000030cd, + 0x000030ce, + 0x000030cf, + 0x000030d0, + 0x000030d1, + 0x000030d2, + 0x000030d3, + 0x000030d4, + 0x000030d5, + 0x000030d6, + 0x000030d7, + 0x000030d8, + 0x000030d9, + 0x000030da, + 0x000030db, + 0x000030dc, + 0x000030dd, + 0x000030de, + 0x000030df, + 0x000030e0, + 0x000030e1, + 0x000030e2, + 0x000030e3, + 0x000030e4, + 0x000030e5, + 0x000030e6, + 0x000030e7, + 0x000030e8, + 0x000030e9, + 0x000030ea, + 0x000030eb, + 0x000030ec, + 0x000030ed, + 0x000030ee, + 0x000030ef, + 0x000030f0, + 0x000030f1, + 0x000030f2, + 0x000030f3, + 0x000030f4, + 0x000030f5, + 0x000030f6, + 0x000030fc, + 0x000030fd, + 0x000030fe, + 0x00003105, + 0x00003106, + 0x00003107, + 0x00003108, + 0x00003109, + 0x0000310a, + 0x0000310b, + 0x0000310c, + 0x0000310d, + 0x0000310e, + 0x0000310f, + 0x00003110, + 0x00003111, + 0x00003112, + 0x00003113, + 0x00003114, + 0x00003115, + 0x00003116, + 0x00003117, + 0x00003118, + 0x00003119, + 0x0000311a, + 0x0000311b, + 0x0000311c, + 0x0000311d, + 0x0000311e, + 0x0000311f, + 0x00003120, + 0x00003121, + 0x00003122, + 0x00003123, + 0x00003124, + 0x00003125, + 0x00003126, + 0x00003127, + 0x00003128, + 0x00003129, + 0x00003220, + 0x00003221, + 0x00003222, + 0x00003223, + 0x00003224, + 0x00003225, + 0x00003226, + 0x00003227, + 0x00003228, + 0x00003229, + 0x00003231, + 0x000032a3, + 0x0000338e, + 0x0000338f, + 0x0000339c, + 0x0000339d, + 0x0000339e, + 0x000033a1, + 0x000033c4, + 0x000033ce, + 0x000033d1, + 0x000033d2, + 0x000033d5, + 0x0000e76c, + 0x0000e78d, + 0x0000e78e, + 0x0000e78f, + 0x0000e790, + 0x0000e791, + 0x0000e792, + 0x0000e793, + 0x0000e794, + 0x0000e795, + 0x0000e796, + 0x0000e7c7, + 0x0000e7c8, + 0x0000e7e7, + 0x0000e7e8, + 0x0000e7e9, + 0x0000e7ea, + 0x0000e7eb, + 0x0000e7ec, + 0x0000e7ed, + 0x0000e7ee, + 0x0000e7ef, + 0x0000e7f0, + 0x0000e7f1, + 0x0000e7f2, + 0x0000e7f3, + 0x0000e815, + 0x0000e816, + 0x0000e817, + 0x0000e818, + 0x0000e819, + 0x0000e81a, + 0x0000e81b, + 0x0000e81c, + 0x0000e81d, + 0x0000e81e, + 0x0000e81f, + 0x0000e820, + 0x0000e821, + 0x0000e822, + 0x0000e823, + 0x0000e824, + 0x0000e825, + 0x0000e826, + 0x0000e827, + 0x0000e828, + 0x0000e829, + 0x0000e82a, + 0x0000e82b, + 0x0000e82c, + 0x0000e82d, + 0x0000e82e, + 0x0000e82f, + 0x0000e830, + 0x0000e831, + 0x0000e832, + 0x0000e833, + 0x0000e834, + 0x0000e835, + 0x0000e836, + 0x0000e837, + 0x0000e838, + 0x0000e839, + 0x0000e83a, + 0x0000e83b, + 0x0000e83c, + 0x0000e83d, + 0x0000e83e, + 0x0000e83f, + 0x0000e840, + 0x0000e841, + 0x0000e842, + 0x0000e843, + 0x0000e844, + 0x0000e845, + 0x0000e846, + 0x0000e847, + 0x0000e848, + 0x0000e849, + 0x0000e84a, + 0x0000e84b, + 0x0000e84c, + 0x0000e84d, + 0x0000e84e, + 0x0000e84f, + 0x0000e850, + 0x0000e851, + 0x0000e852, + 0x0000e853, + 0x0000e854, + 0x0000e855, + 0x0000e856, + 0x0000e857, + 0x0000e858, + 0x0000e859, + 0x0000e85a, + 0x0000e85b, + 0x0000e85c, + 0x0000e85d, + 0x0000e85e, + 0x0000e85f, + 0x0000e860, + 0x0000e861, + 0x0000e862, + 0x0000e863, + 0x0000e864, + 0x0000f92c, + 0x0000f979, + 0x0000f995, + 0x0000f9e7, + 0x0000f9f1, + 0x0000fa0c, + 0x0000fa0d, + 0x0000fa0e, + 0x0000fa0f, + 0x0000fa11, + 0x0000fa13, + 0x0000fa14, + 0x0000fa18, + 0x0000fa1f, + 0x0000fa20, + 0x0000fa21, + 0x0000fa23, + 0x0000fa24, + 0x0000fa27, + 0x0000fa28, + 0x0000fa29, + 0x0000fe30, + 0x0000fe31, + 0x0000fe33, + 0x0000fe34, + 0x0000fe35, + 0x0000fe36, + 0x0000fe37, + 0x0000fe38, + 0x0000fe39, + 0x0000fe3a, + 0x0000fe3b, + 0x0000fe3c, + 0x0000fe3d, + 0x0000fe3e, + 0x0000fe3f, + 0x0000fe40, + 0x0000fe41, + 0x0000fe42, + 0x0000fe43, + 0x0000fe44, + 0x0000fe49, + 0x0000fe4a, + 0x0000fe4b, + 0x0000fe4c, + 0x0000fe4d, + 0x0000fe4e, + 0x0000fe4f, + 0x0000fe50, + 0x0000fe51, + 0x0000fe52, + 0x0000fe54, + 0x0000fe55, + 0x0000fe56, + 0x0000fe57, + 0x0000fe59, + 0x0000fe5a, + 0x0000fe5b, + 0x0000fe5c, + 0x0000fe5d, + 0x0000fe5e, + 0x0000fe5f, + 0x0000fe60, + 0x0000fe61, + 0x0000fe62, + 0x0000fe63, + 0x0000fe64, + 0x0000fe65, + 0x0000fe66, + 0x0000fe68, + 0x0000fe69, + 0x0000fe6a, + 0x0000fe6b, + 0x0000ff01, + 0x0000ff02, + 0x0000ff03, + 0x0000ff04, + 0x0000ff05, + 0x0000ff06, + 0x0000ff07, + 0x0000ff08, + 0x0000ff09, + 0x0000ff0a, + 0x0000ff0b, + 0x0000ff0c, + 0x0000ff0d, + 0x0000ff0e, + 0x0000ff0f, + 0x0000ff10, + 0x0000ff11, + 0x0000ff12, + 0x0000ff13, + 0x0000ff14, + 0x0000ff15, + 0x0000ff16, + 0x0000ff17, + 0x0000ff18, + 0x0000ff19, + 0x0000ff1a, + 0x0000ff1b, + 0x0000ff1c, + 0x0000ff1d, + 0x0000ff1e, + 0x0000ff1f, + 0x0000ff20, + 0x0000ff21, + 0x0000ff22, + 0x0000ff23, + 0x0000ff24, + 0x0000ff25, + 0x0000ff26, + 0x0000ff27, + 0x0000ff28, + 0x0000ff29, + 0x0000ff2a, + 0x0000ff2b, + 0x0000ff2c, + 0x0000ff2d, + 0x0000ff2e, + 0x0000ff2f, + 0x0000ff30, + 0x0000ff31, + 0x0000ff32, + 0x0000ff33, + 0x0000ff34, + 0x0000ff35, + 0x0000ff36, + 0x0000ff37, + 0x0000ff38, + 0x0000ff39, + 0x0000ff3a, + 0x0000ff3b, + 0x0000ff3c, + 0x0000ff3d, + 0x0000ff3e, + 0x0000ff3f, + 0x0000ff40, + 0x0000ff41, + 0x0000ff42, + 0x0000ff43, + 0x0000ff44, + 0x0000ff45, + 0x0000ff46, + 0x0000ff47, + 0x0000ff48, + 0x0000ff49, + 0x0000ff4a, + 0x0000ff4b, + 0x0000ff4c, + 0x0000ff4d, + 0x0000ff4e, + 0x0000ff4f, + 0x0000ff50, + 0x0000ff51, + 0x0000ff52, + 0x0000ff53, + 0x0000ff54, + 0x0000ff55, + 0x0000ff56, + 0x0000ff57, + 0x0000ff58, + 0x0000ff59, + 0x0000ff5a, + 0x0000ff5b, + 0x0000ff5c, + 0x0000ff5d, + 0x0000ff5e, + 0x0000ffe0, + 0x0000ffe1, + 0x0000ffe2, + 0x0000ffe3, + 0x0000ffe4, + 0x0000ffe5, +}; diff --git a/applications/freertos_app/func_23130.c b/applications/freertos_app/func_23130.c new file mode 100644 index 0000000..d2d5bde --- /dev/null +++ b/applications/freertos_app/func_23130.c @@ -0,0 +1,935 @@ + + +/* 2245c - todo */ +void func_2245c(int a, int b) +{ + switch (a) + { + case 11: + //0x22498: Telescope Align + switch (b) + { + case 1: + //0x224c0 + Data_40003360 = strOneStarAlign; + Data_40003364 = strTwoStarAlign; + Data_40003368 = strThreeStarAlign; + Data_4000336c = strTargetSync; + Data_40003370 = strPoleAxisDev; + Data_40003374 = strRaBklashCorr; + Data_40003378 = strDecBklashCorr; + Data_4000337c = Data_40002f4c; + //->0x227ac + break; + + case 2: + //0x22548 + Data_40003360 = strTwoStarAlign; + Data_40003364 = strThreeStarAlign; + Data_40003368 = strTargetSync; + Data_4000336c = strPoleAxisDev; + Data_40003370 = strRaBklashCorr; + Data_40003374 = strDecBklashCorr; + Data_40003378 = Data_40002f4c; + Data_4000337c = Data_40002f50; + //->0x227ac + break; + + case 3: + //0x225d0 + Data_40003360 = strThreeStarAlign; + Data_40003364 = strTargetSync; + Data_40003368 = strPoleAxisDev; + Data_4000336c = strRaBklashCorr; + Data_40003370 = strDecBklashCorr; + Data_40003374 = Data_40002f4c; + Data_40003378 = Data_40002f50; + Data_4000337c = Data_40002f54; + //->0x227ac + break; + + case 4: + //0x22658 + Data_40003360 = strTargetSync; + Data_40003364 = strPoleAxisDev; + Data_40003368 = strRaBklashCorr; + Data_4000336c = strDecBklashCorr; + Data_40003370 = Data_40002f4c; + Data_40003374 = Data_40002f50; + Data_40003378 = Data_40002f54; + Data_4000337c = Data_40002f58; + //->0x227ac + break; + + default: + //227a4 + break; + } + //->0x23128 + break; + + case 12: + //0x227b4: Navigation + switch (b) + { + case 1: + //0x227dc + Data_40003360 = strSolarSystem; + Data_40003364 = strConstellation; + Data_40003368 = strFamousStar; + Data_4000336c = Data_40002f68; + Data_40003370 = Data_40002f6c; + Data_40003374 = Data_40002f70; + Data_40003378 = Data_40002f74; + Data_4000337c = Data_40002f78; + //->0x22a8c + break; + + case 2: + //0x22864 + Data_40003360 = strConstellation; + Data_40003364 = strFamousStar; + Data_40003368 = Data_40002f68; + Data_4000336c = Data_40002f6c; + Data_40003370 = Data_40002f70; + Data_40003374 = Data_40002f74; + Data_40003378 = Data_40002f78; + Data_4000337c = Data_40002f7c; + //->0x22a8c + break; + + case 3: + //0x228ec + Data_40003360 = strFamousStar; + Data_40003364 = Data_40002f68; + Data_40003368 = Data_40002f6c; + Data_4000336c = Data_40002f70; + Data_40003370 = Data_40002f74; + Data_40003374 = Data_40002f78; + Data_40003378 = Data_40002f7c; + Data_4000337c = Data_40002f80; + //->0x22a8c + break; + + case 4: + //0x22974 + Data_40003360 = Data_40002f68; + Data_40003364 = Data_40002f6c; + Data_40003368 = Data_40002f70; + Data_4000336c = Data_40002f74; + Data_40003370 = Data_40002f78; + Data_40003374 = Data_40002f7c; + Data_40003378 = Data_40002f80; + Data_4000337c = Data_40002f84; + //->0x22a8c + break; + + case 5: + //0x229fc + Data_40003360 = Data_40002f6c; + Data_40003364 = Data_40002f70; + Data_40003368 = Data_40002f74; + Data_4000336c = Data_40002f78; + Data_40003370 = Data_40002f7c; + Data_40003374 = Data_40002f80; + Data_40003378 = Data_40002f84; + Data_4000337c = Data_40002f88; + //->0x22a8c + break; + + default: + //0x22a84 + break; + } + break; + + case 13: + //0x22a94: Utilities + switch (b) + { + case 1: + //0x22ab4 + Data_40003360 = strCurrentObjects; + Data_40003364 = Data_40002f90; + Data_40003368 = Data_40002f94; + Data_4000336c = Data_40002f98; + Data_40003370 = Data_40002f9c; + Data_40003374 = Data_40002fa0; + Data_40003378 = Data_40002fa4; + Data_4000337c = Data_40002fa8; + //->0x22c54 + break; + + case 2: + //0x22b3c + Data_40003360 = Data_40002f90; + Data_40003364 = Data_40002f94; + Data_40003368 = Data_40002f98; + Data_4000336c = Data_40002f9c; + Data_40003370 = Data_40002fa0; + Data_40003374 = Data_40002fa4; + Data_40003378 = Data_40002fa8; + Data_4000337c = strParkposition; + //->0x22c54 + break; + + case 3: + //0x22bc4 + Data_40003360 = Data_40002f94; + Data_40003364 = Data_40002f98; + Data_40003368 = Data_40002f9c; + Data_4000336c = Data_40002fa0; + Data_40003370 = Data_40002fa4; + Data_40003374 = Data_40002fa8; + Data_40003378 = strParkposition; + Data_4000337c = Data_40002fb0; + //->0x22c54 + break; + + default: + //0x22c4c + break; + } + break; + + case 14: + //0x22c5c: Setup + switch (b) + { + case 1: + //0x22c7c + Data_40003360 = strTimeAndDate; + Data_40003364 = Data_40002fb8; + Data_40003368 = Data_40002fbc; + Data_4000336c = Data_40002fc0; + Data_40003370 = Data_40002fc4; + Data_40003374 = strTelescopeMount; + Data_40003378 = strTrackingRate; + Data_4000337c = Data_40002fd0; + //->0x22e1c + break; + + case 2: + //0x22d04 + Data_40003360 = Data_40002fb8; + Data_40003364 = Data_40002fbc; + Data_40003368 = Data_40002fc0; + Data_4000336c = Data_40002fc4; + Data_40003370 = strTelescopeMount; + Data_40003374 = strTrackingRate; + Data_40003378 = Data_40002fd0; + Data_4000337c = strReset; + //->0x22e1c + break; + + case 3: + //0x22d8c + Data_40003360 = Data_40002fbc; + Data_40003364 = Data_40002fc0; + Data_40003368 = Data_40002fc4; + Data_4000336c = strTelescopeMount; + Data_40003370 = strTrackingRate; + Data_40003374 = Data_40002fd0; + Data_40003378 = strReset; + Data_4000337c = Data_40002fd8; + //->0x22e1c + break; + + default: + //0x22e14 + break; + } + break; + + case 22: + //0x22e24 + switch (b) + { + case 1: + //0x22e4c + Data_40003360 = Data_40002fdc; + Data_40003364 = Data_40002fe0; + Data_40003368 = Data_40002fe4; + Data_4000336c = Data_40002fe8; + Data_40003370 = Data_40002fec; + Data_40003374 = Data_40002ff0; + Data_40003378 = Data_40002ff4; + Data_4000337c = Data_40002ff8; + //->0x23074 + break; + + case 2: + //0x22ed4 + Data_40003360 = Data_40002fe0; + Data_40003364 = Data_40002fe4; + Data_40003368 = Data_40002fe8; + Data_4000336c = Data_40002fec; + Data_40003370 = Data_40002ff0; + Data_40003374 = Data_40002ff4; + Data_40003378 = Data_40002ff8; + Data_4000337c = Data_40002ffc; + //->0x23074 + break; + + case 3: + //0x22f5c + Data_40003360 = Data_40002fe4; + Data_40003364 = Data_40002fe8; + Data_40003368 = Data_40002fec; + Data_4000336c = Data_40002ff0; + Data_40003370 = Data_40002ff4; + Data_40003374 = Data_40002ff8; + Data_40003378 = Data_40002ffc; + Data_4000337c = Data_40003000; + //->0x23074 + break; + + case 4: + //0x22fe4 + Data_40003360 = Data_40002fe8; + Data_40003364 = Data_40002fec; + Data_40003368 = Data_40002ff0; + Data_4000336c = Data_40002ff4; + Data_40003370 = Data_40002ff8; + Data_40003374 = Data_40002ffc; + Data_40003378 = Data_40003000; + Data_4000337c = Data_40003004; + //->0x23074 + break; + + default: + //0x2306c + break; + } + break; + + case 23: + //0x2307c + switch (b) + { + case 1: + //23088 + Data_40003360 = Data_40003008; + Data_40003364 = Data_4000300c; + Data_40003368 = Data_40003010; + Data_4000336c = Data_40003014; + Data_40003370 = Data_40003018; + Data_40003374 = Data_4000301c; + Data_40003378 = Data_40003020; + Data_4000337c = Data_40003024; + //->0x23074 + break; + + default: + //0x23110 + break; + } + break; + + default: + break; + } +} + +/* 23130 - todo */ +void AdaptDisplayLinesPerMenuLine(void) +{ + //Set Number of Menu Lines depending on Language? + switch (bData_40003196_CurrentLanguage) + { + case MENU_LANGUAGE_ENGLISH: //1: + //0x2315c + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_LANGUAGE_GERMAN: //2: + //0x23170 + bData_40003197_DisplayLinesPerMenuLine = 2; + break; + + case MENU_LANGUAGE_FRENCH: //3: + //0x23184 + bData_40003197_DisplayLinesPerMenuLine = 2; + break; + + case MENU_LANGUAGE_ITALIAN: //4: + //0x23198 + bData_40003197_DisplayLinesPerMenuLine = 2; + break; + + case MENU_LANGUAGE_SPANISH: //5: + //0x231ac + bData_40003197_DisplayLinesPerMenuLine = 2; + break; + + default: + //0x231c0 + break; + } +} + +/* 231d0 - todo */ +void func_231d0(int a, int b) +{ + switch (a) + { + case 11: + //0x2320c + switch (b) + { + case 1: + //0x23240 + Data_400033a8 = strOneStarAlign; + Data_400033ac = strTwoStarAlign; + Data_400033b0 = strThreeStarAlign; + Data_400033b4 = strTargetSync; + break; + + case 2: + //0x23288 + Data_400033a8 = strTwoStarAlign; + Data_400033ac = strThreeStarAlign; + Data_400033b0 = strTargetSync; + Data_400033b4 = strPoleAxisDev; + break; + + case 3: + //0x232d0 + Data_400033a8 = strThreeStarAlign; + Data_400033ac = strTargetSync; + Data_400033b0 = strPoleAxisDev; + Data_400033b4 = strRaBklashCorr; + break; + + case 4: + //0x23318 + Data_400033a8 = strTargetSync; + Data_400033ac = strPoleAxisDev; + Data_400033b0 = strRaBklashCorr; + Data_400033b4 = strDecBklashCorr; + break; + + case 5: + //0x23360 + Data_400033a8 = strPoleAxisDev; + Data_400033ac = strRaBklashCorr; + Data_400033b0 = strDecBklashCorr; + Data_400033b4 = Data_40002f4c; + break; + + case 6: + //0x233a8 + Data_400033a8 = strRaBklashCorr; + Data_400033ac = strDecBklashCorr; + Data_400033b0 = Data_40002f4c; + Data_400033b4 = Data_40002f50; + break; + + case 7: + //0x233f0 + Data_400033a8 = strDecBklashCorr; + Data_400033ac = Data_40002f4c; + Data_400033b0 = Data_40002f50; + Data_400033b4 = Data_40002f54; + break; + + case 8: + //0x23438 + Data_400033a8 = Data_40002f4c; + Data_400033ac = Data_40002f50; + Data_400033b0 = Data_40002f54; + Data_400033b4 = Data_40002f58; + break; + + default: + //0x23480 + break; + } + break; + + case 12: + //0x23490 + switch (b) + { + case 1: + //0x234c8 + Data_400033a8 = strSolarSystem; + Data_400033ac = strConstellation; + Data_400033b0 = strFamousStar; + Data_400033b4 = Data_40002f68; + break; + + case 2: + //0x23510 + Data_400033a8 = strConstellation; + Data_400033ac = strFamousStar; + Data_400033b0 = Data_40002f68; + Data_400033b4 = Data_40002f6c; + break; + + case 3: + //0x23558 + Data_400033a8 = strFamousStar; + Data_400033ac = Data_40002f68; + Data_400033b0 = Data_40002f6c; + Data_400033b4 = Data_40002f70; + break; + + case 4: + //0x235a0 + Data_400033a8 = Data_40002f68; + Data_400033ac = Data_40002f6c; + Data_400033b0 = Data_40002f70; + Data_400033b4 = Data_40002f74; + break; + + case 5: + //0x235e8 + Data_400033a8 = Data_40002f6c; + Data_400033ac = Data_40002f70; + Data_400033b0 = Data_40002f74; + Data_400033b4 = Data_40002f78; + break; + + case 6: + //0x23630 + Data_400033a8 = Data_40002f70; + Data_400033ac = Data_40002f74; + Data_400033b0 = Data_40002f78; + Data_400033b4 = Data_40002f7c; + break; + + case 7: + //0x23678 + Data_400033a8 = Data_40002f74; + Data_400033ac = Data_40002f78; + Data_400033b0 = Data_40002f7c; + Data_400033b4 = Data_40002f80; + break; + + case 8: + //0x237a4 + Data_400033a8 = Data_40002f78; + Data_400033ac = Data_40002f7c; + Data_400033b0 = Data_40002f80; + Data_400033b4 = Data_40002f84; + break; + + case 9: + //0x237ec + Data_400033a8 = Data_40002f7c; + Data_400033ac = Data_40002f80; + Data_400033b0 = Data_40002f84; + Data_400033b4 = Data_40002f88; + break; + + default: + //0x23834 + break; + } + break; + + case 13: + //0x23844 + switch (b) + { + case 1: + //0x23874 + Data_400033a8 = strCurrentObjects; + Data_400033ac = Data_40002f90; + Data_400033b0 = Data_40002f94; + Data_400033b4 = Data_40002f98; + break; + + case 2: + //0x238bc + Data_400033a8 = Data_40002f90; + Data_400033ac = Data_40002f94; + Data_400033b0 = Data_40002f98; + Data_400033b4 = Data_40002f9c; + break; + + case 3: + //0x23904 + Data_400033a8 = Data_40002f94; + Data_400033ac = Data_40002f98; + Data_400033b0 = Data_40002f9c; + Data_400033b4 = Data_40002fa0; + break; + + case 4: + //0x2394c + Data_400033a8 = Data_40002f98; + Data_400033ac = Data_40002f9c; + Data_400033b0 = Data_40002fa0; + Data_400033b4 = Data_40002fa4; + break; + + case 5: + //0x23994 + Data_400033a8 = Data_40002f9c; + Data_400033ac = Data_40002fa0; + Data_400033b0 = Data_40002fa4; + Data_400033b4 = Data_40002fa8; + break; + + case 6: + //0x239dc + Data_400033a8 = Data_40002fa0; + Data_400033ac = Data_40002fa4; + Data_400033b0 = Data_40002fa8; + Data_400033b4 = strParkposition; + break; + + case 7: + //0x23a24 + Data_400033a8 = Data_40002fa4; + Data_400033ac = Data_40002fa8; + Data_400033b0 = strParkposition; + Data_400033b4 = Data_40002fb0; + break; + + default: + //0x23a6c + break; + } + break; + + case 14: + //0x23a7c - Setup + switch (b) + { + case 1: + //0x23aac + Data_400033a8 = strTimeAndDate; + Data_400033ac = Data_40002fb8; + Data_400033b0 = Data_40002fbc; + Data_400033b4 = Data_40002fc0; + break; + + case 2: + //0x23af4 + Data_400033a8 = Data_40002fb8; + Data_400033ac = Data_40002fbc; + Data_400033b0 = Data_40002fc0; + Data_400033b4 = Data_40002fc4; + break; + + case 3: + //0x23b3c + Data_400033a8 = Data_40002fbc; + Data_400033ac = Data_40002fc0; + Data_400033b0 = Data_40002fc4; + Data_400033b4 = strTelescopeMount; + break; + + case 4: + //0x23b84 + Data_400033a8 = Data_40002fc0; + Data_400033ac = Data_40002fc4; + Data_400033b0 = strTelescopeMount; + Data_400033b4 = strTrackingRate; + break; + + case 5: + //0x23bcc + Data_400033a8 = Data_40002fc4; + Data_400033ac = strTelescopeMount; + Data_400033b0 = strTrackingRate; + Data_400033b4 = Data_40002fd0; + break; + + case 6: + //0x23c14 + Data_400033a8 = strTelescopeMount; + Data_400033ac = strTrackingRate; + Data_400033b0 = Data_40002fd0; + Data_400033b4 = strReset; + break; + + case 7: + //0x23c5c + Data_400033a8 = strTrackingRate; + Data_400033ac = Data_40002fd0; + Data_400033b0 = strReset; + Data_400033b4 = Data_40002fd8; + break; + + default: + //0x23ca4 + break; + } + break; + + case 22: + //0x23cb4 + switch (b) + { + case 1: + //0x23ce8 + Data_400033a8 = Data_40002fdc; + Data_400033ac = Data_40002fe0; + Data_400033b0 = Data_40002fe4; + Data_400033b4 = Data_40002fe8; + break; + + case 2: + //0x23d30 + Data_400033a8 = Data_40002fe0; + Data_400033ac = Data_40002fe4; + Data_400033b0 = Data_40002fe8; + Data_400033b4 = Data_40002fec; + break; + + case 3: + //0x23d78 + Data_400033a8 = Data_40002fe4; + Data_400033ac = Data_40002fe8; + Data_400033b0 = Data_40002fec; + Data_400033b4 = Data_40002ff0; + break; + + case 4: + //0x23dc0 + Data_400033a8 = Data_40002fe8; + Data_400033ac = Data_40002fec; + Data_400033b0 = Data_40002ff0; + Data_400033b4 = Data_40002ff4; + break; + + case 5: + //0x23e08 + Data_400033a8 = Data_40002fec; + Data_400033ac = Data_40002ff0; + Data_400033b0 = Data_40002ff4; + Data_400033b4 = Data_40002ff8; + break; + + case 6: + //0x23e50 + Data_400033a8 = Data_40002ff0; + Data_400033ac = Data_40002ff4; + Data_400033b0 = Data_40002ff8; + Data_400033b4 = Data_40002ffc; + break; + + case 7: + //0x23e98 + Data_400033a8 = Data_40002ff4; + Data_400033ac = Data_40002ff8; + Data_400033b0 = Data_40002ffc; + Data_400033b4 = Data_40003000; + break; + + case 8: + //0x23ee0 + Data_400033a8 = Data_40002ff8; + Data_400033ac = Data_40002ffc; + Data_400033b0 = Data_40003000; + Data_400033b4 = Data_40003004; + break; + + default: + //0x23f28 + break; + } + break; + + case 23: + //0x23f38 + switch (b) + { + case 1: + //0x23f60 + Data_400033a8 = Data_40003008; + Data_400033ac = Data_4000300c; + Data_400033b0 = Data_40003010; + Data_400033b4 = Data_40003014; + break; + + case 2: + //0x23fa8 + Data_400033a8 = Data_4000300c; + Data_400033ac = Data_40003010; + Data_400033b0 = Data_40003014; + Data_400033b4 = Data_40003018; + break; + + case 3: + //0x23ff0 + Data_400033a8 = Data_40003010; + Data_400033ac = Data_40003014; + Data_400033b0 = Data_40003018; + Data_400033b4 = Data_4000301c; + break; + + case 4: + //0x24038 + Data_400033a8 = Data_40003014; + Data_400033ac = Data_40003018; + Data_400033b0 = Data_4000301c; + Data_400033b4 = Data_40003020; + break; + + case 5: + //0x24080 + Data_400033a8 = Data_40003018; + Data_400033ac = Data_4000301c; + Data_400033b0 = Data_40003020; + Data_400033b4 = Data_40003024; + break; + + default: + //0x240c8 + break; + } + break; + + default: + //0x240d8 + break; + } +} + +/* 240e8 - todo */ +void func_240e8(unsigned char a, int b) +{ + switch (a) + { + case MENU_RECENT_TARGET_SOLAR_SYSTEM: //1: + //0x24134 + bData_40002eb5_SolarSystemObjectNr = b; + + get_solar_system_object_data(bData_40002eb5_SolarSystemObjectNr, + &fData_40002cd0_ObjectRightAscension, + &fData_40002d18_ObjectDeclination); + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //0x24164 + Data_4000410e[bData_40002f1d] = Data_4000314c_SolarSystemObjectName[bData_40002f1d]; + } + //->0x24568 + break; + + case MENU_RECENT_TARGET_CONSTELLATION: //2: + //0x241b0: Constellation + bData_40002ece_ConstellationNr = b; + + flash_get_constellation_data(bData_40002ece_ConstellationNr, + &Data_40003dd4_FlashConstellationData); + + sprintf(Data_4000410e, "Constellation %d ", bData_40002ece_ConstellationNr); + //->0x24568 + break; + + case MENU_RECENT_TARGET_FAMOUS_STAR: //3: + //0x241e4 + bData_40002ed2_FamousStarNr = b; + + flash_get_famous_star_data(bData_40002ed2_FamousStarNr, + &Data_40003d94_FlashFamousStarData); + + for (bData_40002f1d = 0; bData_40002f1d < 13; bData_40002f1d++) + { + //0x24210 + Data_4000410e[bData_40002f1d] = ((char*)&Data_40003d94_FlashFamousStarData.bData_28)[bData_40002f1d+1]; + } + //->0x24568 + break; + + case MENU_RECENT_TARGET_MESSIER: //4: + //0x2425c + wData_40002eb8_MessierNr = b; + + flash_get_messier_data(wData_40002eb8_MessierNr & 0xFF, &Data_40003e08_FlashMessierData); + + sprintf(Data_4000410e, "Messier %d ", wData_40002eb8_MessierNr); + //->0x24568 + break; + + case MENU_RECENT_TARGET_NGC: //5: + //0x24290 + wData_40002eba_NGCNr = b; + + flash_get_ngc_data(wData_40002eba_NGCNr, &Data_40003ee0_FlashNGCData); + + sprintf(Data_4000410e, "NGC %d ", wData_40002eba_NGCNr); + //->0x24568 + break; + + case MENU_RECENT_TARGET_IC: //6: + //0x242c4 + wData_40002ebc_ICNr = b; + + flash_get_ic_data(wData_40002ebc_ICNr, &Data_40003ec0_FlashICData); + + sprintf(Data_4000410e, "IC %d ", wData_40002ebc_ICNr); + //->0x24568 + break; + + case MENU_RECENT_TARGET_SH2: //7: + //0x242f8 + wData_40002ebe_ShNr = b; + + flash_get_sh2_data(wData_40002ebe_ShNr, &Data_40003350_FlashSh2Data); + + sprintf(Data_4000410e, "Sh %d ", wData_40002ebe_ShNr); + //->0x24568 + break; + + case MENU_RECENT_TARGET_BRIGHT_STAR: //8: + //0x2432c + wData_40002ec0_BrightStarNr = b; + + flash_get_bright_star_data(wData_40002ec0_BrightStarNr & 0xFF, &Data_40003ea0_FlashBrightStarData); + + sprintf(Data_4000410e, "Bright %d ", wData_40002ec0_BrightStarNr); + //->0x24568 + break; + + case MENU_RECENT_TARGET_SAO_CAT: //9: + //0x24478 + Data_40002ec4_SAONr = b; + + flash_get_sao_data(Data_40002ec4_SAONr, &Data_40003358_SAORecord); + + sprintf(Data_4000410e, "SAO %d ", Data_40002ec4_SAONr); + //->0x24568 + break; + + case 10: + //0x244a8 + func_5218(b & 0xFF, &Data_40003f50); + sprintf(Data_4000410e, "Sky F%d ", b); + //->0x24568 + break; + + case 11: + //0x244cc + func_5218(b & 0xFF, &Data_40003f50); + + Data_400033a0 = "My Input Data "; + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //0x244f8 + Data_4000410e[bData_40002f1d] = Data_400033a0[bData_40002f1d]; + } + //->0x24568 + break; + + case 12: + //0x24544 + func_54e0(b & 0xFF, &Data_40003f64); + sprintf(Data_4000410e, "Land F%d ", b); + break; + + #if 0 + default: + //0x24568 + break; + #endif + } +} + diff --git a/applications/freertos_app/func_27844.c b/applications/freertos_app/func_27844.c new file mode 100644 index 0000000..edb7074 --- /dev/null +++ b/applications/freertos_app/func_27844.c @@ -0,0 +1,5871 @@ + + +/* 27844 - todo */ +void PrepareScreenItems(void) +{ + SwapLanguageStrings(); + + #ifdef UART0_DEBUG + { + char buf[100]; + snprintf(buf, sizeof(buf)-1, "PrepareScreenItems: MenuContextId=%d\n\r", Data_40002c64_MenuContextId); + uart0_send(buf, strlen(buf)); + } + #endif + + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x28030 + PrepareMainScreenItems(); + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_NO_TELESCOPE: //2: + //0x28054 + Data_40003364 = strThereIsNoTele; + Data_4000336c = strScopeToConnectThis; + Data_40003374 = strControlTerminal; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case 0x65: //101 + //0x28090 + Data_40003360 = "F1"; + Data_40003364 = "F2"; + Data_40003368 = "F3"; + Data_4000336c = "F4"; + Data_40003370 = "F5"; + Data_40003374 = "F6"; + Data_40003378 = "F7"; + Data_4000337c = "F8"; + Data_40003380 = "F9"; + + switch (bData_40002e79_SkyLandTargetSeletion) + { + case 0: + //0x2811c + Data_40003384 = "Select Sky Target No "; + break; + + case 1: + //0x28130 + Data_40003384 = "Select Land Target No"; + break; + + default: + //0x28144 + break; + } + //->3d71c + break; + + case 0x66: //102 + //0x28154 + switch (bData_40002e79_SkyLandTargetSeletion) + { + case 0: + //0x28174 + func_5218(bData_4000319a_SkyLandTargetId, &Data_40003f50); + break; + + case 1: + //0x2818c + func_54e0(bData_4000319a_SkyLandTargetId, &Data_40003f64); + break; + + default: + //0x281a4 + break; + } + //281b0 + if (((Data_40003f64.bData_0 != 1) && (bData_40002e79_SkyLandTargetSeletion == 1)) || + ((Data_40003f50.bData_0 != 1) && (bData_40002e79_SkyLandTargetSeletion == 0))) + { + //281f0 + Data_40003360 = " "; + Data_40003364 = "Sorry "; + Data_40003368 = " "; + + if (bData_40002e79_SkyLandTargetSeletion == 0) + { + //28224 + sprintf(Data_40003fe8, "Your Sky F%d is Blank ", bData_4000319a_SkyLandTargetId); + } + //28238 + if (bData_40002e79_SkyLandTargetSeletion == 1) + { + //28248 + sprintf(Data_40003fe8, "Your Land F%d is Blank ", bData_4000319a_SkyLandTargetId); + } + //2825c + Data_4000336c = Data_40003fe8; + Data_40003370 = " "; + Data_40003374 = "Please Input Data "; + Data_40003378 = " "; + Data_4000337c = " "; + //->29978 + } + else + { + //283fc + if (bData_40002e79_SkyLandTargetSeletion == 0) + { + //2840c + sprintf(Data_40003fa9, "My Sky Target %d ", bData_4000319a_SkyLandTargetId); + + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = Data_40003f50.bData_1; + Data_4000336c = " "; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = Data_40003f50.fData_12; + Data_40004ae8.dDec = Data_40003f50.fData_16; + fData_40002cd0_ObjectRightAscension = Data_40003f50.fData_12; + fData_40002d18_ObjectDeclination = Data_40003f50.fData_16; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + //284f8 + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)(Data_40004b08.dAzimuth), + (int)((Data_40004b08.dAzimuth - (int)(Data_40004b08.dAzimuth)) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //285d0 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //286cc + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //2885c + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + //288a4 + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + //28910 + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + //28954 + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + //2898c + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + //28a0c + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //28a64 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int)fData_40002cd0_ObjectRightAscension, + (int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60), + (int)(fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int)fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + //28b2c + if (((int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60)) < 10) + { + Data_40004027[8] = ' '; + } + //28b7c + if (((int)(fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + //28bb4 + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //28bd4 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + else + { + //28cf8 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + //28dc4 + if (abs((int)fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + //28df8 + if (abs((int)((fData_40002d18_ObjectDeclination - (int)fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + //28e5c + if (abs((int)(fData_40002d18_ObjectDeclination * 3600) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //28ea8 + Data_4000337c = Data_4000403c; + //->29978 + } + else + { + //28eb8 + sprintf(Data_40003fa9, "My Land Target %d", bData_4000319a_SkyLandTargetId); + + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = Data_40003f64.bData_1; + Data_4000336c = " "; + + Data_40004b08.dAzimuth = Data_40003f64.fData_12; + Data_40004b08.dAltitude = Data_40003f64.fData_16; + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + //28fe8 + if (Data_40004b08.dAltitude >= 0) + { + //29004 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //2915c + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //29254 + if ((int)Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + //29278 + if ((int)Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + //2929c + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + //29308 + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + //2934c + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + //29384 + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + //29404 + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //2945c + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + (int)dData_40002dd0, + (int)((dData_40002dd0 - (int)dData_40002dd0) * 60), + (int)(dData_40002dd0 * 3600) % 60); + //29540 + if (dData_40002e08 >= 0) + { + //29558 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + //->2972c + } + else + { + //29644 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //2972c + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + //2974c + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + //2976c + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + //297d0 + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + //29810 + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + //29894 + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + //2990c + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //29960 + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + } + } + //29978 + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 1: + //0x29994: Recent Targets + bData_40002f14_RecentTargetCount = flash_get_recent_targets(Data_40002f15_RecentTargetTypeArray, + Data_4000359c_RecentTargetIdArray, Data_400035bc); + + Data_40003360 = " "; + Data_40003364 = " "; + Data_40003368 = " "; + Data_4000336c = " "; + Data_40003370 = " "; + Data_40003374 = " "; + Data_40003378 = " "; + Data_4000337c = " "; + + Data_40003380 = " "; + Data_40003384 = " "; + Data_40003388 = " "; + Data_4000338c = " "; + Data_40003390 = " "; + Data_40003394 = " "; + Data_40003398 = " "; + Data_4000339c = " "; + //29a70 + switch (bData_40002f14_RecentTargetCount) + { + case 0: + //0x29aa8 + Data_40003360 = " "; + Data_40003364 = " "; + Data_40003368 = "Sorry "; + Data_4000336c = " "; + Data_40003370 = "No Recent Target "; + Data_40003374 = " "; + Data_40003378 = " "; + Data_4000337c = " "; + //->2a0f8 + break; + + case 8: + //0x29b10 + Data_4000339c = "8: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[7]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[7]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //29b64 + Data_4000403c[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_4000337c = Data_4000403c; + //break; //fall through + + case 7: + //0x29bb8 + Data_40003398 = "7: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[6]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[6]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //29c08 + Data_40004027[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_40003378 = Data_40004027; + //break; //fall through + + case 6: + //0x29c5c + Data_40003394 = "6: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[5]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[5]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + Data_40003374 = Data_400033a4; + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //29cbc + Data_40004012[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_40003374 = Data_40004012; + //break; //fall through + + case 5: + //0x29d10 + Data_40003390 = "5: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[4]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[4]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //0x29e04 + Data_40003ffd[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_40003370 = Data_40003ffd; + //break; //fall through + + case 4: + //0x29e58 + Data_4000338c = "4: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[3]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[3]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //0x29ea8 + Data_40003fe8[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_4000336c = Data_40003fe8; + //break; //fall through + + case 3: + //0x29efc + Data_40003388 = "3: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[2]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[2]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //0x29f4c + Data_40003fd3[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_40003368 = Data_40003fd3; + //break; //fall through + + case 2: + //0x29fa0 + Data_40003384 = "2: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[1]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[1]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //0x29ff0 + Data_40003fbe[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_40003364 = Data_40003fbe; + //break; //fall through + + case 1: + //0x2a044 + Data_40003380 = "1: "; + bData_40002f0d_RecentTargetType = Data_40002f15_RecentTargetTypeArray[0]; + bData_40002f10_RecentTargetId = Data_4000359c_RecentTargetIdArray[0]; + + func_240e8(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + Data_40003360 = Data_400033a4; + + for (bData_40002f1d = 0; bData_40002f1d < 21; bData_40002f1d++) + { + //0x2a0a4 + Data_40003fa9[bData_40002f1d] = Data_4000410e[bData_40002f1d]; + } + + Data_40003360 = Data_40003fa9; + //break; //fall through + + #if 0 + default: + //0x2a0f8 + break; + #endif + } + //->3d71c + break; + + case MENU_CONTEXT_ALIGNMENT: //1000: + //0x2a100 - Telescope Align + Data_40003360 = strTelescopeAlign; + Data_40003364 = ""; + Data_40003368 = strNavigation; + Data_4000336c = ""; + Data_40003370 = strUtilities; + Data_40003374 = ""; + Data_40003378 = strSetup; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + + Data_400033a8 = strTelescopeAlign; + Data_400033ac = strNavigation; + Data_400033b0 = strUtilities; + Data_400033b4 = strSetup; + + bData_4000316f_FocusLineOn4LineDisplay = 1; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case MENU_CONTEXT_NAVIGATION: //2000: + //0x2a220 - Navigation + Data_40003360 = strTelescopeAlign; + Data_40003364 = ""; + Data_40003368 = strNavigation; + Data_4000336c = ""; + Data_40003370 = strUtilities; + Data_40003374 = ""; + Data_40003378 = strSetup; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + + Data_400033a8 = strTelescopeAlign; + Data_400033ac = strNavigation; + Data_400033b0 = strUtilities; + Data_400033b4 = strSetup; + + bData_4000316f_FocusLineOn4LineDisplay = 2; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case MENU_CONTEXT_UTILITIES: //3000: + //0x2a2f4 - Utilities + Data_40003360 = strTelescopeAlign; + Data_40003364 = ""; + Data_40003368 = strNavigation; + Data_4000336c = ""; + Data_40003370 = strUtilities; + Data_40003374 = ""; + Data_40003378 = strSetup; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + + Data_400033a8 = strTelescopeAlign; + Data_400033ac = strNavigation; + Data_400033b0 = strUtilities; + Data_400033b4 = strSetup; + + bData_4000316f_FocusLineOn4LineDisplay = 3; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case MENU_CONTEXT_SETUP: //4000: + //0x2a3c8 - Setup + Data_40003360 = strTelescopeAlign; + Data_40003364 = ""; + Data_40003368 = strNavigation; + Data_4000336c = ""; + Data_40003370 = strUtilities; + Data_40003374 = ""; + Data_40003378 = strSetup; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 7; + + Data_400033a8 = strTelescopeAlign; + Data_400033ac = strNavigation; + Data_400033b0 = strUtilities; + Data_400033b4 = strSetup; + + bData_4000316f_FocusLineOn4LineDisplay = 4; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case MENU_CONTEXT_ONE_STAR_ALIGN: //1100: + //0x2a49c: One Star Align + case MENU_CONTEXT_TWO_STAR_ALIGN: //1200: + //0x2a4a4: Two Star Align + case MENU_CONTEXT_THREE_STAR_ALIGN: //1300: + //0x2a4a8: Three Star Align + case MENU_CONTEXT_TARGET_SYNC: //1400: + //0x2a4ac: Target Sync + case MENU_CONTEXT_POLE_AXIS_DEV: //1500: + //0x2a4b0: Pole-Axis Dev. + case MENU_CONTEXT_RA_BKBLASH_CORR: //1600: + //0x2a4b4: RA Bklash Corr. + case MENU_CONTEXT_DEC_BKLASH_CORR: //1700: + //0x2a4b8: DEC Bklash Corr. + func_2245c(11, bData_40003170); + + bData_4000316e_FocusLineOn8LineDisplay = bData_40003172; + + func_231d0(11, bData_40003171); + + bData_4000316f_FocusLineOn4LineDisplay = bData_40003173; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM: //2100: + //0x2a500: Solar System + case MENU_CONTEXT_NAVIGATION_CONSTELLATION: //2200: + //0x2a508: Constellation + case MENU_CONTEXT_NAVIGATION_FAMOUS_STAR: //2300: + //0x2a50c: Famous Star + case MENU_CONTEXT_NAVIGATION_MESSIER_CAT: //2400: + //0x2a510: Messier Catal. + case MENU_CONTEXT_NAVIGATION_NGC_CAT: //2500: + //0x2a514: NGC Catalog. + case MENU_CONTEXT_NAVIGATION_IC_CAT: //2600: + //0x2a518: IC Catalogue + case MENU_CONTEXT_NAVIGATION_SH2_CAT: //2700: + //0x2a51c: Sh2 Catalog. + case MENU_CONTEXT_NAVIGATION_BRIGHT_STAR: //2800: + //0x2a520: Bright Star Cat. + case MENU_CONTEXT_NAVIGATION_SAO_CAT: //2900: + //0x2a524: SAO Star Catal. + case MENU_CONTEXT_NAVIGATION_CUST_OBJ: //2110: + //0x2a528: Customer Objects + case MENU_CONTEXT_NAVIGATION_RA_DEC: //2120: + //0x2a52c: Input RA and DEC + case MENU_CONTEXT_NAVIGATION_CUST_LAND: //2130: + //0x2a530: Custom Land Goal + func_2245c(12, bData_40003174); + + bData_4000316e_FocusLineOn8LineDisplay = bData_40003176; + + func_231d0(12, bData_40003175); + + bData_4000316f_FocusLineOn4LineDisplay = bData_40003177; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case MENU_CONTEXT_CURRENT_OBJECTS: //3100: + //0x2a578: Current Objects + case MENU_CONTEXT_OBJECT_RISE_SET: //3200: + //0x2a580: Object Rise/Set + case MENU_CONTEXT_LUNAR_PHASE: //3300: + //0x2a584 + case MENU_CONTEXT_TIMER: //3400: + //0x2a588 + case MENU_CONTEXT_ALARM: //3500: + //0x2a58c + case MENU_CONTEXT_EYEPIECE_FOV: //3600: + //0x2a590: Eyepiece FOV + case MENU_CONTEXT_EYEPIECE_MAGN: //3700: + //0x2a594: Eyepiece Magn. + case MENU_CONTEXT_DISPLAY_ILLUMINATION: //3800: + //0x2a598: Display Illumin. + case MENU_CONTEXT_PARK_POSITION: //3900: + //0x2a59c: Parkposition + func_2245c(13, bData_40003178); + + bData_4000316e_FocusLineOn8LineDisplay = bData_4000317a; + + func_231d0(13, bData_40003179); + + bData_4000316f_FocusLineOn4LineDisplay = bData_4000317b; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case MENU_CONTEXT_TIME_DATE: //4100: + //0x2a5e4: Time and Date + case MENU_CONTEXT_DAYLIGHT_SAVING: //4200: + //0x2a5ec + case MENU_CONTEXT_SITE_SETTING: //4300: + //0x2a5f0: Site Setting + case MENU_CONTEXT_SKY_LAND: //4400: + //0x2a5f4 + case MENU_CONTEXT_AZ_EQU: //4500: + //0x2a5f8 + case MENU_CONTEXT_TELESCOPE_MOUNT: //4600: + //0x2a5fc: Telescope Mount + case MENU_CONTEXT_TRACKING_RATE: //4700: + //0x2a600 + case MENU_CONTEXT_LANGUAGE: //4800: + //0x2a604 + case MENU_CONTEXT_RESET: //4900: + //0x2a608 + func_2245c(14, bData_4000317c); + + bData_4000316e_FocusLineOn8LineDisplay = bData_4000317e; + + func_231d0(14, bData_4000317d); + + bData_4000316f_FocusLineOn4LineDisplay = bData_4000317f; + + AdaptDisplayLinesPerMenuLine(); + //->3d71c + break; + + case 0x899: //2201 + //0x2a650 + case 0x89A: //2202 + //0x2a658 + case 0x89B: //2203 + //0x2a65c + case 0x89C: //2204 + //0x2a660 + case 0x89D: //2205 + //0x2a664 + case 0x89E: //2206 + //0x2a668 + case 0x89F: //2207 + //0x2a66c + case 0x8A0: //2208 + //0x2a670 + case 0x8A1: //2209 + //0x2a674 + case 0x55FC: //22012 + //0x2a678 + func_2245c(22, bData_40003180); + + bData_4000316e_FocusLineOn8LineDisplay = bData_40003182; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0x8FD: //2301 + //0x2a6a8 + case 0x8FE: //2302 + //0x2a6b0 + case 0x8ff: //2303 + //0x2a6b4 + case 0x900: //2304 + //0x2a6b8 + case 2305: + //0x2a6bc + case 2306: + //0x2a6c0 + case 2307: + //0x2a6c4 + case 2308: + //0x2a6c8 + func_2245c(23, bData_40003184); + + bData_4000316e_FocusLineOn8LineDisplay = bData_40003186; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0x9c5: //2501 + //0x2a6f8 + Data_40003360 = strScientificName; + Data_40003364 = ""; + Data_40003368 = strSAOCatalog; + Data_4000336c = ""; + Data_40003370 = strHRCatalog; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0x9c6: //2502 + //0x2a780 + Data_40003360 = strScientificName; + Data_40003364 = ""; + Data_40003368 = strSAOCatalog; + Data_4000336c = ""; + Data_40003370 = strHRCatalog; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0x9C7: //2503 + //0x2a80c + Data_40003360 = strScientificName; + Data_40003364 = ""; + Data_40003368 = strSAOCatalog; + Data_4000336c = ""; + Data_40003370 = strHRCatalog; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xAF1: //2801 + //0x2a898 + Data_40003360 = strSelect; + Data_40003364 = ""; + Data_40003368 = strAdd; + Data_4000336c = ""; + Data_40003370 = strDelete; + Data_40003374 = ""; + Data_40003378 = strModify; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xAF2: //2802 + //0x2a924 + Data_40003360 = strSelect; + Data_40003364 = ""; + Data_40003368 = strAdd; + Data_4000336c = ""; + Data_40003370 = strDelete; + Data_40003374 = ""; + Data_40003378 = strModify; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xAF3: //2803 + //0x2aa2c + Data_40003360 = strSelect; + Data_40003364 = ""; + Data_40003368 = strAdd; + Data_4000336c = ""; + Data_40003370 = strDelete; + Data_40003374 = ""; + Data_40003378 = strModify; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xAF4: //2804 + //0x2aabc + Data_40003360 = strSelect; + Data_40003364 = ""; + Data_40003368 = strAdd; + Data_4000336c = ""; + Data_40003370 = strDelete; + Data_40003374 = ""; + Data_40003378 = strModify; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 7; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0x526D: //21101 + //0x2ab4c + Data_40003360 = Data_40003044; + Data_40003364 = ""; + Data_40003368 = Data_40003048; + Data_4000336c = ""; + Data_40003370 = Data_4000304c; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0x526E: //21102 + //0x2abd4 + Data_40003360 = Data_40003044; + Data_40003364 = ""; + Data_40003368 = Data_40003048; + Data_4000336c = ""; + Data_40003370 = Data_4000304c; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0x526F: //21103 + //0x2ac60 + Data_40003360 = Data_40003044; + Data_40003364 = ""; + Data_40003368 = Data_40003048; + Data_4000336c = ""; + Data_40003370 = Data_4000304c; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xE11: //3601 + //0x2acec + Data_40003360 = strEyeshot; + Data_40003364 = strRatio; + Data_40003368 = ""; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xE12: //3602 + //0x2ad70 + Data_40003360 = strEyeshot; + Data_40003364 = strRatio; + Data_40003368 = ""; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 2; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xED9: //3801 + //0x2adf8 + Data_40003360 = strBackBoard; + Data_40003364 = strAccessory; + Data_40003368 = ""; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xEDA: //3802 + //0x2ae7c + Data_40003360 = strBackBoard; + Data_40003364 = strAccessory; + Data_40003368 = ""; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 2; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_COUNTRY_CITY: //4301: + //0x2af04: Country & City + Data_40003360 = strCountryAndCity; + Data_40003368 = strCustomSite; + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_CUSTOM_SITE: //4302: + //0x2af88: Custom Site + Data_40003360 = strCountryAndCity; + Data_40003368 = strCustomSite; + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xA80D: //43021 + //0x2b010 + Data_40003360 = Data_40003068; + Data_40003368 = Data_4000306c; + Data_40003370 = Data_40003070; + Data_40003378 = Data_40003074; + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003374 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xA80E: //43022 + //0x2b09c + Data_40003360 = Data_40003068; + Data_40003368 = Data_4000306c; + Data_40003370 = Data_40003070; + Data_40003378 = Data_40003074; + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003374 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xA80F: //43023 + //0x2b184 + Data_40003360 = Data_40003068; + Data_40003368 = Data_4000306c; + Data_40003370 = Data_40003070; + Data_40003378 = Data_40003074; + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003374 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case 0xA810: //43024 + //0x2b214 + Data_40003360 = Data_40003068; + Data_40003368 = Data_4000306c; + Data_40003370 = Data_40003070; + Data_40003378 = Data_40003074; + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003374 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 7; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_TRACKING_RATE_STAR_SPEED: //4801: + //0x2b2a4 + Data_40003360 = strStarSpeed; + Data_40003364 = strSolarSpeed; + Data_40003368 = strMoonSpeed; + Data_4000336c = Data_40003094; // "Customize Speed" + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = Data_40003098; // "Guiding Speed" + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED: //4802: + //0x2b334 + Data_40003360 = strStarSpeed; + Data_40003364 = strSolarSpeed; + Data_40003368 = strMoonSpeed; + Data_4000336c = Data_40003094; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = Data_40003098; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 2; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_TRACKING_RATE_MOON_SPEED: //4803 + //0x2b3c8 + Data_40003360 = strStarSpeed; + Data_40003364 = strSolarSpeed; + Data_40003368 = strMoonSpeed; + Data_4000336c = Data_40003094; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = Data_40003098; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED: //4804 + //0x2b45c + Data_40003360 = strStarSpeed; + Data_40003364 = strSolarSpeed; + Data_40003368 = strMoonSpeed; + Data_4000336c = Data_40003094; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = Data_40003098; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 4; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED: //4805 + //0x2b4f0 + Data_40003360 = strStarSpeed; + Data_40003364 = strSolarSpeed; + Data_40003368 = strMoonSpeed; + Data_4000336c = Data_40003094; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = Data_40003098; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 7; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED1: //48051 + //0x2b584: Setup -> Tracking Rate -> Guiding Speed + Data_40003360 = "speed1: x 0.125"; + Data_40003364 = "speed2: x 0.250"; + Data_40003368 = "speed3: x 0.375"; + Data_4000336c = "speed4: x 0.500"; + Data_40003370 = "speed5: x 0.625"; + Data_40003374 = "speed6: x 0.750"; + Data_40003378 = "speed7: x 0.875"; + Data_4000337c = "speed8: x 1.000"; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED2: //48052 + //0x2b600 + bData_4000316e_FocusLineOn8LineDisplay = 2; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED3: //48053 + //0x2b614 + bData_4000316e_FocusLineOn8LineDisplay = 3; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED4: //48054 + //0x2b628 + bData_4000316e_FocusLineOn8LineDisplay = 4; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED5: //48055 + //0x2b63c + bData_4000316e_FocusLineOn8LineDisplay = 5; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED6: //48056 + //0x2b650 + bData_4000316e_FocusLineOn8LineDisplay = 6; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED7: //48057 + //0x2b664 + bData_4000316e_FocusLineOn8LineDisplay = 7; + //->3d71c + break; + + case MENU_CONTEXT_GUIDING_SPEED8: //48058 + //0x2b678 + bData_4000316e_FocusLineOn8LineDisplay = 8; + //->3d71c + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x2b68c: One / Two / Three Star Align + numVisibleAlignmentStars = GetCurrentAlignStars(get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude), Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, arAlignmentStarNames, Data_40003b2c); + + sprintf(Data_40003ffd, "R.a: %02dh%02dm ", + (int) Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2], + (int) ((Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2] - (int) Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2]) * 60)); + + if ((int) Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2] < 10) + { + Data_40003ffd[5] = ' '; + } + + if ((int) ((Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2] - (int) Data_40004a68_CurrentAlignStarEquatorialCoord[(bData_40002c60_CurrentAlignStarIndex - 1)*2]) * 60) < 10) + { + Data_40003ffd[8] = ' '; + } + + if (Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1] < 0) + { + //2b848 + sprintf(Data_40004012, "Dec:-%02d %02d ", + abs((int) Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1]), + abs((int) ((Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1] - (int) Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1]) * 60))); + } + else + { + //0x2ba08 + sprintf(Data_40004012, "Dec:+%02d %02d ", + (int) Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1], + abs((int) ((Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1] - (int) Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1]) * 60))); + } + + if ((int) Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1] < 10) + { + Data_40004012[5] = ' '; + } + + if ((int) (((Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1] - (int) Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) /*+ 1*/])+1) * 60) < 10) //BUG! + { + Data_40004012[8] = ' '; + } + //2bb70 + if (bData_40002c62_AlignmentStarMode != 0) + { + //2bb80: Slewing to target -> Show OTA Az/Alt + switch (bData_40002e7a_MountType) + { + case 1: + //2bb98 + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + //->0x2bc04 + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //2bc54 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + + Data_40002dac = dData_40002dd0; + Data_40002db0 = (dData_40002dd0 - Data_40002dac) * 60; + + Data_40002de0 = dData_40002e08; + Data_40002de4 = (dData_40002e08 - Data_40002de0) * 60; + //2be4c + fData_40002de8 = (dData_40002e08 - Data_40002de0 - Data_40002de4 / 60.0) * 3600; + //break; // Fall through? + + case 0: + //0x2bedc + sprintf(Data_40003ffd, "Azi:%03d %02d ", + abs(Data_40002dac), abs(Data_40002db0)); + + if (abs(Data_40002dac) < 100) + { + Data_40003ffd[4] = ' '; + } + if (abs(Data_40002dac) < 10) + { + Data_40003ffd[5] = ' '; + } + if (abs(Data_40002db0) < 10) + { + Data_40003ffd[8] = ' '; + } + + sprintf(Data_40004012, "Alt: %02d %02d ", + abs(Data_40002de0), abs(Data_40002de4)); + + if (abs(Data_40002de0) < 10) + { + Data_40004012[5] = ' '; + } + if (abs(Data_40002de4) < 10) + { + Data_40004012[8] = ' '; + } + break; + + default: + //0x2c068 + break; + } //switch (bData_40002e7a_MountType) + } //if (bData_40002c62_AlignmentStarMode != 0) + //0x2c074 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1)]; + Data_40004ae8.dDec = Data_40004a68_CurrentAlignStarEquatorialCoord[2*(bData_40002c60_CurrentAlignStarIndex - 1) + 1]; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40004027, "Azi:%03d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60)); + + sprintf(Data_4000403c, "Alt:+%02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60))); + + if (bTrackingMode == 1) + { + //2c2cc + sprintf(Data_40004027, "Azi:%03d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60)); + + sprintf(Data_4000403c, "Alt:+%02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60))); + } + //0x2c3fc + if ((int)Data_40004b08.dAzimuth < 100) + { + Data_40004027[4] = ' '; + } + if ((int)Data_40004b08.dAzimuth < 10) + { + Data_40004027[5] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40004027[8] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + + Data_40003360 = strListAlignStars; //"List align stars:" + Data_40003364 = " "; + Data_40003368 = arAlignmentStarNames[bData_40002c60_CurrentAlignStarIndex - 1]; + Data_4000336c = " "; + Data_40003370 = Data_40004027; //"OBJ: Azi:..."??? + Data_40003374 = Data_4000403c; + Data_40003378 = Data_40003ffd; + Data_4000337c = Data_40004012; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_MERIDIAN_FLIP: //3: + //0x2c658 + beep1(1); + + Data_40003360 = "Star move meridian"; + Data_40003364 = "and telestope stop or"; + Data_40003368 = "reverse after 10 mins"; + Data_4000336c = ""; + Data_40003370 = "ENTER: Reverse"; + Data_40003374 = ""; + Data_40003378 = "CANCEL: Stop"; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SYNC_OPEN: //1401: + //0x2c6e0 + Data_40003360 = ""; + Data_40003364 = "Targers Sync. Open?"; + Data_40003368 = ""; + Data_4000336c = ""; + Data_40003370 = " ENTER:Yes"; + Data_40003374 = ""; + Data_40003378 = " CANCEL:No"; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SYNC_ENSURE: //1402: + //0x2c760 + Data_40003360 = "Targers Sync. ensure!"; + Data_40003364 = ""; + Data_40003368 = "Targers Sync. cancel!"; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SYNC_CANCEL: //1403 + //0x2c7dc + Data_40003360 = "Targers Sync. ensure!"; + Data_40003364 = ""; + Data_40003368 = "Targers Sync. cancel!"; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_POLE_AXIS_DEV_INPUT: //18001: + //0x2c85c + Data_40003360 = "Pole Axis Dev: "; + Data_40003364 = ""; + + if (g_dPoleAxisDevEastWest > 0) + { + //2c890 + sprintf(Data_40003fa9, "ToE:%.5f\011Degree", fabs(g_dPoleAxisDevEastWest)); + } + else + { + //0x2c8bc + sprintf(Data_40003fa9, "ToW:%.5f\011Degree", fabs(g_dPoleAxisDevEastWest)); + } + //0x2c8e4 + Data_40003368 = Data_40003fa9; + + if (g_dPoleAxisDevNorthSouth > 0) + { + //2c908 + sprintf(Data_40003fbe, "ToN:%.5f\011Degree", fabs(g_dPoleAxisDevNorthSouth)); + } + else + { + //0x2ca50 + sprintf(Data_40003fbe, "ToS:%.5f\011Degree", fabs(g_dPoleAxisDevNorthSouth)); + } + //0x2ca78 + Data_4000336c = ""; + Data_40003370 = Data_40003fbe; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x2cad0: RA Bklash Corr. - 1st page + Data_40003360 = " "; + Data_40003364 = strPleaseAimAtThe; + Data_40003368 = " "; + Data_4000336c = strTelescopeToDistant; + Data_40003370 = " "; + Data_40003374 = strTargetThenPress; + Data_40003378 = " "; + Data_4000337c = strEnterKey; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT: //11101: + //0x2cb60: RA Bklash Corr. - 2nd page + Data_40003360 = " "; + Data_40003364 = Data_400030dc; // "Press RIGHT or LEFT" + Data_40003368 = " "; + Data_4000336c = Data_400030e0; // "key to start Ra(Azi)" + Data_40003370 = " "; + Data_40003374 = Data_400030e4; // "backlash align,press" + Data_40003378 = " "; + Data_4000337c = Data_400030e8; // "ENTER key to finish!" + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103 + //0x2cbf0 + Data_40003360 = " "; + Data_40003364 = Data_400030ec; //"Slewing....." + Data_40003368 = " "; + Data_4000336c = Data_400030f0; //"After beep, turn tele" + Data_40003370 = " "; + Data_40003374 = Data_400030f4; //"-cope back to target" + Data_40003378 = " "; + Data_4000337c = Data_400030f8; //"then press,ENTER!" + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_RESULT: //11104 + //0x2cc80 + sprintf(Data_40003fa9, "%.1f", fData_40002e90); + + Data_40003360 = " "; + Data_40003364 = " "; + + if (bRaBacklashCorrectionDirection == 2) + { + Data_40003368 = Data_400030fc; + } + //0x2cce4 + if (bRaBacklashCorrectionDirection == 1) + { + Data_40003368 = Data_40003100; + } + //0x2cd04 + Data_4000336c = " "; + Data_40003370 = Data_40003fa9; + Data_40003374 = " "; + Data_40003378 = Data_40003104; //" arcsecond" + Data_4000337c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case 11105: + //0x2cdc0 + sprintf(Data_40003fa9, "%.1f", fData_40002e98); + + Data_40003360 = " "; + Data_40003364 = " "; + Data_40003368 = Data_40003108; //"The mean backlash is:" + Data_4000336c = " "; + Data_40003370 = Data_40003fa9; + Data_40003374 = " "; + Data_40003378 = Data_40003104; //" arcsecond" + Data_4000337c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x2ce70 + Data_40003360 = " "; + Data_40003364 = strPleaseAimAtThe; + Data_40003368 = " "; + Data_4000336c = strTelescopeToDistant; + Data_40003370 = " "; + Data_40003374 = strTargetThenPress; + Data_40003378 = " "; + Data_4000337c = strEnterKey; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN: //11201: + //0x2cf00 + Data_40003360 = " "; + Data_40003364 = Data_4000310c; // "press UP or DOWN" + Data_40003368 = " "; + Data_4000336c = Data_40003110; // "key to start Dec(Alt)" + Data_40003370 = " "; + Data_40003374 = Data_400030e4; // "backlash align,press" + Data_40003378 = " "; + Data_4000337c = Data_400030e8; // "ENTER key to finish!" + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203 + //0x2cf90 + Data_40003360 = " "; + Data_40003364 = Data_400030ec; + Data_40003368 = " "; + Data_4000336c = Data_400030f0; + Data_40003370 = " "; + Data_40003374 = Data_400030f4; + Data_40003378 = " "; + Data_4000337c = Data_400030f8; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_RESULT: //11204 + //0x2d020 + sprintf(Data_40003fa9, "%.1f", fData_40002ea0); + + Data_40003360 = " "; + Data_40003364 = " "; + + if (bDecBacklashCorrectionDirection == 2) + { + Data_40003368 = Data_400030fc; + } + //0x2d084 + if (bDecBacklashCorrectionDirection == 1) + { + Data_40003368 = Data_40003100; + } + //0x2d0a4 + Data_4000336c = " "; + Data_40003370 = Data_40003fa9; + Data_40003374 = " "; + Data_40003378 = Data_40003104; + Data_4000337c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case 0x2BC5: //11205 + //0x2d100 + sprintf(Data_40003fa9, "%.1f", fData_40002ea8); + + Data_40003360 = " "; + Data_40003364 = " "; + Data_40003368 = Data_40003108; //"The mean backlash is:" + Data_4000336c = " "; + Data_40003370 = Data_40003fa9; + Data_40003374 = " "; + Data_40003378 = Data_40003104; //" arcsecond" + Data_4000337c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION: //22001: + //0x2d1b0 + get_solar_system_object_data(bData_40002eb5_SolarSystemObjectNr, + &fData_40002cd0_ObjectRightAscension, &fData_40002d18_ObjectDeclination); + + Data_40003360 = Data_4000314c_SolarSystemObjectName; + Data_40003364 = " "; + Data_40003368 = " "; + Data_4000336c = " "; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int) Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60), + ((int) (Data_40004b08.dAzimuth * 3600)) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //2d35c + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int) Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)), + abs(((int) (Data_40004b08.dAltitude * 3600)) % 60)); + } + else + { + //0x2d458 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int) Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)), + abs(((int) (Data_40004b08.dAltitude * 3600)) % 60)); + } + //0x2d550 + if ((int) Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int) Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40003ffd[15] = ' '; + } + if ((((int) (Data_40004b08.dAzimuth * 3600)) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int) Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int) (Data_40004b08.dAltitude * 3600)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x2d758 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + //2d770 + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int) fData_40002cd0_ObjectRightAscension, + (int) ((fData_40002cd0_ObjectRightAscension - (int) fData_40002cd0_ObjectRightAscension) * 60), + (int) (fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int) fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if ((int) ((fData_40002cd0_ObjectRightAscension - (int) fData_40002cd0_ObjectRightAscension) * 60) < 10) + { + Data_40004027[8] = ' '; + } + if (((int) (fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + //2d8a8 + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //2d8c8 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int) fData_40002d18_ObjectDeclination), + abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)), + abs((int) (fData_40002d18_ObjectDeclination * 3600) % 60)); + } + else + { + //0x2d998 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int) fData_40002d18_ObjectDeclination), + abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)), + abs((int) (fData_40002d18_ObjectDeclination * 3600) % 60)); + } + //0x2da64 + if (abs((int) fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int) (fData_40002d18_ObjectDeclination * 3600) % 60)) < 10) + { + Data_4000403c[11] = ' '; + } + //0x2db48 + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SUN_WARNING: //22112: + //0x2db70: Sun Warning screen + Data_40003360 = " "; + Data_40003364 = " DO NOT POINT "; + Data_40003368 = "the telescope or its "; + Data_4000336c = "viewfinder at or near"; + Data_40003370 = "the Sun!!! "; + Data_40003374 = " "; + Data_40003378 = "ENTER:continue "; + Data_4000337c = " -:return "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x2dd24: Target Under Horizon / Slewing To Target / Find Target,Tracking + get_solar_system_object_data(bData_40002eb5_SolarSystemObjectNr, + &fData_40002cd0_ObjectRightAscension, &fData_40002d18_ObjectDeclination); + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int) Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60), + ((int) (Data_40004b08.dAzimuth * 3600)) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //2de9c + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int) Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)), + abs(((int) (Data_40004b08.dAltitude * 3600)) % 60)); + } + else + { + //0x2df98 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int) Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)), + abs(((int) (Data_40004b08.dAltitude * 3600)) % 60)); + + bTrackingModeMenu = 3; + } + //0x2e09c + if ((int) Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int) Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40003ffd[15] = ' '; + } + if ((((int) (Data_40004b08.dAzimuth * 3600)) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int) Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int) (Data_40004b08.dAltitude * 3600)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x2e2a4 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //2e2ec + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + //->0x2e354 + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //2e3a4 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x2e44c + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + //2e534 + if (dData_40002e08 >= 0) + { + //2e54c + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + //->0x2e720 + } + else + { + //0x2e638 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //2e720 + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x2e904 + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x2e93c + bTrackingModeMenu = bTrackingMode; + } + //0x2e94c + #if 1 + if (Data_40004b08.dAltitude < 0) + { + if ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2)) + { + //0x2e988 + bTrackingModeMenu = 3; + } + } + #else + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x2e988 + bTrackingModeMenu = 3; + } + #endif + //0x2e994 + switch (bTrackingModeMenu) + { + case 1: + //0x2e9c0 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x2e9d4 + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x2e9e8 + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x2ea08 + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x2ea1c + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x2ea30 + Data_40003360 = " "; + break; + } + //0x2ea44 + Data_40003364 = " "; + Data_40003368 = Data_4000314c_SolarSystemObjectName; + Data_4000336c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_CONSTELLATION_SELECTION: //24001: + //0x2ea8c + flash_get_constellation_data(bData_40002ece_ConstellationNr, + &Data_40003dd4_FlashConstellationData); + + fData_40002cd0_ObjectRightAscension = Data_40003dd4_FlashConstellationData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003dd4_FlashConstellationData.fDeclination; + + Data_40003360 = Data_40003dd4_FlashConstellationData.bData_5; + Data_40003364 = " "; + + sprintf(Data_40003fd3, " Area: %d SQ.Deg ", + Data_40003dd4_FlashConstellationData.wArea); + + Data_40003368 = Data_40003fd3; + Data_40003368[0] = Data_40003dd4_FlashConstellationData.bData_5[0]; + Data_40003368[1] = Data_40003dd4_FlashConstellationData.bData_5[1]; + Data_40003368[2] = Data_40003dd4_FlashConstellationData.bData_5[2]; + + sprintf(Data_40003fe8, "Quantity: %d (>6Mag) ", + Data_40003dd4_FlashConstellationData.bQuantity); + + Data_4000336c = Data_40003fe8; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //2ecb0 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + } + else + { + //0x2ef0c + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + } + //0x2f004 + if ((int) Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int) Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40003ffd[15] = ' '; + } + if ((((int) (Data_40004b08.dAzimuth * 3600)) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int) Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int) (Data_40004b08.dAltitude * 3600)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x2f20c + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int) fData_40002cd0_ObjectRightAscension, + (int) ((fData_40002cd0_ObjectRightAscension - (int) fData_40002cd0_ObjectRightAscension) * 60), + (int) (fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int) fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if ((int) ((fData_40002cd0_ObjectRightAscension - (int) fData_40002cd0_ObjectRightAscension) * 60) < 10) + { + Data_40004027[8] = ' '; + } + if (((int) (fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + //0x2f35c + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //2f37c + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int) fData_40002d18_ObjectDeclination), + abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)), + abs((int) (fData_40002d18_ObjectDeclination * 3600) % 60)); + } + else + { + //0x2f44c + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int) fData_40002d18_ObjectDeclination), + abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)), + abs((int) (fData_40002d18_ObjectDeclination * 3600) % 60)); + } + //0x2f518 + if (abs((int) fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int) (fData_40002d18_ObjectDeclination * 3600) % 60)) < 10) + { + Data_4000403c[11] = ' '; + } + //0x2f5fc + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002 + //0x2f624 + flash_get_constellation_data(bData_40002ece_ConstellationNr, &Data_40003dd4_FlashConstellationData); + + fData_40002cd0_ObjectRightAscension = Data_40003dd4_FlashConstellationData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003dd4_FlashConstellationData.fDeclination; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //2f7b8 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + } + else + { + //0x2f8b4 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + + bTrackingModeMenu = 3; + } + //0x2f9b8 + if ((int) Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int) Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40003ffd[15] = ' '; + } + if ((((int) (Data_40004b08.dAzimuth * 3600)) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int) Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int) (Data_40004b08.dAltitude * 3600)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x2fbc0 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //2fc08 + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + //->0x2fc70 + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //2fcc0 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x2fd68 + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + + if (dData_40002e08 >= 0) + { + //2fec8 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x2ffb4 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x3009c + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x30280 + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x302b8 + bTrackingModeMenu = bTrackingMode; + } + //0x302c8 + if (Data_40004b08.dAltitude < 0) + { + if ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2)) + { + //0x30304 + bTrackingModeMenu = 3; + } + } + //0x30310 + switch (bTrackingModeMenu) + { + case 1: + //0x3033c + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x30350 + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x30364 + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x30384 + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x30398 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x303ac + Data_40003360 = " "; + break; + } + //303c4 + Data_40003364 = " "; + Data_40003368 = Data_40003dd4_FlashConstellationData.bData_5; + Data_4000336c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_FAMOUS_STAR_SELECTION: //25001: + //0x30404: Famous Star item + flash_get_famous_star_data(bData_40002ed2_FamousStarNr, &Data_40003d94_FlashFamousStarData); + + fData_40002cd0_ObjectRightAscension = Data_40003d94_FlashFamousStarData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003d94_FlashFamousStarData.fDeclination; + + Data_40003360 = Data_40003d94_FlashFamousStarData.bData_0; + Data_40003364 = " "; + Data_40003368 = Data_40003d94_FlashFamousStarData.bData_28; + + sprintf(Data_40003fe8, "SAO:%d MEG:%.1f", + Data_40003d94_FlashFamousStarData.Data_24, Data_40003d94_FlashFamousStarData.fData_52); + + Data_4000336c = Data_40003fe8; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //305f4 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + } + else + { + //0x30790 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + } + //0x30888 + if ((int) Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int) Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40003ffd[15] = ' '; + } + if ((((int) (Data_40004b08.dAzimuth * 3600)) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int) Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int) (Data_40004b08.dAltitude * 3600)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x30a90 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int) fData_40002cd0_ObjectRightAscension, + (int) ((fData_40002cd0_ObjectRightAscension - (int) fData_40002cd0_ObjectRightAscension) * 60), + (int) (fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int) fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if ((int) ((fData_40002cd0_ObjectRightAscension - (int) fData_40002cd0_ObjectRightAscension) * 60) < 10) + { + Data_40004027[8] = ' '; + } + if (((int) (fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + //0x30be0 + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //30c00 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int) fData_40002d18_ObjectDeclination), + abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)), + abs((int) (fData_40002d18_ObjectDeclination * 3600) % 60)); + } + else + { + //0x30cd0 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int) fData_40002d18_ObjectDeclination), + abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)), + abs((int) (fData_40002d18_ObjectDeclination * 3600) % 60)); + } + //0x30d9c + if (abs((int) fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int) ((fData_40002d18_ObjectDeclination - (int) fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int) (fData_40002d18_ObjectDeclination * 3600) % 60)) < 10) + { + Data_4000403c[11] = ' '; + } + //0x30e80 + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002 + //0x30ea8 + flash_get_famous_star_data(bData_40002ed2_FamousStarNr, &Data_40003d94_FlashFamousStarData); + + fData_40002cd0_ObjectRightAscension = Data_40003d94_FlashFamousStarData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003d94_FlashFamousStarData.fDeclination; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //31040 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + } + else + { + //0x3113c + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60)), + abs(((int)(Data_40004b08.dAltitude * 3600) % 60))); + + bTrackingModeMenu = 3; + } + //0x31240 + if ((int) Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int) Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40003ffd[15] = ' '; + } + if ((((int) (Data_40004b08.dAzimuth * 3600)) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int) Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int) (Data_40004b08.dAltitude * 3600)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x31448 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + //31460 + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //31490 + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + //->0x314f8 + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //31548 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x315f4 + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + //316dc + if (dData_40002e08 >= 0) + { + //316f4 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x317e0 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x318c8 + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x31aac + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + bTrackingModeMenu = bTrackingMode; + } + + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x31b30 + bTrackingModeMenu = 3; + } + //0x31b3c + switch (bTrackingModeMenu) + { + case 1: + //0x31b68 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x31b7c + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x31b90 + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x31bb0 + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x31bc4 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x31bd8 + Data_40003360 = " "; + break; + } + //0x31bec + sprintf(Data_40003fbe, "Sao:%d ", + Data_40003d94_FlashFamousStarData.Data_24); + + Data_40003364 = Data_40003fbe; + Data_40003368 = " "; + Data_4000336c = Data_40003d94_FlashFamousStarData.bData_28; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012 + //0x31c44 + flash_get_messier_data((unsigned char)wData_40002eb8_MessierNr, + &Data_40003e08_FlashMessierData); + + sprintf(Data_40003fa9, "Messier:%d NGC:%d ", + wData_40002eb8_MessierNr, Data_40003e08_FlashMessierData.wData_0); + + Data_40003360 = Data_40003fa9; + Data_40003364 = Data_40003e08_FlashMessierData.bData_32; + Data_40003368 = Data_40003e08_FlashMessierData.bData_60; + Data_4000336c = Data_40003e08_FlashMessierData.bData_108; + Data_40003370 = " "; + + sprintf(Data_40004012, "Size:%.1f Arc Minute ", + Data_40003e08_FlashMessierData.fData_12); + + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "Distance:%.1f ", + Data_40003e08_FlashMessierData.dData_16); + + Data_40003378 = Data_40004027; + Data_4000337c = " K Light-Years"; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002 + //0x31ef0 + flash_get_messier_data((unsigned char)wData_40002eb8_MessierNr, + &Data_40003e08_FlashMessierData); + + fData_40002cd0_ObjectRightAscension = Data_40003e08_FlashMessierData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003e08_FlashMessierData.fDeclination; + + sprintf(Data_40003fa9, "Messier:%d ", + wData_40002eb8_MessierNr); + + Data_40003360 = Data_40003fa9; + Data_40003364 = Data_40003e08_FlashMessierData.bData_32; + Data_40003368 = Data_40003e08_FlashMessierData.bData_60; + Data_4000336c = " "; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + //320b0 + if (Data_40004b08.dAltitude >= 0) + { + //320cc + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x321c8 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //0x32320 + if ((int) Data_40004b08.dAzimuth < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int) Data_40004b08.dAzimuth < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int) Data_40004b08.dAzimuth) * 60) < 10) + { + Data_40003ffd[15] = ' '; + } + if ((((int) (Data_40004b08.dAzimuth * 3600)) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int) Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int) Data_40004b08.dAltitude) * 60)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int) (Data_40004b08.dAltitude * 3600)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x32528 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int)fData_40002cd0_ObjectRightAscension, + (int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60), + (int)(fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int) fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if ((int) ((fData_40002cd0_ObjectRightAscension - (int) fData_40002cd0_ObjectRightAscension) * 60) < 10) + { + Data_40004027[8] = ' '; + } + if (((int) (fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + //0x32678 + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //32698 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + else + { + //0x32768 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + //0x32834 + if (abs((int)fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((fData_40002d18_ObjectDeclination - (int)fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs((int)(fData_40002d18_ObjectDeclination * 3600) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x32918 + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022 + //0x32940 + flash_get_messier_data((unsigned char)wData_40002eb8_MessierNr, + &Data_40003e08_FlashMessierData); + + fData_40002cd0_ObjectRightAscension = Data_40003e08_FlashMessierData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003e08_FlashMessierData.fDeclination; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //32adc + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x32bd8 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + + bTrackingModeMenu = 3; + } + //0x32cdc + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x32ee4 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //32f2c + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + //->0x2e354 + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //32fe4 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x33088 + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + + if (dData_40002e08 >= 0) + { + //33188 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x33274 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x3335c + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x335b8 + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x335f0 + bTrackingModeMenu = bTrackingMode; + } + //0x33600 + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x3363c + bTrackingModeMenu = 3; + } + //0x33648 + switch (bTrackingModeMenu) + { + case 1: + //0x33674 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x33688 + Data_40003360 = "Find Target,Tracking "; + bData_40003432 = 1; + break; + + case 3: + //0x336a8 + Data_40003360 = "Target Under Horizon "; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x336bc + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x336d0 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x336e4 + Data_40003360 = " "; + break; + } + //0x336f8 + sprintf(Data_40003fbe, "Messier:%d ", + wData_40002eb8_MessierNr); + + Data_40003364 = Data_40003fbe; + Data_40003368 = Data_40003e08_FlashMessierData.bData_32; + Data_4000336c = Data_40003e08_FlashMessierData.bData_60; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003 + //0x33750 + flash_get_ngc_data(wData_40002eba_NGCNr, &Data_40003ee0_FlashNGCData); + + fData_40002cd0_ObjectRightAscension = Data_40003ee0_FlashNGCData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003ee0_FlashNGCData.fDeclination; + + sprintf(Data_40003fa9, "NGC:%d ", + wData_40002eba_NGCNr); + + Data_40003360 = Data_40003fa9; + Data_40003364 = Data_40003ee0_FlashNGCData.bData_0; + + if (Data_40003ee0_FlashNGCData.fData_16 != 0) + { + //337c4 + sprintf(Data_40003fd3, "MEG:%.1f ", + Data_40003ee0_FlashNGCData.fData_16); + Data_40003368 = Data_40003fd3; + } + else + { + //0x337fc + Data_40003368 = " "; + } + //0x33808 + Data_4000336c = Data_40003ee0_FlashNGCData.bData_20; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + //3389c + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)(Data_40004b08.dAzimuth), + (int)((Data_40004b08.dAzimuth - (int)(Data_40004b08.dAzimuth)) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //33974 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x33b60 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //0x33c58 + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x33e60 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int)fData_40002cd0_ObjectRightAscension, + (int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60), + (int)(fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int)fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if (((int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60)) < 10) + { + Data_40004027[8] = ' '; + } + if (((int)(fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //33fd0 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + else + { + //0x340a0 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + //0x3416c + if (abs((int)fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((fData_40002d18_ObjectDeclination - (int)fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs((int)(fData_40002d18_ObjectDeclination * 3600) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x34250 + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013 + //0x34278 + flash_get_ngc_data(wData_40002eba_NGCNr, &Data_40003ee0_FlashNGCData); + + fData_40002cd0_ObjectRightAscension = Data_40003ee0_FlashNGCData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003ee0_FlashNGCData.fDeclination; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //3440c + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x34508 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + + bTrackingModeMenu = 3; + } + //0x3460c + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x34814 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //3485c + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //34914 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x349b8 + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + + if (dData_40002e08 >= 0) + { + //34ab8 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x34ba4 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x34c8c + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x34edc + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x34f14 + bTrackingModeMenu = bTrackingMode; + } + //0x34f24 + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x34f60 + bTrackingModeMenu = 3; + } + //0x34f6c + switch (bTrackingModeMenu) + { + case 1: + //0x34f98 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x34fac + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x34fc0 + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x34fe0 + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x34ff4 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x35008 + Data_40003360 = " "; + break; + } + //0x336f8 + sprintf(Data_40003fbe, "NGC:%d ", + wData_40002eba_NGCNr); + + Data_40003364 = Data_40003fbe; + Data_40003368 = Data_40003ee0_FlashNGCData.bData_0; + + if (Data_40003ee0_FlashNGCData.fData_16 != 0) + { + //35060 + sprintf(Data_40003fe8, "MEG:%.1f ", + Data_40003ee0_FlashNGCData.fData_16); + Data_4000336c = Data_40003fe8; + } + else + { + //0x35098 + Data_4000336c = " "; + } + //0x350a4 + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004 + //0x350c0 + flash_get_ic_data(wData_40002ebc_ICNr, &Data_40003ec0_FlashICData); + + fData_40002cd0_ObjectRightAscension = Data_40003ec0_FlashICData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003ec0_FlashICData.fDeclination; + + sprintf(Data_40003fa9, "IC:%d ", + wData_40002ebc_ICNr); + + Data_40003360 = Data_40003fa9; + Data_40003364 = Data_40003ec0_FlashICData.bData_0; + + if (Data_40003ec0_FlashICData.fData_16 != 0) + { + //35134 + sprintf(Data_40003fd3, "MEG:%.1f ", + Data_40003ec0_FlashICData.fData_16); + Data_40003368 = Data_40003fd3; + } + else + { + //0x3516c + Data_40003368 = " "; + } + //0x35178 + Data_4000336c = Data_40003ec0_FlashICData.bData_20; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + //3520c + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)(Data_40004b08.dAzimuth), + (int)((Data_40004b08.dAzimuth - (int)(Data_40004b08.dAzimuth)) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //352e4 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x3549c + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //0x35594 + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x3579c + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int)fData_40002cd0_ObjectRightAscension, + (int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60), + (int)(fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int)fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if (((int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60)) < 10) + { + Data_40004027[8] = ' '; + } + if (((int)(fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //3590c + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + else + { + //0x359dc + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + //0x35aa8 + if (abs((int)fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((fData_40002d18_ObjectDeclination - (int)fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs((int)(fData_40002d18_ObjectDeclination * 3600) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x35b8c + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014 + //0x35bb4 + flash_get_ic_data(wData_40002ebc_ICNr, &Data_40003ec0_FlashICData); + + fData_40002cd0_ObjectRightAscension = Data_40003ec0_FlashICData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003ec0_FlashICData.fDeclination; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //35d4c + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x35e48 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + + bTrackingModeMenu = 3; + } + //0x35f4c + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x36154 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //3619c + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //36254 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x362fc + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + + if (dData_40002e08 >= 0) + { + //363fc + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x364e8 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x365d0 + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x3682c + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x36864 + bTrackingModeMenu = bTrackingMode; + } + //0x36874 + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x368b0 + bTrackingModeMenu = 3; + } + //0x368bc + switch (bTrackingModeMenu) + { + case 1: + //0x368e8 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x368fc + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x36910 + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x36930 + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x36944 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x36958 + Data_40003360 = " "; + break; + } + //0x3696c + sprintf(Data_40003fbe, "IC:%d ", + wData_40002ebc_ICNr); + + Data_40003364 = Data_40003fbe; + Data_40003368 = Data_40003ec0_FlashICData.bData_0; + + if (Data_40003ec0_FlashICData.fData_16 != 0) + { + //369b0 + sprintf(Data_40003fe8, "MEG:%.1f ", + Data_40003ec0_FlashICData.fData_16); + Data_4000336c = Data_40003fe8; + } + else + { + //0x369e8 + Data_4000336c = " "; + } + //0x350a4 + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005 + //0x36a10 + flash_get_sh2_data(wData_40002ebe_ShNr, &Data_40003350_FlashSh2Data); + + fData_40002cd0_ObjectRightAscension = Data_40003350_FlashSh2Data.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003350_FlashSh2Data.fDeclination; + + sprintf(Data_40003fa9, "Sh2:%d ", + wData_40002ebe_ShNr); + + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " "; + Data_4000336c = " "; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)(Data_40004b08.dAzimuth), + (int)((Data_40004b08.dAzimuth - (int)(Data_40004b08.dAzimuth)) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //36be8 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x36d88 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //0x36e80 + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x37088 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int)fData_40002cd0_ObjectRightAscension, + (int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60), + (int)(fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int)fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if (((int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60)) < 10) + { + Data_40004027[8] = ' '; + } + if (((int)(fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //371f8 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + else + { + //0x372c8 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + //0x37394 + if (abs((int)fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((fData_40002d18_ObjectDeclination - (int)fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs((int)(fData_40002d18_ObjectDeclination * 3600) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x37478 + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015 + //0x374a0 + flash_get_sh2_data(wData_40002ebe_ShNr, &Data_40003350_FlashSh2Data); + + fData_40002cd0_ObjectRightAscension = Data_40003350_FlashSh2Data.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003350_FlashSh2Data.fDeclination; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //37634 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x37730 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + + bTrackingModeMenu = 3; + } + //0x37834 + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x37a3c + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //37a84 + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x37be4 + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + + if (dData_40002e08 >= 0) + { + //37ce4 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x37dd0 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x37eb8 + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x38108 + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x38140 + bTrackingModeMenu = bTrackingMode; + } + //0x38150 + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x3818c + bTrackingModeMenu = 3; + } + //0x38198 + switch (bTrackingModeMenu) + { + case 1: + //0x381c4 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x381d8 + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x381ec + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x3820c + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x38220 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x38234 + Data_40003360 = " "; + break; + } + //0x38248 + sprintf(Data_40003fd3, "Sh2:%d ", + wData_40002ebe_ShNr); + + Data_40003368 = Data_40003fd3; + Data_40003364 = " "; + Data_4000336c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006 + //0x382a0 + flash_get_bright_star_data((unsigned char)wData_40002ec0_BrightStarNr, &Data_40003ea0_FlashBrightStarData); + + fData_40002cd0_ObjectRightAscension = Data_40003ea0_FlashBrightStarData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003ea0_FlashBrightStarData.fDeclination; + + sprintf(Data_40003fa9, "Bright:%d ", + wData_40002ec0_BrightStarNr); + + Data_40003360 = Data_40003fa9; + Data_40003364 = Data_40003ea0_FlashBrightStarData.bData_0; + + if (Data_40003ea0_FlashBrightStarData.fData_28 != 0) + { + //38318 + sprintf(Data_40003fd3, "MEG:%.1f ", + Data_40003ea0_FlashBrightStarData.fData_28); + Data_40003368 = Data_40003fd3; + } + else + { + //0x38350 + Data_40003368 = " "; + } + //0x3835c + Data_4000336c = " "; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)(Data_40004b08.dAzimuth), + (int)((Data_40004b08.dAzimuth - (int)(Data_40004b08.dAzimuth)) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //384cc + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x38668 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //0x38760 + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x38968 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int)fData_40002cd0_ObjectRightAscension, + (int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60), + (int)(fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int)fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if (((int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60)) < 10) + { + Data_40004027[8] = ' '; + } + if (((int)(fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //38ad8 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + else + { + //0x38ba8 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + //0x38c74 + if (abs((int)fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((fData_40002d18_ObjectDeclination - (int)fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs((int)(fData_40002d18_ObjectDeclination * 3600) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x38d58 + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016 + //0x38d80 + flash_get_bright_star_data((unsigned char)wData_40002ec0_BrightStarNr, &Data_40003ea0_FlashBrightStarData); + + fData_40002cd0_ObjectRightAscension = Data_40003ea0_FlashBrightStarData.fRightAscension; + fData_40002d18_ObjectDeclination = Data_40003ea0_FlashBrightStarData.fDeclination; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)Data_40004b08.dAzimuth, + (int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //38f18 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x39014 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + + bTrackingModeMenu = 3; + } + //0x39118 + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x39320 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //39368 + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //39420 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x394c8 + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + + if (dData_40002e08 >= 0) + { + //395c8 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x396b4 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x3979c + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x399f8 + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x39a30 + bTrackingModeMenu = bTrackingMode; + } + //0x39a40 + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x39a7c + bTrackingModeMenu = 3; + } + //0x39a88 + switch (bTrackingModeMenu) + { + case 1: + //0x39ab4 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x39ac8 + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x39adc + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x39afc + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x39b10 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x39b24 + Data_40003360 = " "; + break; + } + //0x39b38 + sprintf(Data_40003fbe, "Bright:%d ", + wData_40002ec0_BrightStarNr); + + Data_40003364 = Data_40003fbe; + Data_40003368 = Data_40003ea0_FlashBrightStarData.bData_0; + Data_4000336c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x39b90: SAO item + flash_get_sao_data(Data_40002ec4_SAONr, &Data_40003358_SAORecord); + + fData_40002cd0_ObjectRightAscension = Data_40003358_SAORecord.ra; + fData_40002d18_ObjectDeclination = Data_40003358_SAORecord.dec; + + sprintf(Data_40003fa9, "SAO:%d ", + Data_40002ec4_SAONr); + + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " "; + Data_4000336c = " "; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)(Data_40004b08.dAzimuth), + (int)((Data_40004b08.dAzimuth - (int)(Data_40004b08.dAzimuth)) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //39d68 + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //0x39f00 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + //0x39ff8 + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //0x3a200 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + sprintf(Data_40004027, "R.a: %02dh%02dm%02ds ", + (int)fData_40002cd0_ObjectRightAscension, + (int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60), + (int)(fData_40002cd0_ObjectRightAscension * 3600) % 60); + + if ((int)fData_40002cd0_ObjectRightAscension < 10) + { + Data_40004027[5] = ' '; + } + if (((int)((fData_40002cd0_ObjectRightAscension - (int)fData_40002cd0_ObjectRightAscension) * 60)) < 10) + { + Data_40004027[8] = ' '; + } + if (((int)(fData_40002cd0_ObjectRightAscension * 3600) % 60) < 10) + { + Data_40004027[11] = ' '; + } + + Data_40003378 = Data_40004027; + + if (fData_40002d18_ObjectDeclination >= 0) + { + //3a370 + sprintf(Data_4000403c, "Dec:+%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + else + { + //0x3a440 + sprintf(Data_4000403c, "Dec:-%02d %02d %02d ", + abs((int)fData_40002d18_ObjectDeclination), + abs((int)((fData_40002d18_ObjectDeclination - (int)(fData_40002d18_ObjectDeclination)) * 60)), + abs(((int)(fData_40002d18_ObjectDeclination * 3600) % 60))); + } + //0x3a50c + if (abs((int)fData_40002d18_ObjectDeclination) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((fData_40002d18_ObjectDeclination - (int)fData_40002d18_ObjectDeclination) * 60)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs((int)(fData_40002d18_ObjectDeclination * 3600) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x3a5f0 + Data_4000337c = Data_4000403c; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017 + //0x3a618 + flash_get_sao_data(Data_40002ec4_SAONr, &Data_40003358_SAORecord); + + fData_40002cd0_ObjectRightAscension = Data_40003358_SAORecord.ra; + fData_40002d18_ObjectDeclination = Data_40003358_SAORecord.dec; + + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + Data_40004ae8.dRA = fData_40002cd0_ObjectRightAscension; + Data_40004ae8.dDec = fData_40002d18_ObjectDeclination; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004ae8, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b08); + + sprintf(Data_40003ffd, "OBJ Azi:%03d %02d %02d ", + (int)(Data_40004b08.dAzimuth), + (int)((Data_40004b08.dAzimuth - (int)(Data_40004b08.dAzimuth)) * 60.0), + (int)(Data_40004b08.dAzimuth * 3600.0) % 60); + + if (Data_40004b08.dAltitude >= 0) + { + //3a7ac + sprintf(Data_40004012, "Alt:+%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + } + else + { + //3a8a8 + sprintf(Data_40004012, "Alt:-%02d %02d %02d ", + abs((int)Data_40004b08.dAltitude), + abs((int)((Data_40004b08.dAltitude - (int)(Data_40004b08.dAltitude)) * 60.0)), + abs((int)(Data_40004b08.dAltitude * 3600.0) % 60)); + + bTrackingModeMenu = 3; + } + //3a9ac + if ((int)(Data_40004b08.dAzimuth) < 100) + { + Data_40003ffd[11] = ' '; + } + //3a9d0 + if ((int)(Data_40004b08.dAzimuth) < 10) + { + Data_40003ffd[12] = ' '; + } + //3a9f4 + if ((int)((Data_40004b08.dAzimuth - (int)Data_40004b08.dAzimuth) * 60.0) < 10) + { + Data_40003ffd[15] = ' '; + } + //3aa60 + if (((int)(Data_40004b08.dAzimuth * 3600.0) % 60) < 10) + { + Data_40003ffd[18] = ' '; + } + //3aaa4 + if (abs((int)Data_40004b08.dAltitude) < 10) + { + Data_40004012[5] = ' '; + } + //3aadc + if (abs((int)((Data_40004b08.dAltitude - (int)Data_40004b08.dAltitude) * 60.0)) < 10) + { + Data_40004012[8] = ' '; + } + //3ab5c + if (abs(((int)(Data_40004b08.dAltitude * 3600.0)) % 60) < 10) + { + Data_40004012[11] = ' '; + } + //3abb4 + Data_40003370 = Data_40003ffd; + Data_40003374 = Data_40004012; + + dData_40002dd0 = dData_40002dc0_Azimuth; + dData_40002e08 = dData_40002df8; + + if (bData_40002e7a_MountType == 1) + { + //3abfc + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - dData_40002d78; + + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + //3acb4 + Data_40004ad8.dLongitude = Data_40004128.geographicLongitude; + Data_40004ad8.dLatitude = Data_40004128.geographicLatitude; + + Data_40004b50.dRA = dData_40002c88; + Data_40004b50.dDec = dData_40002c90; + + convert_equatorial_to_horizontal(Data_40004ad8, Data_40004b50, + Data_40004128.Data_40, Data_40004128.bData_44, &Data_40004b70); + + dData_40002dd0 = Data_40004b70.dAzimuth; + dData_40002e08 = Data_40004b70.dAltitude; + } + //0x3ad58 + sprintf(Data_40004027, "OTA Azi:%03d %02d %02d ", + abs((int)dData_40002dd0), + abs((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)), + abs((int)(dData_40002dd0 * 3600) % 60)); + + if (dData_40002e08 >= 0) + { + //3ae58 + sprintf(Data_4000403c, "Alt:+%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + else + { + //0x3af44 + sprintf(Data_4000403c, "Alt:-%02d %02d %02d ", + abs((int)dData_40002e08), + abs((int)((dData_40002e08 - (int)(dData_40002e08)) * 60)), + abs(((int)(dData_40002e08 * 3600) % 60))); + } + //0x3b02c + if ((int)dData_40002dd0 < 100) + { + Data_40004027[11] = ' '; + } + if ((int)dData_40002dd0 < 10) + { + Data_40004027[12] = ' '; + } + if (((int)((dData_40002dd0 - (int)dData_40002dd0) * 60)) < 10) + { + Data_40004027[15] = ' '; + } + if (((int)(dData_40002dd0 * 3600) % 60) < 10) + { + Data_40004027[18] = ' '; + } + + if (abs((int)dData_40002e08) < 10) + { + Data_4000403c[5] = ' '; + } + if (abs((int)((dData_40002e08 - (int)dData_40002e08) * 60.0)) < 10) + { + Data_4000403c[8] = ' '; + } + if (abs(((int)(dData_40002e08 * 3600.0)) % 60) < 10) + { + Data_4000403c[11] = ' '; + } + //0x3b27c + Data_40003378 = Data_40004027; + Data_4000337c = Data_4000403c; + + if ((bTrackingMode == 1) || (bTrackingMode == 2)) + { + //0x3b2b4 + bTrackingModeMenu = bTrackingMode; + } + //0x3b2c4 + if ((Data_40004b08.dAltitude < 0) && + ((bTrackingModeMenu == 1) || (bTrackingModeMenu == 2))) + { + //0x3b300 + bTrackingModeMenu = 3; + } + //0x3b30c + switch (bTrackingModeMenu) + { + case 1: + //0x3b338 + Data_40003360 = "Slewing to Target "; + break; + + case 2: + //0x3b34c + Data_40003360 = "Find Target,Tracking "; + break; + + case 3: + //0x3b360 + Data_40003360 = "Target Under Horizon "; + bData_40003432 = 1; + break; + + case MENU_TRACKING_MODE_PAUSE: //4: + //0x3b380 + Data_40003360 = "Pause "; + break; + + case MENU_TRACKING_MODE_CANCEL: //5: + //0x3b394 + Data_40003360 = "Cancel Operation "; + break; + + default: + //0x3b3a8 + Data_40003360 = " "; + break; + } + //0x3b3bc + Data_40003364 = " "; + + sprintf(Data_40003fd3, "SAO:%d ", + Data_40002ec4_SAONr); + + Data_40003368 = Data_40003fd3; + Data_4000336c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; //case 23017: + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x3b414 + Data_40003360 = "F1"; + Data_40003364 = "F2"; + Data_40003368 = "F3"; + Data_4000336c = "F4"; + Data_40003370 = "F5"; + Data_40003374 = "F6"; + Data_40003378 = "F7"; + Data_4000337c = "F8"; + Data_40003380 = "F9"; + Data_40003384 = "Select F? For Target "; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + //->0x3d71c + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x3b4ac + sprintf(Data_40003fa9, "F%d ", + bData_4000319a_SkyLandTargetId); + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " Please Save Current"; + Data_4000336c = "Target & Input Target"; + Data_40003370 = " "; + Data_40003374 = strCustomerObjectNameInput; + Data_40003378 = strCustomerObjectRaAziInputForStoring; + Data_4000337c = strCustomerObjectDecAltInputForStoring; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x3b540 + sprintf(Data_40003fa9, "F%d ", + bData_4000319a_SkyLandTargetId); + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " Please Save Current"; + Data_4000336c = "Target & Input Target"; + Data_40003370 = " "; + Data_40003374 = strCustomerObjectNameInput; + Data_40003378 = strCustomerObjectRaAziInputForStoring; + Data_4000337c = strCustomerObjectDecAltInputForStoring; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x3b5d4 + sprintf(Data_40003fa9, "F%d ", + bData_4000319a_SkyLandTargetId); + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " Please Save Current"; + Data_4000336c = "Target & Input Target"; + Data_40003370 = " "; + Data_40003374 = strCustomerObjectNameInput; + Data_40003378 = strCustomerObjectRaAziInputForStoring; + Data_4000337c = strCustomerObjectDecAltInputForStoring; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_RA_INPUT: //29001: // "Object Rise/Set" -> "Input Ra Dec:" + //0x3b668 + Data_40003360 = strInputRaDec; // "Input Ra Dec:"? + Data_40003364 = ""; + Data_40003368 = strCustomerObjectRaAziInputForStoring; // "R.a: 19h52m12.0s"? + Data_4000336c = ""; + Data_40003370 = strCustomerObjectDecAltInputForStoring; // "Dec:+90 00 00.0 "? + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_DEC_INPUT: //29002 + //0x3b7d0 + Data_40003360 = strInputRaDec; + Data_40003364 = ""; + Data_40003368 = strCustomerObjectRaAziInputForStoring; + Data_4000336c = ""; + Data_40003370 = strCustomerObjectDecAltInputForStoring; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x3b850 + Data_40003360 = "F1"; + Data_40003364 = "F2"; + Data_40003368 = "F3"; + Data_4000336c = "F4"; + Data_40003370 = "F5"; + Data_40003374 = "F6"; + Data_40003378 = "F7"; + Data_4000337c = "F8"; + Data_40003380 = "F9"; + Data_40003384 = "Select F? For Target "; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x3b8e8 + sprintf(Data_40003fa9, "F%d ", + bData_4000319a_SkyLandTargetId); + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " Please Save Current"; + Data_4000336c = "Target & Input Target"; + Data_40003370 = " "; + Data_40003374 = strCustomerObjectNameInput; + Data_40003378 = strCustomerObjectRaAziInputForStoring; + Data_4000337c = strCustomerObjectDecAltInputForStoring; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x3b97c + sprintf(Data_40003fa9, "F%d ", + bData_4000319a_SkyLandTargetId); + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " Please Save Current"; + Data_4000336c = "Target & Input Target"; + Data_40003370 = " "; + Data_40003374 = strCustomerObjectNameInput; + Data_40003378 = strCustomerObjectRaAziInputForStoring; + Data_4000337c = strCustomerObjectDecAltInputForStoring; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x3ba10 + sprintf(Data_40003fa9, "F%d ", + bData_4000319a_SkyLandTargetId); + Data_40003360 = Data_40003fa9; + Data_40003364 = " "; + Data_40003368 = " Please Save Current"; + Data_4000336c = "Target & Input Target"; + Data_40003370 = " "; + Data_40003374 = strCustomerObjectNameInput; + Data_40003378 = strCustomerObjectRaAziInputForStoring; + Data_4000337c = strCustomerObjectDecAltInputForStoring; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJ_RISE_SET_TIMES: //31001: + //0x3baa4 + get_solar_system_object_data(bData_40002eb5_SolarSystemObjectNr, + &fData_40002cd0_ObjectRightAscension, &fData_40002d18_ObjectDeclination); + + Data_40003360 = Data_4000314c_SolarSystemObjectName; + + dObjectRiseTime = get_object_visibility_time(1, + fData_40002cd0_ObjectRightAscension, + fData_40002d18_ObjectDeclination, + Data_40004128.geographicLongitude, + Data_40004128.geographicLatitude, + (unsigned char)Data_40004128.timeZone); + + dObjectTransitTime = get_object_visibility_time(2, + fData_40002cd0_ObjectRightAscension, + fData_40002d18_ObjectDeclination, + Data_40004128.geographicLongitude, + Data_40004128.geographicLatitude, + (unsigned char)Data_40004128.timeZone); + + dObjectSetTime = get_object_visibility_time(3, + fData_40002cd0_ObjectRightAscension, + fData_40002d18_ObjectDeclination, + Data_40004128.geographicLongitude, + Data_40004128.geographicLatitude, + (unsigned char)Data_40004128.timeZone); + + sprintf(Data_40003fd3, "RiseTime: %02dh%02dm", + (int)dObjectRiseTime, + (int)((dObjectRiseTime - (int)dObjectRiseTime) * 60)); + Data_40003368 = Data_40003fd3; + + sprintf(Data_40003ffd, "TransitTime:%02dh%02dm", + (int)dObjectTransitTime, + (int)((dObjectTransitTime - (int)dObjectTransitTime) * 60)); + Data_40003370 = Data_40003ffd; + + sprintf(Data_40004027, "SetTime: %02dh%02dm", + (int)dObjectSetTime, + (int)((dObjectSetTime - (int)dObjectSetTime) * 60)); + Data_40003378 = Data_40004027; + + Data_40003364 = " "; + Data_4000336c = " "; + Data_40003374 = " "; + Data_4000337c = " "; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_RISE_SET_TIMES: //32001 + //0x3be30 + sprintf(Data_40003fa9, "RiseTime: %02dh%02dm", + (int)dObjectRiseTime, + (int)((dObjectRiseTime - (int)dObjectRiseTime) * 60)); + Data_40003360 = Data_40003fa9; + + sprintf(Data_40003fbe, "TransitTime:%02dh%02dm", + (int)dObjectTransitTime, + (int)((dObjectTransitTime - (int)dObjectTransitTime) * 60)); + Data_40003368 = Data_40003fbe; + + sprintf(Data_40003fd3, "SetTime: %02dh%02dm", + (int)dObjectSetTime, + (int)((dObjectSetTime - (int)dObjectSetTime) * 60)); + Data_40003370 = Data_40003fd3; + + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case 33001: // "Curr. Lunar Phase" -> "2019-11" + //0x3c088 + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_TIMER_COUNTING: //34002: + //0x3c0a8 + sprintf(strEngTimeRemain00000s, "%5lds", Data_40003214_UserTimerSeconds); + + Data_40003360 = strEngCountingDown; // "Counting down:"? + Data_40003364 = ""; + Data_40003368 = strEngTimeRemain; // "Time remain:" + Data_4000336c = ""; + Data_40003370 = strEngTimeRemain00000s; // "00000s" + Data_40003374 = ""; + Data_4000337c = ""; + Data_40003378 = strEngStopBack; // " Stop Back"? + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x3c13c + Data_40003360 = strEngSetTimer; // "Set timer:"? + Data_40003364 = ""; + Data_40003368 = strEng00000s; // "00000s"? + Data_4000336c = ""; + Data_40003370 = Data_400029b3; + Data_40003374 = ""; + Data_40003378 = strEngStartBack; // " Start Back"? + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_ALARM_INPUT: //35001: + //0x3c1bc: Alarm start + Data_40003360 = strEngInputTime; + Data_40003364 = ""; + Data_40003368 = strEngAlarm21h34m23s; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_4000337c = ""; + Data_40003378 = strEngAlarmOnBack; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case 35002: + //0x3c23c: Alarm stop + Data_40003360 = ""; + Data_40003364 = strEngCloseAlarm; + Data_40003368 = ""; + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_4000337c = ""; + Data_40003378 = strEngAlarmCloseBack; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case 0x57E4B: //360011 + //0x3c2bc + Data_40003360 = strEngTelescopeOneMX51; + Data_40003364 = ""; + Data_40003368 = Data_4000239a; //"Scope:3'.3'" + Data_4000336c = ""; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021 + //0x3c33c + Data_40003360 = strEyepieceMagnCaption; //->"Eyep. focal length:"? + Data_40003364 = ""; + Data_40003368 = strEyepieceFovMfInput; + Data_4000336c = ""; + Data_40003370 = strEyepieceFovSfInput; + Data_40003374 = ""; + Data_40003378 = strEyepieceMagnification; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022 + //0x3c41c + Data_40003360 = strEyepieceMagnCaption; + Data_40003364 = ""; + Data_40003368 = strEyepieceFovMfInput; + Data_4000336c = ""; + Data_40003370 = strEyepieceFovSfInput; + Data_40003374 = ""; + Data_40003378 = strEyepieceMagnification; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021 + //0x3c49c + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022 + //0x3c4a4 + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023 + //0x3c4a8 + Data_40003360 = strEyepieceFovCaption; // "Eyep. focal length:" + Data_40003364 = ""; + Data_40003368 = strEyepieceFovMfInput; // "MF:1893mm" + Data_4000336c = ""; + Data_40003370 = strEyepieceFovSfInput; // "SF:43mm" + Data_40003374 = ""; + Data_40003378 = strEyepieceFovInput; // "E-FOV:001°00'" + Data_4000337c = strEyepieceFOV; // " FOV:0.02272°" + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case 0x57E57: //360023 + //0x3c524 + sprintf(Data_4000248c, "MultiplyM:%d", fEyepieceMagnification); + + Data_40003360 = strEyepieceMagnCaption; + Data_40003364 = ""; + Data_40003368 = strEyepieceFovMfInput; + Data_4000336c = ""; + Data_40003370 = strEyepieceFovSfInput; + Data_40003374 = ""; + Data_40003378 = strEyepieceMagnification; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL: //380011: + //0x3c5cc + Data_40003360 = strEngBackgroundLight; + Data_40003364 = ""; + Data_40003368 = strEngPressUpDownKey; + Data_4000336c = ""; + Data_40003370 = Data_40002aee; + Data_40003374 = ""; + Data_40003378 = Data_40002aef; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x3c64c + Data_40003360 = "Date and Time Set: "; + Data_40003364 = ""; + Data_40003368 = Data_400037ec; + Data_4000336c = " YYYY-MM-DD"; + Data_40003370 = Data_40003150; + Data_40003374 = " HH:MM:SS"; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_ON: //42001: + //0x3c6cc + Data_40003360 = Data_40002b70; //"daylight saving" + Data_40003364 = ""; + Data_40003368 = Data_40002b80; //"status:on" + Data_4000336c = ""; + Data_40003370 = Data_40002b8a; + + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40003374 = "hit direction key!"; + } + else + { + Data_40003374 = "Restart & Change!"; + } + Data_40003378 = Data_40002b8b; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_DAYLIGHT_SAVING_OFF: //42002: + //3c76c + Data_40003360 = Data_40002ba5; //"Daylight saving" + Data_40003364 = ""; + Data_40003368 = Data_40002bb5; //"status:off" + Data_4000336c = ""; + Data_40003370 = Data_40002bc0; + + if (bData_40002f1e_SetupLocalData == 1) + { + Data_40003374 = "hit direction key!"; + } + else + { + Data_40003374 = "Restart & Change!"; + } + Data_40003378 = Data_40002bc1; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_COUNTRY_CITY_SELECTION: //43011: + //0x3c8f4: Country & City + flash_get_site_data((unsigned short)(wData_40003250 + wData_40003252), &Data_40003f1c_FlashSiteData); + + if (Data_40003f1c_FlashSiteData.fLongitude >= 0) + { + //3c92c + sprintf(Data_40003ffd, " Lon:E%03d %02d ", + abs((int)Data_40003f1c_FlashSiteData.fLongitude), + abs((int)((Data_40003f1c_FlashSiteData.fLongitude - (int)Data_40003f1c_FlashSiteData.fLongitude) * 60))); + } + else + { + //0x3c9bc + sprintf(Data_40003ffd, " Lon:W%03d %02d ", + abs((int)Data_40003f1c_FlashSiteData.fLongitude), + abs((int)((Data_40003f1c_FlashSiteData.fLongitude - (int)Data_40003f1c_FlashSiteData.fLongitude) * 60))); + } + //0x3ca48 + if (abs((int)Data_40003f1c_FlashSiteData.fLongitude) < 100) + { + Data_40003ffd[10] = ' '; + } + if (abs((int)Data_40003f1c_FlashSiteData.fLongitude) < 10) + { + Data_40003ffd[11] = ' '; + } + if (abs((int)((Data_40003f1c_FlashSiteData.fLongitude - (int)Data_40003f1c_FlashSiteData.fLongitude) * 60)) < 10) + { + Data_40003ffd[14] = ' '; + } + //0x3cb14 + if (Data_40003f1c_FlashSiteData.fLatitude >= 0) + { + //3cb28 + sprintf(Data_40004027, " Lat:N %02d %02d ", + abs((int)Data_40003f1c_FlashSiteData.fLatitude), + abs((int)((Data_40003f1c_FlashSiteData.fLatitude - (int)Data_40003f1c_FlashSiteData.fLatitude) * 60))); + } + else + { + //0x3cbb8 + sprintf(Data_40004027, " Lat:S %02d %02d ", + abs((int)Data_40003f1c_FlashSiteData.fLatitude), + abs((int)((Data_40003f1c_FlashSiteData.fLatitude - (int)Data_40003f1c_FlashSiteData.fLatitude) * 60))); + } + //0x3cc44 + if (abs((int)Data_40003f1c_FlashSiteData.fLatitude) < 10) + { + Data_40004027[11] = ' '; + } + if (abs((int)((Data_40003f1c_FlashSiteData.fLatitude - (int)Data_40003f1c_FlashSiteData.fLatitude) * 60)) < 10) + { + Data_40004027[14] = ' '; + } + //0x3cd74 + if (Data_40003f1c_FlashSiteData.Zone > 0) + { + //3cd84 + sprintf(Data_4000403c, " Zone:E%d ", + abs(Data_40003f1c_FlashSiteData.Zone)); + } + else if (Data_40003f1c_FlashSiteData.Zone < 0) + { + //0x3cdb4 + sprintf(Data_4000403c, " Zone:W%d ", + abs(Data_40003f1c_FlashSiteData.Zone)); + } + else + { + //0x3cdf4 + sprintf(Data_4000403c, " Zone:%d ", + abs(Data_40003f1c_FlashSiteData.Zone)); + } + //0x3ce20 + Data_40003360 = Data_40003f1c_FlashSiteData.cCountry; + Data_40003364 = Data_40003f1c_FlashSiteData.cCity; + Data_40003368 = Data_40003ffd; + Data_4000336c = Data_40004027; + Data_40003370 = Data_4000403c; + Data_40003374 = " "; + Data_40003378 = "up&down key: country!"; + Data_4000337c = "left&right key: city!"; + + bData_4000316e_FocusLineOn8LineDisplay = 0; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x3ce9c: "Custom Site" + Data_40003360 = "Please Input Data: "; + //Data_40003364 = ""; //????? + Data_40003368 = strCustomSiteName; //" Name:" + Data_4000336c = strCustomSiteLongitude; //" Lon:" + Data_40003370 = strCustomSiteLatitude; //" Lat:" + Data_40003374 = strCustomSiteTimezone; //" Zone:" + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_SKY_TARGET: //45001 + //0x3cf10 + Data_40003360 = "Object Mode:"; + Data_40003364 = ""; + Data_40003368 = strSkyTarget; + Data_4000336c = ""; + Data_40003370 = strLandTarget; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_LAND_TARGET: //45002 + //0x3cf90 + Data_40003360 = "Object Mode:"; + Data_40003364 = ""; + Data_40003368 = strSkyTarget; + Data_4000336c = ""; + Data_40003370 = strLandTarget; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_MOUNT_AZ: //46001: + //0x3d010 + Data_40003360 = "Telescope Mount:"; + Data_40003364 = ""; + Data_40003368 = Data_400028a5; + Data_4000336c = ""; + Data_40003370 = Data_400028b3; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_MOUNT_EQU: //46002: + //0x3d154 + Data_40003360 = "Telescope Mount:"; + Data_40003364 = ""; + Data_40003368 = Data_400028a5; + Data_4000336c = ""; + Data_40003370 = Data_400028b3; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: // "Telescope Mount" -> "Please setup OTA zero" + //0x3d1d4 + Data_40003360 = strEngPleaseSetupOtaZero; // "Please setup OTA zero" + Data_40003368 = Data_400028d7; // "Azi:000°" + Data_40003370 = Data_400028e1; // "Alt: 00°" + Data_4000336c = " Range:0-360"; + Data_40003374 = " Range:0-90"; + Data_40003378 = ""; + Data_4000337c = ""; + + if (bData_400032a4_OTAZeroDataErrorCount > 0) + { + bData_400032a4_OTAZeroDataErrorCount--; + Data_40003374 = " "; + Data_40003378 = Data_400028eb; + } + else + { + Data_40003374 = " "; + Data_40003378 = " "; + } + + Data_40003364 = " "; + Data_4000336c = " Range:0-360"; + Data_40003374 = " Range:0-90"; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP_RESTART: //47041: + //0x3d2c4 + Data_40003360 = strEngPleaseSetupOtaZero; // "Please setup OTA zero" + Data_40003368 = Data_400028d7; + Data_40003370 = Data_400028e1; + Data_40003378 = Data_40002901; + Data_40003364 = ""; + Data_4000336c = ""; + Data_40003374 = " "; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_ENGLISH: //49001 + //0x3d344 + Data_40003360 = strEngEnglish; + Data_40003364 = strEngGerman; + Data_40003368 = strEngFrench; + Data_4000336c = strEngItalian; + Data_40003370 = strEngSpanish; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_GERMAN: //49002 + //0x3d3c0 + Data_40003360 = strEngEnglish; + Data_40003364 = strEngGerman; + Data_40003368 = strEngFrench; + Data_4000336c = strEngItalian; + Data_40003370 = strEngSpanish; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 2; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_FRENCH: //49003 + //0x3d440 + Data_40003360 = strEngEnglish; + Data_40003364 = strEngGerman; + Data_40003368 = strEngFrench; + Data_4000336c = strEngItalian; + Data_40003370 = strEngSpanish; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 3; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_ITALIAN: //49004 + //0x3d594 + Data_40003360 = strEngEnglish; + Data_40003364 = strEngGerman; + Data_40003368 = strEngFrench; + Data_4000336c = strEngItalian; + Data_40003370 = strEngSpanish; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 4; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_SPANISH: //49005 + //0x3d614 + Data_40003360 = strEngEnglish; + Data_40003364 = strEngGerman; + Data_40003368 = strEngFrench; + Data_4000336c = strEngItalian; + Data_40003370 = strEngSpanish; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 5; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001 + //0x3d694 + Data_40003360 = "Input Treaking Speed:"; + Data_40003364 = ""; + Data_40003368 = ""; + Data_4000336c = strTrackingRateCustDisplay; + Data_40003370 = ""; + Data_40003374 = ""; + Data_40003378 = ""; + Data_4000337c = ""; + + bData_4000316e_FocusLineOn8LineDisplay = 10; + bData_40003197_DisplayLinesPerMenuLine = 1; + break; + + default: + //0x3d714 + break; + } +} + diff --git a/applications/freertos_app/func_3d72c.c b/applications/freertos_app/func_3d72c.c new file mode 100644 index 0000000..2fa0c96 --- /dev/null +++ b/applications/freertos_app/func_3d72c.c @@ -0,0 +1,3177 @@ + +/* 3d72c - todo */ +void DisplayScreenItems(void) +{ + PrepareScreenItems(); + + switch (bData_40003197_DisplayLinesPerMenuLine) + { + case 1: + //0x3d750 + Data_4000318c = Data_40002c64_MenuContextId; + if (Data_4000318c != Data_40003190) + { + //3d77c + lcd_display_clear(); + Data_40003190 = Data_4000318c; + } + //3d790 + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x3da9c + if (bSystemInitialized == 1) + { + DisplayMainScreen(); + } + //->4684c + break; + + case MENU_CONTEXT_RECENT_TARGETS: //1: + //0x3dab8 + if (bData_40002f14_RecentTargetCount != 0) + { + //3dacc + switch (bData_4000316e_FocusLineOn8LineDisplay) + { + case 1: + //0x3db04 + lcd_display_string(1, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(1, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + case 2: + //0x3dd8c + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(1, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(2, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + case 3: + //0x3e014 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(1, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(1, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + case 4: + //0x3e29c + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(1, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(1, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + case 5: + //0x3e524 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(1, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(1, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + case 6: + //0x3e7ac + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(1, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(1, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + case 7: + //0x3ea90 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(1, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(1, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + case 8: + //0x3ed18 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(1, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(1, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3efa8 + break; + + default: + //0x3efa0 + break; + } + } + else + { + //0x3efac + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + } + //->0x4684c + break; + + case 102: + //0x3f230 + if (((Data_40003f64.bData_0 != 1) && (bData_40002e79_SkyLandTargetSeletion == 1)) || + ((Data_40003f50.bData_0 != 1) && (bData_40002e79_SkyLandTargetSeletion == 0))) + { + //0x3f274 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x3f8cc + } + else + { + //0x3f3f8 + switch (bData_40002e79_SkyLandTargetSeletion) + { + case 0: + //0x3f414 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + //->0x3f8c8 + break; + + case 1: + //0x3f650 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + } + } + //->0x4684c + break; + + case 2: + //0x3f8d0 + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + + beep1(1); + delay_loop(200); + beep1(1); + delay_loop(200); + beep1(1); + delay_loop(200); + Data_40002c64_MenuContextId = 0; + //->0x4684c + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x3f9a4: One / Two / Three Star Align + if (bData_40002c62_AlignmentStarMode == 0) + { + //3f9b8: Alignment Star Selection + if (Data_40002c5c_AlignmentStarCount == 0) + { + //3f9c8: Alignment complete + if (bData_400031e9 != 5) + { + lcd_display_clear(); + } + //0x3f9dc + bData_400031e9 = 5; + ProcessNextAlignmentStar(); + beep1(3); + + Data_40003364 = Data_400030b4; //"The telescope has be" + Data_4000336c = Data_400030b8; //"aligned!" + Data_40003374 = Data_400030bc; + + lcd_display_string(0, 1, 1, 22, " "); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 22, " "); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 22, " "); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 22, " "); + lcd_display_string(0, 8, 1, 22, " "); + + delay_loop(300); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + //->0x4047c + } //if (Data_40002c5c_AlignmentStarCount == 0) + else + { + //0x3fb58 + if (bData_400031e9 != 6) + { + lcd_display_clear(); + } + //0x3fb6c + bData_400031e9 = 6; + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 4, "OBJ:"); + lcd_display_string(0, 7, 11, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 11, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(0, 5, 11, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 11, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 6, 1, 4, " "); + //->0x4047c + } + } //if (bData_40002c62_AlignmentStarMode == 0) + else + { + //0x3fdac: "Slewing to Target" / "Please center this star to the field of view" + if ((bTrackingMode == MENU_TRACKING_MODE_POINTING/*1*/) && (bData_400034cd == 0)) + { + //3fdcc + if (bData_400031e9 != 7) + { + lcd_display_clear(); + } + bData_400031e9 = 7; + + Data_40003360 = strSlewingTo; + Data_40003364 = strAutoloadAlignStars; + + if (Data_40004128.alignmentPause == 0) + { + //3fe1c + lcd_display_string(0, 1, 1, 21, "Slewing to Target "); + } + else + { + //0x3fe3c + lcd_display_string(0, 1, 1, 21, "Pause "); + } + //0x3fe58 + lcd_display_string(0, 2, 1, 21, " "); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 4, "OBJ:"); + lcd_display_string(0, 5, 11, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 11, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 6, 1, 6, " "); + lcd_display_string(0, 7, 1, 4, "OTA:"); + lcd_display_string(0, 7, 11, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 11, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 6, 1, 4, " "); + //->0x402d8 + } //if ((bTrackingMode == MENU_TRACKING_MODE_POINTING) && (bData_400034cd == 0)) + else + { + //0x4015c + if (bData_400034cd == 1) + { + //4016c + if (bData_400031e9 != 8) + { + lcd_display_clear(); + } + bData_400031e9 = 8; + + Data_40003364 = Data_400030a8; //" Please center this " + Data_4000336c = Data_400030ac; //"star to the field of" + Data_40003374 = Data_400030b0; //"view" + + lcd_display_string(0, 1, 1, 22, " "); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 22, " "); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 22, " "); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 22, " "); + lcd_display_string(0, 8, 1, 22, " "); + } + } + //0x402d8 + if (bTrackingMode == 2) + { + //402e8 + bData_400034cd = 1; + + if (bData_400031e9 != 8) + { + lcd_display_clear(); + } + bData_400031e9 = 8; + + Data_40003364 = Data_400030a8; + Data_4000336c = Data_400030ac; + Data_40003374 = Data_400030b0; + + lcd_display_string(0, 1, 1, 22, " "); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 22, " "); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 22, " "); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 22, " "); + lcd_display_string(0, 8, 1, 22, " "); + } + } + //0x4047c -> 0x4684c + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x40480 + case MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT: //11101: + //0x40488 + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + //0x4048c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x4684c + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_RESULT: //11104: + //0x40610 + beep1(1); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11102; + //->0x4684c + break; + + case 11105: + //0x407b4 + beep1(3); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x40958 + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN: //11201: + //0x40960 + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + //0x40964 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_RESULT: //11204: + //0x40ae8 + beep1(1); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11202; + break; + + case 11205: + //0x40c8c + beep1(3); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION: //22001: + //0x40e30: Solar System object + case MENU_CONTEXT_CONSTELLATION_SELECTION: //24001: + //0x40e38: Constellation item + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x40e3c + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x40e40: Sh2 item + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x40e44: Bright Star item + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x40e48: SAO item + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x41080: NGC item + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x41088: IC item + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, 14, "Constellation:"); + lcd_display_string(0, 2, 15, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, 5, "Type:"); + lcd_display_string(0, 4, 6, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x412f8 + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x41300 + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x41304 + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x41308 + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x4130c + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x41310 + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x41314 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + + if (bTrackingModeMenu == 2) + { + //415e4 + func_659c(2000); + beep1(1); + func_659c(1000); + beep1(1); + func_659c(1000); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + //0x41618 -> 0x4684c + break; + + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x4161c + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x41624 + lcd_display_clear(); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 14, "Constellation:"); + lcd_display_string(0, 3, 15, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + + if (bTrackingModeMenu == 2) + { + //418c4 + func_659c(2000); + beep1(1); + func_659c(1000); + beep1(1); + func_659c(1000); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + //0x418f8 -> 0x4684c + break; + + case MENU_CONTEXT_FAMOUS_STAR_SELECTION: //25001: + //0x418fc: Famous Star item + func_91c(0, 1, 1, 64, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 0, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x41af8: Messier item + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x41c80 + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x41c88 + case 101: + //0x41c8c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003384), (unsigned char*)Data_40003384); + + switch (bData_4000319a_SkyLandTargetId) + { + case 1: + //0x41cf8 + lcd_display_string(1, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 2: + //0x41e20 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(1, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 3: + //0x41f48 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(1, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 4: + //0x42070 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(1, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 5: + //0x42198 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(1, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 6: + //0x422c0 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(1, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 7: + //0x423e8 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(1, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 8: + //0x42530 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(1, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 9: + //0x42658 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(1, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + #if 0 + default: + //0x42780 + break; + #endif + } + //->0x4684c + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x42788 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(1, 6, bCharacterInputPosition, 1, (unsigned char*)&Data_40003374[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x4298c + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(1, 7, bCharacterInputPosition, 1, (unsigned char*)&Data_40003378[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x42b90 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(1, 8, bCharacterInputPosition, 1, (unsigned char*)&Data_4000337c[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x42d94 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 1, 3, "Azi"); + lcd_display_string(0, 8, 1, 3, "Alt"); + lcd_display_string(1, 6, bCharacterInputPosition, 1, (unsigned char*)&Data_40003374[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x43048 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 1, 3, "Azi"); + lcd_display_string(0, 8, 1, 3, "Alt"); + lcd_display_string(1, 7, bCharacterInputPosition, 1, (unsigned char*)&Data_40003378[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x43328 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 1, 3, "Azi"); + lcd_display_string(0, 8, 1, 3, "Alt"); + lcd_display_string(1, 8, bCharacterInputPosition, 1, (unsigned char*)&Data_4000337c[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_RA_INPUT: //29001: + //0x435dc + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 16, (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 16, (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_DEC_INPUT: //29002: + //0x437f0 + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 16, (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 16, (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x43a04 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x43bc0 + switch (bDateTimeInputMode) + { + case 0: + //0x43be0 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, &Data_40003368[bCharacterInputPosition - 1]); + //->0x43f60 + break; + + case 1: + //0x43d9c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + //->0x43f60 + break; + + default: + //0x43f58 + break; + } + break; + + case 43011: //Country & City + //0x43f68 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 3, 14, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 3, 17, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 4, 14, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 4, 17, (unsigned char*)cBitmapMinute); + //->0x4684c + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x44140 + lcd_display_bitmap(0, 4, 11, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 4, 14, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 13, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bCurrentCustomSiteInputLine) + { + case 0: + //0x44340 + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 1: + //0x4437c + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + case 2: + //0x443b8 + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + break; + + case 3: + //0x443f4 + lcd_display_string(1, 6, bCharacterInputPosition, 1, (unsigned char*)&Data_40003374[bCharacterInputPosition - 1]); + break; + } + + lcd_display_bitmap(0, 4, 11, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 4, 14, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 13, (unsigned char*)cBitmapMinute); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP_RESTART: //47041: + //0x444b4 + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x444bc + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 8, (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 8, (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003374); //BUG! + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bData_4000316d) + { + case 0: + //0x44638 + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 1: + //0x44674 + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + break; + + default: + //0x446b0 + break; + } + + lcd_display_bitmap(0, 3, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + break; + + case MENU_CONTEXT_RESET_CONFIRM: //100: + //0x446e8: Reset + lcd_display_string(0, 1, 1, 21, "Are you sure reset "); + lcd_display_string(0, 3, 1, 21, "System. "); + lcd_display_string(0, 5, 1, 21, "Back: Cancel "); + lcd_display_string(0, 7, 1, 21, "Enter: Begin Reset "); + break; + + case 33001: + //0x44760: Curr. Lunar Phase + lcd_display_lunar_phase_screen(Data_40003164_LunarPhaseYear, Data_40003168_LunarPhaseMonth); + break; + + case MENU_CONTEXT_TIMER_SET: //34001: + //0x4477c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003378/*BUG!*/), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + //->0x4684c + break; + + case MENU_CONTEXT_ALARM_INPUT: //35001: + //0x44938: Alarm + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + //->0x4684c + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x44b70 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x44d2c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x44ee8 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 7, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 13, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapDegree); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x450e0 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 7, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 13, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapDegree); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x452d8 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 7, bCharacterInputPosition, 1, (unsigned char*)&Data_40003378[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 7, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 13, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapDegree); + break; + + case 211001: + //0x454d0 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bData_40003262) + { + case 1: + //45664 + switch (bData_40003261) + { + case 0: + //0x4568c + lcd_display_string(1, 2, bCharacterInputPosition, 1, (unsigned char*)&Data_40003364[bCharacterInputPosition - 1]); + break; + + case 1: + //0x456c8 + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 2: + //0x45704 + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + default: + //0x45740 +#ifdef __GNUC__ + break; +#else +// break; +#endif + } +// break; + + default: + //0x45750 + break; + } + //->0x4684c + break; + + case 28001: //0x6D61: + //0x4575c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bData_40003263) + { + case 1: + //0x458fc + case 3: + //0x45904 + switch (bData_40003260) + { + case 0: + //0x45928 + lcd_display_string(1, 2, bCharacterInputPosition, 1, (unsigned char*)&Data_40003364[bCharacterInputPosition - 1]); + break; + + case 1: + //0x45964 + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 2: + //0x459a0 + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + default: + //0x459dc +#ifdef __GNUC__ + break; +#else +// break; +#endif + } +// break; + + default: + //0x459ec + break; + } + //->0x4684c + break; + + default: + //->459f8 + switch (bData_4000316e_FocusLineOn8LineDisplay) + { + case 0: + //0x45a34 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 1: + //0x45bbc + lcd_display_string(1, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 2: + //0x45d44 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(2/*1*/, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); //BUG? + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 3: + //0x45ecc + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(1, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 4: + //0x46054 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(1, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 5: + //0x461dc + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(1, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 6: + //0x46364 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(1, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 7: + //0x4652c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(1, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + case 8: + //0x466b4 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(1, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x46844 + break; + + default: + //0x4683c + break; + } //switch (bData_4000316e_FocusLineOn8LineDisplay) + break; + } //switch (Data_40002c64_MenuContextId) + //46850 -> 4edd8 + break; + + case 2: + //0x46854 + Data_4000318c = Data_40002c64_MenuContextId; + + if (Data_4000318c != Data_40003190) + { + //46880 + lcd_display_clear(); + + Data_40003190 = Data_4000318c; + } + //0x46894 + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x46b64 + if (bSystemInitialized == 1) + { + DisplayMainScreen(); + } + //->0x4edc8 + break; + + case MENU_CONTEXT_RECENT_TARGETS: //1: + //0x46b80 + if (bData_40002f14_RecentTargetCount != 0) + { + //46b94 + switch (bData_4000316e_FocusLineOn8LineDisplay) + { + case 1: + //0x46bcc + lcd_display_string(1, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(1, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x4808c + break; + + case 2: + //0x46e54 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(1, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(2/*1*/, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); //BUG? + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case 3: + //0x470dc + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(1, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(1, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case 4: + //0x47364 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(1, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(1, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case 5: + //0x475ec + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(1, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(1, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case 6: + //0x478ec + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(1, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(1, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case 7: + //0x47b74 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(1, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(1, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case 8: + //0x47dfc + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(1, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 3, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 3, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 3, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 3, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 3, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 3, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(1, 8, 3, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + default: + //0x48084 + break; + } //switch (bData_4000316e_FocusLineOn8LineDisplay) + //4808c -> 0x48310 + } //if (bData_40002f14_RecentTargetCount != 0) + else + { + //0x48090 + lcd_display_string(0, 1, 1, 2, Data_40003380); + lcd_display_string(0, 2, 1, 2, Data_40003384); + lcd_display_string(0, 3, 1, 2, Data_40003388); + lcd_display_string(0, 4, 1, 2, Data_4000338c); + lcd_display_string(0, 5, 1, 2, Data_40003390); + lcd_display_string(0, 6, 1, 2, Data_40003394); + lcd_display_string(0, 7, 1, 2, Data_40003398); + lcd_display_string(0, 8, 1, 2, Data_4000339c); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + } + //0x48310 -> 0x4edc8 + break; + + case 102: + //0x48314 + if (((Data_40003f64.bData_0 != 1) && (bData_40002e79_SkyLandTargetSeletion == 1)) || + ((Data_40003f50.bData_0 != 1) && (bData_40002e79_SkyLandTargetSeletion == 0))) + { + //0x48358 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + //->0x489b0 + } + else + { + //0x484dc + switch (bData_40002e79_SkyLandTargetSeletion) + { + case 0: + //0x484f8 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + //->0x3f8c8 + break; + + case 1: + //0x48734 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + } + } + break; + + case 2: + //0x489b4 + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + + beep1(1); + delay_loop(200); + beep1(1); + delay_loop(200); + beep1(1); + delay_loop(200); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + //->0x4edc8 + break; + + case MENU_CONTEXT_ALIGNMENT_STAR_CONTROL: //12001: + //0x48a88 + if (bData_40002c62_AlignmentStarMode == 0) + { + //48a9c: Alignment Star Selection + if (Data_40002c5c_AlignmentStarCount == 0) + { + //48aac: Alignment complete + if (bData_400031e9 != 5) + { + lcd_display_clear(); + } + //0x48ac0 + bData_400031e9 = 5; + ProcessNextAlignmentStar(); + beep1(3); + + Data_40003364 = Data_400030b4; //"The telescope has be" + Data_4000336c = Data_400030b8; //"aligned!" + Data_40003374 = Data_400030bc; + + lcd_display_string(0, 1, 1, 22, " "); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 22, " "); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 22, " "); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 22, " "); + lcd_display_string(0, 8, 1, 22, " "); + + delay_loop(300); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + //->0x4952c + } //if (Data_40002c5c_AlignmentStarCount == 0) + else + { + //0x48c3c + if (bData_400031e9 != 6) + { + lcd_display_clear(); + } + //0x48c50 + bData_400031e9 = 6; + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 4, "OBJ:"); + lcd_display_string(0, 7, 11, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 11, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(0, 5, 11, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 11, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 6, 1, 4, " "); + //->0x4952c + } + } //if (bData_40002c62_AlignmentStarMode == 0) + else + { + //0x48e90: "Slewing to Target" / "Please center this star to the field of view" + if ((bTrackingMode == MENU_TRACKING_MODE_POINTING/*1*/) && (bData_400034cd == 0)) + { + //48eb0 + if (bData_400031e9 != 7) + { + lcd_display_clear(); + } + bData_400031e9 = 7; + + Data_40003360 = strSlewingTo; + Data_40003364 = strAutoloadAlignStars; + + if (Data_40004128.alignmentPause == 0) + { + //48f00 + lcd_display_string(0, 1, 1, 21, "Slewing to Target "); + } + else + { + //0x48f20 + lcd_display_string(0, 1, 1, 21, "Pause "); + } + //0x48f3c + lcd_display_string(0, 2, 1, 21, " "); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 4, "OBJ:"); + lcd_display_string(0, 5, 11, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 11, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 6, 1, 6, " "); + lcd_display_string(0, 7, 1, 4, "OTA:"); + lcd_display_string(0, 7, 11, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 11, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 6, 1, 4, " "); + //->0x493a4 + } //if ((bTrackingMode == MENU_TRACKING_MODE_POINTING) && (bData_400034cd == 0)) + else + { + //0x4918c + if (bData_400034cd == 1) + { + //4919c + if (bData_400031e9 != 8) + { + lcd_display_clear(); + } + bData_400031e9 = 8; + + Data_40003364 = Data_400030a8; //" Please center this " + Data_4000336c = Data_400030ac; //"star to the field of" + Data_40003374 = Data_400030b0; //"view" + + lcd_display_string(0, 1, 1, 22, " "); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 22, " "); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 22, " "); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 22, " "); + lcd_display_string(0, 8, 1, 22, " "); + } + } + //0x493a4 + if (bTrackingMode == 2) + { + //493b4 + bData_400034cd = 1; + + if (bData_400031e9 != 8) + { + lcd_display_clear(); + } + bData_400031e9 = 8; + + Data_40003364 = Data_400030a8; + Data_4000336c = Data_400030ac; + Data_40003374 = Data_400030b0; + + lcd_display_string(0, 1, 1, 22, " "); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 22, " "); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 22, " "); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 22, " "); + lcd_display_string(0, 8, 1, 22, " "); + } + } + //0x4952c -> 0x4edc8 + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11102: + //0x49530 + case MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT: //11101: + //0x49538 + case MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT: //11103: + //0x4953c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case MENU_CONTEXT_RA_BKBLASH_CORR_RESULT: //11104: + //0x496c0 + beep1(1); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11102; + break; + + case 11105: + //0x49864 + beep1(3); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET: //11202: + //0x49a08 + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN: //11201: + //0x49a10 + case MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN: //11203: + //0x49a14 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case MENU_CONTEXT_DEC_BKBLASH_CORR_RESULT: //11204: + //0x49b98 + beep1(1); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET; //11202; + break; + + case 11205: + //0x49d3c + beep1(3); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 8, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + delay_loop(800); + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION: //22001: + //0x49ee0 + case MENU_CONTEXT_CONSTELLATION_SELECTION: //24001: + //0x49ee8 + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x49eec + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x49ef0 + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x49ef4 + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x49ef8 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x4a130 + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x4a138 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, 14, "Constellation:"); + lcd_display_string(0, 2, 15, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, 5, "Type:"); + lcd_display_string(0, 4, 6, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x4a3a8 + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x4a3b0 + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x4a3b4 + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x4a3b8 + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x4a3bc + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x4a3c0 + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x4a3c4 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + + if (bTrackingModeMenu == 2) + { + //4a644 + func_659c(2000); + beep1(1); + func_659c(1000); + beep1(1); + func_659c(1000); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + break; + + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x4a67c + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x4a684 + lcd_display_clear(); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 14, "Constellation:"); + lcd_display_string(0, 3, 15, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + + if (bTrackingModeMenu == 2) + { + //4a96c + func_659c(2000); + beep1(1); + func_659c(1000); + beep1(1); + func_659c(1000); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + break; + + case MENU_CONTEXT_FAMOUS_STAR_SELECTION: //25001: + //0x4a9a4 + func_91c(0, 1, 1, 64, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 0, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 8, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 8, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 8, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 5, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 6, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 6, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 6, 21, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 8, 15, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 18, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x4aba0 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION: //201: + //0x4ad28 + case MENU_CONTEXT_CUST_LAND_OBJ_SELECTION: //202: + //0x4ad30 + case 101: + //0x4ad34 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003384), (unsigned char*)Data_40003384); + + switch (bData_4000319a_SkyLandTargetId) + { + case 1: + //0x4ada0 + lcd_display_string(1, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 2: + //0x4aec8 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(1, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 3: + //0x4aff0 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(1, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 4: + //0x4b118 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(1, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 5: + //0x4b240 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(1, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 6: + //0x4b368 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(1, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 7: + //0x4b490 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(1, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 8: + //0x4b5b8 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(1, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + + case 9: + //0x4b6e0 + lcd_display_string(0, 3, 3, 2, (unsigned char*)Data_40003360); + lcd_display_string(0, 3, 10, 2, (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 17, 2, (unsigned char*)Data_40003368); + lcd_display_string(0, 5, 3, 2, (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 10, 2, (unsigned char*)Data_40003370); + lcd_display_string(0, 5, 17, 2, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 3, 2, (unsigned char*)Data_40003378); + lcd_display_string(0, 7, 10, 2, (unsigned char*)Data_4000337c); + lcd_display_string(1, 7, 17, 2, (unsigned char*)Data_40003380); + //->0x42780 + break; + #if 0 + default: + //0x4b808 + break; + #endif + } + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT: //203: + //0x4b810 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(1, 6, bCharacterInputPosition, 1, (unsigned char*)&Data_40003374[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT: //204: + //0x4ba14 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(1, 7, bCharacterInputPosition, 1, (unsigned char*)&Data_40003378[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT: //205: + //0x4bc54 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(1, 8, bCharacterInputPosition, 1, (unsigned char*)&Data_4000337c[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT: //206: + //0x4be58 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 1, 3, "Azi"); + lcd_display_string(0, 8, 1, 3, "Alt"); + lcd_display_string(1, 6, bCharacterInputPosition, 1, (unsigned char*)&Data_40003374[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT: //207: + //0x4c10c + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 1, 3, "Azi"); + lcd_display_string(0, 8, 1, 3, "Alt"); + lcd_display_string(1, 7, bCharacterInputPosition, 1, (unsigned char*)&Data_40003378[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT: //208: + //0x4c3c0 + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, 13, (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, 16, (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, 16, (unsigned char*)Data_4000337c); + lcd_display_string(0, 7, 1, 3, "Azi"); + lcd_display_string(0, 8, 1, 3, "Alt"); + lcd_display_string(1, 8, bCharacterInputPosition, 1, (unsigned char*)&Data_4000337c[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 8, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 8, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 16, (unsigned char*)cBitmapSecond); + lcd_display_bitmap(0, 7, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 7, 16, (unsigned char*)cBitmapSecond); + break; + + case 29001: + //0x4c674 + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 16, (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 16, (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + break; + + case 29002: + //0x4c888 + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 16, (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 16, (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 11, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 16, (unsigned char*)cBitmapSecond); + break; + + case MENU_CONTEXT_TRACKING_RATE_INPUT: //48001: + //0x4ca9c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_TIME_DATE_INPUT: //41001: + //0x4cc58 + switch (bDateTimeInputMode) + { + case 0: + //0x4cc78 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, &Data_40003368[bCharacterInputPosition - 1]); + break; + + case 1: + //0x4ce34 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + break; + + default: + //0x4d024 + break; + } + break; + + case 43011: + //0x4d034 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_bitmap(0, 3, 14, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 3, 17, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 4, 14, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 4, 17, (unsigned char*)cBitmapMinute); + break; + + case MENU_CONTEXT_CUSTOM_SITE_INPUT: //43002: + //0x4d20c + lcd_display_bitmap(0, 4, 11, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 4, 14, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 13, (unsigned char*)cBitmapMinute); + + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bCurrentCustomSiteInputLine) + { + case 0: + //0x4d40c + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 1: + //0x4d448 + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + case 2: + //0x4d484 + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + break; + + case 3: + //0x4d4c0 + lcd_display_string(1, 6, bCharacterInputPosition, 1, (unsigned char*)&Data_40003374[bCharacterInputPosition - 1]); + break; + } + + lcd_display_bitmap(0, 4, 11, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 4, 14, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 5, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 13, (unsigned char*)cBitmapMinute); + break; + + case MENU_CONTEXT_OTA_ZERO_SETUP_RESTART: //47041: + //0x4d554 + case MENU_CONTEXT_OTA_ZERO_SETUP: //47011: + //0x4d55c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, 8, (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, 8, (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003374); //BUG! + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bData_4000316d) + { + case 0: + //0x4d6d8 + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 1: + //0x4d714 + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + break; + + default: + //0x4d750 + break; + } + + lcd_display_bitmap(0, 3, 8, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 5, 8, (unsigned char*)cBitmapDegree); + break; + + case MENU_CONTEXT_RESET_CONFIRM: //100: + //0x4d788 + lcd_display_string(0, 1, 1, 21, "Are you sure reset "); + lcd_display_string(0, 3, 1, 21, "System. "); + lcd_display_string(0, 5, 1, 21, "Back: Cancel "); + lcd_display_string(0, 7, 1, 21, "Enter: Begin Reset "); + break; + + case 33001: + //0x4d800 + lcd_display_lunar_phase_screen(Data_40003164_LunarPhaseYear, Data_40003168_LunarPhaseMonth); + break; + + case 34001: + //0x4d81c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003378/*BUG!*/), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_ALARM_INPUT: //35001: + //0x4d9d8 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT: //360021: + //0x4db94 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT: //360022: + //0x4dd50 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT: //370021: + //0x4df0c + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 7, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 13, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapDegree); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT: //370022: + //0x4e140 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 5, bCharacterInputPosition, 1, (unsigned char*)&Data_40003370[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 7, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 13, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapDegree); + break; + + case MENU_CONTEXT_EYEPIECE_FOV_INPUT: //370023: + //0x4e338 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + lcd_display_string(1, 7, bCharacterInputPosition, 1, (unsigned char*)&Data_40003378[bCharacterInputPosition - 1]); + + lcd_display_bitmap(0, 7, 10, (unsigned char*)cBitmapDegree); + lcd_display_bitmap(0, 7, 13, (unsigned char*)cBitmapMinute); + lcd_display_bitmap(0, 8, 21, (unsigned char*)cBitmapDegree); + break; + + case 211001: + //0x4e530 + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bData_40003262) + { + case 1: + //4e6c4 + switch (bData_40003261) + { + case 0: + //0x4e6ec + lcd_display_string(1, 2, bCharacterInputPosition, 1, (unsigned char*)&Data_40003364[bCharacterInputPosition - 1]); + break; + + case 1: + //0x4e728 + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 2: + //0x4e764 + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + default: + //0x4e7a0 +#ifdef __GNUC__ + break; +#else +// break; +#endif + } +// break; + + default: + //0x4e7b0 + break; + } + break; + + case 28001: + //0x4e7bc + lcd_display_string(0, 1, 1, (char)strlen(Data_40003360), (unsigned char*)Data_40003360); + lcd_display_string(0, 2, 1, (char)strlen(Data_40003364), (unsigned char*)Data_40003364); + lcd_display_string(0, 3, 1, (char)strlen(Data_40003368), (unsigned char*)Data_40003368); + lcd_display_string(0, 4, 1, (char)strlen(Data_4000336c), (unsigned char*)Data_4000336c); + lcd_display_string(0, 5, 1, (char)strlen(Data_40003370), (unsigned char*)Data_40003370); + lcd_display_string(0, 6, 1, (char)strlen(Data_40003374), (unsigned char*)Data_40003374); + lcd_display_string(0, 7, 1, (char)strlen(Data_40003378), (unsigned char*)Data_40003378); + lcd_display_string(0, 8, 1, (char)strlen(Data_4000337c), (unsigned char*)Data_4000337c); + + switch (bData_40003263) + { + case 1: + //0x4e95c + case 3: + //0x4e964 + switch (bData_40003260) + { + case 0: + //0x4e988 + lcd_display_string(1, 2, bCharacterInputPosition, 1, (unsigned char*)&Data_40003364[bCharacterInputPosition - 1]); + break; + + case 1: + //0x4e9c4 + lcd_display_string(1, 3, bCharacterInputPosition, 1, (unsigned char*)&Data_40003368[bCharacterInputPosition - 1]); + break; + + case 2: + //0x4ea00 + lcd_display_string(1, 4, bCharacterInputPosition, 1, (unsigned char*)&Data_4000336c[bCharacterInputPosition - 1]); + break; + + default: + //0x4ea3c +#ifdef __GNUC__ + break; +#else +// break; +#endif + } +// break; + + default: + //0x4ea4c + break; + } + break; + + default: + //0x4ea58 + switch (bData_4000316f_FocusLineOn4LineDisplay) + { + case 0: + //0x4ea88 + func_91c(0, 1, 1, 136, Data_400033a8); + func_91c(0, 2, 1, 136, Data_400033ac); + func_91c(0, 3, 1, 136, Data_400033b0); + func_91c(0, 4, 1, 136, Data_400033b4); + //->0x4edc0 + break; + + case 1: + //0x4eb10 + func_91c(1, 1, 1, 136, Data_400033a8); + func_91c(0, 2, 1, 136, Data_400033ac); + func_91c(0, 3, 1, 136, Data_400033b0); + func_91c(0, 4, 1, 136, Data_400033b4); + //->0x4edc0 + break; + + case 2: + //0x4eb98 + func_91c(0, 1, 1, 136, Data_400033a8); + func_91c(1, 2, 1, 136, Data_400033ac); + func_91c(0, 3, 1, 136, Data_400033b0); + func_91c(0, 4, 1, 136, Data_400033b4); + //->0x4edc0 + break; + + case 3: + //0x4ec20 + func_91c(0, 1, 1, 136, Data_400033a8); + func_91c(0, 2, 1, 136, Data_400033ac); + func_91c(1, 3, 1, 136, Data_400033b0); + func_91c(0, 4, 1, 136, Data_400033b4); + //->0x4edc0 + break; + + case 4: + //0x4eca8 + func_91c(0, 1, 1, 136, Data_400033a8); + func_91c(0, 2, 1, 136, Data_400033ac); + func_91c(0, 3, 1, 136, Data_400033b0); + func_91c(1, 4, 1, 136, Data_400033b4); + //->0x4edc0 + break; + + case 5: + //0x4ed30 + func_91c(1, 1, 1, 136, Data_400033a8); + func_91c(1, 2, 1, 136, Data_400033ac); + func_91c(1, 3, 1, 136, Data_400033b0); + func_91c(1, 4, 1, 136, Data_400033b4); + //->0x4edc0 + break; + + default: + //0x4edb8 + break; + } //switch (bData_4000316f_FocusLineOn4LineDisplay) + break; + + } //switch (Data_40002c64_MenuContextId) + break; + + default: + break; + } //switch (bData_40003197_DisplayLinesPerMenuLine) + //0x4edd0 + +} + diff --git a/applications/freertos_app/jupiter.c b/applications/freertos_app/jupiter.c new file mode 100644 index 0000000..b5bf777 --- /dev/null +++ b/applications/freertos_app/jupiter.c @@ -0,0 +1,112 @@ + +/* 131ac - todo */ +double jupiter_ecliptic_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double L5 = 0.0; + double res = 0.0; + + L0 += 59954691 * cos(0.0 + a * 0.0); + L0 += 9695899 * cos(5.0619179 + a * 529.6909651); + L0 += 573610 * cos(1.444062 + a * 7.113547); + L0 += 306389 * cos(5.41734/*5.417347*/ + a * 1059.381930); //BUG? + L0 += 97178 * cos(4.14265 + a * 632.78374); + L0 += 72903 * cos(3.64043 + a * 522.57742); + L0 += 64264 * cos(3.41145 + a * 103.09277); + + L1 += 52993480757 * cos(0.0 + a * 0.0); + L1 += 489741 * cos(4.220667 + a * 529.690965); + L1 += 228919 * cos(6.026475 + a * 7.113547); + L1 += 27655 * cos(4.57266 + a * 1059.38193); + L1 += 20721 * cos(5.45939 + a * 522.57742); + L1 += 12106 * cos(0.16986 + a * 536.80451); + + L2 += 47234 * cos(4.32148 + a * 7.11355); + L2 += 38966 * cos(0.0 + a * 0.0); + L2 += 30629 * cos(2.93021 + a * 529.69097); + + L3 += 6502 * cos(2.5986 + a * 7.1135); + L3 += 1357 * cos(1.3464 + a * 529.6910); + + res = (L0 + L1 * a + L2 * a*a + L3 * a*a*a + L4 * a*a*a*a + L5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* 13d10 - todo */ +double jupiter_ecliptic_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double B2 = 0.0; + double B3 = 0.0; + double B4 = 0.0; + double B5 = 0.0; + double res = 0.0; + + B0 += 2268616 * cos(3.5585261 + a * 529.6909651); + B0 += 110090 * cos(0.0 + a * 0.0); + B0 += 109972 * cos(3.908093 + a * 1059.381930); + + B1 += 177352 * cos(5.701665 + a * 529.690965); + B1 += 3230 * cos(5.7794 + a * 1059.3819); + B1 += 3081 * cos(5.4746 + a * 522.5774); + B1 += 2212 * cos(4.7346/*4.7348*/ + a * 536.8045); //BUG? + B1 += 1694 * cos(3.1416 + a * 0.0); + + B2 += 8094 * cos(1.4632 + a * 529.6910); + B2 += 813 * cos(3.1416 + a * 0.0); + B2 += 742 * cos(0.957 + a * 522.577); + B2 += 399 * cos(2.899 + a * 536.8); //536.805); //BUG? + B2 += 342 * cos(1.447 + a * 1059.382); + + res = (B0 + B1 * a + B2 * a*a + B3 * a*a*a + B4 * a*a*a*a + B5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* 145e4 - todo */ +double jupiter_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double R4 = 0.0; + double R5 = 0.0; + double res = 0.0; + + R0 += 520887429 * cos(0.0 + a * 0.0); + R0 += 25209327 * cos(3.49108640 + a * 529.69096509); + R0 += 610600 * cos(3.841154 + a * 1059.381930); + R0 += 282029 * cos(2.574199 + a * 632.783739); + R0 += 187647 * cos(2.075904 + a * 522.577418); + R0 += 86793 * cos(0.71001 + a * 419.48464); + R0 += 72063 * cos(0.21466 + a * 536.80451); + R0 += 65517 * cos(5.97996 + a * 316.39187); + R0 += 30135 * cos(2.16132 + a * 949.17561); + R0 += 29135 * cos(1.67759 + a * 103.02977); //103.09277); //BUG? + R0 += 23947 * cos(0.27458 + a * 7.11355); + + R1 += 1271802 * cos(2.6493751 + a * 529.6909651); + R1 += 61662 * cos(3.00076 + a * 1059.38193); + R1 += 53444 * cos(3.89718 + a * 522.57742); + R1 += 41390 * cos(0.0 + a * 0.0); + R1 += 31185 * cos(4.88277 + a * 536.80451); + R1 += 11847 * cos(2.41330 + a * 419.48464); + R1 += 9166 * cos(4.7598 + a * 7.1135); + + R2 += 79645 * cos(1.35866 + a * 529.69097); + R2 += 8252 * cos(5.7777 + a * 522.5774); + R2 += 7030 * cos(3.2748 + a * 536.8045); + R2 += 5314 * cos(1.8384 + a * 1059.3819); + + res = (R0 + R1 * a + R2 * a*a + R3 * a*a*a + R4 * a*a*a*a + R5 * a*a*a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/freertos_app/language.c b/applications/freertos_app/language.c new file mode 100644 index 0000000..5770d89 --- /dev/null +++ b/applications/freertos_app/language.c @@ -0,0 +1,966 @@ + + +char fill_400003de[1231] = " "; //400003de? + +//English +char strEngTelescopeAlign[] = "Telescope Align"; //400008ad +char strEngNavigation[] = "Navigation"; //400008bd +char strEngUtilities[] = "Utilities"; //400008c8 +char strEngSetup[] = "Setup"; //400008d2 +char strEngOneStarAlign[] = "One Star Align"; //400008d8 +char strEngTwoStarAlign[] = "Two Star Align"; //400008e7 +char strEngThreeStarAlign[] = "Three Star Align"; //400008f6 +char strEngTargetSync[] = "Target Sync"; //40000907 +char strEngPoleAxisDev[] = "Pole-Axis Dev. "; //40000913 +char strEngRaBklashCorr[] = "RA Bklash Corr."; //40000923 +char strEngDecBklashCorr[] = "DEC Bklash Corr."; //40000933 +char strEngSolarSystem[] = "Solar System"; //40000944 +char strEngConstellation[] = "Constellation"; //40000951 +char strEngFamousStar[] = "Famous Star"; //4000095f +char strEngMessierCatal[] = "Messier Catal."; //4000096b +char strEngNGCCatalog[] = "NGC Catalog."; //4000097a +char strEngICCatalogue[] = "IC Catalogue"; //40000987 +char strEngSh2Catalog[] = "Sh2 Catalog."; //40000994 +char strEngBrightStarCat[] = "Bright Star Cat."; //400009a1 +char strEngSAOStarCatal[] = "SAO Star Catal."; //400009b2 +char strEngCustomerObjects[] = "Customer Objects"; //400009c2 +char strEngInputRAandDEC[] = "Input RA and DEC"; //400009d3 +char strEngCustomLandGoal[] = "Custom Land Goal"; //400009e4 +char strEngCurrentObjects[] = "Current Objects"; //400009f5 +char strEngObjectRiseSet[] = "Object Rise/Set"; //40000a05 +char strEngCurrLunarPhase[] = "Curr. Lunar Phase"; //40000a15 +char strEngTimer[] = "Timer"; //40000a27 +char strEngAlarm[] = "Alarm"; //40000a2d +char strEngEyepieceFOV[] = "Eyepiece FOV"; //40000a33 +char strEngEyepieceMagn[] = "Eyepiece Magn."; //40000a40 +char strEngDisplayIllumin[] = "Display Illumin."; //40000a4f +char strEngParkposition[] = "Parkposition"; //40000a60 +char strEngTimeAndDate[] = "Time and Date "; //40000a6d +char strEngDaylightSaving[] = "Daylight Saving"; //40000a7c +char strEngSiteSetting[] = "Site Setting"; //40000a8c +char strEngSkyLand[] = "Sky/Land"; //40000a99 +char strEngAzEqu[] = "AZ / EQ "; //40000aa2 +char strEngTelescopeMount[] = "Telescope Mount"; //40000aab +char strEngTrackingRate[] = "Tracking Rate"; //40000abb +char strEngLanguage[] = "Language"; //40000ac9 +char strEngReset[] = "Reset"; //40000ad2 +char strEngScientificName[] = "Scientific Name"; //40000ad8 +char strEngSAOCatalog[] = "SAO Catalog"; //40000ae8 +char strEngHRCatalog[] = "HR Catalog"; //40000af4 +char strEngSelect[] = "Select"; //40000aff +char strEngAdd[] = "Add"; //40000b06 +char strEngDelete[] = "Delete"; //40000b0a +char strEngModify[] = "Modify"; //40000b11 +char Data_40000b18[] = "Select"; +char Data_40000b1f[] = "Add"; +char Data_40000b23[] = "Delete"; +char Data_40000b2a[] = "Setup"; +char Data_40000b30[] = "Start/Stop "; +char Data_40000b3c[] = "Setup"; +char Data_40000b42[] = "Open/Close"; +char strEngEyeshot[] = "Eyeshot"; //40000b4d +char strEngRatio[] = "Ratio"; //40000b55 +char strEngBackBoard[] = "BackBoard"; //40000b5b +char strEngAccessory[] = "Accessory"; //40000b65 +char strEngCountryAndCity[] = "Country & City"; //40000b6f +char strEngCustomSite[] = "Custom Site"; //40000b7e +char Data_40000b8a[7] = "Select"; +char Data_40000b91[4] = "Add"; +char Data_40000b95[7] = "Delete"; +char Data_40000b9c[7] = "Modify"; +char Data_40000ba3[7] = "Select"; +char Data_40000baa[4] = "Add"; +char Data_40000bae[7] = "Delete"; +char Data_40000bb5[7] = "Modify"; +char strEngStarSpeed[] = "Star Speed"; //40000bbc +char strEngSolarSpeed[] = "Solar Speed"; //40000bc7 +char strEngMoonSpeed[] = "Moon Speed"; //40000bd3 +char strEngCustomizeSpeed[] = "Customize Speed"; //40000bde +char strEngGuidingSpeed[] = "Guiding Speed"; //40000bee +char strEngListAlignStars[] = "List align stars: "; //40000bfc +char strEngSlewingTo[12] = "Slewing to "; //40000c14 +char strEngAutoloadAlignStars[] = "Autoload align stars"; //40000c20 +char Data_40000c35[] = " Please center this "; //40000c35 +char Data_40000c4b[] = "star to the field of"; //40000c4b +char Data_40000c60[] = "view "; //40000c60 +char Data_40000c7a[] = "The telescope has been"; //40000c7a +char Data_40000c92[] = "aligned! "; //40000c92 +char Data_40000ca6[] = " "; //40000ca6 +char strEngPleaseAimAtThe[] = " Please aim at the"; //40000cbe +char strEngTelescopeToDistant[] = "telescope to distant"; //40000cd3 +char strEngTargetThenPress[] = "target,then press "; //40000ce8 +char strEngEnterKey[] = "ENTER key!"; //40000cfb +char Data_40000d06[20] = "Press RIGHT or LEFT"; +char Data_40000d1a[21] = "key to start Ra(Azi)"; +char Data_40000d2f[21] = "backlash align,press"; +char Data_40000d44[21] = "ENTER key to finish!"; +char strEngBklashSlewing[] = "Slewing....."; //40000d59 +char strEngBklashAfterBeep[] = "After beep,turn tele"; //40000d66 +char strEngBklashBackToTarget[] = "-cope back to target"; //40000d7b +char strEngBklashPressEnter[] = "then press,ENTER!"; //40000d90 +char Data_40000da2[22] = "Positive backlash is:"; //40000da2 +char Data_40000db8[23] = "Negative backlash is: "; //40000db8 +char strEngBklashArcsecond[] = " arcsecond"; //40000dcf +char strEngMeanBklash[] = "The mean backlash is:"; //40000de3 +char Data_40000df9[17] = "press UP or DOWN"; +char Data_40000e0a[22] = "key to start Dec(Alt)"; +char Data_40000e20[1] = ""; +char strEngThereIsNoTele[23] = " There is no teles- "; //40000e21 +char strEngScopeToConnectThis[22] = "-cope to connect this"; //40000e38 +char strEngControlTerminal[20] = "control terminal!!!"; //40000e4e + +#if 0 + +//German +char strGerTelescopeAlign[32] = "A\x00u\x00s\x00r\x00i\x00c\x00h\x00t\x00u\x00n\x00g\x00"; //40000e62 +char strGerNavigation[32] = "N\x00a\x00v\x00i\x00g\x00a\x00t\x00i\x00o\x00n\x00"; +char Data_40000ea2[32] = "Z\x00u\x00b\x00e\x00h\x00ö\x00r\x00"; +char Data_40000ec2[32] = "E\x00i\x00n\x00s\x00t\x00e\x00l\x00l\x00u\x00n\x00g\x00e\x00n\x00"; +char Data_40000ee2[32] = "E\x00i\x00n\x00-\x00S\x00t\x00e\x00r\x00n\x00"; +char Data_40000f02[32] = "Z\x00w\x00e\x00i\x00-\x00S\x00t\x00e\x00r\x00n\x00"; +char Data_40000f22[32] = "D\x00r\x00e\x00i\x00-\x00S\x00t\x00e\x00r\x00n\x00"; +char Data_40000f42[32] = "S\x00y\x00n\x00c\x00h\x00r\x00o\x00n\x00i\x00s\x00a\x00t\x00i\x00o\x00n\x00"; +char Data_40000f62[32] = "A\x00b\x00w\x00.\x00 \x00P\x00o\x00l\x00a\x00c\x00h\x00s\x00e\x00"; +char Data_40000f82[32] = "R\x00A\x00 \x00S\x00p\x00i\x00e\x00l\x00a\x00u\x00s\x00g\x00l\x00.\x00"; +char Data_40000fa2[32] = "D\x00E\x00C\x00 \x00S\x00p\x00i\x00e\x00l\x00a\x00u\x00s\x00g\x00l\x00.\x00"; +char Data_40000fc2[32] = "S\x00o\x00n\x00n\x00e\x00n\x00s\x00y\x00s\x00t\x00e\x00m\x00"; +char Data_40000fe2[32] = "S\x00t\x00e\x00r\x00n\x00b\x00i\x00l\x00d\x00e\x00r\x00"; +char Data_40001002[32] = "H\x00e\x00l\x00l\x00e\x00 \x00S\x00t\x00e\x00r\x00n\x00e\x00"; +char Data_40001022[32] = "M\x00e\x00s\x00s\x00i\x00e\x00r\x00 \x00O\x00b\x00j\x00e\x00k\x00t\x00e\x00"; +char Data_40001042[32] = "N\x00G\x00C\x00 \x00O\x00b\x00j\x00e\x00k\x00t\x00e\x00"; +char Data_40001062[32] = "I\x00C\x00 \x00O\x00b\x00j\x00e\x00k\x00t\x00e\x00"; +char Data_40001082[32] = "S\x00h\x002\x00 \x00O\x00b\x00j\x00e\x00k\x00t\x00e\x00"; +char Data_400010a2[32] = "B\x00r\x00i\x00g\x00h\x00t\x00 \x00S\x00t\x00a\x00r\x00 \x00O\x00b\x00j\x00.\x00"; +char Data_400010c2[32] = "S\x00A\x00O\x00 \x00O\x00b\x00j\x00e\x00k\x00t\x00e\x00"; +char Data_400010e2[32] = "B\x00e\x00n\x00u\x00t\x00z\x00e\x00r\x00 \x00O\x00b\x00j\x00.\x00"; +char Data_40001102[32] = "E\x00i\x00n\x00g\x00a\x00b\x00e\x00 \x00K\x00o\x00o\x00r\x00d\x00i\x00n\x00.\x00"; +char Data_40001122[32] = "L\x00a\x00n\x00d\x00o\x00b\x00j\x00e\x00k\x00t\x00e\x00"; +char Data_40001142[32] = "A\x00k\x00t\x00u\x00e\x00l\x00l\x00e\x00 \x00E\x00r\x00e\x00i\x00g\x00n\x00.\x00"; +char Data_40001162[32] = "A\x00u\x00f\x00-\x00u\x00.\x00 \x00U\x00n\x00t\x00e\x00r\x00g\x00a\x00n\x00g\x00"; +char Data_40001182[32] = "M\x00o\x00n\x00d\x00p\x00h\x00a\x00s\x00e\x00"; +char Data_400011a2[32] = "Z\x00e\x00i\x00t\x00"; +char Data_400011c2[32] = "A\x00l\x00a\x00r\x00m\x00"; +char Data_400011e2[32] = "O\x00k\x00u\x00l\x00a\x00r\x00 \x00F\x00O\x00V\x00"; +char Data_40001202[32] = "O\x00k\x00u\x00l\x00a\x00r\x00 \x00V\x00e\x00r\x00g\x00r\x00.\x00"; +char Data_40001222[32] = "B\x00e\x00l\x00e\x00u\x00c\x00h\x00t\x00u\x00n\x00g\x00"; +char Data_40001242[32] = "T\x00e\x00l\x00e\x00s\x00k\x00o\x00p\x00 \x00p\x00a\x00r\x00k\x00e\x00n\x00"; +char Data_40001262[32] = "D\x00a\x00t\x00u\x00m\x00 \x00/\x00 \x00Z\x00e\x00i\x00t\x00"; +char Data_40001282[32] = "S\x00o\x00m\x00m\x00e\x00r\x00/\x00W\x00i\x00n\x00t\x00e\x00r\x00"; +char Data_400012a2[32] = "S\x00t\x00a\x00n\x00d\x00o\x00r\x00t\x00"; +char Data_400012c2[32] = "A\x00s\x00t\x00r\x00o\x00n\x00.\x00/\x00T\x00e\x00r\x00r\x00e\x00s\x00t\x00.\x00"; +char Data_400012e2[32] = "N\x00a\x00c\x00h\x00f\x00ü\x00h\x00r\x00m\x00o\x00d\x00u\x00s\x00"; +char Data_40001302[32] = "M\x00o\x00n\x00t\x00i\x00e\x00r\x00u\x00n\x00g\x00"; +char Data_40001322[32] = "N\x00a\x00c\x00h\x00f\x00ü\x00h\x00r\x00g\x00e\x00s\x00c\x00h\x00w\x00.\x00"; +char Data_40001342[32] = "S\x00p\x00r\x00a\x00c\x00h\x00e\x00"; +char strGerReset[32] = "R\x00e\x00s\x00e\x00t\x00"; + +//French +char strFreTelescopeAlign[32] = "A\x00l\x00i\x00g\x00n\x00e\x00m\x00e\x00n\x00t\x00"; +char strFreNavigation[32] = "O\x00b\x00j\x00e\x00t\x00s\x00"; //400013a2 +char strFreUtilities[32] = "U\x00t\x00i\x00l\x00i\x00t\x00é\x00s\x00"; //400013c2 +char strFreSetup[32] = "S\x00e\x00t\x00u\x00p\x00"; //400013e2 +char strFreOneStarAlign[32] = "A\x00l\x00i\x00g\x00n\x00.\x00 \x001\x00 \x00é\x00t\x00o\x00i\x00l\x00e\x00"; //40001402 +char strFreTwoStarAlign[32] = "A\x00l\x00i\x00g\x00n\x00.\x00 \x002\x00 \x00é\x00t\x00o\x00i\x00l\x00e\x00s\x00"; //40001422 +char strFreThreeStarAlign[32] = "A\x00l\x00i\x00g\x00n\x00.\x00 \x003\x00 \x00é\x00t\x00o\x00i\x00l\x00e\x00s\x00"; +char strFreTargetSync[32] = "S\x00y\x00n\x00c\x00h\x00r\x00.\x00 \x00C\x00i\x00b\x00l\x00e\x00"; //40001462 +char strFrePoleAxisDev[32] = "D\x00é\x00v\x00.\x00 \x00A\x00x\x00e\x00 \x00P\x00o\x00l\x00a\x00i\x00r\x00e\x00"; //40001482 +char strFreRaBklashCorr[32] = "C\x00o\x00r\x00r\x00.\x00 \x00B\x00a\x00c\x00k\x00l\x00.\x00 \x00R\x00A\x00"; //400014a2 +char strFreDecBklashCorr[32] = "C\x00o\x00r\x00r\x00.\x00 \x00B\x00a\x00c\x00k\x00l\x00.\x00 \x00D\x00E\x00C\x00"; //400014c2 +char strFreSolarSystem[32] = "S\x00y\x00s\x00t\x00è\x00m\x00e\x00 \x00S\x00o\x00l\x00a\x00i\x00r\x00e\x00"; //400014e2 +char strFreConstellation[32] = "C\x00o\x00n\x00s\x00t\x00e\x00l\x00l\x00a\x00t\x00i\x00o\x00n\x00s\x00"; //40001502 +char Data_40001522[32] = " "; //40001522 +char Data_40001542[32] = " "; +char Data_40001562[32] = " "; +char Data_40001582[32] = " "; +char Data_400015a2[32] = " "; +char Data_400015c2[32] = " "; +char Data_400015e2[32] = " "; +char Data_40001602[32] = " "; +char Data_40001622[32] = " "; +char Data_40001642[32] = " "; +char Data_40001662[32] = " "; +char Data_40001682[32] = " "; +char Data_400016a2[32] = " "; +char Data_400016c2[32] = " "; +char Data_400016e2[32] = " "; +char Data_40001702[32] = " "; +char Data_40001722[32] = " "; +char Data_40001742[32] = " "; +char Data_40001762[32] = " "; +char Data_40001782[32] = " "; +char Data_400017a2[32] = " "; +char Data_400017c2[32] = " "; +char Data_400017e2[32] = " "; +char Data_40001802[32] = " "; +char Data_40001822[32] = " "; +char Data_40001842[32] = " "; +char strFreLanguage[32] = "L\x00a\x00n\x00g\x00u\x00a\x00g\x00e\x00"; //40001862 +char strFreReset[32] = "R\x00e\x00s\x00e\x00t\x00"; + +//Italian +char strItaTelescopeAlign[32] = "A\x00l\x00l\x00i\x00n\x00e\x00a\x00m\x00e\x00n\x00t\x00o\x00 \x00"; +char Data_400018c2[32] = "N\x00a\x00v\x00i\x00g\x00a\x00z\x00i\x00o\x00n\x00e\x00"; +char Data_400018e2[32] = " "; +char Data_40001902[32] = " "; +char Data_40001922[32] = " "; +char Data_40001942[32] = " "; +char Data_40001962[32] = " "; +char Data_40001982[32] = " "; +char Data_400019a2[32] = " "; +char Data_400019c2[32] = " "; +char Data_400019e2[32] = " "; +char Data_40001a02[32] = " "; +char Data_40001a22[32] = " "; +char Data_40001a42[32] = " "; +char Data_40001a62[32] = " "; +char Data_40001a82[32] = " "; +char Data_40001aa2[32] = " "; +char Data_40001ac2[32] = " "; +char Data_40001ae2[32] = " "; +char Data_40001b02[32] = " "; +char Data_40001b22[32] = " "; +char Data_40001b42[32] = " "; +char Data_40001b62[32] = " "; +char Data_40001b82[32] = " "; +char Data_40001ba2[32] = " "; +char Data_40001bc2[32] = " "; +char Data_40001be2[32] = " "; +char Data_40001c02[32] = " "; +char Data_40001c22[32] = " "; +char Data_40001c42[32] = " "; +char Data_40001c62[32] = " "; +char Data_40001c82[32] = " "; +char Data_40001ca2[32] = " "; +char Data_40001cc2[32] = " "; +char Data_40001ce2[32] = " "; +char Data_40001d02[32] = "A\x00s\x00t\x00r\x00o\x00n\x00.\x00 \x00/\x00 \x00T\x00e\x00r\x00r\x00.\x00"; +char Data_40001d22[32] = "I\x00n\x00s\x00e\x00g\x00u\x00i\x00m\x00e\x00n\x00t\x00o\x00"; +char Data_40001d42[32] = "M\x00o\x00n\x00t\x00a\x00t\x00u\x00r\x00a\x00"; +char Data_40001d62[32] = "V\x00e\x00l\x00o\x00c\x00i\x00t\x00á\x00"; +char Data_40001d82[32] = "I\x00d\x00i\x00o\x00m\x00a\x00"; +char Data_40001da2[32] = "A\x00z\x00z\x00e\x00r\x00a\x00r\x00e\x00"; + +//Spanish +char strSpaTelescopeAlign[32] = "A\x00l\x00i\x00n\x00e\x00a\x00m\x00i\x00e\x00n\x00t\x00o\x00"; +char Data_40001de2[32] = "N\x00a\x00v\x00e\x00g\x00a\x00c\x00i\x00ó\x00n\x00"; +char Data_40001e02[32] = "A\x00c\x00c\x00e\x00s\x00o\x00r\x00i\x00o\x00s\x00"; +char Data_40001e22[32] = "I\x00n\x00s\x00t\x00a\x00l\x00a\x00c\x00i\x00ò\x00n\x00"; +char Data_40001e42[32] = " "; +char Data_40001e62[32] = " "; +char Data_40001e82[32] = " "; +char Data_40001ea2[32] = " "; +char Data_40001ec2[32] = " "; +char Data_40001ee2[32] = " "; +char Data_40001f02[32] = " "; +char Data_40001f22[32] = " "; +char Data_40001f42[32] = " "; +char Data_40001f62[32] = " "; +char Data_40001f82[32] = " "; +char Data_40001fa2[32] = " "; +char Data_40001fc2[32] = " "; +char Data_40001fe2[32] = " "; +char Data_40002002[32] = " "; +char Data_40002022[32] = " "; +char Data_40002042[32] = " "; +char Data_40002062[32] = " "; +char Data_40002082[32] = " "; +char Data_400020a2[32] = " "; +char Data_400020c2[32] = " "; +char Data_400020e2[32] = " "; +char Data_40002102[32] = " "; +char Data_40002122[32] = " "; +char Data_40002142[32] = " "; +char Data_40002162[32] = " "; +char Data_40002182[32] = " "; +char Data_400021a2[32] = " "; +char Data_400021c2[32] = " "; +char Data_400021e2[32] = " "; +char Data_40002202[32] = " "; +char Data_40002222[32] = " "; +char Data_40002242[32] = " "; +char strSpaTelescopeMount[32] = "M\x00o\x00n\x00t\x00u\x00r\x00a\x00"; +char Data_40002282[32] = "V\x00e\x00l\x00o\x00.\x00d\x00e\x00 \x00s\x00e\x00g\x00u\x00i\x00m\x00.\x00\x00\x00"; +char Data_400022a2[32] = "I\x00d\x00i\x00o\x00m\x00a\x00"; +char Data_400022c2[48] = "R\x00e\x00i\x00n\x00i\x00c\x00i\x00a\x00r\x00"; + +#endif + +//Misc +char strCustomerObjectRaAziInputForTracking[16] = "R.a: 12h32m48.2s"; //400022f2 +char Data_40002302[16] = "Dec:+14 26 53.3 "; //40002302 +char fill_40002312[117] = " "; //40002312 +char strEngTelescopeOneMX51[19] = "Telescope one:MX51"; //40002387 +char Data_4000239a[] = "Scope:3'.3'"; //4000239a +char Data_400023a6[206] = " "; //400023a6, size??? +char Data_40002474[13] = " MF:1893mm"; //40002474 +char Data_40002481[11] = " SF:43mm"; //40002481 +char Data_4000248c[21] = " "; //4000248c +char strEyepieceMagnCaption[20] = "Eyep. focal length:"; //400024a1 +char strEyepieceFovCaption[20] = "Eyep. focal length:"; //400024b5 +char strEyepieceFovMfInput[13] = " MF:1893mm"; //400024c9 +char strEyepieceFovSfInput[11] = " SF:43mm"; //400024d6 +char strEyepieceFovInput[14] = "E-FOV:001 00 "; //400024e1 +char strEyepieceMagnification[21] = " "; //400024ef +char strEyepieceFOV[25] = " FOV:0.02272 "; //40002504 +unsigned char Data_4000251d[32] = "\xC3\xFB\xB3\xC6: kunming "; //4000251d +unsigned char Data_4000253d[32] = "\xB7\xBD\xCE\xBB\xA3\xBA180d00m00s "; //4000253d +unsigned char Data_4000255d[33] = "\xB8\xDF\xB6\xC8\xA3\xBA50d00m00s "; //4000255d +unsigned char Data_4000257e[] = "LName:Kunming"; //4000257e +unsigned char Data_4000258c[] = "LAzmu:180d00m00s "; //4000258c +unsigned char Data_400025a0[21] = "LAlti:50d00m00s "; //400025a0 +unsigned char Data_400025b5[36] = "\xC3\xFB\xB3\xC6\xA3\xBAkunming "; //400025b5 +unsigned char Data_400025d9[37] = "\xB3\xE0\xBE\xAD\xA3\xBA00h00m00s "; //400025d9 +unsigned char Data_400025fe[39] = "\xB3\xE0\xCE\xB3\xA3\xBA+00h00m00s "; //400025fe +unsigned char Data_40002625[] = "SName:kunming "; //40002625 +unsigned char Data_40002634[] = "SOR.a:00h00m00s"; //40002634 +unsigned char Data_40002644[] = "SODec:+00h00m00s"; //40002644 +char Data_40002655[] = "2012-01-01"; //40002655, size??? +char Data_40002660[99] = "00:00:00"; //40002660, size??? +unsigned char Data_400026c3[24] = "\xC3\xFB\xB3\xC6\xA3\xBAKunMing "; //400026c3 +unsigned char Data_400026db[24] = "\xBE\xAD\xB6\xC8\xA3\xBAE102d35f "; //400026db +unsigned char Data_400026f3[23] = "\xCE\xB3\xB6\xC8\xA3\xBAN25d35f "; //400026f3 +unsigned char Data_4000270a[16] = "\xCA\xB1\xC7\xF8\xA3\xBAE08 "; //4000270a +unsigned char Data_4000271a[18] = "\xBA\xA3\xB0\xCE\xA3\xBA1880m "; //4000271a +char Data_4000272c[15] = "\xCE\xC2\xB6\xC8:+25C "; //4000272c +char Data_4000273b[15] = "\xCA\xAA\xB6\xC8:82RH "; //4000273b +char Data_4000274a[19] = "\xC6\xF8\xD1\xB9:0680Pa "; //4000274a +char fill_4000275d[44] = " "; //4000275d +unsigned char Data_40002789[] = "Azi:000d"; //40002789 +unsigned char Data_40002792[] = "Alt:000d"; //40002792 +unsigned char Data_4000279b[52] = " "; //4000279b, size?? +char strInputRaDec[16] = "Input Ra Dec:"; //400027cf +unsigned char strCustomerObjectRaAziInputForStoring[16] = "R.a: 12h32m48.2s"; //400027df +unsigned char strCustomerObjectDecAltInputForStoring[16] = "Dec:+14d26m53.3s"; //400027ef +unsigned char strCustomerObjectNameInput[40] = " "; //400027ff +unsigned char strCustomSiteName[16] = " Name:"; //40002827 size??? +unsigned char strCustomSiteLongitude[16] = " Lon:E23014d56f"; //40002837 size?? +unsigned char strCustomSiteLatitude[15] = " Lat:E23014d56"; //40002847 size?? +unsigned char strCustomSiteTimezone[11] = " Zone:E2277"; //40002856 size??? +unsigned char strCustomSiteAltitude[] = "\x00tAlt:1880m "; //40002861 +char Data_4000286e[] = "Tmpt:+25C"; //4000286e +char Data_40002878[] = "Hmdt:82RH"; //40002878 +char Data_40002882[] = "APrs:0680Pa"; //40002882 +char strSkyTarget[11] = "Sky Target"; //4000288e +char strLandTarget[12] = "Land Target"; //40002899, size??? +char Data_400028a5[14] = "Alt Telescope"; //400028a5 +char Data_400028b3[14] = "Equ Telescope"; //400028b3, size??? +char strEngPleaseSetupOtaZero[22] = "Please setup OTA zero"; //400028c1 +unsigned char Data_400028d7[10] = "Azi:000d "; //400028d7 +unsigned char Data_400028e1[10] = "Alt: 00d "; //400028e1 +char Data_400028eb[22] = "Data:error,try again!"; //400028eb +char Data_40002901[] = "ok,poweroff,restart!"; //40002901 +char strEngEnglish[] = "English"; //40002916 +char strEngGerman[] = "German"; //4000291e +char strEngFrench[] = "French"; //40002925 +char strEngItalian[] = "Italian"; //4000292c +char strEngSpanish[22] = "Spanish"; //40002934, size?? +char Data_4000294a[87] = " "; //4000294a, content, size? +char strEngSetTimer[11] = "Set timer:"; //400029a1 +char strEng00000s[7] = "00000s"; //400029ac +char Data_400029b3[] = ""; //400029b3 +char strEngStartBack[22] = " Start Back"; //400029b4 +char strEngCountingDown[16] = "Counting down: "; //400029ca +char strEngTimeRemain[13] = "Time remain:"; //400029da +char strEngTimeRemain00000s[7] = "00000s"; //400029e7 +char strEngStopBack[81] = " Stop Back"; //400029ee, size??? +char Data_40002a3f[] = "21h34m23s"; //40002a3f +char fill_40002A49[25] = " "; //40002A49 +char strEngCloseAlarm[15] = "Close Alarm?"; //40002a62 +char strEngAlarmCloseBack[22] = " Close Back"; //40002a71 +char strEngInputTime[13] = "Input time: "; //40002a87 +char strEngAlarm21h34m23s[10] = "21h34m23s"; //40002a94 +char strEngAlarmOnBack[45] = " On Back"; //40002a9e, size??? +char strEngBackgroundLight[17] = "Background light"; //40002acb +char strEngPressUpDownKey[18] = "Press up/down key"; //40002adc +char Data_40002aee[] = ""; //40002aee +char Data_40002aef[] = ""; //40002aef +char Data_40002af0[25] = " "; //40002af0 +char Data_40002b09[] = "Battery alarm"; //40002b09 +char Data_40002b17[12] = "status:on"; //40002b17 +char fill_40002b23[25] = " "; //40002b23 +char Data_40002b3c[] = "Battery alarm"; //40002b3c +char Data_40002b4a[13] = "status:off"; //40002b4a +char fill_40002b57[25] = " "; //40002b57 +char Data_40002b70[16] = "daylight saving"; //40002b70 +char Data_40002b80[10] = "status:on"; //40002b80 +char Data_40002b8a[] = ""; //40002b8a +char Data_40002b8b[] = ""; //40002b8b +char Data_40002b8c[25] = " "; //40002b8c +char Data_40002ba5[16] = "Daylight saving"; //40002ba5 +char Data_40002bb5[11] = "status:off"; //40002bb5 +char Data_40002bc0[] = ""; //40002bc0 +char Data_40002bc1[] = ""; //40002bc1 +int Data_40002bc4_DayYear[13] = +{ + -1, -1, 30, 58, 89, 119, 150, 180, 211, 241, 272, 303, 333 +}; //40002bc4 + + +/* 2575c - todo */ +void SwapLanguageStrings(void) +{ + switch (bData_40003196_CurrentLanguage) + { + default: + //case MENU_LANGUAGE_ENGLISH: //1: + //0x25788 + strTelescopeAlign = strEngTelescopeAlign; + strNavigation = strEngNavigation; + strUtilities = strEngUtilities; + strSetup = strEngSetup; + strOneStarAlign = strEngOneStarAlign; + strTwoStarAlign = strEngTwoStarAlign; + strThreeStarAlign = strEngThreeStarAlign; + strTargetSync = strEngTargetSync; + strPoleAxisDev = strEngPoleAxisDev; + strRaBklashCorr = strEngRaBklashCorr; + strDecBklashCorr = strEngDecBklashCorr; + Data_40002f4c = " "; + + strSolarSystem = strEngSolarSystem; + strConstellation = strEngConstellation; + strFamousStar = strEngFamousStar; + Data_40002f68 = strEngMessierCatal; + Data_40002f6c = strEngNGCCatalog; + Data_40002f70 = strEngICCatalogue; + Data_40002f74 = strEngSh2Catalog; + Data_40002f78 = strEngBrightStarCat; + Data_40002f7c = strEngSAOStarCatal; + Data_40002f80 = strEngCustomerObjects; + Data_40002f84 = strEngInputRAandDEC; + Data_40002f88 = strEngCustomLandGoal; + + strCurrentObjects = strEngCurrentObjects; + Data_40002f90 = strEngObjectRiseSet; + Data_40002f94 = strEngCurrLunarPhase; + Data_40002f98 = strEngTimer; + Data_40002f9c = strEngAlarm; + Data_40002fa0 = strEngEyepieceFOV; + Data_40002fa4 = strEngEyepieceMagn; + Data_40002fa8 = strEngDisplayIllumin; + strParkposition = strEngParkposition; + + strTimeAndDate = strEngTimeAndDate; + Data_40002fb8 = strEngDaylightSaving; + Data_40002fbc = strEngSiteSetting; + Data_40002fc0 = strEngSkyLand; + Data_40002fc4 = strEngAzEqu; + strTelescopeMount = strEngTelescopeMount; + strTrackingRate = strEngTrackingRate; + Data_40002fd0 = strEngLanguage; + strReset = strEngReset; + + strScientificName = strEngScientificName; + strSAOCatalog = strEngSAOCatalog; + strHRCatalog = strEngHRCatalog; + strSelect = strEngSelect; + strAdd = strEngAdd; + strDelete = strEngDelete; + strModify = strEngModify; + Data_40003044 = Data_40000b18; + Data_40003048 = Data_40000b1f; + Data_4000304c = Data_40000b23; + strEyeshot = strEngEyeshot; + strRatio = strEngRatio; + strBackBoard = strEngBackBoard; + strAccessory = strEngAccessory; + strCountryAndCity = strEngCountryAndCity; + strCustomSite = strEngCustomSite; + Data_40003068 = Data_40000b8a; + Data_4000306c = Data_40000b91; + Data_40003070 = Data_40000b95; + Data_40003074 = Data_40000b9c; + Data_40003078 = Data_40000ba3; + Data_4000307c = Data_40000baa; + Data_40003080 = Data_40000bae; + Data_40003084 = Data_40000bb5; + strStarSpeed = strEngStarSpeed; + strSolarSpeed = strEngSolarSpeed; + strMoonSpeed = strEngMoonSpeed; + Data_40003094 = strEngCustomizeSpeed; + Data_40003098 = strEngGuidingSpeed; + strListAlignStars = strEngListAlignStars; + strSlewingTo = strEngSlewingTo; + strAutoloadAlignStars = strEngAutoloadAlignStars; + Data_400030a8 = Data_40000c35; + Data_400030ac = Data_40000c4b; + Data_400030b0 = Data_40000c60; + Data_400030b4 = Data_40000c7a; + Data_400030b8 = Data_40000c92; + Data_400030bc = Data_40000ca6; + + strPleaseAimAtThe = strEngPleaseAimAtThe; + strTelescopeToDistant = strEngTelescopeToDistant; + strTargetThenPress = strEngTargetThenPress; + strEnterKey = strEngEnterKey; + Data_400030dc = Data_40000d06; + Data_400030e0 = Data_40000d1a; + Data_400030e4 = Data_40000d2f; + Data_400030e8 = Data_40000d44; + Data_400030ec = strEngBklashSlewing; + Data_400030f0 = strEngBklashAfterBeep; + Data_400030f4 = strEngBklashBackToTarget; + Data_400030f8 = strEngBklashPressEnter; + Data_400030fc = Data_40000da2; + Data_40003100 = Data_40000db8; + Data_40003104 = strEngBklashArcsecond; + Data_40003108 = strEngMeanBklash; + Data_4000310c = Data_40000df9; + Data_40003110 = Data_40000e0a; + Data_40003114 = Data_40000e20; + + strThereIsNoTele = strEngThereIsNoTele; + strScopeToConnectThis = strEngScopeToConnectThis; + strControlTerminal = strEngControlTerminal; + //25df4 ->0x2783c + break; + +#if 0 + case MENU_LANGUAGE_GERMAN: //2: + //0x26010 + strTelescopeAlign = strGerTelescopeAlign; + strNavigation = strGerNavigation; + strUtilities = Data_40000ea2; + strSetup = Data_40000ec2; + strOneStarAlign = Data_40000ee2; + strTwoStarAlign = Data_40000f02; + strThreeStarAlign = Data_40000f22; + strTargetSync = Data_40000f42; + strPoleAxisDev = Data_40000f62; + strRaBklashCorr = Data_40000f82; + strDecBklashCorr = Data_40000fa2; + + strSolarSystem = Data_40000fc2; + strConstellation = Data_40000fe2; + strFamousStar = Data_40001002; + Data_40002f68 = Data_40001022; + Data_40002f6c = Data_40001042; + Data_40002f70 = Data_40001062; + Data_40002f74 = Data_40001082; + Data_40002f78 = Data_400010a2; + Data_40002f7c = Data_400010c2; + Data_40002f80 = Data_400010e2; + Data_40002f84 = Data_40001102; + Data_40002f88 = Data_40001122; + strCurrentObjects = Data_40001142; + Data_40002f90 = Data_40001162; + Data_40002f94 = Data_40001182; + Data_40002f98 = Data_400011a2; + Data_40002f9c = Data_400011c2; + Data_40002fa0 = Data_400011e2; + Data_40002fa4 = Data_40001202; + Data_40002fa8 = Data_40001222; + strParkposition = Data_40001242; + + strTimeAndDate = Data_40001262; + Data_40002fb8 = Data_40001282; + Data_40002fbc = Data_400012a2; + Data_40002fc0 = Data_400012c2; + Data_40002fc4 = Data_400012e2; + strTelescopeMount = Data_40001302; + strTrackingRate = Data_40001322; + Data_40002fd0 = Data_40001342; + strReset = strGerReset; + + strScientificName = strEngScientificName; + strSAOCatalog = strEngSAOCatalog; + strHRCatalog = strEngHRCatalog; + strSelect = strEngSelect; + strAdd = strEngAdd; + strDelete = strEngDelete; + strModify = strEngModify; + Data_40003044 = Data_40000b18; + Data_40003048 = Data_40000b1f; + Data_4000304c = Data_40000b23; + strEyeshot = strEngEyeshot; + strRatio = strEngRatio; + strBackBoard = strEngBackBoard; + strAccessory = strEngAccessory; + strCountryAndCity = strEngCountryAndCity; + strCustomSite = strEngCustomSite; + Data_40003068 = Data_40000b8a; + Data_4000306c = Data_40000b91; + Data_40003070 = Data_40000b95; + Data_40003074 = Data_40000b9c; + Data_40003078 = Data_40000ba3; + Data_4000307c = Data_40000baa; + Data_40003080 = Data_40000bae; + Data_40003084 = Data_40000bb5; + strStarSpeed = strEngStarSpeed; + strSolarSpeed = strEngSolarSpeed; + strMoonSpeed = strEngMoonSpeed; + Data_40003094 = strEngCustomizeSpeed; + Data_40003098 = strEngGuidingSpeed; + strListAlignStars = strEngListAlignStars; + strSlewingTo = strEngSlewingTo; + strAutoloadAlignStars = strEngAutoloadAlignStars; + Data_400030a8 = Data_40000c35; + Data_400030ac = Data_40000c4b; + Data_400030b0 = Data_40000c60; + Data_400030b4 = Data_40000c7a; + Data_400030b8 = Data_40000c92; + Data_400030bc = Data_40000ca6; + + strPleaseAimAtThe = strEngPleaseAimAtThe; + strTelescopeToDistant = strEngTelescopeToDistant; + strTargetThenPress = strEngTargetThenPress; + strEnterKey = strEngEnterKey; + Data_400030dc = Data_40000d06; + Data_400030e0 = Data_40000d1a; + Data_400030e4 = Data_40000d2f; + Data_400030e8 = Data_40000d44; + Data_400030ec = strEngBklashSlewing; + Data_400030f0 = strEngBklashAfterBeep; + Data_400030f4 = strEngBklashBackToTarget; + Data_400030f8 = strEngBklashPressEnter; + Data_400030fc = Data_40000da2; + Data_40003100 = Data_40000db8; + Data_40003104 = strEngBklashArcsecond; + Data_40003108 = strEngMeanBklash; + Data_4000310c = Data_40000df9; + Data_40003110 = Data_40000e0a; + Data_40003114 = Data_40000e20; + + strThereIsNoTele = strEngThereIsNoTele; + strScopeToConnectThis = strEngScopeToConnectThis; + strControlTerminal = strEngControlTerminal; + //264d0 ->0x2783c + break; + + case MENU_LANGUAGE_FRENCH: //3: + //0x264d4 + strTelescopeAlign = strFreTelescopeAlign; + strNavigation = strFreNavigation; + strUtilities = strFreUtilities; + strSetup = strFreSetup; + strOneStarAlign = strFreOneStarAlign; + strTwoStarAlign = strFreTwoStarAlign; + strThreeStarAlign = strFreThreeStarAlign; + strTargetSync = strFreTargetSync; + strPoleAxisDev = strFrePoleAxisDev; + strRaBklashCorr = strFreRaBklashCorr; + strDecBklashCorr = strFreDecBklashCorr; + + strSolarSystem = strFreSolarSystem; + strConstellation = strFreConstellation; + strFamousStar = Data_40001522; + Data_40002f68 = Data_40001542; + Data_40002f6c = Data_40001562; + Data_40002f70 = Data_40001582; + Data_40002f74 = Data_400015a2; + Data_40002f78 = Data_400015c2; + Data_40002f7c = Data_400015e2; + Data_40002f80 = Data_40001602; + Data_40002f84 = Data_40001622; + Data_40002f88 = Data_40001642; + strCurrentObjects = Data_40001662; + Data_40002f90 = Data_40001682; + Data_40002f94 = Data_400016a2; + Data_40002f98 = Data_400016c2; + Data_40002f9c = Data_400016e2; + Data_40002fa0 = Data_40001702; + Data_40002fa4 = Data_40001722; + Data_40002fa8 = Data_40001742; + strParkposition = Data_40001762; + strTimeAndDate = Data_40001782; + Data_40002fb8 = Data_400017a2; + Data_40002fbc = Data_400017c2; + Data_40002fc0 = Data_400017e2; + Data_40002fc4 = Data_40001802; + strTelescopeMount = Data_40001822; + strTrackingRate = Data_40001842; + Data_40002fd0 = strFreLanguage; + strReset = strFreReset; + + strScientificName = strEngScientificName; + strSAOCatalog = strEngSAOCatalog; + strHRCatalog = strEngHRCatalog; + strSelect = strEngSelect; + strAdd = strEngAdd; + strDelete = strEngDelete; + strModify = strEngModify; + Data_40003044 = Data_40000b18; + Data_40003048 = Data_40000b1f; + Data_4000304c = Data_40000b23; + strEyeshot = strEngEyeshot; + strRatio = strEngRatio; + strBackBoard = strEngBackBoard; + strAccessory = strEngAccessory; + strCountryAndCity = strEngCountryAndCity; + strCustomSite = strEngCustomSite; + Data_40003068 = Data_40000b8a; + Data_4000306c = Data_40000b91; + Data_40003070 = Data_40000b95; + Data_40003074 = Data_40000b9c; + Data_40003078 = Data_40000ba3; + Data_4000307c = Data_40000baa; + Data_40003080 = Data_40000bae; + Data_40003084 = Data_40000bb5; + strStarSpeed = strEngStarSpeed; + strSolarSpeed = strEngSolarSpeed; + strMoonSpeed = strEngMoonSpeed; + Data_40003094 = strEngCustomizeSpeed; + Data_40003098 = strEngGuidingSpeed; + strListAlignStars = strEngListAlignStars; + strSlewingTo = strEngSlewingTo; + strAutoloadAlignStars = strEngAutoloadAlignStars; + Data_400030a8 = Data_40000c35; + Data_400030ac = Data_40000c4b; + Data_400030b0 = Data_40000c60; + Data_400030b4 = Data_40000c7a; + Data_400030b8 = Data_40000c92; + Data_400030bc = Data_40000ca6; + + strPleaseAimAtThe = strEngPleaseAimAtThe; + strTelescopeToDistant = strEngTelescopeToDistant; + strTargetThenPress = strEngTargetThenPress; + strEnterKey = strEngEnterKey; + Data_400030dc = Data_40000d06; + Data_400030e0 = Data_40000d1a; + Data_400030e4 = Data_40000d2f; + Data_400030e8 = Data_40000d44; + Data_400030ec = strEngBklashSlewing; + Data_400030f0 = strEngBklashAfterBeep; + Data_400030f4 = strEngBklashBackToTarget; + Data_400030f8 = strEngBklashPressEnter; + Data_400030fc = Data_40000da2; + Data_40003100 = Data_40000db8; + Data_40003104 = strEngBklashArcsecond; + Data_40003108 = strEngMeanBklash; + Data_4000310c = Data_40000df9; + Data_40003110 = Data_40000e0a; + Data_40003114 = Data_40000e20; + + strThereIsNoTele = strEngThereIsNoTele; + strScopeToConnectThis = strEngScopeToConnectThis; + strControlTerminal = strEngControlTerminal; + //26994 ->0x2783c + break; + + case MENU_LANGUAGE_ITALIAN: //4: + //0x26ae0 + strTelescopeAlign = strItaTelescopeAlign; + strNavigation = Data_400018c2; + strUtilities = Data_400018e2; + strSetup = Data_40001902; + strOneStarAlign = Data_40001922; + strTwoStarAlign = Data_40001942; + strThreeStarAlign = Data_40001962; + strTargetSync = Data_40001982; + strPoleAxisDev = Data_400019a2; + strRaBklashCorr = Data_400019c2; + strDecBklashCorr = Data_400019e2; + + strSolarSystem = Data_40001a02; + strConstellation = Data_40001a22; + strFamousStar = Data_40001a42; + Data_40002f68 = Data_40001a62; + Data_40002f6c = Data_40001a82; + Data_40002f70 = Data_40001aa2; + Data_40002f74 = Data_40001ac2; + Data_40002f78 = Data_40001ae2; + Data_40002f7c = Data_40001b02; + Data_40002f80 = Data_40001b22; + Data_40002f84 = Data_40001b42; + Data_40002f88 = Data_40001b62; + strCurrentObjects = Data_40001b82; + Data_40002f90 = Data_40001ba2; + Data_40002f94 = Data_40001bc2; + Data_40002f98 = Data_40001be2; + Data_40002f9c = Data_40001c02; + Data_40002fa0 = Data_40001c22; + Data_40002fa4 = Data_40001c42; + Data_40002fa8 = Data_40001c62; + strParkposition = Data_40001c82; + strTimeAndDate = Data_40001ca2; + Data_40002fb8 = Data_40001cc2; + Data_40002fbc = Data_40001ce2; + Data_40002fc0 = Data_40001d02; + Data_40002fc4 = Data_40001d22; + strTelescopeMount = Data_40001d42; + strTrackingRate = Data_40001d62; + Data_40002fd0 = Data_40001d82; + strReset = Data_40001da2; + + strScientificName = strEngScientificName; + strSAOCatalog = strEngSAOCatalog; + strHRCatalog = strEngHRCatalog; + strSelect = strEngSelect; + strAdd = strEngAdd; + strDelete = strEngDelete; + strModify = strEngModify; + Data_40003044 = Data_40000b18; + Data_40003048 = Data_40000b1f; + Data_4000304c = Data_40000b23; + strEyeshot = strEngEyeshot; + strRatio = strEngRatio; + strBackBoard = strEngBackBoard; + strAccessory = strEngAccessory; + strCountryAndCity = strEngCountryAndCity; + strCustomSite = strEngCustomSite; + Data_40003068 = Data_40000b8a; + Data_4000306c = Data_40000b91; + Data_40003070 = Data_40000b95; + Data_40003074 = Data_40000b9c; + Data_40003078 = Data_40000ba3; + Data_4000307c = Data_40000baa; + Data_40003080 = Data_40000bae; + Data_40003084 = Data_40000bb5; + strStarSpeed = strEngStarSpeed; + strSolarSpeed = strEngSolarSpeed; + strMoonSpeed = strEngMoonSpeed; + Data_40003094 = strEngCustomizeSpeed; + Data_40003098 = strEngGuidingSpeed; + strListAlignStars = strEngListAlignStars; + strSlewingTo = strEngSlewingTo; + strAutoloadAlignStars = strEngAutoloadAlignStars; + Data_400030a8 = Data_40000c35; + Data_400030ac = Data_40000c4b; + Data_400030b0 = Data_40000c60; + Data_400030b4 = Data_40000c7a; + Data_400030b8 = Data_40000c92; + Data_400030bc = Data_40000ca6; + + strPleaseAimAtThe = strEngPleaseAimAtThe; + strTelescopeToDistant = strEngTelescopeToDistant; + strTargetThenPress = strEngTargetThenPress; + strEnterKey = strEngEnterKey; + Data_400030dc = Data_40000d06; + Data_400030e0 = Data_40000d1a; + Data_400030e4 = Data_40000d2f; + Data_400030e8 = Data_40000d44; + Data_400030ec = strEngBklashSlewing; + Data_400030f0 = strEngBklashAfterBeep; + Data_400030f4 = strEngBklashBackToTarget; + Data_400030f8 = strEngBklashPressEnter; + Data_400030fc = Data_40000da2; + Data_40003100 = Data_40000db8; + Data_40003104 = strEngBklashArcsecond; + Data_40003108 = strEngMeanBklash; + Data_4000310c = Data_40000df9; + Data_40003110 = Data_40000e0a; + Data_40003114 = Data_40000e20; + + strThereIsNoTele = strEngThereIsNoTele; + strScopeToConnectThis = strEngScopeToConnectThis; + strControlTerminal = strEngControlTerminal; + //26fa0 ->0x2783c + break; + + case MENU_LANGUAGE_SPANISH: //5: + //0x270d0 + strTelescopeAlign = strSpaTelescopeAlign; + strNavigation = Data_40001de2; + strUtilities = Data_40001e02; + strSetup = Data_40001e22; + strOneStarAlign = Data_40001e42; + strTwoStarAlign = Data_40001e62; + strThreeStarAlign = Data_40001e82; + strTargetSync = Data_40001ea2; + strPoleAxisDev = Data_40001ec2; + strRaBklashCorr = Data_40001ee2; + strDecBklashCorr = Data_40001f02; + + strSolarSystem = Data_40001f22; + strConstellation = Data_40001f42; + strFamousStar = Data_40001f62; + Data_40002f68 = Data_40001f82; + Data_40002f6c = Data_40001fa2; + Data_40002f70 = Data_40001fc2; + Data_40002f74 = Data_40001fe2; + Data_40002f78 = Data_40002002; + Data_40002f7c = Data_40002022; + Data_40002f80 = Data_40002042; + Data_40002f84 = Data_40002062; + Data_40002f88 = Data_40002082; + strCurrentObjects = Data_400020a2; + Data_40002f90 = Data_400020c2; + Data_40002f94 = Data_400020e2; + Data_40002f98 = Data_40002102; + Data_40002f9c = Data_40002122; + Data_40002fa0 = Data_40002142; + Data_40002fa4 = Data_40002162; + Data_40002fa8 = Data_40002182; + strParkposition = Data_400021a2; + strTimeAndDate = Data_400021c2; + Data_40002fb8 = Data_400021e2; + Data_40002fbc = Data_40002202; + Data_40002fc0 = Data_40002222; + Data_40002fc4 = Data_40002242; + strTelescopeMount = strSpaTelescopeMount; + strTrackingRate = Data_40002282; + Data_40002fd0 = Data_400022a2; + strReset = Data_400022c2; + + strScientificName = strEngScientificName; + strSAOCatalog = strEngSAOCatalog; + strHRCatalog = strEngHRCatalog; + strSelect = strEngSelect; + strAdd = strEngAdd; + strDelete = strEngDelete; + strModify = strEngModify; + Data_40003044 = Data_40000b18; + Data_40003048 = Data_40000b1f; + Data_4000304c = Data_40000b23; + strEyeshot = strEngEyeshot; + strRatio = strEngRatio; + strBackBoard = strEngBackBoard; + strAccessory = strEngAccessory; + strCountryAndCity = strEngCountryAndCity; + strCustomSite = strEngCustomSite; + Data_40003068 = Data_40000b8a; + Data_4000306c = Data_40000b91; + Data_40003070 = Data_40000b95; + Data_40003074 = Data_40000b9c; + Data_40003078 = Data_40000ba3; + Data_4000307c = Data_40000baa; + Data_40003080 = Data_40000bae; + Data_40003084 = Data_40000bb5; + strStarSpeed = strEngStarSpeed; + strSolarSpeed = strEngSolarSpeed; + strMoonSpeed = strEngMoonSpeed; + Data_40003094 = strEngCustomizeSpeed; + Data_40003098 = strEngGuidingSpeed; + strListAlignStars = strEngListAlignStars; + strSlewingTo = strEngSlewingTo; + strAutoloadAlignStars = strEngAutoloadAlignStars; + Data_400030a8 = Data_40000c35; + Data_400030ac = Data_40000c4b; + Data_400030b0 = Data_40000c60; + Data_400030b4 = Data_40000c7a; + Data_400030b8 = Data_40000c92; + Data_400030bc = Data_40000ca6; + + strPleaseAimAtThe = strEngPleaseAimAtThe; + strTelescopeToDistant = strEngTelescopeToDistant; + strTargetThenPress = strEngTargetThenPress; + strEnterKey = strEngEnterKey; + Data_400030dc = Data_40000d06; + Data_400030e0 = Data_40000d1a; + Data_400030e4 = Data_40000d2f; + Data_400030e8 = Data_40000d44; + Data_400030ec = strEngBklashSlewing; + Data_400030f0 = strEngBklashAfterBeep; + Data_400030f4 = strEngBklashBackToTarget; + Data_400030f8 = strEngBklashPressEnter; + Data_400030fc = Data_40000da2; + Data_40003100 = Data_40000db8; + Data_40003104 = strEngBklashArcsecond; + Data_40003108 = strEngMeanBklash; + Data_4000310c = Data_40000df9; + Data_40003110 = Data_40000e0a; + Data_40003114 = Data_40000e20; + + strThereIsNoTele = strEngThereIsNoTele; + strScopeToConnectThis = strEngScopeToConnectThis; + strControlTerminal = strEngControlTerminal; + //27590 ->0x2783c + break; + + default: + //0x27834 + break; +#endif + } +} + diff --git a/applications/freertos_app/macros.h b/applications/freertos_app/macros.h new file mode 100644 index 0000000..02d3215 --- /dev/null +++ b/applications/freertos_app/macros.h @@ -0,0 +1,10 @@ + + +#define DEGREES_MINUTES_ABS(a) \ + abs((int)a), abs((int)((a - (int)a) * 60)) + + +#define DEGREES_MINUTES(a) \ + ((int)a), ((int)((a - (int)a) * 60)) + + diff --git a/applications/freertos_app/main.c b/applications/freertos_app/main.c new file mode 100644 index 0000000..8404e74 --- /dev/null +++ b/applications/freertos_app/main.c @@ -0,0 +1,5678 @@ + +#if 0 +#include +#include +#include +#include +#include "my_types.h" +#include "data.h" +#include "menu.h" +#endif + +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" + +//#define UART0_DEBUG +#define V2_3 + +extern void uart0_send(unsigned char* a, unsigned char b); + +#include "file_1f30.c" + +/* 4ede4 - todo */ +void HandleStarKey(void) +{ + switch (bData_40003195) + { + case 0: + //0x4ee08 + IO0SET = (1 << 13); + IO0CLR = (1 << 16); + bData_40003195 = 1; + break; + + case 1: + //0x4ee30 + IO0SET = (1 << 13); + IO0SET = (1 << 16); + bData_40003195 = 2; + break; + + case 2: + //0x4ee58 + IO0CLR = (1 << 13); + IO0SET = (1 << 16); + bData_40003195 = 0; + break; + + default: + break; + } +} + +#include "slew2.c" + +/* 4ff84 - todo */ +void HandleAlarmInputData(void) +{ + int h = atoi(Data_40002a3f); + int m = atoi(&Data_40002a3f[3]); + int s = atoi(&Data_40002a3f[6]); + + if ((h > 23) || (m > 59) || (s > 59)) + { + Data_40002c64_MenuContextId = 35001; + bCharacterInputPosition = 1; + } + else + { + //0x4ffe0 + bData_4000322c = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_ALARM; //3500; + Data_40003220_AlarmHours = h; + Data_40003224_AlarmMinutes = m; + Data_40003228_AlarmSeconds = s; + } +} + +/* 50018 - todo */ +void func_50018(void) +{ + unsigned int r1 = CTIME0; + unsigned int r0 = CTIME1; + + Data_40003164_LunarPhaseYear = (r0 >> 16) & 0xfff; + Data_40003168_LunarPhaseMonth = (r0 >> 8) & 0xf; +} + +/* 50048 - todo */ +void PrepareCustomerSkyObjectInputData(void) +{ + if (bData_40002e7a_MountType == 0) + { + //50060 + convert_horizontal_to_equatorial(dData_40002dc0_Azimuth, dData_40002df8, &dData_40002c88, &dData_40002c90); + //->0x5013c + } + else + { + //0x50084 + dData_40002c90 = dData_40002d98; + dData_40002c88 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude) - + dData_40002d78; + + while (dData_40002c88 >= 24) + { + dData_40002c88 -= 24; + } + while (dData_40002c88 < 0) + { + dData_40002c88 += 24; + } + } + //5013c + dData_40002cc8 = dData_40002c88; + Data_40002cb8 = dData_40002cc8; + Data_40002cbc = (dData_40002cc8 - Data_40002cb8) * 60.0; + fData_40002cc0 = (dData_40002cc8 - Data_40002cb8 - Data_40002cbc / 60.0) * 3600.0; + //50238 + dData_40002d10 = fabs(dData_40002c90); + Data_40002cf4 = dData_40002d10; + Data_40002cf8 = (dData_40002d10 - Data_40002cf4) * 60.0; + fData_40002cfc = (dData_40002d10 - Data_40002cf4 - Data_40002cf8 / 60.0) * 3600.0; + //5033c + if (dData_40002c90 > 0) + { + //50354 + Data_40002d40 = 1; + } + else + { + //0x50364 + Data_40002d40 = -1; + } + //0x50370 + if (fData_40002cc0 < 10) + { + //50384 + sprintf(strCustomerObjectRaAziInputForTracking, "R.a: %02dh%02dm0%2.1fs", + Data_40002cb8, Data_40002cbc, fData_40002cc0); + sprintf(strCustomerObjectRaAziInputForStoring, "R.a: %02dh%02dm0%2.1fs", + Data_40002cb8, Data_40002cbc, fData_40002cc0); + } + else + { + //0x503f0 + sprintf(strCustomerObjectRaAziInputForTracking, "R.a: %02dh%02dm%3.1fs", + Data_40002cb8, Data_40002cbc, fData_40002cc0); + sprintf(strCustomerObjectRaAziInputForStoring, "R.a: %02dh%02dm%3.1fs", + Data_40002cb8, Data_40002cbc, fData_40002cc0); + } + //0x50458 + if (fData_40002cfc < 10) + { + //5046c + if (Data_40002d40 == -1) + { + sprintf(Data_40002302, "Dec:-%02d %02d 0%2.1f ", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + sprintf(strCustomerObjectDecAltInputForStoring, "Dec:-%02dd%02dm0%2.1fs", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + } + else + { + //0x5060c + sprintf(Data_40002302, "Dec:+%02d %02d 0%2.1f ", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + sprintf(strCustomerObjectDecAltInputForStoring, "Dec:+%02dd%02dm0%2.1fs", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + } + } + else + { + //0x50678 + if (Data_40002d40 == -1) + { + sprintf(Data_40002302, "Dec:-%02d %02d %3.1f ", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + sprintf(strCustomerObjectDecAltInputForStoring, "Dec:-%02dd%02dm%3.1fs", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + } + else + { + //0x506f4 + sprintf(Data_40002302, "Dec:+%02d %02d %3.1f ", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + sprintf(strCustomerObjectDecAltInputForStoring, "Dec:+%02dd%02dm%3.1fs", + Data_40002cf4, Data_40002cf8, fData_40002cfc); + } + } + + sprintf(strCustomerObjectNameInput, "Name:Target0%d", 0); +} + +/* 50778 - todo */ +void HandleOTAZeroData(void) +{ + fData_4000329c = (unsigned short) atoi(&Data_400028d7[4]); //"Azi:%03d" + fData_400032a0 = (unsigned char) atoi(&Data_400028e1[5]); //"Alt: %02d" + + if ((fData_4000329c >= 0) && (fData_4000329c <= 360) && + (fData_400032a0 >= 0) && (fData_400032a0 <= 90)) + { + //50808 + Data_40004128.dData_192 = fData_4000329c; + Data_40004128.dData_200 = fData_400032a0; + + flash_write_ota_zero_data((unsigned short) fData_4000329c, (unsigned short) fData_400032a0); + + if (bData_40002f1e_SetupLocalData == 1) + { + //5087c + bSystemInitialized = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + bData_40002f1e_SetupLocalData = 0; + } + else + { + //0x5089c + Data_40002c64_MenuContextId = MENU_CONTEXT_OTA_ZERO_SETUP_RESTART; //47041; + } + } + else + { + //0x508ac + Data_40002c64_MenuContextId = MENU_CONTEXT_OTA_ZERO_SETUP; //47011; + bData_400032a4_OTAZeroDataErrorCount = 20; + } +} + +#include "file_5099c.c" + +/* 50b40 - todo */ +void HandleReset(void) +{ + char sp40[528]; + unsigned char customSiteName[20]; + float lon; + float lat; + int zone; + unsigned short i; + + lcd_display_clear(); + lcd_display_string(0, 4, 1, 21, "System resetting... "); + + i = 0; + for (i = 0; i < 16; i++) + { + //0x50b74 + flash_read((unsigned short)(0xddd + i), 0, sizeof(sp40), sp40); + flash_write((unsigned short)(0xdc9 + i), 0, sizeof(sp40), sp40); + } + + func_d2cc(); + func_5099c(); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0x44); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0x64); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0x04); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0x24); + + func_659c(10); + + if (bData_40002c1a == 1) + { + bData_40002e7a_MountType = MENU_MOUNT_TYPE_EQU; //1; + } + else + { + bData_40002e7a_MountType = MENU_MOUNT_TYPE_AZ; //0; + } + //50c98 + Data_400034d0 = 0.05; + Data_400034d8 = 0.045; + + flash_get_ota_zero_data(&fData_4000329c, &fData_400032a0); + + Data_40004128.dData_192 = fData_4000329c; + Data_40004128.dData_200 = fData_400032a0; + + flash_get_custom_site_data(customSiteName, &lon, &lat, &zone); + + Data_40004128.geographicLongitude = lon; + Data_40004128.geographicLatitude = lat; + + Data_40002e54_Zone = zone; + + strCustomSiteName[6] = customSiteName[0]; + strCustomSiteName[7] = customSiteName[1]; + strCustomSiteName[8] = customSiteName[2]; + strCustomSiteName[9] = customSiteName[3]; + strCustomSiteName[10] = customSiteName[4]; + strCustomSiteName[11] = customSiteName[5]; + strCustomSiteName[12] = customSiteName[6]; + strCustomSiteName[13] = customSiteName[7]; + + if (lon > 0) //BUG? East is negative! + { + //50d90 + sprintf(strCustomSiteLongitude, " Lon:E%03dd%02df ", + DEGREES_MINUTES(lon)); + } + else + { + //0x50edc + sprintf(strCustomSiteLongitude, " Lon:W%03dd%02df ", + DEGREES_MINUTES(lon)); //Bug: abs()? + } + //0x50f30 + if (lat > 0) + { + //50f40 + sprintf(strCustomSiteLatitude, " Lat:N%02dd%02df ", + DEGREES_MINUTES(lat)); + } + else + { + //0x50f98 + sprintf(strCustomSiteLatitude, " Lat:S%02dd%02df ", + DEGREES_MINUTES(lat)); //Bug: abs() + } + //0x50fec + if (zone > 0) + { + sprintf(strCustomSiteTimezone, " Zone:E%02d", zone); + } + else + { + //0x5100c + sprintf(strCustomSiteTimezone, " Zone:W%02d", zone); + } + + func_659c(2000); + beep1(2); + func_659c(100); + + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; +} + +/* 5104c - todo */ +void HandleCustomSiteData(void) +{ + unsigned char i; + unsigned char name[8]; + unsigned char lon[8]; + unsigned char lat[8]; + unsigned char tz[4]; + + for (i = 0; i < 8; i++) + { + name[i] = strCustomSiteName[i + 6]; + } + + lon[0] = strCustomSiteLongitude[6]; + lon[1] = atoi(&strCustomSiteLongitude[7]); + lon[2] = atoi(&strCustomSiteLongitude[11]); + + lat[0] = strCustomSiteLatitude[6]; + lat[1] = atoi(&strCustomSiteLatitude[7]); + lat[2] = atoi(&strCustomSiteLatitude[10]); + + tz[0] = strCustomSiteTimezone[6]; + tz[1] = atoi(&strCustomSiteTimezone[7]); + + if ((lon[1] > 179) || (lon[2] > 59) || + (lat[1] > 89) || (lat[2] > 59) || + (tz[1] > 11)) + { + //0x5111c: Invalid Data + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOM_SITE_INPUT; //43002; + } + else + { + //0x5112c + lon[0] = strCustomSiteLongitude[6]; + lon[1] = strCustomSiteLongitude[7]; + lon[2] = strCustomSiteLongitude[8]; + lon[3] = strCustomSiteLongitude[9]; + lon[4] = strCustomSiteLongitude[11]; + lon[5] = strCustomSiteLongitude[12]; + + lat[0] = strCustomSiteLatitude[6]; + lat[1] = strCustomSiteLatitude[7]; + lat[2] = strCustomSiteLatitude[8]; + lat[3] = strCustomSiteLatitude[10]; + lat[4] = strCustomSiteLatitude[11]; + + tz[0] = strCustomSiteTimezone[6]; + tz[1] = strCustomSiteTimezone[7]; + tz[2] = strCustomSiteTimezone[8]; + + flash_write_custom_site_data(name, lon, lat, tz); + flash_get_custom_site_data(arCustomSiteName, + &fCustomSiteLongitude, &fCustomSiteLatitude, + &iCustomSiteTimeZone); + + dData_40002e28_SiteLongitude = fCustomSiteLongitude; + dData_40002e48_SiteLatitude = fCustomSiteLatitude; + Data_40002e54_Zone = iCustomSiteTimeZone; + + Data_40004128.geographicLongitude = dData_40002e28_SiteLongitude; + Data_40004128.geographicLatitude = dData_40002e48_SiteLatitude; + Data_40004128.timeZone = Data_40002e54_Zone; + + beep1(2); + + if (bData_40002f1e_SetupLocalData == 1) + { + if (bData_40002c1a == 1) + { + //51290 + lcd_display_clear(); + + bSystemInitialized = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + bData_40002f1e_SetupLocalData = 0; + } + else + { + //0x51340 + Data_40002c64_MenuContextId = MENU_CONTEXT_OTA_ZERO_SETUP; //47011; + } + } + else + { + //0x51350 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + } +} + +/* 51368 - todo */ +int ValidateDateTimeSetRTC(void) +{ + int valid = 1; + unsigned short y; + unsigned char m; + unsigned char d; + unsigned char h; + unsigned char min; + unsigned char s; + y = atoi(Data_40002655); + m = atoi(&Data_40002655[5]); + + if ((m > 12) || (m == 0)) + { + return 0; + } + + d = atoi(&Data_40002655[8]); + + switch (m) + { + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + if (d > 31) valid = 0; + break; + + case 2: + if (d > 29) valid = 0; + break; + + case 4: + case 6: + case 9: + case 11: + if (d > 30) valid = 0; + break; + + default: + break; + } + + if (d < 1) valid = 0; + + if (valid == 0) + { + return 0; + } + + h = atoi(Data_40002660); + min = atoi(&Data_40002660[3]); + s = atoi(&Data_40002660[6]); + + if ((h > 23) || (min > 59) || (s > 59)) + { + return 0; + } + + CCR = (1 << 4); + YEAR = y; + MONTH = m; + DOM = d; + HOUR = h; + MIN = min; + SEC = s; + CCR = (1 << 4) | (1 << 0); //CLKEN = 1 + + return 1; +} + +/* 514f8 - todo */ +void HandleCustomerLandObjectInput(void) +{ + int r4 = atoi(&strCustomerObjectRaAziInputForTracking[4]); + int r5 = atoi(&strCustomerObjectRaAziInputForTracking[8]); + float sl = atof(&strCustomerObjectRaAziInputForTracking[11]); + int r6 = atoi(&Data_40002302[5]); + int r7 = atoi(&Data_40002302[8]); + float r8 = atof(&Data_40002302[11]); + unsigned char i; + + if ((r4 >= 360) || (r5 > 59) || (sl > 59.9999899999999968258634908125/*60.0*/) || + (r6 > 89) || (r7 > 59) || (r8 > 59.9999899999999968258634908125/*60.0*/)) + { + //0x515c0 + if ((r6 > 89) || (r7 > 59) || (r8 > 59.9999899999999968258634908125/*60.0*/)) + { + //0x515f4 + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT; //208; + bCharacterInputPosition = 6; + } + //0x5160c + if ((r4 >= 360) || (r5 > 59) || (sl > 59.9999899999999968258634908125/*60.0*/)) + { + //0x51640 + Data_40002c64_MenuContextId = MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT; //207; + bCharacterInputPosition = 6; + } + //0x5179c + } + else + { + //0x5165c + for (i = 1; i < 9; i++) + { + //0x51664 + Data_40003f90[i] = strCustomerObjectNameInput[i + 4]; + } + + Data_40003f90[9] = strCustomerObjectRaAziInputForStoring[4] - '0'; + Data_40003f90[10] = strCustomerObjectRaAziInputForStoring[5] - '0'; + Data_40003f90[11] = strCustomerObjectRaAziInputForStoring[6] - '0'; + + Data_40003f90[12] = strCustomerObjectRaAziInputForStoring[8] - '0'; + Data_40003f90[13] = strCustomerObjectRaAziInputForStoring[9] - '0'; + + Data_40003f90[14] = strCustomerObjectRaAziInputForStoring[11] - '0'; + Data_40003f90[15] = strCustomerObjectRaAziInputForStoring[12] - '0'; + + Data_40003f90[16] = strCustomerObjectRaAziInputForStoring[14] - '0'; + + Data_40003f90[17] = strCustomerObjectDecAltInputForStoring[4]; // - '0'; + Data_40003f90[18] = strCustomerObjectDecAltInputForStoring[5] - '0'; + Data_40003f90[19] = strCustomerObjectDecAltInputForStoring[6] - '0'; + + Data_40003f90[20] = strCustomerObjectDecAltInputForStoring[8] - '0'; + Data_40003f90[21] = strCustomerObjectDecAltInputForStoring[9] - '0'; + + Data_40003f90[22] = strCustomerObjectDecAltInputForStoring[11] - '0'; + Data_40003f90[23] = strCustomerObjectDecAltInputForStoring[12] - '0'; + + Data_40003f90[24] = strCustomerObjectDecAltInputForStoring[14] - '0'; + + flash_write_cust_land_target(bData_4000319a_SkyLandTargetId, Data_40003f90); + beep1(1); + } +} + +/* 517f4 - todo */ +void PrepareCustomerLandObjectInputData(void) +{ + if (fData_40002db4 < 10) + { + //51810 + sprintf(strCustomerObjectRaAziInputForStoring, "Azi:%03dh%02dm0%2.1fs", + Data_40002dac, Data_40002db0, fData_40002db4); + sprintf(strCustomerObjectRaAziInputForTracking, "Azi:%03dh%02dm0%2.1fs", + Data_40002dac, Data_40002db0, fData_40002db4); + } + else + { + //0x5187c + sprintf(strCustomerObjectRaAziInputForStoring, "Azi:%03dh%02dm%2.1fs", + Data_40002dac, Data_40002db0, fData_40002db4); + sprintf(strCustomerObjectRaAziInputForTracking, "Azi:%03dh%02dm0%2.1fs", //"Azi:%03dh%02dm%2.1fs", //BUG? + Data_40002dac, Data_40002db0, fData_40002db4); + } + //0x518e4 + if (fData_40002de8 < 10) + { + //518f8 + if (dData_40002df8 < 0) + { + //51910 + sprintf(strCustomerObjectDecAltInputForStoring, "Alt:-%02dd%02dm%2.1fs", + abs(Data_40002de0), abs(Data_40002de4), fabs(fData_40002de8)); + sprintf(Data_40002302, "Alt:-%02dd%02dm%2.1fs", + abs(Data_40002de0), abs(Data_40002de4), fabs(fData_40002de8)); + } + else + { + //0x519fc + sprintf(strCustomerObjectDecAltInputForStoring, "Alt:+%02dd%02dm0%2.1fs", + Data_40002de0, Data_40002de4, fData_40002de8); + sprintf(Data_40002302, "Alt:+%02dd%02dm0%2.1fs", + Data_40002de0, Data_40002de4, fData_40002de8); + } + } + else + { + //0x51a68 + if (dData_40002df8 < 0) + { + //51a80 + sprintf(strCustomerObjectDecAltInputForStoring, "Alt:-%02dd%02dm%2.1fs", + abs(Data_40002de0), abs(Data_40002de4), fabs(fData_40002de8)); + sprintf(Data_40002302, "Alt:-%02dd%02dm%2.1fs", + abs(Data_40002de0), abs(Data_40002de4), fabs(fData_40002de8)); + } + else + { + //0x51bf8 + sprintf(strCustomerObjectDecAltInputForStoring, "Alt:+%02dd%02dm%2.1fs", + Data_40002de0, Data_40002de4, fData_40002de8); + sprintf(Data_40002302, "Alt:+%02dd%02dm%2.1fs", + Data_40002de0, Data_40002de4, fData_40002de8); + } + } + //0x51c60 + sprintf(strCustomerObjectNameInput, "Name:Target0%d", 0); +} + +/* 51c7c - todo */ +void HandleRectascensionDeclinationInput(void) +{ + int raHours = atoi(&strCustomerObjectRaAziInputForTracking[5]); + int raMinutes = atoi(&strCustomerObjectRaAziInputForTracking[8]); + float raSeconds = atof(&strCustomerObjectRaAziInputForTracking[11]); + int decDegrees = atoi(&Data_40002302[5]); + int decMinutes = atoi(&Data_40002302[8]); + float decSeconds = atof(&Data_40002302[11]); + unsigned char i; + + if ((raHours > 23) || (raMinutes > 59) || (raSeconds > 59.99) || + (decDegrees > 89) || (decMinutes > 59) || (decSeconds > 59.99)) + { + //0x51d4c + if ((decDegrees > 89) || (decMinutes > 59) || (decSeconds > 59.99)) + { + //0x51d80 + Data_40002c64_MenuContextId = MENU_CONTEXT_DEC_INPUT; //29002; + bCharacterInputPosition = 5; + } + //0x51d98 + if ((raHours > 23) || (raMinutes > 59) || (raSeconds > 59.99)) + { + //0x51dcc + Data_40002c64_MenuContextId = MENU_CONTEXT_RA_INPUT; //29001; + bCharacterInputPosition = 6; + } + //->0x5246c + } + else + { + //0x51de8 + if (bData_40003162 == 0) + { + //51df8 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + Data_40002cb8 = raHours; + Data_40002cbc = raMinutes; + fData_40002cc0 = raSeconds; + + if (Data_40002302[4] == '-') + { + //51e2c + Data_40002d40 = -1; + } + else + { + //0x51e3c + Data_40002d40 = 1; + } + //0x51e48 + Data_40002cf4 = decDegrees; + Data_40002cf8 = decMinutes; + fData_40002cfc = decSeconds; + + dData_40002cc8 = Data_40002cb8 + Data_40002cbc / 60.0 + fData_40002cc0 / 3600.0; + dData_40002d10 = Data_40002cf4 + Data_40002cf8 / 60.0 + fData_40002cfc / 3600.0; + dData_40002d10 = Data_40002d40 * dData_40002d10; + + bTrackingMode = 1; + + GotoEQCoordinates(dData_40002cc8, dData_40002d10); + + bData_40002f0d_RecentTargetType = 11; + bData_40002f10_RecentTargetId = 10; + + flash_write_recent_target(bData_40002f0d_RecentTargetType, bData_40002f10_RecentTargetId); + + Data_40003f78[0] = 111; + + for (i = 1; i < 9; i++) + { + //0x52078 + Data_40003f78[i] = strCustomerObjectNameInput[i + 4]; + } + //5209c + Data_40003f78[9] = strCustomerObjectRaAziInputForStoring[5] - '0'; + Data_40003f78[10] = strCustomerObjectRaAziInputForStoring[6] - '0'; + Data_40003f78[11] = strCustomerObjectRaAziInputForStoring[8] - '0'; + Data_40003f78[12] = strCustomerObjectRaAziInputForStoring[9] - '0'; + Data_40003f78[13] = strCustomerObjectRaAziInputForStoring[11] - '0'; + Data_40003f78[14] = strCustomerObjectRaAziInputForStoring[12] - '0'; + Data_40003f78[15] = strCustomerObjectRaAziInputForStoring[14] - '0'; + + Data_40003f78[16] = strCustomerObjectDecAltInputForStoring[4]; + Data_40003f78[17] = strCustomerObjectDecAltInputForStoring[5] - '0'; + Data_40003f78[18] = strCustomerObjectDecAltInputForStoring[6] - '0'; + Data_40003f78[19] = strCustomerObjectDecAltInputForStoring[8] - '0'; + Data_40003f78[20] = strCustomerObjectDecAltInputForStoring[9] - '0'; + Data_40003f78[21] = strCustomerObjectDecAltInputForStoring[11] - '0'; + Data_40003f78[22] = strCustomerObjectDecAltInputForStoring[12] - '0'; + Data_40003f78[23] = strCustomerObjectDecAltInputForStoring[14] - '0'; + + flash_write_cust_sky_target((unsigned char) bData_40002f10_RecentTargetId, Data_40003f78); + //->0x5246c + } //if (bData_40003162 == 0) + else + { + //0x521a4 + Data_40002c64_MenuContextId = MENU_CONTEXT_RISE_SET_TIMES; //32001; + Data_40002cb8 = raHours; + Data_40002cbc = raMinutes; + fData_40002cc0 = raSeconds; + + if (Data_40002302[4] == '-') + { + //521d8 + Data_40002d40 = -1; + } + else + { + //0x521e8 + Data_40002d40 = 1; + } + //0x521f4 + Data_40002cf4 = decDegrees; + Data_40002cf8 = decMinutes; + fData_40002cfc = decSeconds; + + dData_40002cc8 = Data_40002cb8 + Data_40002cbc / 60.0 + fData_40002cc0 / 3600.0; + dData_40002d10 = Data_40002cf4 + Data_40002cf8 / 60.0 + fData_40002cfc / 3600.0; + dData_40002d10 = Data_40002d40 * dData_40002d10; + + dObjectRiseTime = get_object_visibility_time(1, + dData_40002cc8, dData_40002d10, + Data_40004128.geographicLongitude, Data_40004128.geographicLatitude, + (unsigned char) Data_40004128.timeZone); + + dObjectTransitTime = get_object_visibility_time(2, + dData_40002cc8, dData_40002d10, + Data_40004128.geographicLongitude, Data_40004128.geographicLatitude, + (unsigned char) Data_40004128.timeZone); + + dObjectSetTime = get_object_visibility_time(3, + dData_40002cc8, dData_40002d10, + Data_40004128.geographicLongitude, Data_40004128.geographicLatitude, + (unsigned char) Data_40004128.timeZone); + } + } +} + +/* 52478 - todo */ +void HandleCustomerSkyObjectInput(void) +{ + int raHours = atoi(&strCustomerObjectRaAziInputForTracking[5]); + int raMinutes = atoi(&strCustomerObjectRaAziInputForTracking[8]); + float raSeconds = atof(&strCustomerObjectRaAziInputForTracking[11]); + int r6 = atoi(&Data_40002302[5]); + int r7 = atoi(&Data_40002302[8]); + float r8 = atof(&Data_40002302[11]); + unsigned char i; + + if ((raHours > 23) || (raMinutes > 59) || (raSeconds > 59.99) || + (r6 > 89) || (r7 > 59) || (r8 > 59.99)) + { + //0x52540 + if ((r6 > 89) || (r7 > 59) || (r8 > 59.99)) + { + //0x52574 + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT; //205; + bCharacterInputPosition = 5; + } + //0x5258c + if ((raHours > 23) || (raMinutes > 59) || (raSeconds > 59.99)) + { + //0x525c0 + Data_40002c64_MenuContextId = MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT; //204; + bCharacterInputPosition = 6; + } + //->0x52718 + } + else + { + //0x525dc + Data_40003f78[0] = 111; + + for (i = 1; i < 9; i++) + { + //0x525f0 + Data_40003f78[i] = strCustomerObjectNameInput[i + 4]; + } + //5209c + Data_40003f78[9] = strCustomerObjectRaAziInputForStoring[5] - '0'; + Data_40003f78[10] = strCustomerObjectRaAziInputForStoring[6] - '0'; + Data_40003f78[11] = strCustomerObjectRaAziInputForStoring[8] - '0'; + Data_40003f78[12] = strCustomerObjectRaAziInputForStoring[9] - '0'; + Data_40003f78[13] = strCustomerObjectRaAziInputForStoring[11] - '0'; + Data_40003f78[14] = strCustomerObjectRaAziInputForStoring[12] - '0'; + Data_40003f78[15] = strCustomerObjectRaAziInputForStoring[14] - '0'; + + Data_40003f78[16] = strCustomerObjectDecAltInputForStoring[4]; + Data_40003f78[17] = strCustomerObjectDecAltInputForStoring[5] - '0'; + Data_40003f78[18] = strCustomerObjectDecAltInputForStoring[6] - '0'; + Data_40003f78[19] = strCustomerObjectDecAltInputForStoring[8] - '0'; + Data_40003f78[20] = strCustomerObjectDecAltInputForStoring[9] - '0'; + Data_40003f78[21] = strCustomerObjectDecAltInputForStoring[11] - '0'; + Data_40003f78[22] = strCustomerObjectDecAltInputForStoring[12] - '0'; + Data_40003f78[23] = strCustomerObjectDecAltInputForStoring[14] - '0'; + + flash_write_cust_sky_target(bData_4000319a_SkyLandTargetId, Data_40003f78); + beep1(1); + } +} + +/* 52720 - todo */ +double func_52720(int a) +{ + union + { + int a; + char b[4]; + } sp8; + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x03); + + switch (a) + { + case 1: + //0x5276c + uart1_write_byte(0x0f); + break; + + case 2: + //0x5277c + uart1_write_byte(0x2f); + break; + + case 3: + //0x5278c + uart1_write_byte(0x4f); + break; + + case 4: + //0x5279c + uart1_write_byte(0x6f); + break; + + default: + //0x527ac + break; + } + + switch (a) + { + case 1: + //0x527dc + sp8.a = fData_40002e98; + uart1_write_byte(sp8.b[1]); + uart1_write_byte(sp8.b[0]); + break; + + case 2: + //0x52804 + sp8.a = fData_40002ea8; + uart1_write_byte(sp8.b[1]); + uart1_write_byte(sp8.b[0]); + break; + + case 3: + //0x5282c + sp8.a = fData_40002e98; + uart1_write_byte(sp8.b[1]); + uart1_write_byte(sp8.b[0]); + break; + + case 4: + //0x52854 + sp8.a = fData_40002ea8; + uart1_write_byte(sp8.b[1]); + uart1_write_byte(sp8.b[0]); + break; + + default: + //0x5287c + break; + } +} + +#include "HandleEnterKey.c" + +#include "HandleRightKey.c" + +#include "HandleLeftKey.c" + +/* 59dd0 - todo */ +void func_59dd0(void) +{ + wData_40003252 = 0; + + switch (wData_40003250) + { + case 1: + //0x5a104 + case 2: + //0x5a10c + wData_40003250++; + break; + + case 3: + //0x5a128 + wData_40003250 = 25; + break; + + case 25: + //0x5a13c + wData_40003250 = 26; + break; + + case 26: + //0x5a150 + wData_40003250 = 29; + break; + + case 29: + //0x5a164 + case 30: + //0x5a16c + case 31: + //0x5a170 + case 32: + //0x5a174 + case 33: + //0x5a178 + case 34: + //0x5a17c + wData_40003250++; + break; + + case 35: + //0x5a198 + wData_40003250 = 38; + break; + + case 38: + //0x5a1ac + case 39: + //0x5a1b4 + wData_40003250++; + break; + + case 40: + //0x5a1d0 + wData_40003250 = 45; + break; + + case 45: + //0x5a1e4 + case 46: + //0x5a1ec + case 47: + //0x5a1f0 + wData_40003250++; + break; + + case 48: + //0x5a20c + wData_40003250 = 53; + break; + + case 53: + //0x5a220 + case 54: + //0x5a228 + case 55: + //0x5a22c + case 56: + //0x5a230 + case 57: + //0x5a234 + case 58: + //0x5a238 + case 59: + //0x5a23c + wData_40003250++; + break; + + case 60: + //0x5a258 + wData_40003250 = 62; + break; + + case 62: + //0x5a26c + case 63: + //0x5a274 + wData_40003250++; + break; + + case 64: + //0x5a290 + wData_40003250 = 73; + break; + + case 73: + //0x5a2a4 + case 74: + //0x5a2ac + case 75: + //0x5a2b0 + case 76: + //0x5a2b4 + wData_40003250++; + break; + + case 77: + //0x5a2d0 + wData_40003250 = 80; + break; + + case 80: + //0x5a2e4 + case 81: + //0x5a2ec + wData_40003250++; + break; + + case 82: + //0x5a308 + wData_40003250 = 89; + break; + + case 89: + //0x5a31c + wData_40003250 = 90; + break; + + case 90: + //0x5a330 + wData_40003250 = 92; + break; + + case 92: + //0x5a344 + case 93: + //0x5a34c + case 94: + //0x5a350 + case 95: + //0x5a354 + case 96: + //0x5a358 + wData_40003250++; + break; + + case 97: + //0x5a374 + wData_40003250 = 98; + break; + + case 98: + //0x5a388 + wData_40003250 = 99; + break; + + case 99: + //0x5a39c + wData_40003250 = 105; + break; + + case 105: + //0x5a3b0 + case 106: + //0x5a3b8 + case 107: + //0x5a3bc + case 108: + //0x5a3c0 + case 109: + //0x5a3c4 + case 110: + //0x5a3c8 + case 111: + //0x5a3cc + case 112: + //0x5a3d0 + case 113: + //0x5a3d4 + case 114: + //0x5a3d8 + case 115: + //0x5a3dc + case 116: + //0x5a3e0 + case 117: + //0x5a3e4 + case 118: + //0x5a3e8 + wData_40003250++; + break; + + case 119: + //0x5a404 + wData_40003250 = 121; + break; + + case 121: + //0x5a418 + case 122: + //0x5a420 + case 123: + //0x5a424 + case 124: + //0x5a428 + case 125: + //0x5a42c + case 126: + //0x5a430 + case 127: + //0x5a434 + case 128: + //0x5a438 + case 129: + //0x5a43c + case 130: + //0x5a440 + case 131: + //0x5a444 + case 132: + //0x5a448 + case 133: + //0x5a44c + wData_40003250++; + break; + + case 134: + //0x5a468 + wData_40003250 = 143; + break; + + case 143: + //0x5a47c + case 144: + //0x5a484 + case 145: + //0x5a488 + case 146: + //0x5a48c + case 147: + //0x5a490 + case 148: + //0x5a494 + case 149: + //0x5a498 + wData_40003250++; + break; + + case 150: + //0x5a4b4 + wData_40003250 = 152; + break; + + case 152: + //0x5a4c8 + wData_40003250 = 154; + break; + + case 154: + //0x5a4dc + wData_40003250 = 155; + break; + + case 155: + //0x5a4f0 + wData_40003250 = 156; + //break; //BUG? + + case 156: + //0x5a504 + wData_40003250 = 158; + break; + + case 158: + //0x5a514 + case 159: + //0x5a51c + case 160: + //0x5a520 + case 161: + //0x5a524 + case 162: + //0x5a528 + case 163: + //0x5a52c + case 164: + //0x5a530 + case 165: + //0x5a534 + case 166: + //0x5a538 + case 167: + //0x5a53c + case 168: + //0x5a540 + case 169: + //0x5a544 + wData_40003250++; + break; + + case 170: + //0x5a560 + wData_40003250 = 1; + break; +#if 0 + default: + //0x5a574 + break; +#endif + } +} + +/* 5a57c - complete */ +void HandleLongListScroll(int upDown, int b) +{ + switch (upDown) + { + case 0: + //0x5a590: Scroll Up + switch (b) + { + case 11: + //0x5a5d0 + if (bData_40003173 > 1) + { + //5a5e4 + bData_40003173--; + } + else + { + //0x5a5fc + bData_40003171--; + } + //0x5a610 + if (bData_40003172 > 1) + { + //5a620 + bData_40003172--; + } + else + { + //0x5a638 + bData_40003170--; + } + //0x5a64c -> 0x5a860 + break; + + case 12: + //0x5a650 + if (bData_40003177 > 1) + { + bData_40003177--; + } + else + { + bData_40003175--; + } + //0x5a690 + if (bData_40003176 > 1) + { + bData_40003176--; + } + else + { + bData_40003174--; + } + //0x5a6cc -> 0x5a860 + break; + + case 13: + //0x5a6d0 + if (bData_4000317b > 1) + { + bData_4000317b--; + } + else + { + bData_40003179--; + } + + if (bData_4000317a > 1) + { + bData_4000317a--; + } + else + { + bData_40003178--; + } + break; + + case 14: + //0x5a750 + if (bData_4000317f > 1) + { + bData_4000317f--; + } + else + { + bData_4000317d--; + } + + if (bData_4000317e > 1) + { + bData_4000317e--; + } + else + { + bData_4000317c--; + } + break; + + case 22: + //0x5a7d0 + if (bData_40003182 > 1) + { + bData_40003182--; + } + else + { + bData_40003180--; + } + break; + + case 23: + //0x5a814 + if (bData_40003186 > 1) + { + bData_40003186--; + } + else + { + bData_40003184--; + } + break; + + default: + //0x5a858 + break; + } + break; + + case 1: + //0x5a868: Scroll Down + switch (b) + { + case 11: + //0x5a8a8: Alignment items + if (bData_40003173 < 4) + { + bData_40003173++; + } + else + { + bData_40003171++; + } + + if (bData_40003172 < 8) + { + bData_40003172++; + } + else + { + bData_40003170++; + } + break; + + case 12: + //0x5a928: Navigation items + if (bData_40003177 < 4) + { + //5a93c + bData_40003177++; + } + else + { + //0x5a954 + bData_40003175++; + } + //0x5a968 + if (bData_40003176 < 8) + { + bData_40003176++; + } + else + { + //0x5a990 + bData_40003174++; + } + //0x5a9a4 -> 0x5ab38 + break; + + case 13: + //0x5a9a8: Utilities items + if (bData_4000317b < 4) + { + bData_4000317b++; + } + else + { + bData_40003179++; + } + + if (bData_4000317a < 8) + { + bData_4000317a++; + } + else + { + bData_40003178++; + } + break; + + case 14: + //0x5aa28: Setup items + if (bData_4000317f < 4) + { + bData_4000317f++; + } + else + { + bData_4000317d++; + } + + if (bData_4000317e < 8) + { + bData_4000317e++; + } + else + { + bData_4000317c++; + } + break; + + case 22: + //0x5aaa8 + if (bData_40003182 < 8) + { + bData_40003182++; + } + else + { + bData_40003180++; + } + break; + + case 23: + //0x5aaec + if (bData_40003186 < 8) + { + bData_40003186++; + } + else + { + bData_40003184++; + } + break; + + default: + break; + } + break; + + default: + //0x5ab40 + break; + } +} + +#include "HandleDownKey.c" + +#include "HandleUpKey.c" + +/* 5f0c0 - complete */ +void SlewStop(void) +{ + if ((g_bSingleSlewActive == 1) || (g_bCombinedSlewActive == 1)) + { + //0x5f0e4 + if (g_bCombinedSlewActive == 1) + { + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(1); + uart1_write_byte(1); + uart1_write_byte(0); + + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + } + //0x5f128 + if (g_bSingleSlewActive == 1) + { + if (bData_40002c1a == 2) + { + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(1); + uart1_write_byte(1); + uart1_write_byte(0); + + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + } + else + { + //0x5f180 + if (g_eSlewRateIndex != SLEW_RATE_MAX) //9) + { + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(1); + uart1_write_byte(1); + uart1_write_byte(0); + + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + } //if (g_eSlewRateIndex != SLEW_RATE_MAX) //9) + else + { + //0x5f1c8 + if (g_stCurrentSlewRampValue.Data >= 4800) + { + g_stCurrentSlewRampValue.Data = 4700; + } + //0x5f1e4 + g_iCurrentSlewRampIndex = -4; // Ramp down (-1200) + } + } + } + //0x5f1f0 + if (g_bSingleSlewActive == 1) + { + g_bSingleSlewActive = 0; + } + //0x5f20c + if (g_bCombinedSlewActive == 1) + { + g_bCombinedSlewActive = 0; + } + } //if ((g_bSingleSlewActive == 1) || (g_bCombinedSlewActive == 1)) + //0x5f228 +} + +#include "HandleMinusKey.c" + +/* 60d54 - complete */ +void HandlePlusKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x60d78 + lcd_display_clear(); + + Data_40002c64_MenuContextId = MENU_CONTEXT_RECENT_TARGETS; //1; + bData_400031be = 1; + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_400031e0 = 1; + + bData_400031bf = func_32a4(); + + bData_400031be = 0; + break; + + case 5000: + //0x60dc0 + Data_40002c64_MenuContextId = 1; + bData_400031be = 1; + bData_4000316e_FocusLineOn8LineDisplay = 1; + bData_400031e0 = 1; + //break; + + default: + //0x60dec + break; + } +} + +/* 60dfc - complete */ +void HandleFKey(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x60e60 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + bData_4000319a_SkyLandTargetId = 1; + bData_4000319b = 1; + + lcd_display_clear(); + //->0x60ec4 + break; + + case MENU_CONTEXT_MESSIER_OBJECT_DETAILS: //23012: + //0x60e8c + case MENU_CONTEXT_MESSIER_OBJECT_SELECTION: //23002: + //0x60e94 + case MENU_CONTEXT_NGC_OBJECT_SELECTION: //23003: + //0x60e98 + case MENU_CONTEXT_IC_OBJECT_SELECTION: //23004: + //0x60e9c + case MENU_CONTEXT_SH2_OBJECT_SELECTION: //23005: + //0x60ea0 + case MENU_CONTEXT_BRIGHT_STAR_SELECTION: //23006: + //0x60ea4 + case MENU_CONTEXT_SAO_OBJECT_SELECTION: //23007: + //0x60ea8 + lcd_display_clear(); + + Data_40002ec8_NavigationDirectInputNr = 0; + + beep1(1); + break; + + } +} + +#include "HandleHelpKey.c" + +/* 61ecc - todo */ +void func_61ecc(int a) +{ + int r3; + unsigned char r4; + unsigned char sp[10]; + + if (bCapsLock != 0) + { + r3 = 5; + } + else + { + r3 = 0; + } + + switch (a) + { + case 0: + //0x61f24 + r4 = '0'; + sp[0] = '0'; + sp[1] = '0'; + sp[2] = '0'; + sp[3] = '0'; + sp[4] = '0'; + sp[5] = '0'; + sp[6] = '0'; + sp[7] = '0'; + sp[8] = '0'; + sp[9] = '0'; + break; + + case 1: + //0x61f5c + r4 = '1'; + sp[0] = '1'; + sp[1] = '1'; + sp[2] = '1'; + sp[3] = '1'; + sp[4] = '1'; + sp[5] = '1'; + sp[6] = '1'; + sp[7] = '1'; + sp[8] = '1'; + sp[9] = '1'; + break; + + case 2: + //0x61f94 + r4 = '2'; + sp[0] = '2'; + sp[1] = 'a'; + sp[2] = 'b'; + sp[3] = 'c'; + sp[4] = ' '; + sp[5] = '2'; + sp[6] = 'A'; + sp[7] = 'B'; + sp[8] = 'C'; + sp[9] = ' '; + break; + + case 3: + //0x61ff0 + r4 = '3'; + sp[0] = '3'; + sp[1] = 'd'; + sp[2] = 'e'; + sp[3] = 'f'; + sp[4] = ' '; + sp[5] = '3'; + sp[6] = 'D'; + sp[7] = 'E'; + sp[8] = 'F'; + sp[9] = ' '; + break; + + case 4: + //0x6204c + r4 = '4'; + sp[0] = '4'; + sp[1] = 'g'; + sp[2] = 'h'; + sp[3] = 'i'; + sp[4] = ' '; + sp[5] = '4'; + sp[6] = 'G'; + sp[7] = 'H'; + sp[8] = 'I'; + sp[9] = ' '; + break; + + case 5: + //0x620a8 + r4 = '5'; + sp[0] = '5'; + sp[1] = 'j'; + sp[2] = 'k'; + sp[3] = 'l'; + sp[4] = ' '; + sp[5] = '5'; + sp[6] = 'J'; + sp[7] = 'K'; + sp[8] = 'L'; + sp[9] = ' '; + break; + + case 6: + //0x62104 + r4 = '6'; + sp[0] = '6'; + sp[1] = 'm'; + sp[2] = 'n'; + sp[3] = 'o'; + sp[4] = ' '; + sp[5] = '6'; + sp[6] = 'M'; + sp[7] = 'N'; + sp[8] = 'O'; + sp[9] = ' '; + break; + + case 7: + //0x62160 + r4 = '7'; + sp[0] = '7'; + sp[1] = 'p'; + sp[2] = 'q'; + sp[3] = 'r'; + sp[4] = 's'; + sp[5] = '7'; + sp[6] = 'P'; + sp[7] = 'Q'; + sp[8] = 'R'; + sp[9] = 'S'; + break; + + case 8: + //0x621bc + r4 = '8'; + sp[0] = '8'; + sp[1] = 't'; + sp[2] = 'u'; + sp[3] = 'v'; + sp[4] = ' '; + sp[5] = '8'; + sp[6] = 'T'; + sp[7] = 'U'; + sp[8] = 'V'; + sp[9] = ' '; + break; + + case 9: + //0x62218 + r4 = '9'; + sp[0] = '9'; + sp[1] = 'w'; + sp[2] = 'x'; + sp[3] = 'y'; + sp[4] = 'z'; + sp[5] = '2'; + sp[6] = 'W'; + sp[7] = 'X'; + sp[8] = 'Y'; + sp[9] = 'Z'; + break; + + default: + //0x62274 + break; + } + + switch (bData_40003262) + { + case 1: + //62290 + switch (bData_40003261) + { + case 0: + //0x622b8 + Data_4000251d[bCharacterInputPosition - 1] = sp[bMapKeyToCharIndex + r3]; + Data_4000257e[bCharacterInputPosition - 1] = sp[bMapKeyToCharIndex + r3]; + + if (bMapKeyToCharIndex < 4) + { + bMapKeyToCharIndex++; + } + else + { + //0x62334 + bMapKeyToCharIndex = 0; + } + //->0x623b4 + break; + + case 1: + //0x62344 + Data_4000253d[bCharacterInputPosition - 1] = r4; + Data_4000258c[bCharacterInputPosition - 1] = r4; + + func_5660c(); + break; + + case 2: + //0x62378 + Data_4000255d[bCharacterInputPosition - 1] = r4; + Data_400025a0[bCharacterInputPosition - 1] = r4; + + func_5660c(); + break; + + default: + //0x623ac + break; + + } //switch (bData_40003261) + break; + + default: + //0x623bc + break; + } //switch (bData_40003262) +} + +/* 623d0 - todo */ +void func_623d0(int a) +{ + unsigned char r3; + + switch (a) + { + case 0: + //0x6240c + r3 = '0'; + break; + + case 1: + //0x62418 + r3 = '1'; + break; + + case 2: + //0x62424 + r3 = '2'; + break; + + case 3: + //0x62430 + r3 = '3'; + break; + + case 4: + //0x6243c + r3 = '4'; + break; + + case 5: + //0x62448 + r3 = '5'; + break; + + case 6: + //0x62454 + r3 = '6'; + break; + + case 7: + //0x62460 + r3 = '7'; + break; + + case 8: + //0x6246c + r3 = '8'; + break; + + case 9: + //0x62478 + r3 = '9'; + break; + + default: + //0x62484 + break; + } + + switch (bData_4000316d) + { + case 0: + //0x624ac + Data_40002789[bCharacterInputPosition - 1] = r3; + Data_400028d7[bCharacterInputPosition - 1] = r3; + break; + + case 1: + //0x624dc + Data_40002792[bCharacterInputPosition - 1] = r3; + Data_400028e1[bCharacterInputPosition - 1] = r3; + break; + + default: + //0x6250c + break; + } + + func_56dac(); +} + +/* 62524 - todo */ +void HandleCustomSiteInputChar(int key) +{ + int capsOffset; + unsigned char digitChar; + unsigned char alphaNumChars[10]; + + if (bCapsLock != 0) + { + capsOffset = 5; + } + else + { + capsOffset = 0; + } + + switch (key) + { + case 0: + //0x6257c + digitChar = '0'; + alphaNumChars[0] = '0'; + alphaNumChars[1] = '0'; + alphaNumChars[2] = '0'; + alphaNumChars[3] = '0'; + alphaNumChars[4] = '0'; + alphaNumChars[5] = '0'; + alphaNumChars[6] = '0'; + alphaNumChars[7] = '0'; + alphaNumChars[8] = '0'; + alphaNumChars[9] = '0'; + break; + + case 1: + //0x625b4 + digitChar = '1'; + alphaNumChars[0] = '1'; + alphaNumChars[1] = '1'; + alphaNumChars[2] = '1'; + alphaNumChars[3] = '1'; + alphaNumChars[4] = '1'; + alphaNumChars[5] = '1'; + alphaNumChars[6] = '1'; + alphaNumChars[7] = '1'; + alphaNumChars[8] = '1'; + alphaNumChars[9] = '1'; + break; + + case 2: + //0x625ec + digitChar = '2'; + alphaNumChars[0] = '2'; + alphaNumChars[1] = 'a'; + alphaNumChars[2] = 'b'; + alphaNumChars[3] = 'c'; + alphaNumChars[4] = ' '; + alphaNumChars[5] = '2'; + alphaNumChars[6] = 'A'; + alphaNumChars[7] = 'B'; + alphaNumChars[8] = 'C'; + alphaNumChars[9] = ' '; + break; + + case 3: + //0x62648 + digitChar = '3'; + alphaNumChars[0] = '3'; + alphaNumChars[1] = 'd'; + alphaNumChars[2] = 'e'; + alphaNumChars[3] = 'f'; + alphaNumChars[4] = ' '; + alphaNumChars[5] = '3'; + alphaNumChars[6] = 'D'; + alphaNumChars[7] = 'E'; + alphaNumChars[8] = 'F'; + alphaNumChars[9] = ' '; + break; + + case 4: + //0x626a4 + digitChar = '4'; + alphaNumChars[0] = '4'; + alphaNumChars[1] = 'g'; + alphaNumChars[2] = 'h'; + alphaNumChars[3] = 'i'; + alphaNumChars[4] = ' '; + alphaNumChars[5] = '4'; + alphaNumChars[6] = 'G'; + alphaNumChars[7] = 'H'; + alphaNumChars[8] = 'I'; + alphaNumChars[9] = ' '; + break; + + case 5: + //0x62700 + digitChar = '5'; + alphaNumChars[0] = '5'; + alphaNumChars[1] = 'j'; + alphaNumChars[2] = 'k'; + alphaNumChars[3] = 'l'; + alphaNumChars[4] = ' '; + alphaNumChars[5] = '5'; + alphaNumChars[6] = 'J'; + alphaNumChars[7] = 'K'; + alphaNumChars[8] = 'L'; + alphaNumChars[9] = ' '; + break; + + case 6: + //0x6275c + digitChar = '6'; + alphaNumChars[0] = '6'; + alphaNumChars[1] = 'm'; + alphaNumChars[2] = 'n'; + alphaNumChars[3] = 'o'; + alphaNumChars[4] = ' '; + alphaNumChars[5] = '6'; + alphaNumChars[6] = 'M'; + alphaNumChars[7] = 'N'; + alphaNumChars[8] = 'O'; + alphaNumChars[9] = ' '; + break; + + case 7: + //0x627b8 + digitChar = '7'; + alphaNumChars[0] = '7'; + alphaNumChars[1] = 'p'; + alphaNumChars[2] = 'q'; + alphaNumChars[3] = 'r'; + alphaNumChars[4] = 's'; + alphaNumChars[5] = '7'; + alphaNumChars[6] = 'P'; + alphaNumChars[7] = 'Q'; + alphaNumChars[8] = 'R'; + alphaNumChars[9] = 'S'; + break; + + case 8: + //0x62814 + digitChar = '8'; + alphaNumChars[0] = '8'; + alphaNumChars[1] = 't'; + alphaNumChars[2] = 'u'; + alphaNumChars[3] = 'v'; + alphaNumChars[4] = ' '; + alphaNumChars[5] = '8'; + alphaNumChars[6] = 'T'; + alphaNumChars[7] = 'U'; + alphaNumChars[8] = 'V'; + alphaNumChars[9] = ' '; + break; + + case 9: + //0x62870 + digitChar = '9'; + alphaNumChars[0] = '9'; + alphaNumChars[1] = 'w'; + alphaNumChars[2] = 'x'; + alphaNumChars[3] = 'y'; + alphaNumChars[4] = 'z'; + alphaNumChars[5] = '2'; + alphaNumChars[6] = 'W'; + alphaNumChars[7] = 'X'; + alphaNumChars[8] = 'Y'; + alphaNumChars[9] = 'Z'; + break; + + default: + //0x628cc + break; + } + + switch (bData_40002edc) + { + case 1: + //0x628f4 + case 3: + //0x628fc + switch (bCurrentCustomSiteInputLine) + { + case 0: + //0x62924: Name + Data_400026c3[bCharacterInputPosition - 1] = alphaNumChars[bMapKeyToCharIndex + capsOffset]; + strCustomSiteName[bCharacterInputPosition - 1] = alphaNumChars[bMapKeyToCharIndex + capsOffset]; + + if (bMapKeyToCharIndex < 4) + { + bMapKeyToCharIndex++; + } + else + { + bMapKeyToCharIndex = 0; + } + //->0x62cc4 + break; + + case 1: + //0x629b0: Longitude + if (bCharacterInputPosition != 7) + { + Data_400026db[bCharacterInputPosition - 1] = digitChar; + strCustomSiteLongitude[bCharacterInputPosition - 1] = digitChar; + } + else + { + //0x629f0 + if (Data_400026db[bCharacterInputPosition - 1] == 'E') + { + //62a0c + Data_400026db[bCharacterInputPosition - 1] = 'W'; + strCustomSiteLongitude[bCharacterInputPosition - 1] = 'W'; + } + else + { + //0x62ad4 + Data_400026db[bCharacterInputPosition - 1] = 'E'; + strCustomSiteLongitude[bCharacterInputPosition - 1] = 'E'; + } + } + //0x62b00 + HandleNextCustomSiteInputPosition(); + //->0x62cc4 + break; + + case 2: + //0x62b08: Latitude + if (bCharacterInputPosition != 7) + { + Data_400026f3[bCharacterInputPosition - 1] = digitChar; + strCustomSiteLatitude[bCharacterInputPosition - 1] = digitChar; + } + else + { + //0x62b48 + if (Data_400026f3[bCharacterInputPosition - 1] == 'N') + { + //62b64 + Data_400026f3[bCharacterInputPosition - 1] = 'S'; + strCustomSiteLatitude[bCharacterInputPosition - 1] = 'S'; + } + else + { + //0x62b94 + Data_400026f3[bCharacterInputPosition - 1] = 'N'; + strCustomSiteLatitude[bCharacterInputPosition - 1] = 'N'; + } + } + //0x62bc0 + HandleNextCustomSiteInputPosition(); + //->0x62cc4 + break; + + case 3: + //0x62bc8: Time Zone + if (bCharacterInputPosition != 7) + { + Data_4000270a[bCharacterInputPosition - 1] = digitChar; + strCustomSiteTimezone[bCharacterInputPosition - 1] = digitChar; + } + else + { + //0x62c08 + if (Data_4000270a[bCharacterInputPosition - 1] == 'E') + { + //62c24 + Data_4000270a[bCharacterInputPosition - 1] = 'W'; + strCustomSiteTimezone[bCharacterInputPosition - 1] = 'W'; + } + else + { + //0x62c54 + Data_4000270a[bCharacterInputPosition - 1] = 'E'; + strCustomSiteTimezone[bCharacterInputPosition - 1] = 'E'; + } + } + //0x62c80 + HandleNextCustomSiteInputPosition(); + //->0x62cc4 + break; + + case 4: + //0x62c88: Altitude + Data_4000271a[bCharacterInputPosition - 1] = digitChar; + strCustomSiteAltitude[bCharacterInputPosition - 1] = digitChar; + + HandleNextCustomSiteInputPosition(); + //->0x62cc4 + break; + + default: + //0x62cbc + break; + } //switch (bCurrentCustomSiteInputLine) + break; + + default: + //0x62ccc + break; + } //switch (bData_40003262) +} + +#include "Handle9Key.c" +#include "Handle8Key.c" +#include "Handle7Key.c" +#include "Handle6Key.c" +#include "Handle5Key.c" +#include "Handle4Key.c" +#include "Handle3Key.c" +#include "Handle2Key.c" + + +/* 68394 - todo */ +void func_68394(int a) +{ + int r3; + unsigned char r4; + unsigned char sp[10]; + + if (bCapsLock != 0) + { + r3 = 5; + } + else + { + r3 = 0; + } + + switch (a) + { + case 0: + r4 = '0'; + sp[0] = '0'; + sp[1] = '0'; + sp[2] = '0'; + sp[3] = '0'; + sp[4] = '0'; + sp[5] = '0'; + sp[6] = '0'; + sp[7] = '0'; + sp[8] = '0'; + sp[9] = '0'; + break; + + case 1: + r4 = '1'; + sp[0] = '1'; + sp[1] = '1'; + sp[2] = '1'; + sp[3] = '1'; + sp[4] = '1'; + sp[5] = '1'; + sp[6] = '1'; + sp[7] = '1'; + sp[8] = '1'; + sp[9] = '1'; + break; + + case 2: + r4 = '2'; + sp[0] = '2'; + sp[1] = 'a'; + sp[2] = 'b'; + sp[3] = 'c'; + sp[4] = ' '; + sp[5] = '2'; + sp[6] = 'A'; + sp[7] = 'B'; + sp[8] = 'C'; + sp[9] = ' '; + break; + + case 3: + r4 = '3'; + sp[0] = '3'; + sp[1] = 'd'; + sp[2] = 'e'; + sp[3] = 'f'; + sp[4] = ' '; + sp[5] = '3'; + sp[6] = 'D'; + sp[7] = 'E'; + sp[8] = 'F'; + sp[9] = ' '; + break; + + case 4: + r4 = '4'; + sp[0] = '4'; + sp[1] = 'g'; + sp[2] = 'h'; + sp[3] = 'i'; + sp[4] = ' '; + sp[5] = '4'; + sp[6] = 'G'; + sp[7] = 'H'; + sp[8] = 'I'; + sp[9] = ' '; + break; + + case 5: + r4 = '5'; + sp[0] = '5'; + sp[1] = 'j'; + sp[2] = 'k'; + sp[3] = 'l'; + sp[4] = ' '; + sp[5] = '5'; + sp[6] = 'J'; + sp[7] = 'K'; + sp[8] = 'L'; + sp[9] = ' '; + break; + + case 6: + r4 = '6'; + sp[0] = '6'; + sp[1] = 'm'; + sp[2] = 'n'; + sp[3] = 'o'; + sp[4] = ' '; + sp[5] = '6'; + sp[6] = 'M'; + sp[7] = 'N'; + sp[8] = 'O'; + sp[9] = ' '; + break; + + case 7: + r4 = '7'; + sp[0] = '7'; + sp[1] = 'p'; + sp[2] = 'q'; + sp[3] = 'r'; + sp[4] = 's'; + sp[5] = '7'; + sp[6] = 'P'; + sp[7] = 'Q'; + sp[8] = 'R'; + sp[9] = 'S'; + break; + + case 8: + r4 = '8'; + sp[0] = '8'; + sp[1] = 't'; + sp[2] = 'u'; + sp[3] = 'v'; + sp[4] = ' '; + sp[5] = '8'; + sp[6] = 'T'; + sp[7] = 'U'; + sp[8] = 'V'; + sp[9] = ' '; + break; + + case 9: + r4 = '9'; + sp[0] = '9'; + sp[1] = 'w'; + sp[2] = 'x'; + sp[3] = 'y'; + sp[4] = 'z'; + sp[5] = '2'; + sp[6] = 'W'; + sp[7] = 'X'; + sp[8] = 'Y'; + sp[9] = 'Z'; + break; + + default: + break; + } + + switch (bData_40003263) + { + case 1: + //0x68764 + case 3: + //0x6876c + switch (bData_40003260) + { + case 0: + //0x68790 + Data_400025b5[bCharacterInputPosition - 1] = sp[bMapKeyToCharIndex + r3]; + Data_40002625[bCharacterInputPosition - 1] = sp[bMapKeyToCharIndex + r3]; + + if (bMapKeyToCharIndex < 4) + { + bMapKeyToCharIndex++; + } + else + { + bMapKeyToCharIndex = 0; + } + break; + + case 1: + //0x6881c + Data_400025d9[bCharacterInputPosition - 1] = r4; + Data_40002634[bCharacterInputPosition - 1] = r4; + + func_563c8(); + //->0x62cc4 + break; + + case 2: + //0x68850 + if (bCharacterInputPosition != 7) + { + Data_400025fe[bCharacterInputPosition - 1] = r4; + Data_40002644[bCharacterInputPosition - 1] = r4; + } + else + { + //0x68890 + if (Data_400025fe[bCharacterInputPosition - 1] == '+') + { + Data_400025fe[bCharacterInputPosition - 1] = '-'; + Data_40002644[bCharacterInputPosition - 1] = '-'; + } + else + { + //0x688dc + Data_400025fe[bCharacterInputPosition - 1] = '+'; + Data_40002644[bCharacterInputPosition - 1] = '+'; + } + } + //0x68908 + func_563c8(); + break; + + default: + //0x68910 + break; + } //switch (bData_40003260) + break; + + default: + //0x68920 + break; + } //switch (bData_40003262) +} + +#include "Handle1Key.c" + +#include "Handle0Key.c" + +/* 6a0e4 - todo */ +unsigned char ConvertKeyCode(void) +{ +#ifndef OLIMEX_LPC2148 + unsigned char hwKey = get_hw_key_code(); + unsigned char menuKey; + + if (hwKey & 0x20) //Valid? + { + hwKey &= 0x1f; + + ack_hw_key(); + + bData_40002c68 = 0; + Data_400031e4 = 0; + } + else + { + hwKey = 100; + } + + switch (hwKey) + { + case 1: + //0x6a18c: 10100001 / 11100001 + menuKey = 16; + break; + + case 2: + //0x6a198: 10100010 / 11100010 + menuKey = 1; + break; + + case 3: + //0x6a1a4: 10100011 / 11100011 + menuKey = 4; + break; + + case 4: + //0x6a1b0: 10100100 / 11100100 + menuKey = 7; + break; + + case 5: + //0x6a1bc: 10100101 / 11100101 + menuKey = 10; + break; + + case 6: + //0x6a1c8: 10100110 / 11100110 + menuKey = 15; + break; + + case 7: + //0x6a1d4: 10100111 / 11100111 + menuKey = 2; + break; + + case 8: + //0x6a1e0: 10101000 / 11101000 + menuKey = 5; + break; + + case 9: + //0x6a1ec: 10101001 / 11101001 + menuKey = 8; + break; + + case 10: + //0x6a1f8: 10101010 / 11101010 + menuKey = 0; + break; + + case 11: + //0x6a204: 10101011 / 11101011 + menuKey = 17; + break; + + case 12: + //0x6a210: 10101100 / 11101100 + menuKey = 3; + break; + + case 13: + //0x6a21c: 10101101 / 11101101 + menuKey = 6; + break; + + case 14: + //0x6a228: 10101110 / 11101110 + menuKey = 9; + break; + + case 15: + //0x6a234: 10101111 / 11101111 + menuKey = 11; + break; + + case 16: + //0x6a240: 10110000 / 11110000 + menuKey = 14; + break; + + case 17: + //0x6a24c: 10110001 / 11110001 + menuKey = 19; + break; + + case 18: + //0x6a258: 10110010 / 11110010 + menuKey = 12; + break; + + case 19: + //0x6a264: 10110011 / 11110011 + menuKey = 20; + break; + + case 20: + //0x6a270: 10110100 / 11110100 + menuKey = 13; + break; + + case 21: + //0x6a27c + menuKey = 21; + break; + + case 22: + //0x6a288 + menuKey = 22; + break; + + case 23: + //0x6a294 + menuKey = 23; + break; + + case 24: + //0x6a2a0 + menuKey = 24; + break; + + default: + //6a2ac + SlewStop(); + SlewStop(); + break; + } + + return menuKey; +#else + return 0xFF; +#endif +} + +/* 6a2cc - todo */ +void UserInterfaceCycle(void) +{ + get_rtc_date_time(); + + if (bData_40003505 != 0) + { + func_659c(10); + ack_hw_key(); + + if (bData_4000322d_AlarmTimeElapsed == 1) + { + bData_4000322c = 0; + bData_4000322d_AlarmTimeElapsed = 0; + } + } + //6a314 + bData_40002c69_KeyCode = ConvertKeyCode(); + + if (bData_40002c68 == 0) + { + //6a330 + if (bData_40002c5a == 1) + { + func_d784(1); + } + //6a348 + switch (bData_40002c69_KeyCode) + { + case 0: + //0x6a3c0: "0 / Stop" + Handle0Key(); + bData_40003505 = 1; + break; + + case 1: + //0x6a3d8: "1" + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a40c + Handle1Key(); + } + bData_40003505 = 1; + break; + + case 2: + //0x6a420 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a454 + Handle2Key(); + } + bData_40003505 = 1; + break; + + case 3: + //0x6a468 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a49c + Handle3Key(); + } + bData_40003505 = 1; + break; + + case 4: + //0x6a4b0 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a4e4 + Handle4Key(); + } + bData_40003505 = 1; + break; + + case 5: + //0x6a4f8 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a52c + Handle5Key(); + } + bData_40003505 = 1; + break; + + case 6: + //0x6a540 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a574 + Handle6Key(); + } + bData_40003505 = 1; + break; + + case 7: + //0x6a588 + Handle7Key(); + bData_40003505 = 1; + break; + + case 8: + //0x6a5a0 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a5d4 + Handle8Key(); + } + bData_40003505 = 1; + break; + + case 9: + //0x6a5e8 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a61c + Handle9Key(); + } + bData_40003505 = 1; + break; + + case 10: + //0x6a630: "Help" + HandleHelpKey(); + bData_40003505 = 1; + break; + + case 11: + //0x6a648: "F" + HandleFKey(); + bData_40003505 = 1; + break; + + case 12: + //0x6a660: "+" + HandlePlusKey(); + bData_40003505 = 1; + break; + + case 13: + //0x6a678: "-" + HandleMinusKey(); + bData_40003505 = 1; + break; + + case 14: + //0x6a690: "Up" + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a6c4 + HandleUpKey(); + } + bData_40003505 = 1; + break; + + case 15: + //0x6a6d8: "Down" + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a70c + HandleDownKey(); + } + bData_40003505 = 1; + break; + + case 16: + //0x6a720: "Left" + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a754 + HandleLeftKey(); + } + bData_40003505 = 1; + break; + + case 17: + //0x6a768: "Right" + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a79c + HandleRightKey(); + } + bData_40003505 = 1; + break; + + #if 0 + case 18: + //0x6a900 + #endif + + case 19: + //0x6a7b0: "Enter" + HandleEnterKey(); + bData_40003505 = 1; + break; + + case 22: + //0x6a7c8 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a7fc + func_4fda8(); + } + bData_40003505 = 1; + break; + + case 21: + //0x6a810 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a844 + func_4fbc8(); + } + bData_40003505 = 1; + break; + + case 23: + //0x6a858 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a88c + func_4f9e4(); + } + bData_40003505 = 1; + break; + + case 24: + //0x6a8a0 + if (((Data_40004128.bTrackingRequest != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/)) || + (Data_40004128.bTrackingRequest == 0)) + { + //6a8d4 + func_4f804(); + } + bData_40003505 = 1; + break; + + case 20: + //0x6a8e8: "*" + HandleStarKey(); + bData_40003505 = 1; + break; + + default: + //6a900 + break; + } //switch (bData_40002c69_KeyCode) + + bData_40002c68 = 1; + //->6a948 + } + else + { + //6a91c + bData_40003505 = 0; + g_iSlewStepRaAxis = 0; + g_iSlewStepDecAxis = 0; + Data_40002e80 = 0; + Data_40002e84 = 0; + } + //6a948 + if ((Data_40002c64_MenuContextId != MENU_CONTEXT_MAIN) && //0 + (Data_40002c64_MenuContextId != MENU_CONTEXT_ALIGNMENT_STAR_CONTROL) && //12001 + (Data_40002c64_MenuContextId != MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT) && //11103 + (Data_40002c64_MenuContextId != MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN) && //11203 + (Data_40002c64_MenuContextId != MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET) && //11102 + (Data_40002c64_MenuContextId != MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET) && //11202 + (bData_40003505 == 0)) + { + if (bData_40002ef6 == 0) + { + bData_40002ef6 = 1; + Data_40002ef8 = 0; + } + //->6aa04 + } + else + { + //6a9f8 + bData_40002ef6 = 0; + } + //6aa04 + if (bData_40002f1e_SetupLocalData == 1) + { + //6aa14 + if (bData_400031ec != 0) + { + //6aa24 + get_rtc_date_time(); + + sprintf(Data_400037ec, "%04d-%02d-%02d", Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40003150, "%02d:%02d:%02d", bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + sprintf(Data_40002655, "%04d-%02d-%02d", Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40002660, "%02d:%02d:%02d", bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + + bData_400031ec = 0; + } + //6aad4 + } + //6aad4 + if (bHelpActive == 0) + { + DisplayScreenItems(); + } + else + { + //0x6aaec + DisplayHelpScreen(); + } + //6aaf0 + if ((bData_4000322c == 1) && + (Data_40003220_AlarmHours == bData_40002e62_Hours) && + (Data_40003224_AlarmMinutes == bData_40002e63_Minutes) && + (Data_40003228_AlarmSeconds == bData_40002e64_Seconds)) + { + bData_4000322d_AlarmTimeElapsed = 1; + } + //6ab54 + if (bData_4000322d_AlarmTimeElapsed == 1) + { + beep1(10); + } +} + +/* 6ab74 - todo */ +double func_6ab74(int a) +{ + unsigned char r5; + union + { + unsigned char b[4]; + int i; + } sp8; + double d; + + bData_40002c13_uart1ReceiveComplete = 0; + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + + switch (a) + { + case 1: + uart1_write_byte(0x10); + break; + + case 2: + uart1_write_byte(0x30); + break; + + case 3: + uart1_write_byte(0x50); + break; + + case 4: + uart1_write_byte(0x70); + break; + + default: + break; + } + + bData_40002c13_uart1ReceiveComplete = 0; + + delay_loop(10); + + for (r5 = 50; (bData_40002c13_uart1ReceiveComplete == 0) && (r5 > 2); r5--) + { + func_659c(5); + } + + sp8.i = 0; + + if (bData_40002c13_uart1ReceiveComplete == 1) + { + switch (a) + { + case 1: + sp8.b[1] = Data_40003592_uart1ReceiveDataBuffer[1]; + sp8.b[0] = Data_40003592_uart1ReceiveDataBuffer[2]; + d = sp8.i; + break; + + case 2: + sp8.b[1] = Data_40003592_uart1ReceiveDataBuffer[1]; + sp8.b[0] = Data_40003592_uart1ReceiveDataBuffer[2]; + d = sp8.i; + break; + + case 3: + sp8.b[1] = Data_40003592_uart1ReceiveDataBuffer[1]; + sp8.b[0] = Data_40003592_uart1ReceiveDataBuffer[2]; + d = sp8.i; + break; + + case 4: + sp8.b[1] = Data_40003592_uart1ReceiveDataBuffer[1]; + sp8.b[0] = Data_40003592_uart1ReceiveDataBuffer[2]; + d = sp8.i; + break; + + default: + break; + } + + bData_40002c13_uart1ReceiveComplete = 0; + } + + return d; +} + +/* 6ae24 - complete */ +double InquireMotorData(int a) +{ + unsigned char wait; + double dValue; + + bData_40002c13_uart1ReceiveComplete = 0; + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(1); + + switch (a) + { + case 1: + //0x6ae7c + uart1_write_byte(0x04); //RA Inquire? + break; + + case 2: + //0x6ae8c + uart1_write_byte(0x24); //DEC Inquire? + break; + + case 3: + //0x6ae9c + uart1_write_byte(0x44); + break; + + case 4: + //0x6aeac + uart1_write_byte(0x64); + break; + + default: + //0x6aebc + break; + } + + bData_40002c13_uart1ReceiveComplete = 0; + + delay_loop(2); + + wait = 20; + + if (bData_40002c1a != 0) + { + while ((bData_40002c13_uart1ReceiveComplete == 0) && (wait > 2)) + { + //0x6aef4 + func_659c(5); + wait--; + } + } + //0x6af1c + if (bData_40002c13_uart1ReceiveComplete == 1) + { + //6af2c + switch (a) + { + case 1: + //0x6af50 + if (Data_40003592_uart1ReceiveDataBuffer[0] == 0x04) + { + //6af64 + Data_400031a0.bData[3] = Data_40003592_uart1ReceiveDataBuffer[2]; + Data_400031a0.bData[2] = Data_40003592_uart1ReceiveDataBuffer[3]; + Data_400031a0.bData[1] = Data_40003592_uart1ReceiveDataBuffer[4]; + + dValue = Data_400031a0.Data; + g_dMotorPositionRaAxis = dValue * 360.0 / 841763108.524032; + } + //0x6afcc -> 0x6b15c + break; + + case 2: + //0x6afd0 + if (Data_40003592_uart1ReceiveDataBuffer[0] == 0x24) + { + //6af64: DEC Inquire response? + Data_400031a0.bData[3] = Data_40003592_uart1ReceiveDataBuffer[2]; + Data_400031a0.bData[2] = Data_40003592_uart1ReceiveDataBuffer[3]; + Data_400031a0.bData[1] = Data_40003592_uart1ReceiveDataBuffer[4]; + + dValue = Data_400031a0.Data; + g_dMotorPositionDecAxis = dValue * 360.0 / 841763108.524032; + } + //0x6b04c -> 0x6b15c + break; + + case 3: + //0x6b050 + if (Data_40003592_uart1ReceiveDataBuffer[0] == 0x44) + { + //6b064 + Data_400031a0.bData[3] = Data_40003592_uart1ReceiveDataBuffer[2]; + Data_400031a0.bData[2] = Data_40003592_uart1ReceiveDataBuffer[3]; + Data_400031a0.bData[1] = Data_40003592_uart1ReceiveDataBuffer[4]; + + dValue = Data_400031a0.Data; + g_dMotorPositionAziAxis = dValue * 360.0 / 278879846.40000004; + #if 1 + if (Data_400031a0.Data == 0) + { + } + #endif + } + //0x6b0d0 -> 0x6b15c + break; + + case 4: + //0x6b0d4 + if (Data_40003592_uart1ReceiveDataBuffer[0] == 0x64) + { + //6b0e8 + Data_400031a0.bData[3] = Data_40003592_uart1ReceiveDataBuffer[2]; + Data_400031a0.bData[2] = Data_40003592_uart1ReceiveDataBuffer[3]; + Data_400031a0.bData[1] = Data_40003592_uart1ReceiveDataBuffer[4]; + + dValue = Data_400031a0.Data; + g_dMotorPositionAltAxis = dValue * 360.0 / 383201280.0; + } + //0x6b150 -> 0x6b15c + break; + + default: + //0x6b154 + break; + } + //6b160 + bData_40002c13_uart1ReceiveComplete = 0; + } //if (bData_40002c13_uart1ReceiveComplete == 1) + //0x6b16c +} + +/* 6b17c - complete */ +void ReceiveMountAutoguideValues(void) +{ + unsigned char wait; + + iMountAutoguideRa = 0; + iMountAutoguideDec = 0; + bData_40002c13_uart1ReceiveComplete = 0; + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0x81); + + bData_40002c13_uart1ReceiveComplete = 0; + + wait = 10; + while ((bData_40002c13_uart1ReceiveComplete == 0) && + (bData_40002c13_uart1ReceiveComplete == 0)) + { + //0x6b1d8 + delay_loop(1); + wait--; + } + //0x6b208 + if (bData_40002c13_uart1ReceiveComplete == 1) + { + //6b218 + if (Data_40003592_uart1ReceiveDataBuffer[0] == 0x81) + { + //6b228 + Data_40003592_uart1ReceiveDataBuffer[1] = + ~Data_40003592_uart1ReceiveDataBuffer[1]; + + if ((Data_40003592_uart1ReceiveDataBuffer[1] & 1) == 1) + { + //6b250 + iMountAutoguideRa = 1; + } + //0x6b25c + if ((Data_40003592_uart1ReceiveDataBuffer[1] & 8) == 8) + { + //6b270 + iMountAutoguideRa = -1; + } + //0x6b27c + if ((Data_40003592_uart1ReceiveDataBuffer[1] & 2) == 2) + { + //6b290 + iMountAutoguideDec = 1; + } + //0x6b29c + if ((Data_40003592_uart1ReceiveDataBuffer[1] & 4) == 4) + { + //6b290 + iMountAutoguideDec = -1; + } + #if 1 + if ((Data_40003592_uart1ReceiveDataBuffer[1] & 16) == 16) + { + } + #endif + } + //0x6b2c0 + bData_40002c13_uart1ReceiveComplete = 0; + } + //0x6b2cc +} + +/* 6b310 - todo */ +void func_6b310(void) +{ + switch (wData_40002eda) + { + case 10000: + //6b33c + wData_40002eda = 1000; + break; + + case 1000: + //0x6b350 + wData_40002eda = 100; + break; + + case 100: + //0x6b364 + wData_40002eda = 10; + break; + + case 10: + //0x6b378 + wData_40002eda = 1; + break; + + default: + //0x6b38c + break; + } +} + +/* 6b39c - complete */ +void func_6b39c(void) +{ +} + +/* 6b3a0 - complete */ +void func_6b3a0(void) +{ +} + +/* 6b3a4 - complete */ +void func_6b3a4(void) +{ +} + +/* 6b3a8 - todo */ +int func_6b3a8(double a, double b, double c, double d) +{ + float r6; + float r7; + float r4; + float r5; + + if ((d >= 4) || (d <= 20)) + { + //0x6b3e0 + r6 = d - 4; + r7 = d + 4; + } + else + { + //0x6b42c + if (d < 4) + { + //6b444 + r6 = d + 24 - 4; + r7 = d + 4; + } + else + { + //0x6b4a4 + r6 = d - 4; + r7 = d - 24 + 4; + } + } + //0x6b500 + if (c >= 0) + { + //6b518 + r4 = c - 60; + r5 = c + 60; + + if (r5 > 90) + { + r5 = 90; + } + } + else + { + //0x6b578 + r4 = c - 60; + r5 = c + 60; + + if (r4 < -90) + { + r4 = -90; + } + } + //0x6b5d4 + if ((d >= 4) || (d <= 20)) + { + //0x6b604 + if ((a >= r6) && (a <= r7)) + { + if ((b >= r4) && (b <= r5)) + { + return 1; + } + } + //0x6b774 + } + else + { + //0x6b68c + if ((d <= 4) || (d >= 20)) + { + //0x6b6bc + if (((a >= r6) && (a <= 24)) || ((a >= 0) && (a <= r7))) + { + if ((b >= r4) && (b <= r5)) + { + return 1; + } + } + //0x6b774 + } + else + { + //0x6b76c + return 0; + } + } +} + +/* 6b778 - todo */ +void func_6b778(void) +{ + double sp456; + float sp452; + float sp448; + unsigned char strStarNames[10][10]; //sp348 + unsigned char sp128[10][22]; + unsigned char sp36[9][10] = + { + "Moon ", + "Mercury ", + "Vernus ", + "Mars ", + "Jupiter ", + "Saturn ", + "Uranrs ", + "Neptune ", + "Sun " + }; + + unsigned char r4 = 0; + unsigned char r5; + + sp456 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude); + + bData_40003161 = GetCurrentAlignStars(sp456, + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, + strStarNames, sp128); + + get_solar_system_object_data(8, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + //0x6b894 + Data_400038e8[r4 - 1][r5] = sp36[0][r5]; + } + } + //0x6b8c0 + get_solar_system_object_data(0, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + //0x6b95c + Data_400038e8[r4 - 1][r5] = sp36[1][r5]; + } + } + //6b988 + get_solar_system_object_data(1, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp36[2][r5]; + } + } + //6ba50 + get_solar_system_object_data(2, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp36[3][r5]; + } + } + //6bb18 + get_solar_system_object_data(3, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp36[4][r5]; + } + } + //6bbe0 + get_solar_system_object_data(4, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp36[5][r5]; + } + } + //6bca8 + get_solar_system_object_data(5, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp36[6][r5]; + } + } + //6bd70 + get_solar_system_object_data(6, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp36[7][r5]; + } + } + //6be38 + get_solar_system_object_data(7, &sp452, &sp448); + + if (1 == func_6b3a8(sp452, sp448, Data_40004128.geographicLatitude, sp456)) + { + r4++; + + Data_400037f8[2*(r4 - 1)] = sp452; + Data_400037f8[2*(r4 - 1) + 1] = sp448; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp36[8][r5]; + } + } + //6bf00 + for (bData_40003504 = 0; bData_40003504 < bData_40003161; bData_40003504++) + { + //0x6bf10 + Data_400037f8[2*r4 + 2*bData_40003504] = + Data_40004a68_CurrentAlignStarEquatorialCoord[2 * bData_40003504]; + Data_400037f8[2*r4 + 2*bData_40003504 + 1] = + Data_40004a68_CurrentAlignStarEquatorialCoord[2 * bData_40003504 + 1]; + + for (r5 = 0; r5 < 10; r5++) + { + //0x6bf7c + Data_400038e8[bData_40003504 + r4][r5] = strStarNames[bData_40003504][r5]; + } + } + //6bfec + bData_40003161 += r4; +} + +/* 6c00c - todo */ +void func_6c00c(void) +{ + double sp1000; + float sp996; + float sp992; + unsigned char strStarNames[28][10]; //sp712 + unsigned char sp96[28][22]; + unsigned char sp4[9][10] = + { + "Moon ", + "Mercury ", + "Vernus ", + "Mars ", + "Jupiter ", + "Saturn ", + "Uranrs ", + "Neptune ", + "Sun " + }; + + unsigned char r4 = 0; + unsigned char r5; + + sp1000 = get_local_sidereal_time(1, 0, Data_40004128.geographicLongitude); + + bData_40003161 = GetCurrentAlignStars(sp1000, + Data_40004128.geographicLatitude, + Data_40004a68_CurrentAlignStarEquatorialCoord, + strStarNames, sp96); + + get_solar_system_object_data(8, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + //0x6c0d0 + Data_400038e8[r4 - 1][r5] = sp4[0][r5]; + } + //6c0fc + get_solar_system_object_data(0, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[1][r5]; + } + //6c170 + get_solar_system_object_data(1, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[2][r5]; + } + //6c1e4 + get_solar_system_object_data(2, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[3][r5]; + } + //6c298 + get_solar_system_object_data(3, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[4][r5]; + } + //6c30c + get_solar_system_object_data(4, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[5][r5]; + } + //6c380 + get_solar_system_object_data(5, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[6][r5]; + } + //6c3f4 + get_solar_system_object_data(6, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[7][r5]; + } + //6c468 + get_solar_system_object_data(7, &sp996, &sp992); + + r4++; + + Data_400037f8[2*(r4 - 1)] = sp996; + Data_400037f8[2*(r4 - 1) + 1] = sp992; + + for (r5 = 0; r5 < 10; r5++) + { + Data_400038e8[r4 - 1][r5] = sp4[8][r5]; + } + //6c4dc + for (bData_40003504 = 0; bData_40003504 < bData_40003161; bData_40003504++) + { + //6c4ec + Data_400037f8[2*r4 + 2*bData_40003504] = + Data_40004a68_CurrentAlignStarEquatorialCoord[2 * bData_40003504]; + Data_400037f8[2*r4 + 2*bData_40003504 + 1] = + Data_40004a68_CurrentAlignStarEquatorialCoord[2 * bData_40003504 + 1]; + + for (r5 = 0; r5 < 10; r5++) + { + //0x6c558 + Data_400038e8[bData_40003504 + r4][r5] = strStarNames[bData_40003504][r5]; + } + } + //6c5c8 + bData_40003161 += r4; +} + +/* 6c5e8 - todo */ +void func_6c5e8(void) +{ + unsigned char i; + + for (i = 0; i < 7; i++) + { + Data_4000327f[i] = Data_4000251d[i + 6]; + } + + Data_4000327f[7] = 0; + + Data_40003290.wData_0 = atoi(&Data_4000253d[6]); + Data_40003290.wData_2 = atoi(&Data_4000253d[10]); + Data_40003290.wData_4 = atoi(&Data_4000253d[13]); + + Data_40003296.bData_0 = atoi(&Data_4000255d[6]); + Data_40003296.bData_1 = atoi(&Data_4000255d[9]); + Data_40003296.bData_2 = atoi(&Data_4000255d[12]); + + if ((Data_40003290.wData_0 >= 360) || + (Data_40003290.wData_2 > 59) || + (Data_40003290.wData_4 > 59) || + (Data_40003296.bData_0 > 89) || + (Data_40003296.bData_1 > 59) || + (Data_40003296.bData_2 > 59)) + { + Data_40002c64_MenuContextId = 211001; + } + else + { + //0x6c6f4 + fData_40003288 = (float)Data_40003290.wData_0 + + (float)Data_40003290.wData_2 / 60 + + (float)Data_40003290.wData_2 / 3600; //BUG? + + fData_4000328c = (float)Data_40003296.bData_0 + + (float)Data_40003296.bData_1 / 60 + + (float)Data_40003296.bData_1 / 3600; //BUG? + + switch (bData_40003262) + { + case 1: + //6c7cc + func_3230(Data_4000327f, &fData_40003288, &fData_4000328c); + + Data_40002c64_MenuContextId = 21102; + break; + + default: + break; + } + } +} + +/* 6c804 - complete */ +void ShowStartupScreen(void) +{ + #ifdef UART0_DEBUG + lcd_display_string(0, 1, 1, 22, " OPEN GOTO SYSTEM "); + lcd_display_string(0, 2, 1, 22, "based on EXOS EQ v2.3 "); + lcd_display_string(0, 4, 1, 22, "github.com/Spitzbube/ "); + lcd_display_string(0, 5, 1, 22, "Commit: 08ba598fa99635"); + #else + lcd_display_string(0, 3, 1, 22, " BRESSER GOTO SYSTEM "); + lcd_display_string(0, 5, 1, 22, " EXOS EQ v2.3 "); + #endif +} + +#include "ascom.c" + + +static void vLEDTask( void *pvParameters ) +{ + int off = 1; + + //OFF + IO0SET = (1 << 16); + + for( ;; ) + { + vTaskDelay( ( TickType_t ) 1000 / portTICK_PERIOD_MS ); + + if (off) + { + //ON + IO0CLR = (1 << 16); + off = 0; + } + else + { + //OFF + IO0SET = (1 << 16); + off = 1; + } + } +} + +static void vUART0Task( void *pvParameters ) +{ +#if 0 + uart0_init(360); + + VICVectCntl1 = (1 << 5) | 6; // UART0 -> Slot 1 + VICIntEnable = (1 << 6); // Enable UART0 +#endif + + for( ;; ) + { + vTaskDelay( ( TickType_t ) 1000 / portTICK_PERIOD_MS ); +#if 0 + { + static char buf[105]; + portTickType xtick = xTaskGetTickCount(); + + snprintf(buf, 100, "vUART0Task=%u\n\r", (unsigned int)xtick); + uart1_send((unsigned char*)buf, strlen(buf)); + } +#endif + } +} + +static void vUART1Task( void *pvParameters ) +{ +#if 0 + uart1_init(360); + + VICVectCntl2 = (1 << 5) | 7; // UART1 -> Slot 2 + VICIntEnable = (1 << 7); // Enable UART1 +#endif + + for( ;; ) + { + extern QueueHandle_t xQueueUart1; + unsigned char uart1ReceiveDataBuffer[10]; + if (xQueueReceive(xQueueUart1, &uart1ReceiveDataBuffer, 100)) + { + static char buf[35]; + portTickType xtick = xTaskGetTickCount(); + + snprintf(buf, 30, "vUART1Task=%u\n\r", (unsigned int)xtick); + uart0_send((unsigned char*)buf, strlen(buf)); + } + +// vTaskDelay( ( TickType_t ) 1000 / portTICK_PERIOD_MS ); +#if 0 + { + static char buf[105]; + portTickType xtick = xTaskGetTickCount(); + + snprintf(buf, 100, "vUART1Task=%u\n\r", (unsigned int)xtick); + uart1_send((unsigned char*)buf, strlen(buf)); + } +#endif + } +} + +static void vTimerTask( void *pvParameters ) +{ + for( ;; ) + { + vTaskDelay( ( TickType_t ) 10 / portTICK_PERIOD_MS ); + timer_isr(); +#if 0 + { + static char buf[105]; + portTickType xtick = xTaskGetTickCount(); + + snprintf(buf, 100, "vTimerTask=%u\n\r", (unsigned int)xtick); + uart1_send((unsigned char*)buf, strlen(buf)); + } +#endif + } +} + +/* 6d054 - todo */ +static void vMainTask(void *pvParameters) +{ +#if 0 + { + static char buf[105]; + + snprintf(buf, 100, "vMainTask\n\r"); + uart1_send((unsigned char*)buf, strlen(buf)); + } +#endif + + func_7590(); //Send Stop on Uart1? + func_d2cc(); //Initialize variables + func_5099c(); //Initialize variables + + flash_read(0xdcb, 0, 10, Data_40004c58); + bData_40003196_CurrentLanguage = Data_40004c58[0]; + if (Data_40004c58[1] == 1) + { + ValidateDateTimeSetRTC(); + Data_40004c58[1] = 0; + flash_write(0xdcb, 0, 2, Data_40004c58); + } + + ShowStartupScreen(); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(1); + uart1_write_byte(1); + uart1_write_byte(0x44); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(1); + uart1_write_byte(1); + uart1_write_byte(0x64); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(1); + uart1_write_byte(1); + uart1_write_byte(0x04); + + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(1); + uart1_write_byte(1); + uart1_write_byte(0x24); + + func_659c(10); //delay + + fData_40002e98 = func_6ab74(1); //receive data for Cmd=0x10 + + func_659c(50); //delay + + fData_40002ea8 = func_6ab74(2); //receive data for Cmd=0x30 + + func_659c(50); //delay + + if (bData_40002c1a == 1) + { + bData_40002e7a_MountType = MENU_MOUNT_TYPE_EQU; //1; + } + else + { + bData_40002e7a_MountType = MENU_MOUNT_TYPE_AZ; //0; + } + + bData_40003432 = 0; + + Data_400034d0 = 0.05; + Data_400034d8 = 0.045; + + Data_40004128.dData_192 = 100.0; + Data_40004128.dData_200 = 60.0; + + flash_get_ota_zero_data(&fData_4000329c, &fData_400032a0); + + Data_40004128.dData_192 = fData_4000329c; + Data_40004128.dData_200 = fData_400032a0; + + Data_40004128.dData_112 = -180.0; + Data_40004128.dData_120 = 90.0; + + //6d2ac + flash_get_custom_site_data(arInitialCustomSiteName, + &fInitialCustomSiteLongitude, + &fInitialCustomSiteLatitude, + &iInitialCustomSiteTimezone); + + Data_40004128.geographicLongitude = fInitialCustomSiteLongitude; + Data_40004128.geographicLatitude = fInitialCustomSiteLatitude; + Data_40002e54_Zone = iInitialCustomSiteTimezone; + + strCustomSiteName[6] = arInitialCustomSiteName[0]; + strCustomSiteName[7] = arInitialCustomSiteName[1]; + strCustomSiteName[8] = arInitialCustomSiteName[2]; + strCustomSiteName[9] = arInitialCustomSiteName[3]; + strCustomSiteName[10] = arInitialCustomSiteName[4]; + strCustomSiteName[11] = arInitialCustomSiteName[5]; + strCustomSiteName[12] = arInitialCustomSiteName[6]; + strCustomSiteName[13] = arInitialCustomSiteName[7]; + //6d364 + if (fInitialCustomSiteLongitude > 0) + { + //6d378 + sprintf(strCustomSiteLongitude, " Lon:E%03dd%02df ", + DEGREES_MINUTES_ABS(fInitialCustomSiteLongitude)); + //->6d494 + } + else + { + //6d408 + sprintf(strCustomSiteLongitude, " Lon:W%03dd%02df ", + DEGREES_MINUTES_ABS(fInitialCustomSiteLongitude)); + } + //6d494 + if (fInitialCustomSiteLatitude > 0) + { + //6d4a8 + sprintf(strCustomSiteLatitude, " Lat:N%02dd%02df ", + DEGREES_MINUTES_ABS(fInitialCustomSiteLatitude)); + //->6d5c4 + } + else + { + //6d538 + sprintf(strCustomSiteLatitude, " Lat:S%02dd%02df ", + DEGREES_MINUTES_ABS(fInitialCustomSiteLatitude)); + } + //6d5c4 + if (iInitialCustomSiteTimezone > 0) + { + //6d5d4 + sprintf(strCustomSiteTimezone, " Zone:E%02d", abs(iInitialCustomSiteTimezone)); + } + else + { + //6d604 + sprintf(strCustomSiteTimezone, " Zone:W%02d", abs(iInitialCustomSiteTimezone)); + } + //6d630 + func_659c(2000); + lcd_display_clear(); + + if (bData_40002f1e_SetupLocalData == 1) + { + //6d64c + get_rtc_date_time(); + + if (Data_40002e5c_Year < 2000) + { + //6d660 + Data_40002e5c_Year = 2000; + bData_40002e60_Month = 1; + bData_40002e61_Day = 1; + bData_40002e62_Hours = 0; + bData_40002e63_Minutes = 0; + bData_40002e64_Seconds = 0; + } + //6d69c + sprintf(Data_400037ec, "%04d-%02d-%02d", Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40003150, "%02d:%02d:%02d", bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + sprintf(Data_40002655, "%04d-%02d-%02d", Data_40002e5c_Year, bData_40002e60_Month, bData_40002e61_Day); + sprintf(Data_40002660, "%02d:%02d:%02d", bData_40002e62_Hours, bData_40002e63_Minutes, bData_40002e64_Seconds); + + bCharacterInputPosition = 1; + bDateTimeInputMode = 0; + Data_40002c64_MenuContextId = MENU_CONTEXT_TIME_DATE_INPUT; //41001; + //->6d880 + } + else + { + //6d874 + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; //0; + } + //6d880 + Data_40002c1c = 0; + Data_40002c20 = 0; + //6d894 -> 729ec + + //########################################################################## + //#################### Main Loop ########################################### + //########################################################################## + while (1) + { +#if 0 + { + static char buf[100]; + snprintf(buf, sizeof(buf)-1, "Main Loop (Context: %d)\n\r", Data_40002c64_MenuContextId); + uart1_send(buf, strlen(buf)); + } +#endif + + #if 0 //def UART0_DEBUG + { + static char buf[100]; + snprintf(buf, sizeof(buf)-1, "Main Loop (Context: %d)\n\r", Data_40002c64_MenuContextId); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "dData_40002dc0_Azimuth: %f\n\r", dData_40002dc0_Azimuth); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "dData_40002df8: %f\n\r", dData_40002df8); + uart0_send(buf, strlen(buf)); + + snprintf(buf, sizeof(buf)-1, "bData_40002c1a: %d\n\r", bData_40002c1a); + uart0_send(buf, strlen(buf)); + } + #endif + + //6d898 + fData_40002efc = dData_40002dc0_Azimuth; + fData_40002f00 = dData_40002df8; + + ProcessAscomCommands(); + +#if 0 //OLIMEX_LPC2148 + volatile int j; + //for (j = 0; j < 500000; j++ ); // wait 500 msec + func_659c(500); +// IOSET0 = 0x00000800; + IOCLR0 = 0x00000400; + //for (j = 0; j < 500000; j++ ); // wait 500 msec + func_659c(500); + IOSET0 = 0x00000400; +// IOCLR0 = 0x00000800; +#endif + + if (bData_40002c1a == 1) + { + //6d8d4 + bData_40002e7a_MountType = MENU_MOUNT_TYPE_EQU; //1; + //6d8e0 + g_dObjectRightAcension = Data_40004128.dObjHourAngleDisplay - 0.00083333333333/* 1/1200 */; + Data_40002cd8_ObjectRightAscensionHours = g_dObjectRightAcension; + Data_40002cdc_ObjectRightAscensionMinutes = (g_dObjectRightAcension - Data_40002cd8_ObjectRightAscensionHours) * 60.0; + fData_40002ce0_ObjectRightAscensionSeconds = (g_dObjectRightAcension - Data_40002cd8_ObjectRightAscensionHours - + Data_40002cdc_ObjectRightAscensionMinutes / 60.0) * 3600.0; + + fData_40002d18_ObjectDeclination = fabs(Data_40004128.dObjDeclinationDisplay); + Data_40002d00_ObjectDeclinationDegrees = fData_40002d18_ObjectDeclination; + Data_40002d04_ObjectDeclinationMinutes = (fData_40002d18_ObjectDeclination - + (float)Data_40002d00_ObjectDeclinationDegrees) * 60.0; + fData_40002d08_ObjectDeclinationSeconds = (fData_40002d18_ObjectDeclination - + (float)Data_40002d00_ObjectDeclinationDegrees - Data_40002d04_ObjectDeclinationMinutes / 60.0) * 3600.0; + + //6db14 + if (Data_40004128.dObjDeclination >= 0.0) + { + //6db30 + g_iObjectDeclinationSign = 1; + } + else + { + //0x6db40 + g_iObjectDeclinationSign = -1; + } + //6db4c + InquireMotorData(1); //RA Inquire? + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionRaAxis; + dData_400034e8 = g_dMotorPositionRaAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + dData_40002d78 = g_dMotorPositionRaAxis; + + func_659c(5); + InquireMotorData(2); //DEC Inquire? + //6dbbc + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionDecAxis; + dData_400034f8 = g_dMotorPositionDecAxis; + dData_40002df8 = fabs(Data_40004128.dMotorPositionDecAxis); + dData_40002d98 = dData_40002df8; // = fabs(Data_40004128.dMotorPositionDecAxis); + //6dc04 + dData_40002d98 = fabs(dData_40002d98); + //->0x6dc9c + while (dData_40002d98 > 360.0) + { + //0x6dc80 + dData_40002d98 -= 360.0; + } + //6dcb4 + if (Data_40004128.geographicLatitude >= 0) + { + //6dcd0 + if (dData_40002d98 > 180) + { + //6dce8 + dData_40002d98 -= 270.0; + } + else + { + //0x6dd08 + dData_40002d98 = 90.0 - dData_40002d98; + } + //0x6dd24 + dData_40002d78 += 90.0; + + if ((g_dMotorPositionDecAxis > 0) && (g_dMotorPositionDecAxis < 180)) + { + //6dd70 + dData_40002d78 += 180; + } + //0x6dd8c + if ((g_dMotorPositionDecAxis < 0) && (g_dMotorPositionDecAxis < -180)) + { + //6ddbc + dData_40002d78 += 90; + } + //0x6ddd8 -> 0x6ddf8 + while (dData_40002d78 >= 360) + { + //0x6dddc + dData_40002d78 -= 360; + } + //->0x6de30 + while (dData_40002d78 < 0) + { + //0x6de14 + dData_40002d78 += 360; + } + //->0x6dfc4 + } //if (Data_40004128.geographicLatitude >= 0) + else + { + //0x6de4c + if (dData_40002d98 > 180) + { + //6dce8 + dData_40002d98 = 270.0 - dData_40002d98; + //->0x6dea0 + } + else + { + //0x6de84 + dData_40002d98 -= 90.0; + } + //0x6dea0 + dData_40002d78 = 270.0 - dData_40002d78; + + if ((g_dMotorPositionDecAxis > 0) && (g_dMotorPositionDecAxis < 180)) + { + //6deec + dData_40002d78 -= 180; + } + //0x6df08 + if ((g_dMotorPositionDecAxis < 0) && (g_dMotorPositionDecAxis < -180)) + { + //6df38 + dData_40002d78 -= 180; + } + //0x6df54 -> 0x6df74 + while (dData_40002d78 >= 360) + { + //0x6df58 + dData_40002d78 -= 360; + } + //->0x6dfac + while (dData_40002d78 < 0) + { + //0x6df90 + dData_40002d78 += 360; + } + } + //0x6dfc4 + dData_40002d78 /= 15.0; + #if 0 + sp64 = dData_400031f0 / 15.0; + sp56 = dData_40003420 / 15.0; + sp48 = dData_40002d78 - sp56; + sp40 = sp48 - sp64; + sp32 = fData_400034c8; + sp24 = sp32 - sp40; + fData_40003508 = sp24; + #else + fData_40003508 = fData_400034c8 - + ((dData_40002d78 - dData_40003420 / 15.0) - dData_400031f0 / 15.0); + #endif + if (fData_40003508 < 0) + { + //6e08c + fData_40003508 += 24; + } + //0x6e0a4 + if (fData_40003508 > 24) + { + //6e0b8 + fData_40003508 -= 24; + } + //0x6e0d0 + #if 0 + sp64 = dData_40003420 / 15.0; + sp56 = dData_40002d78 - sp64; + sp48 = sp56 + dData_400033e8; + Data_40002d68_OTARightAscensionHours = sp48; + #else + Data_40002d68_OTARightAscensionHours = dData_40002d78 - + dData_40003420 / 15.0 + dData_400033e8; + #endif + + #if 0 + sp64 = Data_40002d68_OTARightAscensionHours; + sp56 = dData_40003420 / 15.0; + sp48 = dData_40002d78 - sp56; + sp40 = sp48 + dData_400033e8; + sp32 = sp40 - sp64; + sp24 = sp32 * 60.0; + 40002d6c = sp24; + #else + Data_40002d6c_OTARightAscensionMinutes = 60 * + (dData_40002d78 - dData_40003420 / 15.0 + dData_400033e8 - + Data_40002d68_OTARightAscensionHours); + #endif + + #if 0 + sp64 = Data_40002d6c_OTARightAscensionMinutes; + sp56 = sp64 / 60.0; + sp48 = Data_40002d68_OTARightAscensionHours; + sp40 = dData_40003420 / 15.0; + sp32 = dData_40002d78 - sp40; + sp24 = sp32 + dData_400033e8; + sp16 = sp24 - sp48; + sp8 = sp16 - sp56; + sp = sp8 * 3600.0; + #else + fData_40002d70_OTARightAscensionSeconds = 3600.0 * + ((dData_40002d78 - dData_40003420 / 15.0 + dData_400033e8 - + Data_40002d68_OTARightAscensionHours) - + Data_40002d6c_OTARightAscensionMinutes / 60.0); + #endif + + if ((bData_40003200 == 1) && (Data_40004128.dData_304 == 2.0)) + { + //6e2c0 + dData_400033e8 = g_dObjectRightAcension - dData_40002d78; + Data_40002d68_OTARightAscensionHours = Data_40002cd8_ObjectRightAscensionHours; + Data_40002d6c_OTARightAscensionMinutes = Data_40002cdc_ObjectRightAscensionMinutes; + fData_40002d70_OTARightAscensionSeconds = fData_40002ce0_ObjectRightAscensionSeconds; + } + //0x6e30c + #if 0 + sp64 = dData_40002d98 - dData_40003428; + sp56 = sp64 - dData_400031f8; + fData_4000350c = sp56; + #else + fData_4000350c = dData_40002d98 - dData_40003428 - dData_400031f8; + #endif + + #if 0 + sp64 = dData_40002d98 - dData_40003428; + sp56 = sp64 + dData_400033f0; + Data_40002d8c_OTADeclinationDegrees = sp56; + #else + Data_40002d8c_OTADeclinationDegrees = dData_40002d98 - dData_40003428 + dData_400033f0; + #endif + + #if 0 + sp64 = Data_40002d8c_OTADeclinationDegrees; + sp56 = dData_40002d98 - dData_40003428; + sp48 = sp56 + dData_400033f0; + sp40 = sp48 - sp64; + sp32 = sp40 * 60.0; + Data_40002d90_OTADeclinationMinutes = sp32; + #else + Data_40002d90_OTADeclinationMinutes = 60.0 * + (dData_40002d98 - dData_40003428 + dData_400033f0 - Data_40002d8c_OTADeclinationDegrees); + #endif + + #if 0 + sp64 = Data_40002d90_OTADeclinationMinutes; + sp56 = sp64 / 60.0; + sp48 = Data_40002d8c_OTADeclinationDegrees; + sp40 = dData_40002d98 - dData_40003428; + sp32 = sp40 + dData_400033f0; + sp24 = sp32 - sp48; + sp16 = sp24 - sp56; + sp8 = sp16 * 3600.0; + #else + fData_40002d94_OTADeclinationSeconds = 3600.0 * + (dData_40002d98 - dData_40003428 + dData_400033f0 - Data_40002d8c_OTADeclinationDegrees - + Data_40002d90_OTADeclinationMinutes / 60.0); + #endif + + if ((bData_40003201 == 1) && (Data_40004128.dData_312 == 2.0)) + { + //6e4f8 + #if 0 + sp64 = fData_40002d18_ObjectDeclination; + dData_400033f0 = sp64 - dData_40002d98; + #else + dData_400033f0 = fData_40002d18_ObjectDeclination - dData_40002d98; + #endif + + Data_40002d8c_OTADeclinationDegrees = Data_40002d00_ObjectDeclinationDegrees; + Data_40002d90_OTADeclinationMinutes = Data_40002d04_ObjectDeclinationMinutes; + fData_40002d94_OTADeclinationSeconds = fData_40002d08_ObjectDeclinationSeconds; + } + //6e554 -> 0x6f8d0 + } //if (bData_40002c1a == 1) + //6e558 + else if (bData_40002c1a == 2) + { + //6e568 + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + //6e578 + dData_40002d30 = Data_40004128.dObjHourAngleDisplay + 180.0; + Data_40002d20 = dData_40002d30; + Data_40002d24 = (dData_40002d30 - Data_40002d20) * 60.0; + fData_40002d28 = (dData_40002d30 - Data_40002d20 - Data_40002d24 / 60.0) * 3600.0; + //6e68c + dData_40002d58 = 90.0 - Data_40004128.dObjDeclinationDisplay; + Data_40002d48 = dData_40002d58; + Data_40002d4c = (dData_40002d58 - Data_40002d48) * 60.0; + fData_40002d50 = (dData_40002d58 - Data_40002d48 - Data_40002d4c / 60.0) * 3600.0; + + InquireMotorData(3); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionAziAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + + if (bData_40003430 == 0) + { + //6e7e8 + dData_40002dc0_Azimuth = Data_40004128.dData_192; + } + else + { + //0x6e800 + dData_40002dc0_Azimuth += Data_40004128.dData_192; + } + //0x6e820 + while (dData_40002dc0_Azimuth >= 360) + { + dData_40002dc0_Azimuth -= 360; + } + + while (dData_40002dc0_Azimuth < 0) + { + dData_40002dc0_Azimuth += 360; + } + //6e890 + fData_40003508 = dData_40002dc0_Azimuth - dData_40003410 - dData_400031f0; + Data_40002dac = dData_40002dc0_Azimuth - dData_40003410 + dData_400033e8; + Data_40002db0 = (dData_40002dc0_Azimuth - dData_40003410 + dData_400033e8 - Data_40002dac) * 60.0; + fData_40002db4 = (int)((dData_40002dc0_Azimuth - dData_40003410 + dData_400033e8 - + Data_40002dac - Data_40002db0 / 60.0) * 3600.0); + //6ea58 + if ((bData_40003200 == 1) && (Data_40004128.dData_304 == 2.0)) + { + //6ea84 + dData_400033e8 = dData_40002d30 - dData_40002dc0_Azimuth; + Data_40002dac = Data_40002d20; + Data_40002db0 = Data_40002d24; + fData_40002db4 = fData_40002d28; + } + //0x6ead0 + func_659c(2); + InquireMotorData(4); + //6eae8 + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionAltAxis; + dData_40002df8 = Data_40004128.dMotorPositionDecAxis; + + if (bData_40003430 == 0) + { + //6eb20 + dData_40002df8 = Data_40004128.dData_200; + } + else + { + //0x6eb38 + dData_40002df8 = Data_40004128.dData_200 - dData_40002df8; + } + //0x6eb58 + if (dData_40002df8 > 90) + { + dData_40002df8 = 180 - dData_40002df8; + } + //0x6eb8c + fData_4000350c = dData_40002df8 - dData_40003418 - dData_400031f8; + Data_40002de0 = dData_40002df8 - dData_40003418 + dData_400033f0; + Data_40002de4 = (dData_40002df8 - dData_40003418 + dData_400033f0 - Data_40002de0) * 60.0; + fData_40002de8 = (int)((dData_40002df8 - dData_40003418 + dData_400033f0 - + Data_40002de0 - Data_40002de4 / 60.0) * 3600.0); + + if ((bData_40003201 == 1) && (Data_40004128.dData_312 == 2.0)) + { + //6ee28 + dData_400033f0 = dData_40002d58 - dData_40002df8; + Data_40002de0 = Data_40002d48; + Data_40002de4 = Data_40002d4c; + fData_40002de8 = fData_40002d50; + } + //0x6f8d0 + } //if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) + else + { + //6ee78 + g_dObjectRightAcension = Data_40004128.dData_88; + Data_40002cd8_ObjectRightAscensionHours = g_dObjectRightAcension; + Data_40002cdc_ObjectRightAscensionMinutes = + (g_dObjectRightAcension - Data_40002cd8_ObjectRightAscensionHours) * 60.0; + fData_40002ce0_ObjectRightAscensionSeconds = + ((g_dObjectRightAcension - Data_40002cd8_ObjectRightAscensionHours) - + Data_40002cdc_ObjectRightAscensionMinutes / 60.0) * 3600.0; + //6ef7c + fData_40002d18_ObjectDeclination = fabs(Data_40004128.dObjDeclination); + Data_40002d00_ObjectDeclinationDegrees = fData_40002d18_ObjectDeclination; + Data_40002d04_ObjectDeclinationMinutes = + (fData_40002d18_ObjectDeclination - Data_40002d00_ObjectDeclinationDegrees) * 60.0; + fData_40002d08_ObjectDeclinationSeconds = + ((fData_40002d18_ObjectDeclination - Data_40002d00_ObjectDeclinationDegrees) - + Data_40002d04_ObjectDeclinationMinutes / 60.0) * 3600.0; + + if (Data_40004128.dObjDeclination > 0) + { + g_iObjectDeclinationSign = 1; + } + else + { + g_iObjectDeclinationSign = -1; + } + //0x6f0d4 + InquireMotorData(3); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionAziAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + //->0x6f12c + while (dData_40002dc0_Azimuth >= 360) + { + dData_40002dc0_Azimuth -= 360; + } + //->0x6f164 + while (dData_40002dc0_Azimuth < 0) + { + dData_40002dc0_Azimuth += 360; + } + //6f17c + dData_40002d78 = dData_40002dc0_Azimuth; + + func_659c(2); + InquireMotorData(4); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionAltAxis; + dData_40002df8 = fabs(Data_40004128.dMotorPositionDecAxis); + dData_40002d98 = dData_40002df8; + + if (Data_40004128.geographicLatitude >= 0) + { + //6f1f8 + if (dData_40002d78 > 360) + { + dData_40002d78 += 360; //BUG? + } + //0x6f22c + dData_40002d78 -= 180; + + if (dData_40002d78 < 0) + { + dData_40002d78 += 360; + } + //0x6f27c + dData_40002d98 = 90 - dData_40002d98; + //->0x6f328 + } + else + { + //0x6f29c + dData_40002d78 -= 180; + + if (dData_40002d78 < 0) + { + dData_40002d78 = -1 * dData_40002d78; + } + else + { + //0x6f2f0 + dData_40002d78 = 360 - dData_40002d78; + } + //0x6f30c + dData_40002d98 -= 90; + } + //0x6f328 + dData_40002d78 /= 15; + + fData_40003508 = fData_400034c8 - + (dData_40002d78 - dData_40003420 / 15 - dData_400031f0 / 15); + + if (fData_40003508 < 0) + { + fData_40003508 += 24; + } + //0x6f408 + if (fData_40003508 > 24) + { + fData_40003508 -= 24; + } + //0x6f434 + Data_40002d68_OTARightAscensionHours = dData_40002d78 - dData_40003420 / 15 + dData_400033e8; + Data_40002d6c_OTARightAscensionMinutes = (dData_40002d78 - dData_40003420 / 15 + dData_400033e8 - Data_40002d68_OTARightAscensionHours) * 60; + fData_40002d70_OTARightAscensionSeconds = (dData_40002d78 - dData_40003420 / 15 + + dData_400033e8 - Data_40002d68_OTARightAscensionHours - Data_40002d6c_OTARightAscensionMinutes / 60.0) * 3600.0; + //6f5f8 + if ((bData_40003200 == 1) && (Data_40004128.dData_304 == 2)) + { + //6f624 + dData_400033e8 = g_dObjectRightAcension - dData_40002d78; + Data_40002d68_OTARightAscensionHours = Data_40002cd8_ObjectRightAscensionHours; + Data_40002d6c_OTARightAscensionMinutes = Data_40002cdc_ObjectRightAscensionMinutes; + fData_40002d70_OTARightAscensionSeconds = fData_40002ce0_ObjectRightAscensionSeconds; + bData_40002d88 = 1; + } + //0x6f67c + fData_4000350c = dData_40002d98 - dData_40003428 - dData_400031f8; + Data_40002d8c_OTADeclinationDegrees = dData_40002d98 - dData_40003428 + dData_400033f0; + Data_40002d90_OTADeclinationMinutes = (dData_40002d98 - dData_40003428 + dData_400033f0 - Data_40002d8c_OTADeclinationDegrees) * 60; + fData_40002d94_OTADeclinationSeconds = (dData_40002d98 - dData_40003428 + + dData_400033f0 - Data_40002d8c_OTADeclinationDegrees - Data_40002d90_OTADeclinationMinutes / 60.0) * 3600.0; + + if ((bData_40003201 == 1) && (Data_40004128.dData_312 == 2)) + { + //6f868 + dData_400033f0 = fData_40002d18_ObjectDeclination - dData_40002d98; + Data_40002d8c_OTADeclinationDegrees = Data_40002d00_ObjectDeclinationDegrees; + Data_40002d90_OTADeclinationMinutes = Data_40002d04_ObjectDeclinationMinutes; + fData_40002d94_OTADeclinationSeconds = fData_40002d08_ObjectDeclinationSeconds; + bData_40002da8 = 1; + } + //0x6f8d0 + } + } //else if (bData_40002c1a == 2) + //6f8d0 + if (bSystemInitialized == 0) + { + //6f8e0 + lcd_display_clear(); + lcd_display_string(0, 4, 1, 22, "System Initializing..."); + get_all_solar_system_object_equatorial_coordinates(); + func_659c(1000); + beep1(1); + lcd_display_clear(); + lcd_display_string(0, 4, 1, 22, "System Initialized "); + func_659c(1000); + lcd_display_clear(); + + bSystemInitialized = 1; + } + //6f94c + UserInterfaceCycle(); + //6f950 + if (Data_40004128.bAlignmentComplete == 0) + { + //6f960 + func_c57c(); + + bData_400034cc = 0; + } + //6f970 + if ((g_bMaxSlewRampActive != 0) && (g_stCurrentSlewRampValue.Data <= 4800)) + { + //6f990 + if (g_stCurrentSlewRampValue.Data < 4800) + { + if (g_iCurrentSlewRampIndex == 1) + { + //6f9b0: Ramp up (+100) + g_stCurrentSlewRampValue.Data += g_iCurrentSlewRampIndex * 100; + } + else + { + //0x6f9d8 + g_stCurrentSlewRampValue.Data += g_iCurrentSlewRampIndex * 300; + } + } + //0x6f9fc + if (g_stCurrentSlewRampValue.Data >= 2560) + { + //6fa0c + if (bData_400031bc == 1) + { + //6fa1c + Data_400031ac.Data = 2514862080.0; + } + else + { + //0x6fa34 + Data_400031ac.Data = -2514862080.0; + } + //0x6fa48 + if (g_bCombinedSlewActive != 1) + { + //6fa58 + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(1 + 2 + 3); + + if (bData_400031ba == 0x01) + { + //6fa88 + uart1_write_byte(0x02); //Send RA? + } + //0x6fa90 + if (bData_400031ba == 0x21) + { + //6faa0 + uart1_write_byte(0x22); //Send DEC? + } + //0x6faa8 + uart1_write_byte(g_stCurrentSlewRampValue.bData[1]); + uart1_write_byte(g_stCurrentSlewRampValue.bData[0]); + uart1_write_byte(Data_400031ac.bData[3]); + uart1_write_byte(Data_400031ac.bData[2]); + uart1_write_byte(Data_400031ac.bData[1]); + } + //0x6fb24 + } //if (g_stCurrentSlewRampValue.Data >= 2560) + else + { + //0x6fae8 + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(1); + uart1_write_byte(0x00); + + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + g_bMaxSlewRampActive = 0; + } + } //if ((g_bMaxSlewRampActive != 0) && (g_stCurrentSlewRampValue.Data <= 4800)) + //6fb24 + if (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/) + { + //6fb34 + ReceiveMountAutoguideValues(); + + Data_40003488 = Data_40002c1c; + Data_4000348c = Data_40002c20; + + Data_40004128.dAutoguideRa += (2 * Data_40003488 + iMountAutoguideRa) * + dGuidingSpeed * 0.00153; + + Data_40004128.dAutoguideDec += (4 * Data_4000348c + iMountAutoguideDec) * + dGuidingSpeed * 0.00153; + + Data_40002c1c = 0; + Data_40002c20 = 0; + } + //6fd3c + if ((bData_40003211 == 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/) && + (g_dObjectRightAcension < 23.99999)) + { + //6fd4c + bData_40003211 = 1; + } + //6fd80 + if ((bData_40003211 != 0) && + (bData_40003210 == 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/) && + (g_dObjectRightAcension >= 23.83) && + (g_dObjectRightAcension < 23.99717)) + { + //6fde0 + bData_40003210 = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_MERIDIAN_FLIP; + } + //6fdf8 + if ((bData_40003210 != 0) && + (bTrackingMode == MENU_TRACKING_MODE_TRACKING/*2*/) && + (g_dObjectRightAcension >= 23.99717)) + { + //6fe30 + g_bSlewingStop = 1; + Data_40002c64_MenuContextId = MENU_CONTEXT_MAIN; + bData_40003210 = 0; + bData_40003211 = 0; + + beep1(3); + StopSlewing(); + } + //6fe64 + if (bData_40002c1a == 1) + { + //6fe74 + if ((Data_40004128.bTrackingActive != 0) && (g_bSlewingStop != 1)) + { + //6fe94 + if (Data_40002c64_MenuContextId != MENU_CONTEXT_ALIGNMENT_STAR_CONTROL) //12001) + { + //6fea8 + switch (g_eSlewRateIndex) + { + case 0: + //0x6fee4 + g_dSlewRateRaAxis = 0; + g_dSlewRateDecAxis = 0; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 1: + //0x6ff94 + g_dSlewRateRaAxis = 0.00153; + g_dSlewRateDecAxis = 0.0012; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 2: + //0x70098 + g_dSlewRateRaAxis = 0.0031; + g_dSlewRateDecAxis = 0.0031; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 3: + //0x70148 + g_dSlewRateRaAxis = 0.0148; + g_dSlewRateDecAxis = 0.0148; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 4: + //0x701f8 + g_dSlewRateRaAxis = 0.0602; + g_dSlewRateDecAxis = 0.0602; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 5: + //0x702a8 + g_dSlewRateRaAxis = 0.11; + g_dSlewRateDecAxis = 0.11; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 6: + //0x70358 + g_dSlewRateRaAxis = 0.16; + g_dSlewRateDecAxis = 0.16; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 7: + //0x7042c + g_dSlewRateRaAxis = 0.481; + g_dSlewRateDecAxis = 0.481; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 8: + //0x704dc + g_dSlewRateRaAxis = 0.765; + g_dSlewRateDecAxis = 0.765; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + case 9: + //0x7058c + g_dSlewRateRaAxis = 1.56; + g_dSlewRateDecAxis = 1.56; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + + default: + //0x7063c + g_dSlewRateRaAxis = 0; + g_dSlewRateDecAxis = 0; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x706ec + break; + } //switch (g_eSlewRateIndex) + //706ec -> 0x72040 + } //if (Data_40002c64_MenuContextId != MENU_CONTEXT_ALIGNMENT_STAR_CONTROL) + else + { + //0x706f0 + switch (g_eSlewRateIndex) + { + case 0: + //0x70744 + g_dSlewRateRaAxis = 0; + g_dSlewRateDecAxis = 0; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 1: + //0x707f4 + g_dSlewRateRaAxis = 0.00154; + g_dSlewRateDecAxis = 0.00154; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 2: + //0x708a4 + g_dSlewRateRaAxis = 0.0031; + g_dSlewRateDecAxis = 0.0031; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 3: + //0x70954 + g_dSlewRateRaAxis = 0.026; + g_dSlewRateDecAxis = 0.0236; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 4: + //0x70a04 + g_dSlewRateRaAxis = 0.084; + g_dSlewRateDecAxis = 0.084; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 5: + //0x70ab4 + g_dSlewRateRaAxis = 0.154; + g_dSlewRateDecAxis = 0.142; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 6: + //0x70b98 + g_dSlewRateRaAxis = 0.2423; + g_dSlewRateDecAxis = 0.2187; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 7: + //0x70c48 + g_dSlewRateRaAxis = 0.6305; + g_dSlewRateDecAxis = 0.6305; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 8: + //0x70cf8 + g_dSlewRateRaAxis = 1.031; + g_dSlewRateDecAxis = 1.031; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case 9: + //0x70da8 + g_dSlewRateRaAxis = 2.15; + g_dSlewRateDecAxis = 2.15; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x70f08 + break; + + default: + //0x70e58 + g_dSlewRateRaAxis = 0; + g_dSlewRateDecAxis = 0; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + } //switch (g_eSlewRateIndex) + //0x70f08 -> 0x72040 + } + } //if ((Data_40004128.bTrackingActive != 0) && (g_bSlewingStop != 1)) + //->0x72040 + } //if (bData_40002c1a == 1) + else + { + //70f38 + if ((Data_40004128.bTrackingActive != 0) && (g_bSlewingStop != 1)) + { + //70f58 + if (Data_40002c64_MenuContextId != MENU_CONTEXT_ALIGNMENT_STAR_CONTROL) //12001) + { + //70f6c + switch (g_eSlewRateIndex) + { + case 0: + //0x70fa8 + g_dSlewRateRaAxis = 0.0007; + g_dSlewRateDecAxis = 0.0007; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x717d4 + break; + + case SLEW_RATE_1X: //1: + //0x71058 + g_dSlewRateRaAxis = 0.0015; + g_dSlewRateDecAxis = 0.0015; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_2X: //2: + //0x71108 + g_dSlewRateRaAxis = 0.0083; + g_dSlewRateDecAxis = 0.0083; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_8X: //3: + //0x711b8 + g_dSlewRateRaAxis = 0.0234; + g_dSlewRateDecAxis = 0.0235; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_16X: //4: + //0x71268 + g_dSlewRateRaAxis = 0.042; + g_dSlewRateDecAxis = 0.041; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_64X: //5: + //0x71368 + g_dSlewRateRaAxis = 0.071; + g_dSlewRateDecAxis = 0.0708; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_128X: //6: + //0x71418 + g_dSlewRateRaAxis = 0.142; + g_dSlewRateDecAxis = 0.106; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_256X: //7: + //0x714c8 + g_dSlewRateRaAxis = 0.26; + g_dSlewRateDecAxis = 0.236; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_512X: //8: + //0x71578 + g_dSlewRateRaAxis = 0.634; + g_dSlewRateDecAxis = 0.39; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_MAX: //9: + //0x71628 + g_dSlewRateRaAxis = 0.98; + g_dSlewRateDecAxis = 0.45; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x717d4 + break; + + default: + //0x71724 + g_dSlewRateRaAxis = 0.0; + g_dSlewRateDecAxis = 0.0; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + } //switch (g_eSlewRateIndex) + //0x717d4 -> 0x72040 + + } //if (Data_40002c64_MenuContextId != MENU_CONTEXT_ALIGNMENT_STAR_CONTROL) + else + { + //0x717d8 + switch (g_eSlewRateIndex) + { + case 0: + //0x71814 + g_dSlewRateRaAxis = 0.0011; + g_dSlewRateDecAxis = 0.0007; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x717d4 + break; + + case SLEW_RATE_1X: //1: + //0x718c4 + g_dSlewRateRaAxis = 0.0024; + g_dSlewRateDecAxis = 0.0019; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_2X: //2: + //0x71974 + g_dSlewRateRaAxis = 0.015; + g_dSlewRateDecAxis = 0.0076; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_8X: //3: + //0x71a24 + g_dSlewRateRaAxis = 0.035; + g_dSlewRateDecAxis = 0.035; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_16X: //4: + //0x71ad4 + g_dSlewRateRaAxis = 0.062; + g_dSlewRateDecAxis = 0.06; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_64X: //5: + //0x71bcc + g_dSlewRateRaAxis = 0.093; + g_dSlewRateDecAxis = 0.09; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_128X: //6: + //0x71c7c + g_dSlewRateRaAxis = 0.178; + g_dSlewRateDecAxis = 0.13; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_256X: //7: + //0x71d2c + g_dSlewRateRaAxis = 0.335; + g_dSlewRateDecAxis = 0.3; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_512X: //8: + //0x71ddc + g_dSlewRateRaAxis = 0.805; + g_dSlewRateDecAxis = 0.485; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + + case SLEW_RATE_MAX: //9: + //0x71e8c + g_dSlewRateRaAxis = 1.005; + g_dSlewRateDecAxis = 0.69; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + //->0x7203c + break; + + default: + //0x71f8c + g_dSlewRateRaAxis = 0.0; + g_dSlewRateDecAxis = 0.0; + + dData_400033d8 += g_iSlewStepRaAxis * g_dSlewRateRaAxis; + dData_400033e0 += g_iSlewStepDecAxis * g_dSlewRateDecAxis; + break; + } //switch (g_eSlewRateIndex) + } + } //if ((Data_40004128.bTrackingActive != 0) && (g_bSlewingStop != 1)) + } //if (bData_40002c1a != 1) + //72040 + if ((g_iSlewStepDecAxis != 0) || (g_iSlewStepRaAxis != 0)) + { + //72060 + bData_400034b4 = 0; + } + //7206c + if (Data_40004128.bTrackingRequest != 0) + { + //7207c + if (bData_40002c1a == 0) + { + //7208c + Data_40002c64_MenuContextId = MENU_CONTEXT_NO_TELESCOPE; //2; + Data_40004128.bTrackingRequest = 0; + Data_40004128.bAlignmentComplete = 1; + } + else + { + //720b0 + if (bData_40002e7a_MountType == MENU_MOUNT_TYPE_AZ) //0) + { + //720c0 + func_acd8(); + } + else + { + //720c8 + func_9178(); + } + } + } + //720cc + if (iBacklashCorrectionSlewing == 1) + { + //720dc + func_659c(3000); + + switch (bData_40002edd) + { + case 0: + //0x72110 + InquireMotorData(3); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionAziAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + //->7221c + break; + + case 1: + //0x72150 + InquireMotorData(4); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionDecAxis; + dData_40002df8 = fabs(Data_40004128.dMotorPositionDecAxis); + //->7221c + break; + + case 2: + //0x72194 + InquireMotorData(1); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionRaAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + break; + + case 3: + //0x721d4 + InquireMotorData(2); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionDecAxis; + dData_40002df8 = Data_40004128.dMotorPositionDecAxis; + break; + + default: + //0x72214 + break; + } + //7221c + SlewStop(); + func_659c(100); + + switch (bData_40002edd) + { + case 0: + //0x72258 + InquireMotorData(3); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionAziAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + //->0x72364 + break; + + case 1: + //0x72298 + InquireMotorData(4); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionDecAxis; + dData_40002df8 = fabs(Data_40004128.dMotorPositionDecAxis); + //->0x72364 + break; + + case 2: + //0x722dc + InquireMotorData(1); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionRaAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + break; + + case 3: + //0x7231c + InquireMotorData(2); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionDecAxis; + dData_40002df8 = Data_40004128.dMotorPositionDecAxis; + break; + + default: + //7235c + break; + } + //72368 + switch (bData_40002edd) + { + case 0: + //0x72394 + InquireMotorData(3); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionAziAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + dData_40002dc0_Azimuth += Data_40004128.dData_192; + //->72410 + while (dData_40002dc0_Azimuth >= 360.0) + { + //723f4 + dData_40002dc0_Azimuth -= 360.0; + } + //->72448 + while (dData_40002dc0_Azimuth < 0.0) + { + //7242c + dData_40002dc0_Azimuth += 360.0; + } + //->7257c + while (fabs(dData_40002dc0_Azimuth - dRaBklashCorrStartAzimuth) > 0.0014) + { + //72464 + if (bRaBacklashCorrectionDirection == 2) + { + //72474 + SlewAxis(3, 4, SLEW_RATE_1X); + } + //72484 + if (bRaBacklashCorrectionDirection == 1) + { + //72494 + SlewAxis(3, 3, SLEW_RATE_1X); + } + //724a4 + func_659c(10); + InquireMotorData(3); + func_659c(10); + //724c4 + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionAziAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + dData_40002dc0_Azimuth += Data_40004128.dData_192; + //->7252c + while (dData_40002dc0_Azimuth >= 360.0) + { + //72510 + dData_40002dc0_Azimuth -= 360.0; + } + //->72564 + while (dData_40002dc0_Azimuth < 0.0) + { + //72548 + dData_40002dc0_Azimuth += 360.0; + } + } //while(...) + //->72968 + break; + + case 1: + //0x725bc + InquireMotorData(4); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionAltAxis; + dData_40002df8 = Data_40004128.dMotorPositionDecAxis; + dData_40002df8 = Data_40004128.dData_200 - dData_40002df8; + //->0x726bc + while (fabs(dData_40002df8 - dData_40002e00) > 0.0014) + { + //0x72618 + if (bDecBacklashCorrectionDirection == 2) + { + //72628 + SlewAxis(4, 2, SLEW_RATE_1X); + } + //72638 + if (bDecBacklashCorrectionDirection == 1) + { + //72648 + SlewAxis(4, 1, SLEW_RATE_1X); + } + //72658 + func_659c(10); + InquireMotorData(4); + func_659c(10); + //72678 + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionAltAxis; + dData_40002df8 = Data_40004128.dMotorPositionDecAxis; + dData_40002df8 = Data_40004128.dData_200 - dData_40002df8; + } + //->72968 + break; + + case 2: + //0x726fc + InquireMotorData(1); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionRaAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + //->727c4 + while (fabs(dData_40002dc0_Azimuth - dRaBklashCorrStartAzimuth) > 0.0014) + { + //7273c + if (bRaBacklashCorrectionDirection == 2) + { + SlewAxis(1, 4, SLEW_RATE_2X); + } + + if (bRaBacklashCorrectionDirection == 1) + { + SlewAxis(1, 3, SLEW_RATE_2X); + } + + func_659c(10); + InquireMotorData(1); + func_659c(10); + + Data_40004128.dMotorPositionRaAxis = g_dMotorPositionRaAxis; + dData_40002dc0_Azimuth = Data_40004128.dMotorPositionRaAxis; + } + //->72968 + break; + + case 3: + //0x72804 + InquireMotorData(2); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionDecAxis; + dData_40002df8 = fabs(Data_40004128.dMotorPositionDecAxis); + //->72928 + while (fabs(dData_40002df8 - dData_40002e00) > 0.0014) + { + //728a0 + if (bDecBacklashCorrectionDirection == 2) + { + SlewAxis(2, 2, SLEW_RATE_2X); + } + + if (bDecBacklashCorrectionDirection == 1) + { + SlewAxis(2, 1, SLEW_RATE_2X); + } + + func_659c(10); + InquireMotorData(2); + func_659c(10); + + Data_40004128.dMotorPositionDecAxis = g_dMotorPositionDecAxis; + dData_40002df8 = fabs(Data_40004128.dMotorPositionDecAxis); + } + #if 0 + break; + #endif + + #if 0 + default: + //0x72968 + break; + #endif + } + //7296c + SlewStop(); + func_659c(100); + beep1(2); + //72980 + iBacklashCorrectionSlewing = 0; + } //if (iBacklashCorrectionSlewing == 1) + //7298c + g_dPoleAxisDevEastWest = Data_40004380.dData_24; + g_dPoleAxisDevNorthSouth = Data_40004380.dData_16; + + func_659c(2); + //729bc + if (bData_40002c1a == 0) + { + func_659c(50); + } + //729d4 + if (Data_40004128.bTrackingRequest == 0) + { + func_659c(100); + } + //729ec -> 6d898 + } //while (1) +} + + +/* 6d054 - todo */ +int main(void) +{ + lpc_hw_init(); + uart0_init(360); + uart1_init(360); + + VICVectCntl1 = (1 << 5) | 6; // UART0 -> Slot 1 + VICIntEnable = (1 << 6); // Enable UART0 + + VICVectCntl2 = (1 << 5) | 7; // UART1 -> Slot 2 + VICIntEnable = (1 << 7); // Enable UART1 + + //ON + IO0CLR = (1 << 16); + + xTaskCreate( vLEDTask, "LEDTask", /*configMINIMAL_STACK_SIZE*/100, NULL, tskIDLE_PRIORITY+1, NULL ); + xTaskCreate( vMainTask, "MainTask", /*configMINIMAL_STACK_SIZE*/1000, NULL, tskIDLE_PRIORITY+1, NULL ); + xTaskCreate( vTimerTask, "TimerTask", /*configMINIMAL_STACK_SIZE*/100, NULL, tskIDLE_PRIORITY+2, NULL ); + xTaskCreate( vUART0Task, "UART0Task", /*configMINIMAL_STACK_SIZE*/100, NULL, tskIDLE_PRIORITY+3, NULL ); + xTaskCreate( vUART1Task, "UART1Task", /*configMINIMAL_STACK_SIZE*/100, NULL, tskIDLE_PRIORITY+3, NULL ); + +#if 0 + { + static char buf[105]; + + snprintf(buf, 100, "vTaskStartScheduler\n\r"); + uart1_send((unsigned char*)buf, strlen(buf)); + } +#endif + + vTaskStartScheduler(); +} + diff --git a/applications/freertos_app/mars.c b/applications/freertos_app/mars.c new file mode 100644 index 0000000..9c7a098 --- /dev/null +++ b/applications/freertos_app/mars.c @@ -0,0 +1,90 @@ + +/* 11af4 - todo */ +double mars_ecliptic_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double L5 = 0.0; + double res = 0.0; + + L0 += 620347712 * cos(0.0 + a * 0.0); + L0 += 18656368 * cos(5.05037100 + a * 3340.61242670); + L0 += 1108217 * cos(5.4009984 + a * 6681.2248534); + L0 += 91798 * cos(5.75479 + a * 10021.83728); + L0 += 27745 * cos(5.97050 + a * 3.52312); + L0 += 12316 * cos(0.84956 + a * 2810.92146); + L0 += 10610 * cos(2.93959 + a * 2281.23050); + + L1 += 334085627474 * cos(0.0 + a * 0.0); + L1 += 1458227 * cos(3.6042605 + a * 3340.6124267); + L1 += 164901 * cos(3.926313 + a * 6681.224853); + L1 += 19963 * cos(4.26594 + a * 10021.83728); + + L2 += 58016 * cos(2.04979 + a * 3340.61243); + L2 += 54188 * cos(0.0 + a * 0.0); + L2 += 13908 * cos(2.45742 + a * 6681.22485); + + res = (L0 + L1 * a + L2 * a*a + L3 * a*a*a + L4 * a*a*a*a + L5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* 12450 - todo */ +double mars_ecliptic_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double B2 = 0.0; + double B3 = 0.0; + double B4 = 0.0; + double res = 0.0; + + B0 += 3197135 * cos(3.7683204 + a * 3340.6124267); + B0 += 298033 * cos(4.106170 + a * 6681.224853); + B0 += 289105 * cos(0.0 + a * 0.0); + B0 += 31366 * cos(4.44651 + a * 10021.83728); + + B1 += 350069 * cos(5.368478 + a * 3340.612427); + B1 += 14116 * cos(3.14159 + a * 0.0); + B1 += 9671 * cos(5.4788 + a * 6681.2249); + + B2 += 16727 * cos(0.60221 + a * 3340.61243); + B2 += 4987 * cos(3.1416 + a * 0.0); + + res = (B0 + B1 * a + B2 * a*a + B3 * a*a*a + B4 * a*a*a*a) / 100000000.0; + + return res; +} + +/* 12a8c - todo */ +double mars_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double R4 = 0.0; + double res = 0.0; + + R0 += 153033488 * cos(0.0 + a * 0.0); + R0 += 14184953 * cos(3.47971284 + a * 3340.61242670); + R0 += 660776 * cos(3.817834 + a * 6681.224853); + R0 += 46179 * cos(4.15595 + a * 10021.83728); + R0 += 8110 * cos(5.5596 + a * 2810.9215); + + R1 += 1107433 * cos(2.0325052 + a * 3340.6124267); + R1 += 103176 * cos(2.370718 + a * 6681.224853); + R1 += 12877 * cos(0.0 + a * 0.0); + R1 += 10816 * cos(2.70888 + a * 10021.83728); + + R2 += 44242 * cos(0.47931 + a * 3340.61243); + R2 += 8138 * cos(0.8700 + a * 6681.2249); + + res = (R0 + R1 * a + R2 * a*a + R3 * a*a*a + R4 * a*a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/freertos_app/menu.h b/applications/freertos_app/menu.h new file mode 100644 index 0000000..2f7aced --- /dev/null +++ b/applications/freertos_app/menu.h @@ -0,0 +1,194 @@ + +typedef enum +{ + MENU_CONTEXT_MAIN = 0, + MENU_CONTEXT_RECENT_TARGETS = 1, + MENU_CONTEXT_NO_TELESCOPE = 2, + MENU_CONTEXT_MERIDIAN_FLIP = 3, + + MENU_CONTEXT_ALIGNMENT = 1000, + MENU_CONTEXT_ONE_STAR_ALIGN = 1100, + MENU_CONTEXT_TWO_STAR_ALIGN = 1200, + MENU_CONTEXT_THREE_STAR_ALIGN = 1300, + MENU_CONTEXT_ALIGNMENT_STAR_CONTROL = 12001, + MENU_CONTEXT_TARGET_SYNC = 1400, + MENU_CONTEXT_SYNC_OPEN = 1401, + MENU_CONTEXT_SYNC_ENSURE = 1402, + MENU_CONTEXT_SYNC_CANCEL = 1403, + MENU_CONTEXT_POLE_AXIS_DEV = 1500, + MENU_CONTEXT_POLE_AXIS_DEV_INPUT = 18001, + MENU_CONTEXT_RA_BKBLASH_CORR = 1600, + MENU_CONTEXT_RA_BKBLASH_CORR_1ST_STEP_AIM_TARGET = 11102, + MENU_CONTEXT_RA_BKBLASH_CORR_2ND_STEP_START_LEFT_RIGHT = 11101, + MENU_CONTEXT_RA_BKBLASH_CORR_3RD_STEP_MOVING_LEFT_RIGHT = 11103, + MENU_CONTEXT_RA_BKBLASH_CORR_RESULT = 11104, + MENU_CONTEXT_DEC_BKLASH_CORR = 1700, + MENU_CONTEXT_DEC_BKBLASH_CORR_1ST_STEP_AIM_TARGET = 11202, + MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_START_UP_DOWN = 11201, + MENU_CONTEXT_DEC_BKBLASH_CORR_2ND_STEP_MOVING_UP_DOWN = 11203, + MENU_CONTEXT_DEC_BKBLASH_CORR_RESULT = 11204, + + MENU_CONTEXT_NAVIGATION = 2000, + MENU_CONTEXT_NAVIGATION_SOLAR_SYSTEM = 2100, + MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_SELECTION = 22001, + MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING = 22111, + MENU_CONTEXT_SUN_WARNING = 22112, + MENU_CONTEXT_NAVIGATION_CONSTELLATION = 2200, + MENU_CONTEXT_CONSTELLATION_SELECTION = 24001, + MENU_CONTEXT_CONSTELLATION_TRACKING = 24002, + MENU_CONTEXT_NAVIGATION_FAMOUS_STAR = 2300, + MENU_CONTEXT_FAMOUS_STAR_SELECTION = 25001, + MENU_CONTEXT_FAMOUS_STAR_TRACKING = 25002, + MENU_CONTEXT_NAVIGATION_MESSIER_CAT = 2400, + MENU_CONTEXT_MESSIER_OBJECT_DETAILS = 23012, + MENU_CONTEXT_MESSIER_OBJECT_SELECTION = 23002, + MENU_CONTEXT_MESSIER_OBJECT_TRACKING = 23022, + MENU_CONTEXT_NAVIGATION_NGC_CAT = 2500, + MENU_CONTEXT_NGC_OBJECT_SELECTION = 23003, + MENU_CONTEXT_NGC_OBJECT_TRACKING = 23013, + MENU_CONTEXT_NAVIGATION_IC_CAT = 2600, + MENU_CONTEXT_IC_OBJECT_SELECTION = 23004, + MENU_CONTEXT_IC_OBJECT_TRACKING = 23014, + MENU_CONTEXT_NAVIGATION_SH2_CAT = 2700, + MENU_CONTEXT_SH2_OBJECT_SELECTION = 23005, + MENU_CONTEXT_SH2_OBJECT_TRACKING = 23015, + MENU_CONTEXT_NAVIGATION_BRIGHT_STAR = 2800, + MENU_CONTEXT_BRIGHT_STAR_SELECTION = 23006, + MENU_CONTEXT_BRIGHT_STAR_TRACKING = 23016, + MENU_CONTEXT_NAVIGATION_SAO_CAT = 2900, + MENU_CONTEXT_SAO_OBJECT_SELECTION = 23007, + MENU_CONTEXT_SAO_OBJECT_TRACKING = 23017, + MENU_CONTEXT_NAVIGATION_CUST_OBJ = 2110, + MENU_CONTEXT_CUSTOMER_OBJECT_SELECTION = 201, + MENU_CONTEXT_CUSTOMER_OBJECT_NAME_INPUT = 203, + MENU_CONTEXT_CUSTOMER_OBJECT_RA_INPUT = 204, + MENU_CONTEXT_CUSTOMER_OBJECT_DEC_INPUT = 205, + MENU_CONTEXT_NAVIGATION_RA_DEC = 2120, + MENU_CONTEXT_NAVIGATION_CUST_LAND = 2130, + MENU_CONTEXT_CUST_LAND_OBJ_SELECTION = 202, + MENU_CONTEXT_CUST_LAND_OBJ_NAME_INPUT = 206, + MENU_CONTEXT_CUST_LAND_OBJ_AZI_INPUT = 207, + MENU_CONTEXT_CUST_LAND_OBJ_ALT_INPUT = 208, + + MENU_CONTEXT_UTILITIES = 3000, + MENU_CONTEXT_CURRENT_OBJECTS = 3100, + MENU_CONTEXT_SOLAR_SYSTEM_OBJ_RISE_SET_TIMES = 31001, + MENU_CONTEXT_OBJECT_RISE_SET = 3200, + MENU_CONTEXT_RA_INPUT = 29001, + MENU_CONTEXT_DEC_INPUT = 29002, + MENU_CONTEXT_RISE_SET_TIMES = 32001, + MENU_CONTEXT_LUNAR_PHASE = 3300, + MENU_CONTEXT_TIMER = 3400, + MENU_CONTEXT_TIMER_SET = 34001, + MENU_CONTEXT_TIMER_COUNTING = 34002, + MENU_CONTEXT_ALARM = 3500, + MENU_CONTEXT_ALARM_INPUT = 35001, + + MENU_CONTEXT_EYEPIECE_FOV = 3600, + MENU_CONTEXT_EYEPIECE_FOV_MF_INPUT = 370021, + MENU_CONTEXT_EYEPIECE_FOV_SF_INPUT = 370022, + MENU_CONTEXT_EYEPIECE_FOV_INPUT = 370023, + MENU_CONTEXT_EYEPIECE_MAGN = 3700, + MENU_CONTEXT_EYEPIECE_MAGN_MF_INPUT = 360021, + MENU_CONTEXT_EYEPIECE_MAGN_SF_INPUT = 360022, + MENU_CONTEXT_DISPLAY_ILLUMINATION = 3800, + MENU_CONTEXT_DISPLAY_ILLUMINATION_CONTROL = 380011, + MENU_CONTEXT_PARK_POSITION = 3900, + + MENU_CONTEXT_SETUP = 4000, + MENU_CONTEXT_TIME_DATE = 4100, + MENU_CONTEXT_TIME_DATE_INPUT = 41001, + MENU_CONTEXT_DAYLIGHT_SAVING = 4200, + MENU_CONTEXT_DAYLIGHT_SAVING_ON = 42001, + MENU_CONTEXT_DAYLIGHT_SAVING_OFF = 42002, + MENU_CONTEXT_SITE_SETTING = 4300, + MENU_CONTEXT_COUNTRY_CITY = 4301, + MENU_CONTEXT_COUNTRY_CITY_SELECTION = 43011, + MENU_CONTEXT_CUSTOM_SITE = 4302, + MENU_CONTEXT_CUSTOM_SITE_INPUT = 43002, + MENU_CONTEXT_SKY_LAND = 4400, + MENU_CONTEXT_SKY_TARGET = 45001, + MENU_CONTEXT_LAND_TARGET = 45002, + MENU_CONTEXT_AZ_EQU = 4500, + MENU_CONTEXT_MOUNT_AZ = 46001, + MENU_CONTEXT_MOUNT_EQU = 46002, + MENU_CONTEXT_TELESCOPE_MOUNT = 4600, + MENU_CONTEXT_OTA_ZERO_SETUP = 47011, + MENU_CONTEXT_OTA_ZERO_SETUP_RESTART = 47041, + MENU_CONTEXT_TRACKING_RATE = 4700, + MENU_CONTEXT_TRACKING_RATE_STAR_SPEED = 4801, + MENU_CONTEXT_TRACKING_RATE_SOLAR_SPEED = 4802, + MENU_CONTEXT_TRACKING_RATE_MOON_SPEED = 4803, + MENU_CONTEXT_TRACKING_RATE_CUSTOM_SPEED = 4804, + MENU_CONTEXT_TRACKING_RATE_INPUT = 48001, + MENU_CONTEXT_TRACKING_RATE_GUIDING_SPEED = 4805, + MENU_CONTEXT_GUIDING_SPEED1 = 48051, + MENU_CONTEXT_GUIDING_SPEED2 = 48052, + MENU_CONTEXT_GUIDING_SPEED3 = 48053, + MENU_CONTEXT_GUIDING_SPEED4 = 48054, + MENU_CONTEXT_GUIDING_SPEED5 = 48055, + MENU_CONTEXT_GUIDING_SPEED6 = 48056, + MENU_CONTEXT_GUIDING_SPEED7 = 48057, + MENU_CONTEXT_GUIDING_SPEED8 = 48058, + MENU_CONTEXT_LANGUAGE = 4800, + MENU_CONTEXT_ENGLISH = 49001, + MENU_CONTEXT_GERMAN = 49002, + MENU_CONTEXT_FRENCH = 49003, + MENU_CONTEXT_ITALIAN = 49004, + MENU_CONTEXT_SPANISH = 49005, + MENU_CONTEXT_RESET = 4900, + MENU_CONTEXT_RESET_CONFIRM = 100, + +} MENU_CONTEX_ID; + +typedef enum +{ + MENU_MOUNT_TYPE_AZ = 0, + MENU_MOUNT_TYPE_EQU = 1, + +} MENU_MOUNT_TYPE; + +typedef enum +{ + MENU_TRACKING_RATE_STAR_SPEED = 0, + MENU_TRACKING_RATE_SOLAR_SPEED = 1, + MENU_TRACKING_RATE_MOON_SPEED = 2, + MENU_TRACKING_RATE_CUST_SPEED = 3, + +} MENU_TRACKING_RATE_TYPE; + +typedef enum +{ + MENU_TRACKING_MODE_STOP = 0, + MENU_TRACKING_MODE_POINTING = 1, //after 2 or 3 Star Alignment and an Object was chosen + MENU_TRACKING_MODE_TRACKING = 2, //after manual slewing with direction buttons + MENU_TRACKING_MODE_UNDER_HORIZON = 3, + MENU_TRACKING_MODE_PAUSE = 4, + MENU_TRACKING_MODE_CANCEL = 5, + MENU_TRACKING_MODE_SLEWING = 10, + +} MENU_TRACKING_MODE; + +typedef enum +{ + MENU_RECENT_TARGET_SOLAR_SYSTEM = 1, + MENU_RECENT_TARGET_CONSTELLATION = 2, + MENU_RECENT_TARGET_FAMOUS_STAR = 3, + MENU_RECENT_TARGET_MESSIER = 4, + MENU_RECENT_TARGET_NGC = 5, + MENU_RECENT_TARGET_IC = 6, + MENU_RECENT_TARGET_SH2 = 7, + MENU_RECENT_TARGET_BRIGHT_STAR = 8, + MENU_RECENT_TARGET_SAO_CAT = 9, + +} MENU_RECENT_TARGET_TYPE; + +typedef enum +{ + MENU_LANGUAGE_ENGLISH = 1, + MENU_LANGUAGE_GERMAN = 2, + MENU_LANGUAGE_FRENCH = 3, + MENU_LANGUAGE_ITALIAN = 4, + MENU_LANGUAGE_SPANISH = 5, + +} MENU_LANGUAGE_TYPE; diff --git a/applications/freertos_app/mercury.c b/applications/freertos_app/mercury.c new file mode 100644 index 0000000..31db1e4 --- /dev/null +++ b/applications/freertos_app/mercury.c @@ -0,0 +1,108 @@ + +//http://home.mnet-online.de/reimay/Projects/pc/Astronomie/libaa/AAMercury.cpp + +/* f22c - todo */ +double mercury_ecliptic_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double L5 = 0.0; + double res = 0.0; + + L0 += 440250710 * cos(0.0 + a * 0.0); + L0 += 40989415 * cos(1.48302034 + a * 26087.90314157); + L0 += 5046294 * cos(4.4778549 + a * 52175.8062831); + L0 += 855347 * cos(1.165203 + a * 78263.709425); + L0 += 165590 * cos(4.119692 + a * 104351.612566); + L0 += 34562 * cos(0.77931 + a * 130439.51571); + L0 += 7583 * cos(3.7135 + a * 156527.4188); + L0 += 3560 * cos(1.5120 + a * 1109.3786); + + L1 += 2608814706223 * cos(0.0 + a * 0.0); + L1 += 1126008 * cos(6.2170397 + a * 26087.9031416); + L1 += 303471 * cos(3.055655 + a * 52175.806283); + L1 += 80538 * cos(6.10455 + a * 78263.70942); + L1 += 21245 * cos(2.83532 + a * 104351.61257); + + L2 += 53050 * cos(0.0 + a * 0.0); + L2 += 16904 * cos(4.69072 + a * 26087.90314); + + res = (L0 + + L1 * a + + L2 * a*a + + L3 * a*a*a + + L4 * a*a*a*a + + L5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* fc20 - todo */ +double mercury_ecliptic_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double B2 = 0.0; + double B3 = 0.0; + double B4 = 0.0; + double res = 0.0; + + B0 += 11737529 * cos(1.98357499 + a * 26087.90314157); + B0 += 2388077 * cos(5.0373896 + a * 52175.8062831); + B0 += 1222840 * cos(3.1415927 + a * 0.0); + B0 += 543252 * cos(1.796444 + a * 78263.709425); + B0 += 129779 * cos(4.832325 + a * 104351.612566); + B0 += 31867 * cos(1.58088 + a * 130439.51571); + + B1 += 429151 * cos(3.501698 + a * 26087.903142); + B1 += 146234 * cos(3.141593 + a * 0.0); + B1 += 22675 * cos(0.01515 + a * 52175.80628); + + B2 += 11831 * cos(4.79066 + a * 26087.90314); + B2 += 1914 * cos(0.0 + a * 0.0); + B2 += 1045 * cos(1.2122 + a * 52175.8063); + + res = (B0 + + B1 * a + + B2 * a*a + + B3 * a*a*a + + B4 * a*a*a*a) / 100000000.0; + + return res; +} + +/* 103dc - todo */ +double mercury_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double res = 0.0; + + R0 += 39528272 * cos(0.0 + a * 0.0); + R0 += 7834132 * cos(6.1923372 + a * 26087.9031416); + R0 += 795526 * cos(2.959897 + a * 52175.806283); + R0 += 121282 * cos(6.010642 + a * 78263.709425); + R0 += 21922 * cos(2.77820 + a * 104351.61257); + + R1 += 217348 * cos(4.656172 + a * 26087.9031416); //26087.903142); //BUG??? + R1 += 44142 * cos(1.42386 + a * 52175.80628); + R1 += 10094 * cos(4.47466 + a * 8263.70942); //78263.70942); //BUG??? + + R2 += 3118 * cos(3.0823 + a * 26087.9031); + R2 += 1245 * cos(6.1518 + a * 52175.8063); + R2 += 425 * cos(2.926 + a * 78263.709); + R2 += 136 * cos(5.98 + a * 104351.613); + + res = (R0 + + R1 * a + + R2 * a*a + + R3 * a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/freertos_app/my_types.h b/applications/freertos_app/my_types.h new file mode 100644 index 0000000..4fcc7fd --- /dev/null +++ b/applications/freertos_app/my_types.h @@ -0,0 +1,232 @@ + +#define FALSE 0 +#define TRUE 1 + +typedef struct +{ + unsigned char bData_0[12]; //0 + unsigned char bData_12[12]; //12 + int Data_24; //24 + unsigned char bData_28[14]; //28 + unsigned char bData_42[10]; //42 + float fData_52; //52 + float fRightAscension; //56 + float fDeclination; //60 +} Struct_FamousStarData; + +typedef struct +{ + unsigned char bData_0[5]; //0 + unsigned char bData_5[21]; //5 + unsigned char bData_26[10]; //26 + float fRightAscension; //36 + float fDeclination; //40 + unsigned short wArea; //44 / Square Degrees? + unsigned char bData_46; //46 + unsigned char bQuantity; //47 / Number of Stars >6Mag? +} Struct_ConstellationData; + +typedef struct +{ + unsigned short wData_0; //0 + float fRightAscension; //4 + float fDeclination; //8 + float fData_12; //12 + double dData_16; //16 + unsigned char bData_24[8]; //24, size?? + unsigned char bData_32[16]; //32, size?? + unsigned char bData_48[12]; //48, size?? + unsigned char bData_60[26]; //60, size?? + unsigned char bData_86[22]; //86, size?? + unsigned char bData_108[36]; //108, size?? + char fill[8]; //??? +} Struct_MessierData; + +typedef struct +{ + unsigned char bData_0[18]; //0 + float fRightAscension; //20 + float fDeclination; //24 + float fData_28; //28 +} Struct_BrightStarData; + +typedef struct +{ + float fRightAscension; //0 + float fDeclination; //4 + +} Struct_Sh2Data; + +typedef struct +{ + unsigned char bData_0[5]; //0 + float fRightAscension; //8 + float fDeclination; //12 + float fData_16; //16 + unsigned char bData_20[10]; //20 size?? +} Struct_ICData; + +typedef struct +{ + unsigned char bData_0[5]; //0 + float fRightAscension; //8 + float fDeclination; //12 + float fData_16; //16 + unsigned char bData_20[10]; //20 size?? + char fill_30[28]; //30 +} Struct_NGCData; + +typedef struct +{ + float ra; //0 + float dec; //4 + +} Struct_SAOData; + +typedef struct +{ + unsigned char bData_0[10]; //0 + unsigned char bData_10[10]; //10 + float fData_20; //20 + float fData_24; //24 +} Struct_4dd0; + +typedef struct +{ + unsigned char cCountry[20]; //0 + unsigned char cCity[20]; //20 + float fLongitude; //40 + float fLatitude; //44 + int Zone; //48 +} Struct_SiteData; + +typedef struct +{ + unsigned char bData_0; //0 + unsigned char bData_1[9]; //1 + float fData_12; //12 + float fData_16; //16 +} Struct_5218; + +typedef struct +{ + unsigned char bData_0; + unsigned char bData_1[8]; //1 + float fData_12; //12 + float fData_16; //16 +} Struct_54e0; + +typedef struct +{ + unsigned short wYear; //0 + unsigned char bMonth; //2 + unsigned char bDay; //3 + unsigned char bHours; //4 + unsigned char bMinutes; //5 + unsigned char bSeconds; //6 + unsigned short wMilliSeconds; //8 +} Struct_DateTime; + +typedef struct +{ + double dData_0; //0 + double dData_8; //8 + double dData_16; //16 + double dData_24; //24 + double dData_32; //32 + double dData_40; //40 +} Struct_7978; + +typedef struct +{ + double dLongitude; //0 + double dLatitude; //8 + +} Struct_GeographicCoordinates; + +typedef struct +{ + double dRA; //0 + double dDec; //8 + double fill1; //16 + double fill2; //24 +} Struct_EquatorialCoordinates; + +typedef struct +{ + double dData_0; + double dData_8; + double dData_16; + double dData_24; + double dData_32; + double dData_40; +} Struct_b1a8; + +typedef struct +{ + double dData_0; + double dData_8; + double dData_16; + double dData_24; + double dData_32; + double dData_40; +} Struct_b7f4; + + +typedef struct +{ + double dData_0; + double dData_8; + double dData_16; + double dData_24; + // +} Struct_40004b70; + + +typedef struct +{ + double dData_0; + double dAzimuth; //8 + double dZenithDistance; //16 + double dAltitude; //24 + double dData_32; + double dData_40; + double dData_48; + double fill1; //56 + double fill2; //64 + //72 +} Struct_HorizontalCoordinates; + +typedef struct +{ + unsigned short wData_0; //0 + unsigned short wData_2; //2 + unsigned short wData_4; //4 + +} Struct_40003290; + +typedef struct +{ + unsigned char bData_0; //0 + unsigned char bData_1; //1 + unsigned char bData_2; //2 + +} Struct_40003296; + + +typedef enum +{ + SLEW_STOP = 0, + SLEW_RATE_1X = 1, + SLEW_RATE_2X = 2, + SLEW_RATE_8X = 3, + SLEW_RATE_16X = 4, + SLEW_RATE_64X = 5, + SLEW_RATE_128X = 6, + SLEW_RATE_256X = 7, + SLEW_RATE_512X = 8, + SLEW_RATE_MAX = 9, + +} eSlewRate; + + diff --git a/applications/freertos_app/neptun.c b/applications/freertos_app/neptun.c new file mode 100644 index 0000000..06bb00e --- /dev/null +++ b/applications/freertos_app/neptun.c @@ -0,0 +1,81 @@ + +/* 19118 - todo */ +double neptune_ecliptic_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double res = 0.0; + + L0 += 531188633 * cos(0 + a * 0); + L0 += 1798476 * cos(2.9010127 + a * 38.1330356); + L0 += 1019728 * cos(0.4858092 + a * 1.4844727); + L0 += 124532 * cos(4.830081 + a * 36.648563); + L0 += 42064 * cos(5.41055 + a * 2.96895); + L0 += 37715 * cos(6.09222 + a * 35.16409); + + L1 += 3837687717 * cos(0 + a * 0); + + L2 += 53893 * cos(0 + a * 0); + + res = (L0 + L1 * a + L2 * a*a + L3 * a*a*a + L4 * a*a*a*a) / 100000000.0; + + return res; +} + +/* 196cc - todo */ +double neptune_ecliptic_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double B2 = 0.0; + double B3 = 0.0; + double B4 = 0.0; + double res = 0.0; + + B0 += 3088623 * cos(1.4410437 + a * 38.1330356); + B0 += 27780 * cos(5.91272 + a * 76.26607); + B0 += 27624 * cos(0 + a * 0); + B0 += 15448 * cos(3.50877 + a * 39.61751); + B0 += 15355 * cos(2.52124 + a * 36.64856); + + B1 += 227279 * cos(3.807931 + a * 38.133036); + +// B2 += 9691 * cos(5.5712 + a * 38.1330); + B2 += 273 * cos(1.107 + a * 38.1330); //BUG! + + res = (B0 + B1 * a + B2 * a*a + B3 * a*a*a + B4 * a*a*a*a) / 100000000.0; + + return res; +} + +/* 19c18 - todo */ +double neptune_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double res = 0.0; + + R0 += 3007013206 * cos(0 + a * 0); + R0 += 27062259 * cos(1.32999459 + a * 38.13303364); //38.13303564); //BUG? + R0 += 1691764 * cos(3.2518614 + a * 36.6485629); + R0 += 807831 * cos(5.185928 + a * 1.484473 ); + R0 += 537761 * cos(4.521139 + a * 35.164090); + R0 += 495726 * cos(1.571057 + a * 491.557929); + R0 += 274572 * cos(1.845523 + a * 175.166060); + + R1 += 236339 * cos(0.704980 + a * 38.133036); + R1 += 13220 * cos(3.32015 + a * 1.48447); + R1 += 8622 * cos(6.2163 + a * 35.1641); + + R2 += 4247 * cos(5.8991 + a * 38.1330); + + res = (R0 + R1 * a + R2 * a*a + R3 * a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/freertos_app/object_database.c b/applications/freertos_app/object_database.c new file mode 100644 index 0000000..76c6a19 --- /dev/null +++ b/applications/freertos_app/object_database.c @@ -0,0 +1,429 @@ + +/* 34e4 - todo */ +int flash_get_famous_star_data(int a, Struct_FamousStarData* b) +{ + unsigned char buf[51]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 33)) + { + return 0; + } + + r6 = (a - 1) / 10; + r7 = ((a - 1) % 10) * 51; + + flash_read((unsigned short)(0x00 + r6), r7, sizeof(buf), buf); + + for (i = 0; i < 10; i++) + { + b->bData_0[i] = buf[i]; + } + b->bData_0[10] = 0; + b->bData_0[11] = 0; + + for (i = 10; i < 20; i++) + { + b->bData_12[i-10] = buf[i]; + } + b->bData_12[10] = 0; + b->bData_12[11] = 0; + + b->Data_24 = buf[20] * 10000 + buf[21] * 100 + buf[22]; + + for (i = 23; i < 35; i++) + { + b->bData_28[i-22] = buf[i]; + } + b->bData_28[0] = ' '; + b->bData_28[13] = 0; + + for (i = 35; i < 43; i++) + { + b->bData_42[i-35] = buf[i]; + } + b->bData_42[8] = 0; + b->bData_42[9] = 0; + + if (buf[43] >= 0x80) + { + b->fData_52 = 0x80 - buf[43] - buf[44] / 10.0; + } + else + { + b->fData_52 = buf[43] + buf[44] / 10.0; + } + + b->fRightAscension = buf[45] + buf[46] / 60.0 + buf[47] / 3600.00; + + if (buf[48] >= 0x80) + { + b->fDeclination = 0x80 - buf[48] - buf[49] / 60.0 - buf[50] / 3600.0; + } + else + { + b->fDeclination = buf[48] + buf[49] / 60.0 + buf[50] / 3600.0; + } + + return 1; +} + +/* 38dc - todo */ +int flash_get_constellation_data(int a, Struct_ConstellationData* b) +{ + unsigned char buf[38]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 33)) + { + return 0; + } + + r6 = (a - 1) / 13; + r7 = ((a - 1) % 13) * 38; + + flash_read((unsigned short)(0x04 + r6), r7, sizeof(buf), buf); + + for (i = 0; i < 3; i++) + { + b->bData_0[i] = buf[i]; + } + + b->bData_0[3] = ' '; + b->bData_0[4] = 0; + + for (i = 3; i < 22; i++) + { + b->bData_5[i-3] = buf[i]; + } + + b->bData_5[19] = ' '; + b->bData_5[20] = 0; + + for (i = 22; i < 30; i++) + { + b->bData_26[i-22] = buf[i]; + } + + b->bData_26[8] = 0; + b->bData_26[9] = 0; + + b->fRightAscension = buf[30] + buf[31] / 60.0; + + if (buf[32] >= 0x80) + { + b->fDeclination = 0x80 - buf[32] - buf[33] / 100.0; + } + else + { + b->fDeclination = buf[32] + buf[33] / 100.0; + } + + b->wArea = buf[34] * 100 + buf[35]; + + b->bData_46 = buf[36]; + b->bQuantity = buf[37]; + + return 1; +} + +/* 3b58 - todo */ +int flash_get_messier_data(int a, Struct_MessierData* b) +{ + unsigned char buf[124]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 110)) + { + return 0; + } + + r6 = (a - 1) / 4; + r7 = ((a - 1) % 4) * 124; + + flash_read((unsigned short)(0x0b + r6), r7, sizeof(buf), buf); + + b->wData_0 = buf[0] * 100 + buf[1]; + b->fRightAscension = buf[2] + buf[3] / 60.0 + buf[4] / 3600.0; + + if (buf[5] >= 0x80) + { + b->fDeclination = 0x80 - buf[5] - buf[6] / 60.0 - buf[7] / 3600.0; + } + else + { + b->fDeclination = buf[5] + buf[6] / 60.0 + buf[7] / 3600.0; + } + + b->fData_12 = buf[8] + buf[9] / 10.0; + + b->dData_16 = buf[10] * 10000.0 + buf[11] * 100.0 + buf[12] + buf[13] / 10.0; + + for (i = 14; i < 20; i++) + { + b->bData_24[i-14] = buf[i]; + } + + b->bData_24[6] = 0; + b->bData_24[7] = 0; + + for (i = 20; i < 34; i++) + { + b->bData_32[i-20] = buf[i]; + } + + b->bData_32[14] = ' '; + b->bData_32[15] = 0; + + for (i = 34; i < 44; i++) + { + b->bData_48[i-34] = buf[i]; + } + + b->bData_48[10] = 0; + b->bData_48[11] = 0; + + for (i = 44; i < 68; i++) + { + b->bData_60[i-44] = buf[i]; + } + + b->bData_60[24] = ' '; + b->bData_60[25] = 0; + + for (i = 68; i < 90; i++) + { + b->bData_86[i-68] = buf[i]; + } + + b->bData_86[22] = 0; //Bug + b->bData_86[23] = 0; //Bug + + for (i = 90; i < 124; i++) + { + b->bData_108[i-90] = buf[i]; + } + + b->bData_108[34] = ' '; + b->bData_108[35] = 0; + + return 1; +} + +/* 4028 - todo */ +int flash_get_bright_star_data(int a, Struct_BrightStarData* b) +{ + unsigned char buf[24]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 167)) + { + return 0; + } + + r6 = (a - 1) / 22; + r7 = ((a - 1) % 22) * 24; + + flash_read((unsigned short)(0x27 + r6), r7, sizeof(buf), buf); + + for (i = 0; i < 16; i++) + { + b->bData_0[i] = buf[i]; + } + + b->bData_0[16] = ' '; + b->bData_0[17] = 0; + + b->fRightAscension = buf[16] + buf[17] / 60.0 + buf[18] / 3600.0; + + if (buf[19] >= 0x80) + { + b->fDeclination = 0x80 - buf[19] - buf[20] / 60.0 - buf[21] / 3600.0; + } + else + { + b->fDeclination = buf[19] + buf[20] / 60.0 + buf[21] / 3600.0; + } + + if (buf[22] >= 0x80) + { + b->fData_28 = 0x80 - buf[22] - buf[23] / 100.0; + } + else + { + b->fData_28 = buf[22] + buf[23] / 100.0; + } + + return 1; +} + +/* 435c - todo */ +int flash_get_sh2_data(int a, Struct_Sh2Data* b) +{ + unsigned char buf[6]; + unsigned short r6; + unsigned short r7; + + if ((a == 0) && (a > 313)) + { + return 0; + } + + r6 = (a - 1) / 88; + r7 = ((a - 1) % 88) * 6; + + flash_read((unsigned short)(0x2f + r6), r7, sizeof(buf), buf); + + b->fRightAscension = buf[0] + buf[1] / 60.0 + buf[2] / 3600.0; + + if (buf[3] >= 0x80) + { + b->fDeclination = 0x80 - buf[3] - buf[4] / 60.0 - buf[5] / 3600.0; + } + else + { + b->fDeclination = buf[3] + buf[4] / 60.0 + buf[5] / 3600.0; + } + + return 1; +} + +/* 4594 - todo */ +int flash_get_ic_data(int a, Struct_ICData* b) +{ + unsigned char buf[19]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 5386)) + { + return 0; + } + + r6 = (a - 1) / 27; + r7 = ((a - 1) % 27) * 19; + + flash_read((unsigned short)(0x33 + r6), r7, sizeof(buf), buf); + + for (i = 0; i < 3; i++) + { + b->bData_0[i] = buf[i]; + } + + b->bData_0[3] = ' '; + b->bData_0[4] = 0; + + b->fRightAscension = buf[3] + buf[4] / 60.0 + buf[5] / 3600.0; + + if (buf[6] >= 0x80) + { + b->fDeclination = 0x80 - buf[6] - buf[7] / 60.0 - buf[8] / 3600.0; + } + else + { + b->fDeclination = buf[6] + buf[7] / 60.0 + buf[8] / 3600.0; + } + + b->fData_16 = buf[9] + buf[10] / 10.0; + + for (i = 11; i < 19; i++) + { + b->bData_20[i-11] = buf[i]; + } + + b->bData_0[8] = ' '; //bug! + b->bData_0[9] = 0; //bug! + + return 1; +} + +/* 4894 - todo */ +int flash_get_ngc_data(int a, Struct_NGCData* b) +{ + unsigned char buf[19]; + unsigned short r6; + unsigned short r7; + unsigned char i; + + if ((a == 0) && (a > 7840)) + { + return 0; + } + + r6 = (a - 1) / 27; + r7 = ((a - 1) % 27) * 19; + + flash_read((unsigned short)(0xfb + r6), r7, sizeof(buf), buf); + + for (i = 0; i < 3; i++) + { + b->bData_0[i] = buf[i]; + } + + b->bData_0[3] = ' '; + b->bData_0[4] = 0; + + b->fRightAscension = buf[3] + buf[4] / 60.0 + buf[5] / 3600.0; + + if (buf[6] >= 0x80) + { + b->fDeclination = 0x80 - buf[6] - buf[7] / 60.0 - buf[8] / 3600.0; + } + else + { + b->fDeclination = buf[6] + buf[7] / 60.0 + buf[8] / 3600.0; + } + + b->fData_16 = buf[9] + buf[10] / 10.0; + + for (i = 11; i < 19; i++) + { + b->bData_20[i-11] = buf[i]; + } + + b->bData_0[8] = ' '; //bug! + b->bData_0[9] = 0; //bug! + + return 1; +} + +/* 4b94 - complete */ +int flash_get_sao_data(unsigned int a, Struct_SAOData* b) +{ + unsigned char buf[6]; + unsigned short r6; + unsigned short r7; + + if ((a == 0) && (a > 258997)) + { + return 0; + } + + r6 = (a - 1) / 88; + r7 = ((a - 1) % 88) * 6; + + flash_read((unsigned short)(0x21e + r6), r7, sizeof(buf), buf); + + b->ra = buf[0] + buf[1] / 60.0 + buf[2] / 3600.0; + + if (buf[3] >= 0x80) + { + b->dec = 0x80 - buf[3] - buf[4] / 60.0 - buf[5] / 3600.0; + } + else + { + b->dec = buf[3] + buf[4] / 60.0 + buf[5] / 3600.0; + } + + return 1; +} + diff --git a/applications/freertos_app/pluto.c b/applications/freertos_app/pluto.c new file mode 100644 index 0000000..5962637 --- /dev/null +++ b/applications/freertos_app/pluto.c @@ -0,0 +1,77 @@ + + //See: https://github.com/engerim42/wmsolar/blob/master/Pluto.cpp + //See: home.mnet-online.de/reimay/Projects/pc/Astronomie/libaa/AAPluto.cpp + +/* 1a2d0 - todo */ +double pluto_ecliptic_longitude(double a) +{ + double sp120 = 0.0; + double J; + double S; + double P; + double sp88; + + J = 34.35 + a * 3034.9057; + S = 50.08 + a * 1222.1138; + P = 238.96 + a * 144.96; + + sp120 += sin(1.0 * P / 180.0 * 3.1415927) * -19798886 + + cos(1.0 * P / 180.0 * 3.1415927) * 19848454; + sp120 += sin(2.0 * P / 180.0 * 3.1415927) * 897499 - + cos(2.0 * P / 180.0 * 3.1415927) * 4955707; + + sp88 = a * 144.96 + 238.956785 + sp120 / 1000000; + + return sp88; +} + +/* 1a680 - todo */ +double pluto_ecliptic_latitude(double a) +{ + double sp120 = 0.0; + double J; + double S; + double P; + double sp88; + + J = 34.35 + a * 3034.9057; + S = 50.08 + a * 1222.1138; + P = 238.96 + a * 144.96; + + sp120 += sin(1.0 * P / 180.0 * 3.1415927) * -5453098 - + cos(1.0 * P / 180.0 * 3.1415927) * 14974876; + sp120 += sin(2.0 * P / 180.0 * 3.1415927) * 3527363 + + cos(2.0 * P / 180.0 * 3.1415927) * 1672673; + sp120 += sin(3.0 * P / 180.0 * 3.1415927) * -1050939 + + cos(3.0 * P / 180.0 * 3.1415927) * 327763; + + sp88 = -3.908202 + sp120 / 1000000; + + return sp88; +} + +/* 1aac4 - todo */ +double pluto_radius_vector(double a) +{ + double sp120 = 0.0; + double J; + double S; + double P; + double sp88; + + J = a * 3034.9057 + 34.35; + S = a * 1222.1138 + 50.08; + P = a * 144.96 + 238.96; + + sp120 += sin((1.0 * P) / 180.0 * 3.1415927) * 66867334.0 + + cos((1.0 * P) / 180.0 * 3.1415927) * 68955876.0; + sp120 += sin((2.0 * P) / 180.0 * 3.1415927) * -11826086 - + cos((2.0 * P) / 180.0 * 3.1415927) * 333765; + sp120 += sin(3.0 * P / 180.0 * 3.1415927) * 1593657 - + cos(3.0 * P / 180.0 * 3.1415927) * 1439953; + + sp88 = 40.7247248 + sp120 / 10000000; + + return sp88; +} + diff --git a/applications/freertos_app/saturn.c b/applications/freertos_app/saturn.c new file mode 100644 index 0000000..ae36c54 --- /dev/null +++ b/applications/freertos_app/saturn.c @@ -0,0 +1,114 @@ + +/* 15340 - todo */ +double saturn_ecliptic_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double L5 = 0.0; + double res = 0.0; + + L0 += 87401354 * cos(0.0 + a * 0.0); + L0 += 11107660 * cos(3.96205090 + a * 213.29909544); + L0 += 1414151 * cos(4.5858152 + a * 7.1135470); + L0 += 398379 * cos(0.521120 + a * 206.185548); + L0 += 350769 * cos(3.303299 + a * 426.598191); + L0 += 206816 * cos(0.246584 + a * 103.092774); + L0 += 79271 * cos(3.84007 + a * 220.41264); + L0 += 23990 * cos(4.66977 + a * 110.20632); + L0 += 16574 * cos(0.43719 + a * 419.48464); + L0 += 15820 * cos(0.93809 + a * 632.78374); + L0 += 15054 * cos(2.71670 + a * 639.89729); + L0 += 14907 * cos(5.76903 + a * 316.39187); + + L1 += 21354295596 * cos(0.0 + a * 0.0); + L1 += 1296855 * cos(1.828205/*1.8282054*/ + a * 213.2990954); //BUG? + L1 += 564348 * cos(2.885001 + a * 7.113547); + L1 += 107679 * cos(2.277699 + a * 206.185548); + L1 += 98323 * cos(1.08070 + a * 426.59819); + L1 += 40255 * cos(2.04128 + a * 220.41264); + L1 += 19942 * cos(1.27955 + a * 103.09277); + L1 += 10512 * cos(2.74880 + a * 14.22709); + + L2 += 116441 * cos(1.179879 + a * 7.113547); + L2 += 91921 * cos(0.07425 + a * 213.29910); + L2 += 90592 * cos(0.0 + a * 0.0); + + res = (L0 + L1 * a + L2 * a*a + L3 * a*a*a + L4 * a*a*a*a + L5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* 16114 - todo */ +double saturn_ecliptic_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double B2 = 0.0; + double B3 = 0.0; + double B4 = 0.0; + double B5 = 0.0; + double res = 0.0; + + B0 += 4330678 * cos(3.6028443 + a * 213.2990954); + B0 += 240348 * cos(2.852385 + a * 426.598191); + B0 += 84746 * cos(0.0 + a * 0.0); + B0 += 34116 * cos(0.57297 + a * 206.18555); + B0 += 30863 * cos(3.48442 + a * 220.41264); + + B1 += 397555 * cos(5.332900 + a * 213.299095); + B1 += 49479 * cos(3.14159 + a * 0.0); + B1 += 18572 * cos(6.09919 + a * 426.59819); + B1 += 14801 * cos(2.30586 + a * 206.18555); + B1 += 9644 * cos(1.6967 + a * 220.4126); + + B2 += 20630 * cos(0.50482 + a * 213.29910); + B2 += 3720 * cos(3.9983 + a * 206.1855); + B2 += 1627 * cos(6.1819 + a * 220.4126); + B2 += 1346 * cos(0.0 + a * 0.0); + + res = (B0 + B1 * a + B2 * a*a + B3 * a*a*a + B4 * a*a*a*a + B5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* 16a5c - todo */ +double saturn_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double R4 = 0.0; + double R5 = 0.0; + double res = 0.0; + + R0 += 955758136 * cos(0.0 + a * 0.0); + R0 += 52921382 * cos(2.39226220 + a * 213.29909544); + R0 += 1873680 * cos(5.2354961 + a * 206.1855484); + R0 += 1464664 * cos(1.6476305 + a * 426.5981909); + R0 += 821891 * cos(5.935200 + a * 316.391870); + R0 += 547507 * cos(5.015326 + a * 103.092774); + R0 += 371684 * cos(2.271148 + a * 220.412642); + R0 += 361778 * cos(3.139043 + a * 7.113547); + R0 += 140618 * cos(5.074067/*5.704067*/ + a * 632.783739); //BUG? + R0 += 108975 * cos(3.293136 + a * 110.206321); + + R1 += 6182981 * cos(0.2584352 + a * 213.2990954); + R1 += 506578 * cos(0.711147 + a * 206.185548); + R1 += 341394 * cos(5.796358 + a * 426.598191); + R1 += 188491 * cos(0.472157 + a * 220.412642); + R1 += 186262 * cos(3.141593 + a * 0.0); + R1 += 143891 * cos(1.407449 + a * 7.113547); + + R2 += 436902 * cos(4.786717 + a * 213.299095); + R2 += 71923 * cos(2.50070 + a * 206.18555); + R2 += 49767 * cos(4.97168 + a * 220.412642); //220.41264); //BUG? + + res = (R0 + R1 * a + R2 * a*a + R3 * a*a*a + R4 * a*a*a*a + R5 * a*a*a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/freertos_app/slew1.c b/applications/freertos_app/slew1.c new file mode 100644 index 0000000..bb9c3a2 --- /dev/null +++ b/applications/freertos_app/slew1.c @@ -0,0 +1,311 @@ + + +/* 57414 - todo */ +void SlewAxis(int axis, int direction, int speed) +{ + unsigned char i; + char sp12[12]; + char sp[12]; + + bData_40003430 = 1; + bData_40003200 = 0; + bData_40003201 = 0; + + sp[0] = 0x55; + sp[1] = 0xaa; + sp[2] = 0x01; + sp[3] = 0x04; + + switch (axis) + { + case 1: + //0x57488: Equatorial East-West + sp[4] = 0x21; + break; + + case 2: + //0x57498: Equatorial North-South + sp[4] = 0x01; + break; + + case 3: + //0x574a8 + sp[4] = 0x61; + break; + + case 4: + //0x574b8 + sp[4] = 0x41; + break; + + default: + //0x574c8 + break; + } + + switch (direction) + { + case 3: + //0x574f8 + case 1: + //0x57500 + sp[5] = 0; + break; + + case 4: + //0x5750c + case 2: + //0x57514 + sp[5] = 1; + break; + + default: + //0x57520 + break; + } + + sp[6] = 0; + sp[7] = 0; + + for (i = 0; i < 8; i++) + { + //0x57540 + uart1_write_byte(sp[i]); + } + + if (g_bSingleSlewActive == 0) + { + //5756c + g_bSingleSlewActive = 1; + + func_7590(); + + sp12[0] = 0x55; + sp12[1] = 0xaa; + sp12[2] = 0x01; + sp12[3] = 0x04; + + switch (axis) + { + case 1: + //0x575c0: Equatorial East-West + sp12[4] = 0x01; + break; + + case 2: + //0x575d0: Equatorial North-South + sp12[4] = 0x21; + break; + + case 3: + //0x575e0 + sp12[4] = 0x41; + break; + + case 4: + //0x575f0 + sp12[4] = 0x61; + break; + + default: + //0x57600 + break; + } + + switch (direction) + { + case 3: + //0x57630 + case 1: + //0x57638 + sp12[5] = 0; + break; + + case 4: + //0x57644 + case 2: + //0x5764c + sp12[5] = 1; + break; + + default: + //0x57658 + break; + } + + if (bData_40002c1a == 1) + { + //57674 + switch (speed) + { + case 0: + //0x576a8 + sp12[6] = 0; sp12[7] = 0; + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + break; + + case SLEW_RATE_1X: //1: + //0x576c4 + sp12[6] = 0x00; sp12[7] = 0x05; //5 + bTrackingMode = 10; + break; + + case SLEW_RATE_2X: //2: + //0x576e8 + sp12[6] = 0x00; sp12[7] = 0x0a; //10 + bTrackingMode = 10; + break; + + case SLEW_RATE_8X: //3: + //0x57708 + sp12[6] = 0x00; sp12[7] = 0x28; //40 + bTrackingMode = 10; + break; + + case SLEW_RATE_16X: //4: + //0x5772c + sp12[6] = 0x00; sp12[7] = 0xa0; //160 + bTrackingMode = 10; + break; + + case SLEW_RATE_64X: //5: + //0x57750 + sp12[6] = 0x01; sp12[7] = 0x40; //320 + bTrackingMode = 10; + break; + + case SLEW_RATE_128X: //6: + //0x57774 + sp12[6] = 0x02; sp12[7] = 0x80; //640 + bTrackingMode = 10; + break; + + case SLEW_RATE_256X: //7: + //0x57798 + sp12[6] = 0x05; sp12[7] = 0x00; //1280 + bTrackingMode = 10; + break; + + case SLEW_RATE_512X: //8: + //0x577bc + sp12[6] = 0x0a; sp12[7] = 0x00; //2560 + bTrackingMode = 10; + break; + + case SLEW_RATE_MAX: //9: + //0x577e0 + sp12[6] = 0x0a; sp12[7] = 0x00; //2560 + + g_stCurrentSlewRampValue.Data = 2560; + + g_bMaxSlewRampActive = 1; + bData_400031ba = sp12[4]; + bData_400031bc = sp12[5]; + g_iCurrentSlewRampIndex = 1; //Ramp up (+100) + + bData_400031b9 = 0; + bData_400031bb = sp12[4]; + bData_400031bd = sp12[5]; + Data_400031a8 = 0; + + bTrackingMode = 10; + break; + #if 0 + default: + //0x57870 + break; + #endif + } + } //if (bData_40002c1a == 1) + //0x57874 + if (bData_40002c1a == 2) + { + //57884 + switch (speed) + { + case 0: + //0x578b8 + sp12[6] = 0; + sp12[7] = 0; + bTrackingMode = MENU_TRACKING_MODE_STOP; //0; + break; + + case SLEW_RATE_1X: //1: + //0x578d4 + sp12[6] = 0; + sp12[7] = 6; + bTrackingMode = 10; + break; + + case SLEW_RATE_2X: //2: + //0x578f8 + sp12[6] = 0; + sp12[7] = 12; + bTrackingMode = 10; + break; + + case SLEW_RATE_8X: //3: + //0x5791c + sp12[6] = 0; + sp12[7] = 48; + bTrackingMode = 10; + break; + + case SLEW_RATE_16X: //4: + //0x57940 + sp12[6] = 0; + sp12[7] = 96; + bTrackingMode = 10; + break; + + case SLEW_RATE_64X: //5: + //0x57964 + sp12[6] = 0; + sp12[7] = 192; + bTrackingMode = 10; + break; + + case SLEW_RATE_128X: //6: + //0x57988 + sp12[6] = 1; + sp12[7] = 128; + bTrackingMode = 10; + break; + + case SLEW_RATE_256X: //7: + //0x579ac + sp12[6] = 2; + sp12[7] = 28; + bTrackingMode = 10; + break; + + case SLEW_RATE_512X: //8: + //0x579d0 + sp12[6] = 3; + sp12[7] = 56; + bTrackingMode = 10; + break; + + case SLEW_RATE_MAX: //9: + //0x579f4 + sp12[6] = 3; + sp12[7] = 212; + bTrackingMode = 10; + break; + #if 0 + default: + //0x57a18 + break; + #endif + } + } //if (bData_40002c1a == 2) + //0x57a1c + for (i = 0; i < 8; i++) + { + //0x57a24 + uart1_write_byte(sp12[i]); + } + } //if (g_bSingleSlewActive == 0) + //0x57a40 +} + diff --git a/applications/freertos_app/slew2.c b/applications/freertos_app/slew2.c new file mode 100644 index 0000000..ce64fca --- /dev/null +++ b/applications/freertos_app/slew2.c @@ -0,0 +1,677 @@ + + +/* 4ee90 - todo */ +void SlewBothAxes(int a, int b, int speed1, int d, int e, int speed2) +{ + unsigned char sp[12]; + unsigned char i; + + bData_40003430 = 1; + bData_40003200 = 0; + bData_40003201 = 0; + + if (g_bCombinedSlewActive == 1) + { + //4eed4 + sp[0] = 0x55; + sp[1] = 0xaa; + sp[2] = 0x01; + sp[3] = 0x04; + + switch (a) + { + case 1: + //0x4ef18 + sp[4] = 0x01; + break; + + case 2: + //0x4ef28 + sp[4] = 0x21; + break; + + case 3: + //0x4ef38 + sp[4] = 0x41; + break; + + case 4: + //0x4ef48 + sp[4] = 0x61; + break; + + default: + //0x4ef58 + break; + } + + switch (b) + { + case 3: + //0x4ef88 + case 1: + //0x4ef90 + sp[5] = 0x00; + break; + + case 4: + //0x4ef9c + case 2: + //0x4efa4 + sp[5] = 0x01; + break; + + default: + //0x4efb0 + break; + } + + if (bData_40002c1a == 1) + { + //4efcc + switch (speed1) + { + case SLEW_STOP: //0: + //0x4f000 + sp[6] = 0x00; sp[7] = 0x00; + bTrackingMode = 0; + break; + + case SLEW_RATE_1X: //1: + //0x4f06c + sp[6] = 0x00; sp[7] = 0x05; + bTrackingMode = 10; + break; + + case SLEW_RATE_2X: //2: + //0x4f090 + sp[6] = 0x00; sp[7] = 0x0a; + bTrackingMode = 10; + break; + + case SLEW_RATE_8X: //3: + //0x4f0b0 + sp[6] = 0x00; sp[7] = 0x28; + bTrackingMode = 10; + break; + + case SLEW_RATE_16X: //4: + //0x4f0d4 + sp[6] = 0x00; sp[7] = 0xa0; + bTrackingMode = 10; + break; + + case SLEW_RATE_64X: //5: + //0x4f0f8 + sp[6] = 0x01; sp[7] = 0x40; + bTrackingMode = 10; + break; + + case SLEW_RATE_128X: //6: + //0x4f11c + sp[6] = 0x02; sp[7] = 0x80; + bTrackingMode = 10; + break; + + case SLEW_RATE_256X: //7: + //0x4f140 + sp[6] = 0x05; sp[7] = 0x00; + bTrackingMode = 10; + break; + + case SLEW_RATE_512X: //8: + //0x4f164 + sp[6] = 0x0a; sp[7] = 0x00; + bTrackingMode = 10; + break; + + case SLEW_RATE_MAX: //9: + //0x4f188 + sp[6] = 0x0a; sp[7] = 0x00; + bTrackingMode = 10; + break; + #if 0 + default: + //0x4f1ac + break; + #endif + } //switch (c) + } //if (bData_40002c1a == 1) + //0x4f1b0 + if (bData_40002c1a == 2) + { + //4f1c0 + switch (speed1) + { + case SLEW_STOP: //0: + //0x4f1f4 + sp[6] = 0; sp[7] = 0; + bTrackingMode = 0; + break; + + case SLEW_RATE_1X: //1: + //0x4f210 + sp[6] = 0x00; sp[7] = 0x06; + bTrackingMode = 10; + break; + + case SLEW_RATE_2X: //2: + //0x4f234 + sp[6] = 0x00; sp[7] = 0x0c; + bTrackingMode = 10; + break; + + case SLEW_RATE_8X: //3: + //0x4f258 + sp[6] = 0x00; sp[7] = 0x30; + bTrackingMode = 10; + break; + + case SLEW_RATE_16X: //4: + //0x4f27c + sp[6] = 0x00; sp[7] = 0x60; + bTrackingMode = 10; + break; + + case SLEW_RATE_64X: //5: + //0x4f2a0 + sp[6] = 0x00; sp[7] = 0xc0; + bTrackingMode = 10; + break; + + case SLEW_RATE_128X: //6: + //0x4f2c4 + sp[6] = 0x01; sp[7] = 0x80; + bTrackingMode = 10; + break; + + case SLEW_RATE_256X: //7: + //0x4f2e8 + sp[6] = 0x02; sp[7] = 0x1c; + bTrackingMode = 10; + break; + + case SLEW_RATE_512X: //8: + //0x4f30c + sp[6] = 0x03; sp[7] = 0x38; + bTrackingMode = 10; + break; + + case SLEW_RATE_MAX: //9: + //0x4f330 + sp[6] = 0x03; sp[7] = 0xD4; + bTrackingMode = 10; + break; + #if 0 + default: + //0x4f354 + break; + #endif + } //switch (c) + } + //0x4f358 + for (i = 0; i < 8; i++) + { + //0x4f360 + uart1_write_byte(sp[i]); + } + + switch (d) + { + case 1: + //0x4f3a0 + sp[4] = 0x01; + break; + + case 2: + //0x4f3b0 + sp[4] = 0x21; + break; + + case 3: + //0x4f3c0 + sp[4] = 0x41; + break; + + case 4: + //0x4f3d0 + sp[4] = 0x61; + break; + + default: + //0x4f3e0 + break; + } + + switch (e) + { + case 3: + //0x4f410 + case 1: + //0x4f418 + sp[5] = 0x00; + break; + + case 4: + //0x4f424 + case 2: + //0x4f42c + sp[5] = 0x01; + break; + + default: + //0x4f438 + break; + } + //0x4f440 + if (bData_40002c1a == 1) + { + //4f454 + switch (speed2) + { + case SLEW_STOP: //0: + //0x4f488 + sp[6] = 0x00; sp[7] = 0x00; + bTrackingMode = 0; + break; + + case SLEW_RATE_1X: //1: + //0x4f4a4 + sp[6] = 0x00; sp[7] = 0x05; + bTrackingMode = 10; + break; + + case SLEW_RATE_2X: //2: + //0x4f4c8 + sp[6] = 0x00; sp[7] = 0x0a; + bTrackingMode = 10; + break; + + case SLEW_RATE_8X: //3: + //0x4f4e8 + sp[6] = 0x00; sp[7] = 0x28; + bTrackingMode = 10; + break; + + case SLEW_RATE_16X: //4: + //0x4f50c + sp[6] = 0x00; sp[7] = 0xa0; + bTrackingMode = 10; + break; + + case SLEW_RATE_64X: //5: + //0x4f530 + sp[6] = 0x01; sp[7] = 0x40; + bTrackingMode = 10; + break; + + case SLEW_RATE_128X: //6: + //0x4f554 + sp[6] = 0x02; sp[7] = 0x80; + bTrackingMode = 10; + break; + + case SLEW_RATE_256X: //7: + //0x4f578 + sp[6] = 0x05; sp[7] = 0x00; + bTrackingMode = 10; + break; + + case SLEW_RATE_512X: //8: + //0x4f59c + sp[6] = 0x0a; sp[7] = 0x00; + bTrackingMode = 10; + break; + + case SLEW_RATE_MAX: //9: + //0x4f5c0 + sp[6] = 0x0a; sp[7] = 0x00; + bTrackingMode = 10; + break; + #if 0 + default: + //0x4f5e4 + break; + #endif + } //switch (f) + } + //0x4f5e8 + if (bData_40002c1a == 2) + { + //4f5f8 + switch (speed2) + { + case SLEW_STOP: //0: + //0x4f62c + sp[6] = 0; sp[7] = 0; + bTrackingMode = 0; + break; + + case SLEW_RATE_1X: //1: + //0x4f648 + sp[6] = 0x00; sp[7] = 0x06; + bTrackingMode = 10; + break; + + case SLEW_RATE_2X: //2: + //0x4f66c + sp[6] = 0x00; sp[7] = 0x0c; + bTrackingMode = 10; + break; + + case SLEW_RATE_8X: //3: + //0x4f690 + sp[6] = 0x00; sp[7] = 0x30; + bTrackingMode = 10; + break; + + case SLEW_RATE_16X: //4: + //0x4f6b4 + sp[6] = 0x00; sp[7] = 0x60; + bTrackingMode = 10; + break; + + case SLEW_RATE_64X: //5: + //0x4f6d8 + sp[6] = 0x00; sp[7] = 0xc0; + bTrackingMode = 10; + break; + + case SLEW_RATE_128X: //6: + //0x4f6fc + sp[6] = 0x01; sp[7] = 0x80; + bTrackingMode = 10; + break; + + case SLEW_RATE_256X: //7: + //0x4f720 + sp[6] = 0x02; sp[7] = 0x1c; + bTrackingMode = 10; + break; + + case SLEW_RATE_512X: //8: + //0x4f744 + sp[6] = 0x03; sp[7] = 0x38; + bTrackingMode = 10; + break; + + case SLEW_RATE_MAX: //9: + //0x4f768 + sp[6] = 0x03; sp[7] = 0xD4; + bTrackingMode = 10; + break; + #if 0 + default: + //0x4f78c + break; + #endif + } //switch (f) + } //if (bData_40002c1a == 2) + //0x4f790 + for (i = 0; i < 8; i++) + { + //0x4f798 + uart1_write_byte(sp[i]); + } + } //if (g_bCombinedSlewActive == 1) + else + { + //0x4f7b8 + g_bCombinedSlewActive = 1; + + if (g_bSingleSlewActive == 0) + { + uart1_write_byte(0x55); + uart1_write_byte(0xaa); + uart1_write_byte(0x01); + uart1_write_byte(0x01); + uart1_write_byte(0xff); + } + } +} + +/* 4f804 - todo */ +void func_4f804(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + //0x4f88c + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + //0x4f894 + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + //0x4f898 + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + //0x4f89c + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + //0x4f8a0 + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + //0x4f8a4 + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + //0x4f8a8 + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + //0x4f8ac + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + //0x4f8b0 + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + //0x4f8b4 + if (g_bLandTarget == 0) + { + //4f8c4 + if ((Data_40004128.bTrackingActive != 0) && + (g_bSlewingStop != 1)) + { + //4f8e4 + g_iSlewStepRaAxis = 1; + g_iSlewStepDecAxis = 1; + bData_40003201 = 0; + bData_40003200 = 0; + //->4f9cc + } + //4f910 + else if (bData_40002c1a == 1) + { + //4f920 + //40002e7d + SlewBothAxes(1, 4, g_eSlewRateIndex, 2, 1, g_eSlewRateIndex); + //->4f9cc + } + else + { + //0x4f948 + SlewBothAxes(3, 4, g_eSlewRateIndex, 4, 1, g_eSlewRateIndex); + //->4f9cc + } + } + else + { + //0x4f970 + if (bData_40002c1a == 1) + { + //4f980 + SlewBothAxes(1, 4, g_eSlewRateIndex, 2, 1, g_eSlewRateIndex); + //->4f9cc + } + else + { + //4f9a8 + SlewBothAxes(3, 4, g_eSlewRateIndex, 4, 1, g_eSlewRateIndex); + //->4f9cc + } + } + break; + + default: + //0x4f9d0 + break; + } +} + +/* 4f9e4 - todo */ +void func_4f9e4(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + if (g_bLandTarget == 0) + { + //4faa4 + if ((Data_40004128.bTrackingActive != 0) && + (g_bSlewingStop != 1)) + { + g_iSlewStepRaAxis = 1; + g_iSlewStepDecAxis = -1; + bData_40003201 = 0; + bData_40003200 = 0; + } + //0x4faf4 + else if (bData_40002c1a == 1) + { + SlewBothAxes(1, 4, g_eSlewRateIndex, 2, 2, g_eSlewRateIndex); + } + else + { + //0x4fb2c + SlewBothAxes(3, 4, g_eSlewRateIndex, 4, 2, g_eSlewRateIndex); + } + } + else + { + //0x4fb54 + if (bData_40002c1a == 1) + { + SlewBothAxes(1, 4, g_eSlewRateIndex, 2, 2, g_eSlewRateIndex); + } + else + { + SlewBothAxes(3, 4, g_eSlewRateIndex, 4, 2, g_eSlewRateIndex); + } + } + break; + + default: + break; + } +} + +/* 4fbc8 - todo */ +void func_4fbc8(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + if (g_bLandTarget == 0) + { + //4fc88 + if ((Data_40004128.bTrackingActive != 0) && + (g_bSlewingStop != 1)) + { + g_iSlewStepRaAxis = -1; + g_iSlewStepDecAxis = -1; + bData_40003201 = 0; + bData_40003200 = 0; + } + //0x4fcd4 + else if (bData_40002c1a == 1) + { + SlewBothAxes(1, 3, g_eSlewRateIndex, 2, 2, g_eSlewRateIndex); + } + else + { + //0x4fd0c + SlewBothAxes(3, 3, g_eSlewRateIndex, 4, 2, g_eSlewRateIndex); + } + } + else + { + //0x4fd34 + if (bData_40002c1a == 1) + { + SlewBothAxes(1, 3, g_eSlewRateIndex, 2, 2, g_eSlewRateIndex); + } + else + { + SlewBothAxes(3, 3, g_eSlewRateIndex, 4, 2, g_eSlewRateIndex); + } + } + break; + + default: + break; + } +} + +/* 4fda8 - todo */ +void func_4fda8(void) +{ + switch (Data_40002c64_MenuContextId) + { + case MENU_CONTEXT_MAIN: //0: + case MENU_CONTEXT_SOLAR_SYSTEM_OBJECT_TRACKING: //22111: + case MENU_CONTEXT_CONSTELLATION_TRACKING: //24002: + case MENU_CONTEXT_FAMOUS_STAR_TRACKING: //25002: + case MENU_CONTEXT_MESSIER_OBJECT_TRACKING: //23022: + case MENU_CONTEXT_NGC_OBJECT_TRACKING: //23013: + case MENU_CONTEXT_IC_OBJECT_TRACKING: //23014: + case MENU_CONTEXT_SH2_OBJECT_TRACKING: //23015: + case MENU_CONTEXT_BRIGHT_STAR_TRACKING: //23016: + case MENU_CONTEXT_SAO_OBJECT_TRACKING: //23017: + if (g_bLandTarget == 0) + { + //4fe68 + if ((Data_40004128.bTrackingActive != 0) && + (g_bSlewingStop != 1)) + { + g_iSlewStepRaAxis = -1; + g_iSlewStepDecAxis = 1; + bData_40003201 = 0; + //bData_40003200 = 0; //Bug?? + } + //0x4feb0 + else if (bData_40002c1a == 1) + { + SlewBothAxes(1, 3, g_eSlewRateIndex, 2, 1, g_eSlewRateIndex); + } + else + { + //0x4fee8 + SlewBothAxes(3, 3, g_eSlewRateIndex, 4, 1, g_eSlewRateIndex); + } + } + else + { + //0x4ff10 + if (bData_40002c1a == 1) + { + SlewBothAxes(1, 3, g_eSlewRateIndex, 2, 1, g_eSlewRateIndex); + } + else + { + SlewBothAxes(3, 3, g_eSlewRateIndex, 4, 1, g_eSlewRateIndex); + } + } + break; + + default: + break; + } +} + diff --git a/applications/freertos_app/uart.c b/applications/freertos_app/uart.c new file mode 100644 index 0000000..b721507 --- /dev/null +++ b/applications/freertos_app/uart.c @@ -0,0 +1,431 @@ + +#include "my_types.h" +#include "data.h" +#include "FreeRTOS.h" +#include "queue.h" + + +void uart0_send(unsigned char* a, unsigned char b); + + +QueueHandle_t xQueueUart1; + + + +/* 19f0 - complete */ +#ifdef __GNUC__ +void uart1_isr(void) __attribute__ ((interrupt ("IRQ"))); +void uart1_isr(void) +#else +void uart1_isr(void) __irq +#endif +{ + uart1_bRxData = U1RBR; + + if (bData_40002c1a == 0) + { + //First Response from Mount + bData_40002c1a = 3; + } + + if (bData_40002c13_uart1ReceiveComplete == 0) + { + switch (bData_40002c14_uart1ReceiveStep) + { + case 0: + //Check first byte of header signature + if (bData_40002c15_uart1ReceiveHeader[0] == uart1_bRxData) + { + bData_40002c14_uart1ReceiveStep++; + } + break; + + case 1: + //Check second byte of header signature + if (bData_40002c15_uart1ReceiveHeader[1] == uart1_bRxData) + { + bData_40002c14_uart1ReceiveStep++; + } + else + { + bData_40002c14_uart1ReceiveStep = 0; + } + break; + + case 2: + //Check third byte of header signature + if (bData_40002c15_uart1ReceiveHeader[2] == uart1_bRxData) + { + bData_40002c14_uart1ReceiveStep++; + } + else + { + bData_40002c14_uart1ReceiveStep = 0; + } + break; + + case 3: + //Check and store payload length information + if (uart1_bRxData < 10) + { + bData_40002c15_uart1ReceiveHeader[3] = uart1_bRxData; + bData_40002c14_uart1ReceiveStep++; + } + else + { + bData_40002c14_uart1ReceiveStep = 0; + } + break; + + case 4: + //Store payload data + if (bData_40002c15_uart1ReceiveHeader[3] > bData_40002c12_uart1ReceiveDataCount) + { + Data_40003592_uart1ReceiveDataBuffer[bData_40002c12_uart1ReceiveDataCount] = uart1_bRxData; + bData_40002c12_uart1ReceiveDataCount++; + if (bData_40002c12_uart1ReceiveDataCount == bData_40002c15_uart1ReceiveHeader[3]) + { +#if 1 + BaseType_t xHigherPriorityTaskWokenByPost = pdFALSE; + + xQueueSendFromISR(xQueueUart1, + &Data_40003592_uart1ReceiveDataBuffer[0], + &xHigherPriorityTaskWokenByPost); + + if (xHigherPriorityTaskWokenByPost) + { + //portYIELD_FROM_ISR(); + } +#else + int i; + for (i = 0; i < bData_40002c12_uart1ReceiveDataCount; i++) + { + char buf[20]; + snprintf(buf, sizeof(buf)-1, "Rx%d=0x%02x\n\r", i, + Data_40003592_uart1ReceiveDataBuffer[i]); + uart0_send(buf, strlen(buf)); + } +#endif + bData_40002c13_uart1ReceiveComplete = 1; + bData_40002c14_uart1ReceiveStep = 0; + bData_40002c12_uart1ReceiveDataCount = 0; + + if (!((bData_40002c1a == 1) && (bData_40002c1a == 2))) + { + //First Response from Mount + switch (Data_40003592_uart1ReceiveDataBuffer[0]) + { + case 0x04: + case 0x24: + //EQU + bData_40002c1a = 1; + break; + + case 0x44: + case 0x64: + //AZ + bData_40002c1a = 2; + break; + + default: + break; + } + } + } + } + break; + + default: + break; + } + } + + VICVectAddr = 0; +} + +/* 1c88 - complete */ +#ifdef __GNUC__ +void uart0_isr(void) __attribute__ ((interrupt ("IRQ"))); +void uart0_isr(void) +#else +void uart0_isr(void) __irq +#endif +{ + uart0_bRxData = U0RBR; + + if (uart0ReceiveFlag == 0) + { + switch (bData_40002c0c_uart0ReceiveStep) + { + case 0: + //Check first byte of header signature + if (Data_40002c0d_uart0ReceiveHeader[0] == uart0_bRxData) + { + bData_40002c0c_uart0ReceiveStep++; + } + break; + + case 1: + //Check second byte of header signature + if (Data_40002c0d_uart0ReceiveHeader[1] == uart0_bRxData) + { + bData_40002c0c_uart0ReceiveStep++; + } + else + { + bData_40002c0c_uart0ReceiveStep = 0; + } + break; + + case 2: + //Check third byte of header signature + if (Data_40002c0d_uart0ReceiveHeader[2] == uart0_bRxData) + { + bData_40002c0c_uart0ReceiveStep++; + } + else + { + bData_40002c0c_uart0ReceiveStep = 0; + } + break; + + case 3: + //Store payload length information + if (uart0_bRxData < 10) + { + Data_40002c0d_uart0ReceiveHeader[3] = uart0_bRxData; + bData_40002c0c_uart0ReceiveStep++; + } + else + { + bData_40002c0c_uart0ReceiveStep = 0; + } + break; + + case 4: + //Store payload data + if (Data_40002c0d_uart0ReceiveHeader[3] > bData_40002c0a_uart0ReceiveDataCount) + { + uart0ReceiveDataBuffer[bData_40002c0a_uart0ReceiveDataCount] = uart0_bRxData; + bData_40002c0a_uart0ReceiveDataCount++; + if (Data_40002c0d_uart0ReceiveHeader[3] == bData_40002c0a_uart0ReceiveDataCount) + { + uart0ReceiveFlag = 1; + bData_40002c0c_uart0ReceiveStep = 0; + bData_40002c0a_uart0ReceiveDataCount = 0; + + switch (uart0ReceiveDataBuffer[0]) + { + case 1: + Data_40002c1c = -1; + uart0ReceiveFlag = 0; + break; + + case 2: + Data_40002c1c = 1; + uart0ReceiveFlag = 0; + break; + + case 4: + Data_40002c20 = -1; + uart0ReceiveFlag = 0; + break; + + case 8: + Data_40002c20 = 1; + uart0ReceiveFlag = 0; + break; + + default: + break; + } + } + } + break; + + default: + break; + } + } + + VICVectAddr = 0; +} + +/* 1f30 - complete */ +void uart0_init(int a) +{ + U0LCR = 0x83; + +#ifdef OLIMEX_LPC2148 + // 12000000 * 2/2 / (16 * 78) = 9615.38 => 9600 + U0DLM = 0; + U0DLL = 78; +#else + // 11059200 * 2/2 / (16 * 72) = 9600 + U0DLM = 0; + U0DLL = 72; +#endif + + U0LCR = 0x03; + U0FCR = 0x01; //U0IIR = 0x01;? + U0IER = 0x01; + #if 1 + VICVectAddr1 = (unsigned int) uart0_isr; //UART0 -> Slot 1 + #else + VICVectAddr2 = (unsigned int) uart0_isr; //UART0 -> Slot 2 + #endif + + bData_40002c0a_uart0ReceiveDataCount = 0; + uart0ReceiveFlag = 0; + bData_40002c0c_uart0ReceiveStep = 0; + Data_40002c0d_uart0ReceiveHeader[0] = 0x55; + Data_40002c0d_uart0ReceiveHeader[1] = 0xaa; + Data_40002c0d_uart0ReceiveHeader[2] = 0x01; + Data_40002c0d_uart0ReceiveHeader[3] = 0x00; //payload length information +} + +/* 1fb0 - complete */ +unsigned char uart0_read_byte(void) +{ + unsigned char b; + while (!(U0LSR & 0x01)) {} + b = U0RBR; + return b; +} + +/* 2054 - complete */ +void uart0_receive(unsigned char* a, int b) +{ + while (b) + { + *a++ = uart0_read_byte(); + b--; + } +} + +/* 2080 - complete */ +void uart0_write_byte(unsigned char a) +{ + U0THR = a; + while (!(U0LSR & 0x40)) {} +} + +/* 20a0 - complete */ +void uart0_send(unsigned char* a, unsigned char b) +{ + while (b--) + { + uart0_write_byte(*a++); + } +} + +/* 20d0 - complete */ +void uart0_send_packets(unsigned char* a) +{ + unsigned char i; + + while (1) + { + if (*a == 0) break; + + for (i = 0; i < 44; i++) + { + uart0_write_byte(*a++); + } + } +} + +/* 211c - complete */ +void uart1_init(int a) +{ + U1LCR = 0x83; + +#ifdef OLIMEX_LPC2148 + // 12000000 * 2/2 / (16 * 78) = 9615.38 => 9600 + U1DLM = 0; + U1DLL = 78; +#else + // 11059200 * 2/2 / (16 * 72) = 9600 + U1DLM = 0; + U1DLL = 72; +#endif + + U1LCR = 0x03; + U1FCR = 0x01; // + U1IER = 0x01; + #if 1 + VICVectAddr2 = (unsigned int) uart1_isr; //UART1 -> Slot 2 + #else + VICVectAddr3 = (unsigned int) uart1_isr; //UART1 -> Slot 3 + #endif + + bData_40002c12_uart1ReceiveDataCount = 0; + bData_40002c13_uart1ReceiveComplete = 0; + bData_40002c14_uart1ReceiveStep = 0; + bData_40002c15_uart1ReceiveHeader[0] = 0x55; + bData_40002c15_uart1ReceiveHeader[1] = 0xaa; + bData_40002c15_uart1ReceiveHeader[2] = 0x01; + bData_40002c15_uart1ReceiveHeader[3] = 0x00; + + xQueueUart1 = xQueueCreate(2, 10); +} + +/* 219c - complete */ +unsigned char uart1_read_byte(void) +{ + unsigned char b; + while (!(U1LSR & 0x01)) {} + b = U1RBR; + return b; +} + +/* 21bc - complete */ +void uart1_receive(unsigned char* a, int b) +{ + while (b) + { + *a++ = uart1_read_byte(); + b--; + } +} + +/* 21e8 - complete */ +void uart1_write_byte(unsigned char a) +{ + U1THR = a; + while (!(U1LSR & 0x40)) {} +#if 1 + { + char buf[20]; + snprintf(buf, sizeof(buf)-1, "Tx=0x%02x\n\r", a); + uart0_send(buf, strlen(buf)); + } +#endif +} + +#ifdef OLIMEX_LPC2148 +void uart1_send(unsigned char* a, unsigned char b) +{ + while (b--) + { + uart1_write_byte(*a++); + } +} +#endif + +/* 2208 - complete */ +void uart1_send_packets(unsigned char* a) +{ + unsigned char i; + + while (1) + { + if (*a == 0) break; + + for (i = 0; i < 44; i++) + { + uart1_write_byte(*a++); + } + } +} + diff --git a/applications/freertos_app/uranus.c b/applications/freertos_app/uranus.c new file mode 100644 index 0000000..6cb466b --- /dev/null +++ b/applications/freertos_app/uranus.c @@ -0,0 +1,98 @@ + +/* 17630 - todo */ +double uranus_ecliptic_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double res = 0.0; + + L0 += 548129294 * cos(0.0 + a * 0.0); + L0 += 9260408 * cos(0.8910642 + a * 74.7815986); + L0 += 1504248 * cos(3.6271926 + a * 1.4844727); + L0 += 365982 * cos(1.899622 + a * 73.297126); + L0 += 272328 * cos(3.358237 + a * 149.563197); + L0 += 70328 * cos(5.39254 + a * 63.73590); + L0 += 68893 * cos(6.09292 + a * 76.26607); + L0 += 61999 * cos(2.26952 + a * 2.96895); + L0 += 61951 * cos(2.85099 + a * 11.04570); + L0 += 26469 * cos(3.14152 + a * 71.81265 ); + L0 += 25711 * cos(6.11380 + a * 454.90937 ); + + L1 += 7502543122 * cos(0.0 + a * 0.0); + L1 += 154458 * cos(5.242017 + a * 74.7815986); //74.781599); //BUG? + L1 += 24456 * cos(1.71256 + a * 1.4844727); //1.48447); //BUG? + L1 += 9258 * cos(0.4284 + a * 73.297126); //11.0457); //BUG? + L1 += 8266 * cos(1.5022 + a * 149.563197); //63.7359); //BUG? + L1 += 7842 * cos(1.3198 + a * 63.7359); //149.5632); //BUG? + + L2 += 53033 * cos(0.0 + a * 0.0); + L2 += 2358 * cos(2.2601 + a * 74.7816); + + res = (L0 + L1 * a + L2 * a*a + L3 * a*a*a + L4 * a*a*a*a) / 100000000.0; + + return res; +} + +/* 18160 - todo */ +double uranus_ecliptic_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double B2 = 0.0; + double B3 = 0.0; + double B4 = 0.0; + double res = 0.0; + + B0 += 1346278 * cos(2.6187781 + a * 74.7815986); + B0 += 62341 * cos(5.08111 + a * 149.56320); + B0 += 61601 * cos(3.14159 + a * 0.0); + B0 += 9964 * cos(1.6160 + a * 76.2661); + B0 += 9926 * cos(0.5763 + a * 73.2971); + + B1 += 206366 * cos(4.123943 + a * 74.781599); + B1 += 8563 * cos(0.3382 + a * 149.5632); + + B2 += 9212 * cos(5.8004 + a * 74.7816); + + res = (B0 + B1 * a + B2 * a*a + B3 * a*a*a + B4 * a*a*a*a) / 100000000.0; + + return res; +} + +/* 18748 - todo */ +double uranus_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double R4 = 0.0; + double res = 0.0; + + R0 += 1921264848 * cos(0 + a * 0); + R0 += 88784984 * cos(5.60377527 + a * 74.78159857); + R0 += 3440836 * cos(0.3283610 + a * 73.2971259); + R0 += 2055653 * cos(1.7829517 + a * 149.5631971); + R0 += 649322 * cos(4.522473 + a * 76.266071); + R0 += 602248 * cos(3.860038 + a * 63.735898); + R0 += 496404 * cos(1.401399 + a * 454.909367); + R0 += 338526 * cos(1.580027 + a * 138.517497); + + R1 += 1479896 * cos(3.6720571 + a * 74.7815986); + R1 += 71212 * cos(6.22601 + a * 63.73590); + R1 += 68627 * cos(6.13411 + a * 149.56320); + R1 += 24060 * cos(3.14159 + a * 0); + R1 += 21468 * cos(2.60177 + a * 76.26607); + R1 += 20857 * cos(5.24625 + a * 11.04570); + + R2 += 22440 * cos(0.69953 + a * 74.78160); + R2 += 4727 * cos(1.6990 + a * 63.7359); + + res = (R0 + R1 * a + R2 * a*a + R3 * a*a*a + R4 * a*a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/freertos_app/venus.c b/applications/freertos_app/venus.c new file mode 100644 index 0000000..63d14f6 --- /dev/null +++ b/applications/freertos_app/venus.c @@ -0,0 +1,81 @@ + +/* 10b2c - todo */ +double venus_ecliptic_longitude(double a) +{ + double L0 = 0.0; + double L1 = 0.0; + double L2 = 0.0; + double L3 = 0.0; + double L4 = 0.0; + double L5 = 0.0; + double res = 0.0; + + L0 += 317614667 * cos(0.0 + a * 0.0); + L0 += 1353968 * cos(5.5931332 + a * 10213.2855462); + L0 += 89892 * cos(5.30650 + a * 20426.57109); + L0 += 5477 * cos(4.4163 + a * 7860.4194); + + L1 += 1021352943053 * cos(0.0 + a * 0.0); + L1 += 95708 * cos(2.46424 + a * 10213.28555); + L1 += 14445 * cos(0.51625 + a * 20426.57109); + + L2 += 54127 * cos(0.0 + a * 0.0); + L2 += 3891 * cos(0.3451 + a * 10213.2855); + L2 += 1338 * cos(2.0201 + a * 20426.5711); + + res = (L0 + + L1 * a + + L2 * a*a + + L3 * a*a*a + + L4 * a*a*a*a + + L5 * a*a*a*a*a) / 100000000.0; + + return res; +} + +/* 1127c - todo */ +double venus_ecliptic_latitude(double a) +{ + double B0 = 0.0; + double B1 = 0.0; + double B2 = 0.0; + double B3 = 0.0; + double B4 = 0.0; + double res = 0.0; + + B0 += 5923638 * cos(0.2670278 + a * 10213.2855462); + B0 += 40108 * cos(1.14737 + a * 20426.57109); + B0 += 32815 * cos(3.14159 + a * 0.0); + + B1 += 513348 * cos(1.803643 + a * 10213.285546); + B1 += 4380 * cos(3.3862 + a * 20426.5711); + + B2 += 22378 * cos(3.38509 + a * 10213.28555); + + res = (B0 + B1 * a + B2 * a*a + B3 * a*a*a + B4 * a*a*a*a) / 100000000.0; + + return res; +} + +/* 1173c - todo */ +double venus_radius_vector(double a) +{ + double R0 = 0.0; + double R1 = 0.0; + double R2 = 0.0; + double R3 = 0.0; + double R4 = 0.0; + double res = 0.0; + + R0 += 72334821 * cos(0.0 + a * 0.0); + R0 += 489824 * cos(4.021518 + a * 10213.285546); + + R1 += 34551 * cos(0.89199 + a * 10213.28555); + + R2 += 1407 * cos(5.0637 + a * 10213.2855); + + res = (R0 + R1 * a + R2 * a*a + R3 * a*a*a + R4 * a*a*a*a) / 100000000.0; + + return res; +} + diff --git a/applications/v2.3/Makefile b/applications/v2.3/Makefile index b9f56eb..13925ae 100644 --- a/applications/v2.3/Makefile +++ b/applications/v2.3/Makefile @@ -40,7 +40,7 @@ SOURCES += Startup.s # define library used ################################################################################ -LIBRARIES = adi image +#LIBRARIES = adi image ################################################################################ # define target name diff --git a/env/FreeRTOSConfig.h b/env/FreeRTOSConfig.h new file mode 100644 index 0000000..c831cb8 --- /dev/null +++ b/env/FreeRTOSConfig.h @@ -0,0 +1,77 @@ +/* + * FreeRTOS V202011.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +#include + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( ( unsigned long ) 44236800/4 ) /* =12.0MHz xtal multiplied by 5 using the PLL. */ +#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) +#define configMAX_PRIORITIES ( 4 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 90 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) 10 * 1024 ) +#define configMAX_TASK_NAME_LEN ( 8 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 + +#define configQUEUE_REGISTRY_SIZE 0 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 + + + +#endif /* FREERTOS_CONFIG_H */ diff --git a/env/LPC214x.h b/env/LPC214x.h new file mode 100644 index 0000000..497ef3b --- /dev/null +++ b/env/LPC214x.h @@ -0,0 +1,364 @@ +/***********************************************************************/ +/* This file is part of the uVision/ARM development tools */ +/* Copyright KEIL ELEKTRONIK GmbH 2002-2005 */ +/***********************************************************************/ +/* */ +/* LPC214X.H: Header file for Philips LPC2141/42/44/46/48 */ +/* */ +/***********************************************************************/ + +#ifndef __LPC214x_H +#define __LPC214x_H + +/* Vectored Interrupt Controller (VIC) */ +#define VICIRQStatus (*((volatile unsigned long *) 0xFFFFF000)) +#define VICFIQStatus (*((volatile unsigned long *) 0xFFFFF004)) +#define VICRawIntr (*((volatile unsigned long *) 0xFFFFF008)) +#define VICIntSelect (*((volatile unsigned long *) 0xFFFFF00C)) +#define VICIntEnable (*((volatile unsigned long *) 0xFFFFF010)) +#define VICIntEnClr (*((volatile unsigned long *) 0xFFFFF014)) +#define VICSoftInt (*((volatile unsigned long *) 0xFFFFF018)) +#define VICSoftIntClr (*((volatile unsigned long *) 0xFFFFF01C)) +#define VICProtection (*((volatile unsigned long *) 0xFFFFF020)) +#define VICVectAddr (*((volatile unsigned long *) 0xFFFFF030)) +#define VICDefVectAddr (*((volatile unsigned long *) 0xFFFFF034)) +#define VICVectAddr0 (*((volatile unsigned long *) 0xFFFFF100)) +#define VICVectAddr1 (*((volatile unsigned long *) 0xFFFFF104)) +#define VICVectAddr2 (*((volatile unsigned long *) 0xFFFFF108)) +#define VICVectAddr3 (*((volatile unsigned long *) 0xFFFFF10C)) +#define VICVectAddr4 (*((volatile unsigned long *) 0xFFFFF110)) +#define VICVectAddr5 (*((volatile unsigned long *) 0xFFFFF114)) +#define VICVectAddr6 (*((volatile unsigned long *) 0xFFFFF118)) +#define VICVectAddr7 (*((volatile unsigned long *) 0xFFFFF11C)) +#define VICVectAddr8 (*((volatile unsigned long *) 0xFFFFF120)) +#define VICVectAddr9 (*((volatile unsigned long *) 0xFFFFF124)) +#define VICVectAddr10 (*((volatile unsigned long *) 0xFFFFF128)) +#define VICVectAddr11 (*((volatile unsigned long *) 0xFFFFF12C)) +#define VICVectAddr12 (*((volatile unsigned long *) 0xFFFFF130)) +#define VICVectAddr13 (*((volatile unsigned long *) 0xFFFFF134)) +#define VICVectAddr14 (*((volatile unsigned long *) 0xFFFFF138)) +#define VICVectAddr15 (*((volatile unsigned long *) 0xFFFFF13C)) +#define VICVectCntl0 (*((volatile unsigned long *) 0xFFFFF200)) +#define VICVectCntl1 (*((volatile unsigned long *) 0xFFFFF204)) +#define VICVectCntl2 (*((volatile unsigned long *) 0xFFFFF208)) +#define VICVectCntl3 (*((volatile unsigned long *) 0xFFFFF20C)) +#define VICVectCntl4 (*((volatile unsigned long *) 0xFFFFF210)) +#define VICVectCntl5 (*((volatile unsigned long *) 0xFFFFF214)) +#define VICVectCntl6 (*((volatile unsigned long *) 0xFFFFF218)) +#define VICVectCntl7 (*((volatile unsigned long *) 0xFFFFF21C)) +#define VICVectCntl8 (*((volatile unsigned long *) 0xFFFFF220)) +#define VICVectCntl9 (*((volatile unsigned long *) 0xFFFFF224)) +#define VICVectCntl10 (*((volatile unsigned long *) 0xFFFFF228)) +#define VICVectCntl11 (*((volatile unsigned long *) 0xFFFFF22C)) +#define VICVectCntl12 (*((volatile unsigned long *) 0xFFFFF230)) +#define VICVectCntl13 (*((volatile unsigned long *) 0xFFFFF234)) +#define VICVectCntl14 (*((volatile unsigned long *) 0xFFFFF238)) +#define VICVectCntl15 (*((volatile unsigned long *) 0xFFFFF23C)) + +/* Pin Connect Block */ +#define PINSEL0 (*((volatile unsigned long *) 0xE002C000)) +#define PINSEL1 (*((volatile unsigned long *) 0xE002C004)) +#define PINSEL2 (*((volatile unsigned long *) 0xE002C014)) + +/* General Purpose Input/Output (GPIO) */ +#define IOPIN0 (*((volatile unsigned long *) 0xE0028000)) +#define IOSET0 (*((volatile unsigned long *) 0xE0028004)) +#define IODIR0 (*((volatile unsigned long *) 0xE0028008)) +#define IOCLR0 (*((volatile unsigned long *) 0xE002800C)) +#define IOPIN1 (*((volatile unsigned long *) 0xE0028010)) +#define IOSET1 (*((volatile unsigned long *) 0xE0028014)) +#define IODIR1 (*((volatile unsigned long *) 0xE0028018)) +#define IOCLR1 (*((volatile unsigned long *) 0xE002801C)) +#define IO0PIN (*((volatile unsigned long *) 0xE0028000)) +#define IO0SET (*((volatile unsigned long *) 0xE0028004)) +#define IO0DIR (*((volatile unsigned long *) 0xE0028008)) +#define IO0CLR (*((volatile unsigned long *) 0xE002800C)) +#define IO1PIN (*((volatile unsigned long *) 0xE0028010)) +#define IO1SET (*((volatile unsigned long *) 0xE0028014)) +#define IO1DIR (*((volatile unsigned long *) 0xE0028018)) +#define IO1CLR (*((volatile unsigned long *) 0xE002801C)) +#define FIO0DIR (*((volatile unsigned long *) 0x3FFFC000)) +#define FIO0MASK (*((volatile unsigned long *) 0x3FFFC010)) +#define FIO0PIN (*((volatile unsigned long *) 0x3FFFC014)) +#define FIO0SET (*((volatile unsigned long *) 0x3FFFC018)) +#define FIO0CLR (*((volatile unsigned long *) 0x3FFFC01C)) +#define FIO1DIR (*((volatile unsigned long *) 0x3FFFC020)) +#define FIO1MASK (*((volatile unsigned long *) 0x3FFFC030)) +#define FIO1PIN (*((volatile unsigned long *) 0x3FFFC034)) +#define FIO1SET (*((volatile unsigned long *) 0x3FFFC038)) +#define FIO1CLR (*((volatile unsigned long *) 0x3FFFC03C)) + +/* Memory Accelerator Module (MAM) */ +#define MAMCR (*((volatile unsigned char *) 0xE01FC000)) +#define MAMTIM (*((volatile unsigned char *) 0xE01FC004)) +#define MEMMAP (*((volatile unsigned char *) 0xE01FC040)) + +/* Phase Locked Loop 0 (PLL0) */ +#define PLL0CON (*((volatile unsigned char *) 0xE01FC080)) +#define PLL0CFG (*((volatile unsigned char *) 0xE01FC084)) +#define PLL0STAT (*((volatile unsigned short*) 0xE01FC088)) +#define PLL0FEED (*((volatile unsigned char *) 0xE01FC08C)) + +/* Phase Locked Loop 1 (PLL1) */ +#define PLL1CON (*((volatile unsigned char *) 0xE01FC0A0)) +#define PLL1CFG (*((volatile unsigned char *) 0xE01FC0A4)) +#define PLL1STAT (*((volatile unsigned short*) 0xE01FC0A8)) +#define PLL1FEED (*((volatile unsigned char *) 0xE01FC0AC)) + +/* VPB Divider */ +#define VPBDIV (*((volatile unsigned char *) 0xE01FC100)) + +/* Power Control */ +#define PCON (*((volatile unsigned char *) 0xE01FC0C0)) +#define PCONP (*((volatile unsigned long *) 0xE01FC0C4)) + +/* External Interrupts */ +#define EXTINT (*((volatile unsigned char *) 0xE01FC140)) +#define INTWAKE (*((volatile unsigned short*) 0xE01FC144)) +#define EXTMODE (*((volatile unsigned char *) 0xE01FC148)) +#define EXTPOLAR (*((volatile unsigned char *) 0xE01FC14C)) + +/* Reset */ +#define RSID (*((volatile unsigned char *) 0xE01FC180)) + +/* Code Security / Debugging */ +#define CSPR (*((volatile unsigned char *) 0xE01FC184)) + +/* System Control Miscellaneous */ +#define SCS (*((volatile unsigned long *) 0xE01FC1A0)) + +/* Timer 0 */ +#define T0IR (*((volatile unsigned long *) 0xE0004000)) +#define T0TCR (*((volatile unsigned long *) 0xE0004004)) +#define T0TC (*((volatile unsigned long *) 0xE0004008)) +#define T0PR (*((volatile unsigned long *) 0xE000400C)) +#define T0PC (*((volatile unsigned long *) 0xE0004010)) +#define T0MCR (*((volatile unsigned long *) 0xE0004014)) +#define T0MR0 (*((volatile unsigned long *) 0xE0004018)) +#define T0MR1 (*((volatile unsigned long *) 0xE000401C)) +#define T0MR2 (*((volatile unsigned long *) 0xE0004020)) +#define T0MR3 (*((volatile unsigned long *) 0xE0004024)) +#define T0CCR (*((volatile unsigned long *) 0xE0004028)) +#define T0CR0 (*((volatile unsigned long *) 0xE000402C)) +#define T0CR1 (*((volatile unsigned long *) 0xE0004030)) +#define T0CR2 (*((volatile unsigned long *) 0xE0004034)) +#define T0CR3 (*((volatile unsigned long *) 0xE0004038)) +#define T0EMR (*((volatile unsigned long *) 0xE000403C)) +#define T0CTCR (*((volatile unsigned long *) 0xE0004070)) + +/* Timer 1 */ +#define T1IR (*((volatile unsigned long *) 0xE0008000)) +#define T1TCR (*((volatile unsigned long *) 0xE0008004)) +#define T1TC (*((volatile unsigned long *) 0xE0008008)) +#define T1PR (*((volatile unsigned long *) 0xE000800C)) +#define T1PC (*((volatile unsigned long *) 0xE0008010)) +#define T1MCR (*((volatile unsigned long *) 0xE0008014)) +#define T1MR0 (*((volatile unsigned long *) 0xE0008018)) +#define T1MR1 (*((volatile unsigned long *) 0xE000801C)) +#define T1MR2 (*((volatile unsigned long *) 0xE0008020)) +#define T1MR3 (*((volatile unsigned long *) 0xE0008024)) +#define T1CCR (*((volatile unsigned long *) 0xE0008028)) +#define T1CR0 (*((volatile unsigned long *) 0xE000802C)) +#define T1CR1 (*((volatile unsigned long *) 0xE0008030)) +#define T1CR2 (*((volatile unsigned long *) 0xE0008034)) +#define T1CR3 (*((volatile unsigned long *) 0xE0008038)) +#define T1EMR (*((volatile unsigned long *) 0xE000803C)) +#define T1CTCR (*((volatile unsigned long *) 0xE0008070)) + +/* Pulse Width Modulator (PWM) */ +#define PWMIR (*((volatile unsigned long *) 0xE0014000)) +#define PWMTCR (*((volatile unsigned long *) 0xE0014004)) +#define PWMTC (*((volatile unsigned long *) 0xE0014008)) +#define PWMPR (*((volatile unsigned long *) 0xE001400C)) +#define PWMPC (*((volatile unsigned long *) 0xE0014010)) +#define PWMMCR (*((volatile unsigned long *) 0xE0014014)) +#define PWMMR0 (*((volatile unsigned long *) 0xE0014018)) +#define PWMMR1 (*((volatile unsigned long *) 0xE001401C)) +#define PWMMR2 (*((volatile unsigned long *) 0xE0014020)) +#define PWMMR3 (*((volatile unsigned long *) 0xE0014024)) +#define PWMMR4 (*((volatile unsigned long *) 0xE0014040)) +#define PWMMR5 (*((volatile unsigned long *) 0xE0014044)) +#define PWMMR6 (*((volatile unsigned long *) 0xE0014048)) +#define PWMPCR (*((volatile unsigned long *) 0xE001404C)) +#define PWMLER (*((volatile unsigned long *) 0xE0014050)) + +/* Universal Asynchronous Receiver Transmitter 0 (UART0) */ +#define U0RBR (*((volatile unsigned char *) 0xE000C000)) +#define U0THR (*((volatile unsigned char *) 0xE000C000)) +#define U0IER (*((volatile unsigned long *) 0xE000C004)) +#define U0IIR (*((volatile unsigned long *) 0xE000C008)) +#define U0FCR (*((volatile unsigned char *) 0xE000C008)) +#define U0LCR (*((volatile unsigned char *) 0xE000C00C)) +#define U0MCR (*((volatile unsigned char *) 0xE000C010)) +#define U0LSR (*((volatile unsigned char *) 0xE000C014)) +#define U0MSR (*((volatile unsigned char *) 0xE000C018)) +#define U0SCR (*((volatile unsigned char *) 0xE000C01C)) +#define U0DLL (*((volatile unsigned char *) 0xE000C000)) +#define U0DLM (*((volatile unsigned char *) 0xE000C004)) +#define U0ACR (*((volatile unsigned long *) 0xE000C020)) +#define U0FDR (*((volatile unsigned long *) 0xE000C028)) +#define U0TER (*((volatile unsigned char *) 0xE000C030)) + +/* Universal Asynchronous Receiver Transmitter 1 (UART1) */ +#define U1RBR (*((volatile unsigned char *) 0xE0010000)) +#define U1THR (*((volatile unsigned char *) 0xE0010000)) +#define U1IER (*((volatile unsigned long *) 0xE0010004)) +#define U1IIR (*((volatile unsigned long *) 0xE0010008)) +#define U1FCR (*((volatile unsigned char *) 0xE0010008)) +#define U1LCR (*((volatile unsigned char *) 0xE001000C)) +#define U1MCR (*((volatile unsigned char *) 0xE0010010)) +#define U1LSR (*((volatile unsigned char *) 0xE0010014)) +#define U1MSR (*((volatile unsigned char *) 0xE0010018)) +#define U1SCR (*((volatile unsigned char *) 0xE001001C)) +#define U1DLL (*((volatile unsigned char *) 0xE0010000)) +#define U1DLM (*((volatile unsigned char *) 0xE0010004)) +#define U1ACR (*((volatile unsigned long *) 0xE0010020)) +#define U1FDR (*((volatile unsigned long *) 0xE0010028)) +#define U1TER (*((volatile unsigned char *) 0xE0010030)) + +/* I2C Interface 0 */ +#define I2C0CONSET (*((volatile unsigned char *) 0xE001C000)) +#define I2C0STAT (*((volatile unsigned char *) 0xE001C004)) +#define I2C0DAT (*((volatile unsigned char *) 0xE001C008)) +#define I2C0ADR (*((volatile unsigned char *) 0xE001C00C)) +#define I2C0SCLH (*((volatile unsigned short*) 0xE001C010)) +#define I2C0SCLL (*((volatile unsigned short*) 0xE001C014)) +#define I2C0CONCLR (*((volatile unsigned char *) 0xE001C018)) + +/* I2C Interface 1 */ +#define I2C1CONSET (*((volatile unsigned char *) 0xE005C000)) +#define I2C1STAT (*((volatile unsigned char *) 0xE005C004)) +#define I2C1DAT (*((volatile unsigned char *) 0xE005C008)) +#define I2C1ADR (*((volatile unsigned char *) 0xE005C00C)) +#define I2C1SCLH (*((volatile unsigned short*) 0xE005C010)) +#define I2C1SCLL (*((volatile unsigned short*) 0xE005C014)) +#define I2C1CONCLR (*((volatile unsigned char *) 0xE005C018)) + +/* SPI0 (Serial Peripheral Interface 0) */ +#define S0SPCR (*((volatile unsigned short*) 0xE0020000)) +#define S0SPSR (*((volatile unsigned char *) 0xE0020004)) +#define S0SPDR (*((volatile unsigned short*) 0xE0020008)) +#define S0SPCCR (*((volatile unsigned char *) 0xE002000C)) +#define S0SPINT (*((volatile unsigned char *) 0xE002001C)) + +/* SSP Controller (SPI1) */ +#define SSPCR0 (*((volatile unsigned short*) 0xE0068000)) +#define SSPCR1 (*((volatile unsigned char *) 0xE0068004)) +#define SSPDR (*((volatile unsigned short*) 0xE0068008)) +#define SSPSR (*((volatile unsigned char *) 0xE006800C)) +#define SSPCPSR (*((volatile unsigned char *) 0xE0068010)) +#define SSPIMSC (*((volatile unsigned char *) 0xE0068014)) +#define SSPRIS (*((volatile unsigned char *) 0xE0068018)) +#define SSPMIS (*((volatile unsigned char *) 0xE006801C)) +#define SSPICR (*((volatile unsigned char *) 0xE0068020)) + +/* Real Time Clock */ +#define ILR (*((volatile unsigned char *) 0xE0024000)) +#define CTC (*((volatile unsigned short*) 0xE0024004)) +#define CCR (*((volatile unsigned char *) 0xE0024008)) +#define CIIR (*((volatile unsigned char *) 0xE002400C)) +#define AMR (*((volatile unsigned char *) 0xE0024010)) +#define CTIME0 (*((volatile unsigned long *) 0xE0024014)) +#define CTIME1 (*((volatile unsigned long *) 0xE0024018)) +#define CTIME2 (*((volatile unsigned long *) 0xE002401C)) +#define SEC (*((volatile unsigned char *) 0xE0024020)) +#define MIN (*((volatile unsigned char *) 0xE0024024)) +#define HOUR (*((volatile unsigned char *) 0xE0024028)) +#define DOM (*((volatile unsigned char *) 0xE002402C)) +#define DOW (*((volatile unsigned char *) 0xE0024030)) +#define DOY (*((volatile unsigned short*) 0xE0024034)) +#define MONTH (*((volatile unsigned char *) 0xE0024038)) +#define YEAR (*((volatile unsigned short*) 0xE002403C)) +#define ALSEC (*((volatile unsigned char *) 0xE0024060)) +#define ALMIN (*((volatile unsigned char *) 0xE0024064)) +#define ALHOUR (*((volatile unsigned char *) 0xE0024068)) +#define ALDOM (*((volatile unsigned char *) 0xE002406C)) +#define ALDOW (*((volatile unsigned char *) 0xE0024070)) +#define ALDOY (*((volatile unsigned short*) 0xE0024074)) +#define ALMON (*((volatile unsigned char *) 0xE0024078)) +#define ALYEAR (*((volatile unsigned short*) 0xE002407C)) +#define PREINT (*((volatile unsigned short*) 0xE0024080)) +#define PREFRAC (*((volatile unsigned short*) 0xE0024084)) + +/* A/D Converter 0 (AD0) */ +#define AD0CR (*((volatile unsigned long *) 0xE0034000)) +#define AD0GDR (*((volatile unsigned long *) 0xE0034004)) +#define AD0STAT (*((volatile unsigned long *) 0xE0034030)) +#define AD0INTEN (*((volatile unsigned long *) 0xE003400C)) +#define AD0DR0 (*((volatile unsigned long *) 0xE0034010)) +#define AD0DR1 (*((volatile unsigned long *) 0xE0034014)) +#define AD0DR2 (*((volatile unsigned long *) 0xE0034018)) +#define AD0DR3 (*((volatile unsigned long *) 0xE003401C)) +#define AD0DR4 (*((volatile unsigned long *) 0xE0034020)) +#define AD0DR5 (*((volatile unsigned long *) 0xE0034024)) +#define AD0DR6 (*((volatile unsigned long *) 0xE0034028)) +#define AD0DR7 (*((volatile unsigned long *) 0xE003402C)) + +/* A/D Converter 1 (AD1) */ +#define AD1CR (*((volatile unsigned long *) 0xE0060000)) +#define AD1GDR (*((volatile unsigned long *) 0xE0060004)) +#define AD1STAT (*((volatile unsigned long *) 0xE0060030)) +#define AD1INTEN (*((volatile unsigned long *) 0xE006000C)) +#define AD1DR0 (*((volatile unsigned long *) 0xE0060010)) +#define AD1DR1 (*((volatile unsigned long *) 0xE0060014)) +#define AD1DR2 (*((volatile unsigned long *) 0xE0060018)) +#define AD1DR3 (*((volatile unsigned long *) 0xE006001C)) +#define AD1DR4 (*((volatile unsigned long *) 0xE0060020)) +#define AD1DR5 (*((volatile unsigned long *) 0xE0060024)) +#define AD1DR6 (*((volatile unsigned long *) 0xE0060028)) +#define AD1DR7 (*((volatile unsigned long *) 0xE006002C)) + +/* A/D Converter Global */ +#define ADGSR (*((volatile unsigned long *) 0xE0034008)) + +/* D/A Converter */ +#define DACR (*((volatile unsigned long *) 0xE006C000)) + +/* Watchdog */ +#define WDMOD (*((volatile unsigned char *) 0xE0000000)) +#define WDTC (*((volatile unsigned long *) 0xE0000004)) +#define WDFEED (*((volatile unsigned char *) 0xE0000008)) +#define WDTV (*((volatile unsigned long *) 0xE000000C)) + +/* USB Controller */ +#define USBIntSt (*((volatile unsigned long *) 0xE01FC1C0)) +#define USBDevIntSt (*((volatile unsigned long *) 0xE0090000)) +#define USBDevIntEn (*((volatile unsigned long *) 0xE0090004)) +#define USBDevIntClr (*((volatile unsigned long *) 0xE0090008)) +#define USBDevIntSet (*((volatile unsigned long *) 0xE009000C)) +#define USBDevIntPri (*((volatile unsigned char *) 0xE009002C)) +#define USBEpIntSt (*((volatile unsigned long *) 0xE0090030)) +#define USBEpIntEn (*((volatile unsigned long *) 0xE0090034)) +#define USBEpIntClr (*((volatile unsigned long *) 0xE0090038)) +#define USBEpIntSet (*((volatile unsigned long *) 0xE009003C)) +#define USBEpIntPri (*((volatile unsigned long *) 0xE0090040)) +#define USBReEp (*((volatile unsigned long *) 0xE0090044)) +#define USBEpInd (*((volatile unsigned long *) 0xE0090048)) +#define USBMaxPSize (*((volatile unsigned long *) 0xE009004C)) +#define USBRxData (*((volatile unsigned long *) 0xE0090018)) +#define USBRxPLen (*((volatile unsigned long *) 0xE0090020)) +#define USBTxData (*((volatile unsigned long *) 0xE009001C)) +#define USBTxPLen (*((volatile unsigned long *) 0xE0090024)) +#define USBCtrl (*((volatile unsigned long *) 0xE0090028)) +#define USBCmdCode (*((volatile unsigned long *) 0xE0090010)) +#define USBCmdData (*((volatile unsigned long *) 0xE0090014)) +#define USBDMARSt (*((volatile unsigned long *) 0xE0090050)) +#define USBDMARClr (*((volatile unsigned long *) 0xE0090054)) +#define USBDMARSet (*((volatile unsigned long *) 0xE0090058)) +#define USBUDCAH (*((volatile unsigned long *) 0xE0090080)) +#define USBEpDMASt (*((volatile unsigned long *) 0xE0090084)) +#define USBEpDMAEn (*((volatile unsigned long *) 0xE0090088)) +#define USBEpDMADis (*((volatile unsigned long *) 0xE009008C)) +#define USBDMAIntSt (*((volatile unsigned long *) 0xE0090090)) +#define USBDMAIntEn (*((volatile unsigned long *) 0xE0090094)) +#define USBEoTIntSt (*((volatile unsigned long *) 0xE00900A0)) +#define USBEoTIntClr (*((volatile unsigned long *) 0xE00900A4)) +#define USBEoTIntSet (*((volatile unsigned long *) 0xE00900A8)) +#define USBNDDRIntSt (*((volatile unsigned long *) 0xE00900AC)) +#define USBNDDRIntClr (*((volatile unsigned long *) 0xE00900B0)) +#define USBNDDRIntSet (*((volatile unsigned long *) 0xE00900B4)) +#define USBSysErrIntSt (*((volatile unsigned long *) 0xE00900B8)) +#define USBSysErrIntClr (*((volatile unsigned long *) 0xE00900BC)) +#define USBSysErrIntSet (*((volatile unsigned long *) 0xE00900C0)) + +#endif // __LPC214x_H diff --git a/env/Makefile b/env/Makefile index be343e0..be23b1a 100644 --- a/env/Makefile +++ b/env/Makefile @@ -16,6 +16,9 @@ include $(TOPDIR)/env/make/Makefile.config + HEADERS += LPC214x.h + HEADERS += FreeRTOSConfig.h + ################################################################################ # define user targets ################################################################################ @@ -28,7 +31,7 @@ build: install: -headers: +headers: install-headers all: diff --git a/env/make/Makefile.common b/env/make/Makefile.common index 0720f87..a654e86 100644 --- a/env/make/Makefile.common +++ b/env/make/Makefile.common @@ -111,6 +111,9 @@ OBJECTS += $(subst \,/,$(SOURCES_CPP:%.CPP=%$(OBJECT_EXT))) BUILD_OBJECTS = $(OBJECTS:%$(OBJECT_EXT)=$(BUILD_OBJECT_SUBDIR)/%$(OBJECT_EXT)) BUILD_DEBUG_OBJECTS = $(OBJECTS:%$(OBJECT_EXT)=$(BUILD_OBJECT_SUBDIR)/%$(OBJECT_DEBUG_EXT)) BUILD_PROFILE_OBJECTS = $(OBJECTS:%$(OBJECT_EXT)=$(BUILD_OBJECT_SUBDIR)/%$(OBJECT_PROFILE_EXT)) +BUILD_LIBRARY = $(BUILD_LIBRARY_SUBDIR)/$(LIBRARY)$(LIBRARY_EXT) +BUILD_LIBRARY_OBJECTS = $(BUILD_OBJECTS) +BUILD_PROGRAM_LIBRARIES = $(LIBRARIES:%=$(INSTALL_DIR)/$(INSTALL_OBJECT_SUBDIR)/lib%$(LIBRARY_EXT)) BUILD_PROGRAM = $(BUILD_PROGRAM_SUBDIR)/$(PROGRAM)$(PROGRAM_EXT) BUILD_PROGRAM_OBJECTS = $(BUILD_OBJECTS) @@ -124,6 +127,8 @@ BUILD_PROFILE_ELFDUMP_PROGRAM = $(BUILD_PROGRAM_SUBDIR)/$(PROGRAM)$(PROGRAM_PR BUILD_INTELHEX_PROGRAM = $(BUILD_PROGRAM_SUBDIR)/$(PROGRAM)$(PROGRAM_INTELHEX_EXT) BUILD_BINARY_PROGRAM = $(BUILD_PROGRAM_SUBDIR)/$(PROGRAM)$(PROGRAM_BINARY_EXT) +INSTALL_LIBRARY = $(INSTALL_DIR)/$(BUILD_LIBRARY:$(BUILD_LIBRARY_SUBDIR)/%=$(INSTALL_LIBRARY_SUBDIR)/%) INSTALL_PROGRAM = $(INSTALL_DIR)/$(BUILD_PROGRAM:$(BUILD_PROGRAM_SUBDIR)/%=$(INSTALL_PROGRAM_SUBDIR)/%) INSTALL_INTELHEX_PROGRAM = $(INSTALL_DIR)/$(BUILD_INTELHEX_PROGRAM:$(BUILD_PROGRAM_SUBDIR)/%=$(INSTALL_PROGRAM_SUBDIR)/%) +INSTALL_INCLUDE_DIRECTORIES = $(INSTALL_DIR)/include diff --git a/env/make/Makefile.rules b/env/make/Makefile.rules index 0241c37..bdd9204 100644 --- a/env/make/Makefile.rules +++ b/env/make/Makefile.rules @@ -19,6 +19,16 @@ clean-objects: force $(BUILD_DEBUG_OBJECTS) \ $(BUILD_PROFILE_OBJECTS) +clean-library: force + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Deleting library files + -$(ATSIGN)$(DELETE) $(DELETEFLAGS) \ + $(BUILD_LIBRARY) \ + $(BUILD_SHARED_LIBRARY) \ + $(BUILD_DEBUG_LIBRARY) \ + $(BUILD_PROFILE_LIBRARY) \ + $(BUILD_INFO) + clean-program: force @$(NEWLINE) @$(ECHO) $(ECHOPREFIX) Deleting program files @@ -134,7 +144,16 @@ $(BUILD_OBJECT_SUBDIR)/%$(OBJECT_PROFILE_EXT) : %.s @$(ECHO) $(ECHOPREFIX) "-->" [$@] $(ATSIGN)$(MKDIR) $(MKDIRFLAGS) $(dir $@) $(ATSIGN)$(CC) $(CCFLAGS) $(CCFLAGS_USER) $(CCFLAGS_AS) $(CCGPROF) -D__GPROF__=1 -D__DEBUG__=1 $(CC_out)$(DOLLAR@) -c $(word 1,$(DOLLAR^)) + +$(BUILD_LIBRARY) : $(BUILD_LIBRARY_OBJECTS) +# @$(SUBMAKE) $(BUILD_INFO) + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Archiving [$(DOLLAR@)] + $(ATSIGN)$(MKDIR) $(MKDIRFLAGS) $(dir $@) + $(ATSIGN)$(AR) $(ARFLAGS) $(ARFLAGS_USER) $(AR_out)$(DOLLAR@) $(BUILD_LIBRARY_OBJECTS) + + $(BUILD_PROGRAM) : $(BUILD_PROGRAM_OBJECTS) $(BUILD_PROGRAM_LIBRARIES) $(BUILD_PROGRAM_STARTUP_OBJECT) # @$(SUBMAKE) $(BUILD_INFO) @$(NEWLINE) @@ -158,7 +177,7 @@ $(BUILD_ELFDUMP_PROGRAM) : $(BUILD_PROGRAM) @$(NEWLINE) @$(ECHO) $(ECHOPREFIX) Creating ELF dump [$(DOLLAR@)] $(ATSIGN)$(MKDIR) $(MKDIRFLAGS) $(dir $@) - $(ATSIGN)$(ELFDUMP) $(ELFDUMPFLAGS) $(ELFDUMPFLAGS_USER) $(DOLLAR^) $(ELFDUMP_out)$(DOLLAR@) + -$(ATSIGN)$(ELFDUMP) $(ELFDUMPFLAGS) $(ELFDUMPFLAGS_USER) $(DOLLAR^) $(ELFDUMP_out)$(DOLLAR@) $(BUILD_DEBUG_ELFDUMP_PROGRAM) : $(BUILD_DEBUG_PROGRAM) @$(NEWLINE) @@ -203,7 +222,14 @@ else endif install-intelhex-program: $(INSTALL_INTELHEX_PROGRAM) +install-headers: $(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/.dummy +$(INSTALL_LIBRARY_DIR)/%: $(BUILD_LIBRARY_SUBDIR)/% force + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Installing library [$(word 1,$^)] + @$(ECHO) $(ECHOPREFIX) "-->" [$@] + $(ATSIGN)$(MKDIR) $(MKDIRFLAGS) $(dir $@) + $(ATSIGN)$(COPY) $(COPYFLAGS) $(word 1,$^) $@ $(INSTALL_PROGRAM_DIR)/%: $(BUILD_PROGRAM_SUBDIR)/% force @$(NEWLINE) @@ -215,7 +241,20 @@ $(INSTALL_PROGRAM_DIR)/%: $(BUILD_PROGRAM_SUBDIR)/% force # $(ATSIGN)$(MKDIR) $(MKDIRFLAGS) $(INSTALL_BIN_DIR) # $(ATSIGN)$(COPY) $(COPYFLAGS) $(word 1,$^) $(INSTALL_BIN_DIR) - +$(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/.dummy : $(HEADERS) + @$(NEWLINE) + @$(ECHO) $(ECHOPREFIX) Installing headers [$(HEADERS)] + @$(ECHO) $(ECHOPREFIX) "-->" [$(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/] + $(ATSIGN)$(MKDIR) $(MKDIRFLAGS) $(dir $@) + $(ATSIGN)$(COPY) $(COPYFLAGS) $(HEADERS) $(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR) +# @$(ECHO) $(ECHOPREFIX) Removing installed SVN folders +# @$(ECHO) $(ECHOPREFIX) "-->" [$(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/*/$(SVN_SUBDIR)] +# $(ATSIGN)$(DELETE) $(DELETEFLAGS) \ +# $(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/$(SVN_SUBDIR) \ +# $(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/*/$(SVN_SUBDIR) \ +# $(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/*/*/$(SVN_SUBDIR) \ +# $(INSTALL_DIR)/$(INSTALL_INCLUDE_SUBDIR)/*/*/*/$(SVN_SUBDIR) + .PHONY: force force: diff --git a/env/make/Makefile.target.arm7-realview b/env/make/Makefile.target.arm7-realview index c926858..7cf2e95 100644 --- a/env/make/Makefile.target.arm7-realview +++ b/env/make/Makefile.target.arm7-realview @@ -33,9 +33,13 @@ CCFLAGS += $(CPU_MODEL) CCFLAGS += --apcs=interwork CCFLAGS += --signed_chars CCFLAGS += -g -O0 +CCFLAGS += $(INSTALL_INCLUDE_DIRECTORIES:%=-I%) CCFLAGS += -I$(SDKHOME3) CC_out = -o$(SPACE) +AR = $(SDKHOME)/armar.exe +ARFLAGS = --create -r -c -s -v +AR_out = $(SPACE) LD = $(SDKHOME)/armlink.exe LDFLAGS += $(CPU_MODEL) @@ -54,7 +58,9 @@ ELFDUMP = $(SDKHOME-arm7-gcc)/bin/$(CCTARGET)-objdump$(TOOL_EXT) ELFDUMPFLAGS = --all -D ELFDUMP_out = >$(SPACE) + ELF2HEX = $(SDKHOME)/fromelf.exe ELF2HEXFLAGS_INTELHEX = --i32 ELF2HEXFLAGS_BIN = --bin +