repo_name
stringlengths 6
97
| path
stringlengths 3
341
| text
stringlengths 8
1.02M
|
---|---|---|
mstewartgallus/linted | src/locale/locale.c | /*
* Copyright 2013, 2014, 2015 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include "config.h"
#include "lntd/locale.h"
#include "lntd/error.h"
#include "lntd/io.h"
#include "lntd/ko.h"
#include "lntd/mem.h"
#include "lntd/str.h"
#include <stddef.h>
lntd_error lntd_locale_on_bad_option(lntd_ko ko,
char const *process_name,
char const *bad_option)
{
lntd_error err;
size_t size = 0U;
size_t capacity = 0U;
char *buffer = 0;
err = lntd_str_append_cstring(&buffer, &capacity, &size,
process_name);
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size, "\
: unrecognized option '");
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size,
bad_option);
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size, "'\n");
if (err != 0)
goto free_buffer;
err = lntd_io_write_all(ko, 0, buffer, size);
if (err != 0)
goto free_buffer;
free_buffer:
lntd_mem_free(buffer);
return err;
}
lntd_error lntd_locale_try_for_more_help(lntd_ko ko,
char const *process_name,
char const *help_option)
{
lntd_error err;
size_t size = 0U;
size_t capacity = 0U;
char *buffer = 0;
err =
lntd_str_append_cstring(&buffer, &capacity, &size, "Try `");
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size,
process_name);
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size, " ");
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size,
help_option);
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size, "\
' for more information.\n");
if (err != 0)
goto free_buffer;
err = lntd_io_write_all(ko, 0, buffer, size);
if (err != 0)
goto free_buffer;
free_buffer:
lntd_mem_free(buffer);
return err;
}
lntd_error lntd_locale_version(lntd_ko ko, char const *package_string,
char const *copyright_year)
{
lntd_error err;
size_t size = 0U;
size_t capacity = 0U;
char *buffer = 0;
err = lntd_str_append_cstring(&buffer, &capacity, &size,
package_string);
if (err != 0)
goto free_buffer;
err =
lntd_str_append_cstring(&buffer, &capacity, &size, "\n\n");
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size, "\
Copyright (C) ");
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size,
copyright_year);
if (err != 0)
goto free_buffer;
err = lntd_str_append_cstring(&buffer, &capacity, &size, "\
<NAME>\n\
License Apache License 2 <http://www.apache.org/licenses/LICENSE-2.0>\n\
This is free software, and you are welcome to redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n");
if (err != 0)
goto free_buffer;
err = lntd_io_write_all(ko, 0, buffer, size);
if (err != 0)
goto free_buffer;
free_buffer:
lntd_mem_free(buffer);
return err;
}
|
mstewartgallus/linted | src/nesc/async.h | /*
* Copyright 2015 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#ifndef LNTD_ASYNC_H
#define LNTD_ASYNC_H
#include "bool.h"
#include "lntd/error.h"
#include "lntd/ko.h"
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
enum { LNTD_ASYNC_CMD_TYPE_IDLE,
LNTD_ASYNC_CMD_TYPE_POLL,
LNTD_ASYNC_CMD_TYPE_TIMER,
LNTD_ASYNC_CMD_TYPE_WRITE,
LNTD_ASYNC_CMD_TYPE_READ };
typedef unsigned char lntd_async_cmd_type;
typedef uint_least8_t lntd_async_command_id;
typedef uint_least8_t lntd_async_poller_id;
typedef uint_least8_t lntd_task_id;
struct lntd_async_cmd_write {
char const *bytes;
size_t size;
size_t bytes_left;
lntd_ko ko;
lntd_async_poller_id poller;
};
struct lntd_async_cmd_read {
char *bytes;
size_t size;
size_t bytes_left;
lntd_ko ko;
lntd_async_poller_id poller;
};
struct lntd_async_cmd_poll {
uint_least64_t events;
uint_least64_t revents;
lntd_ko ko;
lntd_async_poller_id poller;
};
struct lntd_async_cmd_timer {
struct timespec request;
lntd_ko ko;
lntd_async_poller_id poller;
};
#define LNTD_ASYNC_COMMAND \
"LntdAsyncCommand-6d5734b0-1474-4a28-945e-8ca970fc2a58"
#define LNTD_ASYNC_POLLER \
"LntdAsyncPoller-6d5734b0-1474-4a28-945e-8ca970fc2a58"
enum { LNTD_ASYNC_POLLER_IN = 1, LNTD_ASYNC_POLLER_OUT = 1 << 1 };
#endif /* LNTD_ASYNC_H */
|
mstewartgallus/linted | src/log/log-windows.c | <filename>src/log/log-windows.c
/*
* Copyright 2015 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include "config.h"
#include "lntd/io.h"
#include "lntd/log.h"
#include <stdarg.h>
/**
* @file
*
* @bug Windows NT: provide Event Tracing events.
*/
void lntd_log_open(char const *ident)
{
}
void lntd_log(lntd_log_level log_level, char const *format, ...)
{
va_list ap;
va_start(ap, format);
lntd_io_write_va_list(LNTD_KO_STDERR, 0, format, ap);
lntd_io_write_string(LNTD_KO_STDERR, 0, "\n");
va_end(ap);
}
|
mstewartgallus/linted | docs/builds.h | <reponame>mstewartgallus/linted<gh_stars>0
/* Copyright (C) 2014, 2015 <NAME>
*
* Copying and distribution of this file, with or without
* modification, are permitted in any medium without royalty provided
* the copyright notice and this notice are preserved.
*/
/**
*
* @file
*
* Linted -- Builds
*
* A list of types of final build products.
*
* @section supported-builds Supported Builds
*
* @subsection x86_64-linux-gnu x86_64 Linux GNU with GCC and GNU ld
*(GNU Binutils)
*
* This is the main build. Other builds may work but are only worked
* on for the purpose of making the code more modular and better.
*
* @subsubsection buildtime Build Time Dependencies
*
* - The GNU Compiler Collection
* - Main Site - https://www.gnu.org/software/gcc/
* - Bug Mailing List - http://gcc.gnu.org/ml/gcc-bugs/
* - Bug Database - http://gcc.gnu.org/bugzilla/
* - The GNU Binary Utilities
* - Main Site - https://www.gnu.org/software/binutils/
* - Bug Mailing List - <a
*href="mailto://<EMAIL>"><<EMAIL>></a>
* - Autoconf
* - Main Site - https://www.gnu.org/software/autoconf
* - Bug Mailing List - <a
*href="mailto://<EMAIL>"><<EMAIL>></a>
* - Automake
* - Main Site - https://www.gnu.org/software/automake
* - Bug Mailing List - <a
*href="mailto://<EMAIL>"><<EMAIL>></a>
* - GNU Make
* - Main Site - https://www.gnu.org/software/make
* - Bug Mailing List - <a
*href="mailto://<EMAIL>"><<EMAIL>></a>
*
* @subsection i686-linux-gnu i686 Linux GNU with GCC and GNU ld (GNU
*Binutils)
*
* This is basically the same as for x86_64 but 32 bit.
*
* @section unsupported Unsupported Builds
*
* This is not a supported final build product. This is only worked
* on for a challenge and for making the code more modular and better.
* In the future it may be supported.
*
* - `aarch64-linux-gnu`
* - `arm-linux-androideabi`
* - `arm-linux-gnueabi`
* - `i686-linux-gnu`
* - `i686-w64-mingw32`
* - `x86_64-linux-dietlibc`
* - `x86_64-linux-gnu`
* - `x86_64-linux-musl`
* - `x86_64-w64-mingw32`
*
* @subsection x86_64-w64-mingw32 x86_64 MinGW-w64
*
* Options that don't work well with Windows NT builds:
* - `-gplit-dwarf`
* - `-flto`
* - `-fstack-protector`
*
* Functions in the CRT that can be replaced with Win32 functions see
* https://support.microsoft.com/en-us/kb/99456
*
* <table>
* <tr><td> `isalnum` </td><td> `IsCharAlphaNumeric`</td></tr>
* <tr><td> `isalpha` </td><td> `IsCharAlpha`, `GetStringTypeW
*(Unicode)`</td></tr>
* <tr><td> `__isascii` </td><td> none</td></tr>
* <tr><td> `iscntrl` </td><td> none, `GetStringTypeW
*(Unicode)`</td></tr>
* <tr><td> `__iscsym` </td><td> none</td></tr>
* <tr><td> `__iscsymf` </td><td> none</td></tr>
* <tr><td> `isdigit` </td><td> none, `GetStringTypeW
*(Unicode)`</td></tr>
* <tr><td> `isgraph` </td><td> none</td></tr>
* <tr><td> `islower` </td><td> `IsCharLower`, `GetStringTypeW
*(Unicode)`</td></tr>
* <tr><td> `isprint` </td><td> none</td></tr>
* <tr><td> `ispunct` </td><td> none, `GetStringTypeW
*(Unicode)`</td></tr>
* <tr><td> `isspace` </td><td> none, `GetStringTypeW
*(Unicode)`</td></tr>
* <tr><td> `isupper` </td><td> `IsCharUpper`, `GetStringTypeW
*(Unicode)`</td></tr>
* <tr><td> `isxdigit` </td><td> none, `GetStringTypeW (Unicode)`
* <tr><td> `__toascii` </td><td> none</td></tr>
* <tr><td> `tolower` </td><td> `CharLower`</td></tr>
* <tr><td> `_tolower` </td><td> none</td></tr>
* <tr><td> `toupper` </td><td> `CharUpper`</td></tr>
* <tr><td> `_toupper` </td><td> none</td></tr>
* <tr><td> `_chdir` </td><td> `SetCurrentDirectory`</td></tr>
* <tr><td> `_chdrive` </td><td> `SetCurrentDirectory`</td></tr>
* <tr><td> `_getcwd` </td><td> `GetCurrentDirectory`</td></tr>
* <tr><td> `_getdrive` </td><td> GetCurrentDirectory</td></tr>
* <tr><td> `_mkdir` </td><td> `CreateDirectory`</td></tr>
* <tr><td> `_rmdir` </td><td> RemoveDirectory</td></tr>
* <tr><td> `_searchenv` </td><td> `SearchPath`</td></tr>
* <tr><td> `_access` </td><td> none</td></tr>
* <tr><td> `_chmod` </td><td> `SetFileAttributes`</td></tr>
* <tr><td> `_chsize` </td><td> SetEndOfFile</td></tr>
* <tr><td> `_filelength` </td><td> `GetFileSize`</td></tr>
* <tr><td> `_fstat` </td><td> See Note 5</td></tr>
* <tr><td> `_fullpath` </td><td> `GetFullPathName`</td></tr>
* <tr><td> `_get_osfhandle` </td><td> none</td></tr>
* <tr><td> `_isatty` </td><td> `GetFileType`</td></tr>
* <tr><td> `_locking` </td><td> `LockFileEx`</td></tr>
* <tr><td> `_makepath` </td><td> none</td></tr>
* <tr><td> `_mktemp` </td><td> `GetTempFileName`</td></tr>
* <tr><td> `_open_osfhandle` </td><td> none</td></tr>
* <tr><td> `remove` </td><td> `DeleteFile`</td></tr>
* <tr><td> `rename` </td><td> `MoveFile`</td></tr>
* <tr><td> `_setmode` </td><td> none</td></tr>
* <tr><td> `_splitpath` </td><td> none</td></tr>
* <tr><td> `_stat` </td><td> none</td></tr>
* <tr><td> `_umask` </td><td> none</td></tr>
* <tr><td> `_unlink` </td><td> `DeleteFile`</td></tr>
* <tr><td> `_displaycursor` </td><td> `SetConsoleCursorInfo`</td></tr>
* <tr><td> `_gettextcolor` </td><td>
*`GetConsoleScreenBufferInfo`</td></tr>
* <tr><td> `_gettextcursor` </td><td> `GetConsoleCursorInfo`</td></tr>
* <tr><td> `_gettextposition` </td><td>
*`GetConsoleScreenBufferInfo`</td></tr>
* <tr><td> `_gettextwindow` </td><td> `GetConsoleWindowInfo`</td></tr>
* <tr><td> `_outtext` </td><td> `WriteConsole`</td></tr>
* <tr><td> `_scrolltextwindow` </td><td>
*`ScrollConsoleScreenBuffer`</td></tr>
* <tr><td> `_settextcolor` </td><td>
*`SetConsoleTextAttribute`</td></tr>
* <tr><td> `_settextcursor` </td><td> `SetConsoleCursorInfo`</td></tr>
* <tr><td> `_settextposition` </td><td>
*`SetConsoleCursorPosition`</td></tr>
* <tr><td> `_settextwindow` </td><td> `SetConsoleWindowInfo`</td></tr>
* <tr><td> `_wrapon` </td><td> `SetConsoleMode`</td></tr>
* <tr><td> `clearerr` </td><td> none</td></tr>
* <tr><td> `fclose` </td><td> `CloseHandle`</td></tr>
* <tr><td> `_fcloseall` </td><td> none</td></tr>
* <tr><td> `_fdopen` </td><td> none</td></tr>
* <tr><td> `feof` </td><td> none</td></tr>
* <tr><td> `ferror` </td><td> none</td></tr>
* <tr><td> `fflush` </td><td> `FlushFileBuffers`</td></tr>
* <tr><td> `fgetc` </td><td> none</td></tr>
* <tr><td> `_fgetchar` </td><td> none</td></tr>
* <tr><td> `fgetpos` </td><td> none</td></tr>
* <tr><td> `fgets` </td><td> none</td></tr>
* <tr><td> `_fileno` </td><td> none</td></tr>
* <tr><td> `_flushall` </td><td> none</td></tr>
* <tr><td> `fopen` </td><td> `CreateFile`</td></tr>
* <tr><td> `fprintf` </td><td> none</td></tr>
* <tr><td> `fputc` </td><td> none</td></tr>
* <tr><td> `_fputchar` </td><td> none</td></tr>
* <tr><td> `fputs` </td><td> none</td></tr>
* <tr><td> `fread` </td><td> `ReadFile`</td></tr>
* <tr><td> `freopen` (std handles) </td><td> `SetStdHandle`</td></tr>
* <tr><td> `fscanf` </td><td> none</td></tr>
* <tr><td> `fseek` </td><td> `SetFilePointer`</td></tr>
* <tr><td> `fsetpos` </td><td> `SetFilePointer`</td></tr>
* <tr><td> `_fsopen` </td><td> `CreateFile`</td></tr>
* <tr><td> `ftell` </td><td> `SetFilePointer` (check return
*value)</td></tr>
* <tr><td> `fwrite` </td><td> `WriteFile`</td></tr>
* <tr><td> `getc` </td><td> none</td></tr>
* <tr><td> `getchar` </td><td> none</td></tr>
* <tr><td> `gets` </td><td> none</td></tr>
* <tr><td> `_getw` </td><td> none</td></tr>
* <tr><td> `printf` </td><td> none</td></tr>
* <tr><td> `putc` </td><td> none</td></tr>
* <tr><td> `putchar` </td><td> none</td></tr>
* <tr><td> `puts` </td><td> none</td></tr>
* <tr><td> `_putw` </td><td> none</td></tr>
* <tr><td> `rewind` </td><td> `SetFilePointer`</td></tr>
* <tr><td> `_rmtmp` </td><td> none</td></tr>
* <tr><td> `scanf` </td><td> none</td></tr>
* <tr><td> `setbuf` </td><td> none</td></tr>
* <tr><td> `setvbuf` </td><td> none</td></tr>
* <tr><td> `_snprintf` </td><td> none</td></tr>
* <tr><td> `sprintf` </td><td> `wsprintf`</td></tr>
* <tr><td> `sscanf` </td><td> none</td></tr>
* <tr><td> `_tempnam` </td><td> `GetTempFileName`</td></tr>
* <tr><td> `tmpfile` </td><td> none</td></tr>
* <tr><td> `tmpnam` </td><td> `GetTempFileName`</td></tr>
* <tr><td> `ungetc` </td><td> none</td></tr>
* <tr><td> `vfprintf` </td><td> none</td></tr>
* <tr><td> `vprintf` </td><td> none</td></tr>
* <tr><td> `_vsnprintf` </td><td> none</td></tr>
* <tr><td> `vsprintf` </td><td> `wvsprintf`</td></tr>
* <tr><td> `_close` </td><td> `_lclose`, `CloseHandle`</td></tr>
* <tr><td> `_commit` </td><td> `FlushFileBuffers`</td></tr>
* <tr><td> `_creat` </td><td> `_lcreat`, `CreateFile`</td></tr>
* <tr><td> `_dup` </td><td> `DuplicateHandle`</td></tr>
* <tr><td> `_dup2` </td><td> none</td></tr>
* <tr><td> `_eof` </td><td> none</td></tr>
* <tr><td> `_lseek` </td><td> `_llseek`, `SetFilePointer`</td></tr>
* <tr><td> `_open` </td><td> `_lopen`, `CreateFile`</td></tr>
* <tr><td> `_read` </td><td> `_lread`, `ReadFile`</td></tr>
* <tr><td> `_sopen` </td><td> `CreateFile`</td></tr>
* <tr><td> `_tell` </td><td> `SetFilePointer (check return
*value)`</td></tr>
* <tr><td> `_write` </td><td> `_lread`</td></tr>
* <tr><td> `_cgets` </td><td> none</td></tr>
* <tr><td> `_cprintf` </td><td> none</td></tr>
* <tr><td> `_cputs` </td><td> none</td></tr>
* <tr><td> `_cscanf` </td><td> none</td></tr>
* <tr><td> `_getch` </td><td> `ReadConsoleInput`</td></tr>
* <tr><td> `_getche` </td><td> `ReadConsoleInput`</td></tr>
* <tr><td> `_inp` </td><td> none</td></tr>
* <tr><td> `_inpw` </td><td> none</td></tr>
* <tr><td> `_kbhit` </td><td> `PeekConsoleInput`</td></tr>
* <tr><td> `_outp` </td><td> none</td></tr>
* <tr><td> `_outpw` </td><td> none</td></tr>
* <tr><td> `_putch` </td><td> `WriteConsoleInput`</td></tr>
* <tr><td> `_ungetch` </td><td> none</td></tr>
* <tr><td> `_alloca` </td><td> none</td></tr>
* <tr><td> `_bfreeseg` </td><td> none</td></tr>
* <tr><td> `_bheapseg` </td><td> none</td></tr>
* <tr><td> `calloc` </td><td> `GlobalAlloc`</td></tr>
* <tr><td> `_expand` </td><td> none</td></tr>
* <tr><td> `free` </td><td> `GlobalFree`</td></tr>
* <tr><td> `_freect` </td><td> `GlobalMemoryStatus`</td></tr>
* <tr><td> `_halloc` </td><td> `GlobalAlloc`</td></tr>
* <tr><td> `_heapadd` </td><td> none</td></tr>
* <tr><td> `_heapchk` </td><td> none</td></tr>
* <tr><td> `_heapmin` </td><td> none</td></tr>
* <tr><td> `_heapset` </td><td> none</td></tr>
* <tr><td> `_heapwalk` </td><td> none</td></tr>
* <tr><td> `_hfree` </td><td> `GlobalFree`</td></tr>
* <tr><td> `malloc` </td><td> GlobalAlloc</td></tr>
* <tr><td> `_memavl` </td><td> `GlobalMemoryStatus`</td></tr>
* <tr><td> `_memmax` </td><td> `GlobalMemoryStatus`</td></tr>
* <tr><td> `_msize` </td><td> `GlobalSize`</td></tr>
* <tr><td> `realloc` </td><td> `GlobalReAlloc`</td></tr>
* <tr><td> `_set_new_handler` </td><td> none</td></tr>
* <tr><td> `_set_hnew_handler` </td><td> none</td></tr>
* <tr><td> `_stackavail` </td><td> none</td></tr>
* <tr><td> `abort` </td><td> none</td></tr>
* <tr><td> `assert` </td><td> none</td></tr>
* <tr><td> `atexit` </td><td> none</td></tr>
* <tr><td> `_cexit` </td><td> none</td></tr>
* <tr><td> `_c_exit` </td><td> none</td></tr>
* <tr><td> `_exec` functions </td><td> none</td></tr>
* <tr><td> `exit` </td><td> `ExitProcess`</td></tr>
* <tr><td> `_exit` </td><td> `ExitProcess`</td></tr>
* <tr><td> `getenv` </td><td> `GetEnvironmentVariable`</td></tr>
* <tr><td> `_getpid` </td><td> `GetCurrentProcessId`</td></tr>
* <tr><td> `longjmp` </td><td> none</td></tr>
* <tr><td> `_onexit` </td><td> none</td></tr>
* <tr><td> `perror` </td><td> `FormatMessage`</td></tr>
* <tr><td> `_putenv` </td><td> `SetEnvironmentVariable`</td></tr>
* <tr><td> `raise` </td><td> `RaiseException`</td></tr>
* <tr><td> `setjmp` </td><td> none</td></tr>
* <tr><td> `signal` (ctrl-c only) </td><td>
*`SetConsoleCtrlHandler`</td></tr>
* <tr><td> `_spawn` functions </td><td> `CreateProcess`</td></tr>
* <tr><td> `system` </td><td> `CreateProcess`</td></tr>
* <tr><td> `strcat`, `wcscat` </td><td> `lstrcat`</td></tr>
* <tr><td> `strchr`, `wcschr` </td><td> none</td></tr>
* <tr><td> `strcmp`, `wcscmp` </td><td> `lstrcmp`</td></tr>
* <tr><td> `strcpy`, `wcscpy` </td><td> `lstrcpy`</td></tr>
* <tr><td> `strcspn`, `wcscspn` </td><td> none</td></tr>
* <tr><td> `_strdup`, `_wcsdup` </td><td> none</td></tr>
* <tr><td> `strerror` </td><td> `FormatMessage`</td></tr>
* <tr><td> `_strerror` </td><td> `FormatMessage`</td></tr>
* <tr><td> `_stricmp`, `_wcsicmp` </td><td> `lstrcmpi`</td></tr>
* <tr><td> `strlen`, `wcslen` </td><td> `lstrlen`</td></tr>
* <tr><td> `_strlwr`, `_wcslwr` </td><td> `CharLower`,
*`CharLowerBuffer`</td></tr>
* <tr><td> `strncat`, `wcsncat` </td><td> none</td></tr>
* <tr><td> `strncmp`, `wcsncmp` </td><td> none</td></tr>
* <tr><td> `strncpy`, `wcsncpy` </td><td> none</td></tr>
* <tr><td> `_strnicmp`, `_wcsnicmp` </td><td> none</td></tr>
* <tr><td> `_strnset`, `_wcsnset` </td><td> `FillMemory`,
*`ZeroMemory`</td></tr>
* <tr><td> `strpbrk`, `wcspbrk` </td><td> none</td></tr>
* <tr><td> `strrchr`, `wcsrchr` </td><td> none</td></tr>
* <tr><td> `_strrev`, `_wcsrev` </td><td> none</td></tr>
* <tr><td> `_strset`, `_wcsset` </td><td> `FillMemory,
*ZeroMemory`</td></tr>
* <tr><td> `strspn`, `wcsspn` </td><td> none</td></tr>
* <tr><td> `strstr`, `wcsstr` </td><td> none</td></tr>
* <tr><td> `strtok`, `wcstok` </td><td> none</td></tr>
* <tr><td> `_strupr`, `_wcsupr` </td><td> `CharUpper`,
*`CharUpperBuffer`</td></tr>
* <tr><td> `_bdos` </td><td> none</td></tr>
* <tr><td> `_chain_intr` </td><td> none</td></tr>
* <tr><td> `_disable` </td><td> none</td></tr>
* <tr><td> `_dos_allocmem` </td><td> `GlobalAlloc`</td></tr>
* <tr><td> `_dos_close` </td><td> `CloseHandle`</td></tr>
* <tr><td> `_dos_commit` </td><td> `FlushFileBuffers`</td></tr>
* <tr><td> `_dos_creat` </td><td> `CreateFile`</td></tr>
* <tr><td> `_dos_creatnew` </td><td> `CreateFile`</td></tr>
* <tr><td> `_dos_findfirst` </td><td> `FindFirstFile`</td></tr>
* <tr><td> `_dos_findnext` </td><td> `FindNextFile`</td></tr>
* <tr><td> `_dos_freemem` </td><td> `GlobalFree`</td></tr>
* <tr><td> `_dos_getdate` </td><td> `GetSystemTime`</td></tr>
* <tr><td> `_dos_getdiskfree` </td><td> `GetDiskFreeSpace`</td></tr>
* <tr><td> `_dos_getdrive` </td><td> `GetCurrentDirectory`</td></tr>
* <tr><td> `_dos_getfileattr` </td><td> `GetFileAttributes`</td></tr>
* <tr><td> `_dos_getftime` </td><td> `GetFileTime`</td></tr>
* <tr><td> `_dos_gettime` </td><td> `GetSystemTime`</td></tr>
* <tr><td> `_dos_getvect` </td><td> none</td></tr>
* <tr><td> `_dos_keep` </td><td> none</td></tr>
* <tr><td> `_dos_open` </td><td> `OpenFile`</td></tr>
* <tr><td> `_dos_read` </td><td> `ReadFile`</td></tr>
* <tr><td> `_dos_setblock` </td><td> `GlobalReAlloc`</td></tr>
* <tr><td> `_dos_setdate` </td><td> `SetSystemTime`</td></tr>
* <tr><td> `_dos_setdrive` </td><td> `SetCurrentDirectory`</td></tr>
* <tr><td> `_dos_setfileattr` </td><td> `SetFileAttributes`</td></tr>
* <tr><td> `_dos_setftime` </td><td> `SetFileTime`</td></tr>
* <tr><td> `_dos_settime` </td><td> `SetSystemTime`</td></tr>
* <tr><td> `_dos_setvect` </td><td> none</td></tr>
* <tr><td> `_dos_write` </td><td> `WriteFile`</td></tr>
* <tr><td> `_dosexterr` </td><td> `GetLastError`</td></tr>
* <tr><td> `_enable` </td><td> none</td></tr>
* <tr><td> `_FP_OFF` </td><td> none</td></tr>
* <tr><td> `_FP_SEG` </td><td> none</td></tr>
* <tr><td> `_harderr` </td><td> See Note 1</td></tr>
* <tr><td> `_hardresume` </td><td> See Note 1</td></tr>
* <tr><td> `_hardretn` </td><td> See Note 1</td></tr>
* <tr><td> `_int86` </td><td> none</td></tr>
* <tr><td> `_int86x` </td><td> none</td></tr>
* <tr><td> `_intdos` </td><td> none</td></tr>
* <tr><td> `_intdosx` </td><td> none</td></tr>
* <tr><td> `_segread` </td><td> none</td></tr>
* <tr><td> `asctime` </td><td> See Note 2</td></tr>
* <tr><td> `clock` </td><td> See Note 2</td></tr>
* <tr><td> `ctime` </td><td> See Note 2</td></tr>
* <tr><td> `difftime` </td><td> See Note 2</td></tr>
* <tr><td> `_ftime` </td><td> See Note 2</td></tr>
* <tr><td> `_getsystime` </td><td> `GetLocalTime`</td></tr>
* <tr><td> `gmtime` </td><td> See Note 2</td></tr>
* <tr><td> `localtime` </td><td> See Note 2</td></tr>
* <tr><td> `mktime` </td><td> See Note 2</td></tr>
* <tr><td> `_strdate` </td><td> See Note 2</td></tr>
* <tr><td> `_strtime` </td><td> See Note 2</td></tr>
* <tr><td> `time` </td><td> See Note 2</td></tr>
* <tr><td> `_tzset` </td><td> See Note 2</td></tr>
* <tr><td> `_utime` </td><td> `SetFileTime`</td></tr>
* <tr><td> `_vfree` </td><td> See Note 3</td></tr>
* <tr><td> `_vheapinit` </td><td> See Note 3</td></tr>
* <tr><td> `_vheapterm` </td><td> See Note 3</td></tr>
* <tr><td> `_vload` </td><td> See Note 3</td></tr>
* <tr><td> `_vlock` </td><td> See Note 3</td></tr>
* <tr><td> `_vlockcnt` </td><td> See Note 3</td></tr>
* <tr><td> `_vmalloc` </td><td> See Note 3</td></tr>
* <tr><td> `_vmsize` </td><td> See Note 3</td></tr>
* <tr><td> `_vrealloc` </td><td> See Note 3</td></tr>
* <tr><td> `_vunlock` </td><td> See Note 3</td></tr>
* <tr><td> `_beginthread` </td><td> `CreateThread`</td></tr>
* <tr><td> `_cwait` </td><td> `WaitForSingleObject` w/
*`GetExitCodeProcess`</td></tr>
* <tr><td> `_endthread` </td><td> `ExitThread`</td></tr>
* <tr><td> `_findclose` </td><td> `FindClose`</td></tr>
* <tr><td> `_findfirst` </td><td> `FindFirstFile`</td></tr>
* <tr><td> `_findnext` </td><td> `FindNextFile`</td></tr>
* <tr><td> `_futime` </td><td> `SetFileTime`</td></tr>
* <tr><td> `_get_osfhandle` </td><td> none</td></tr>
* <tr><td> `_open_osfhandle` </td><td> none</td></tr>
* <tr><td> `_pclose` </td><td> See Note 4</td></tr>
* <tr><td> `_pipe` </td><td> `CreatePipe`</td></tr>
* <tr><td> `_popen` </td><td> See Note 4</td></tr>
* <tr><td> `_popen` </td><td> `CreatePipe`, `CreateProcess`</td></tr>
* <tr><td> `_pclose` </td><td> `WaitForSingleObject`,
*`CloseHandle`</td></tr>
* </table>
*
* @subsection asmjs-unknown-emscripten Emscripten
*
* This build is temporarily out of service until I figure out why
* Emscripten generates broken code (it seems to generate null
* pointers out of nowhere) or the Emscripten compiler improves.
*/
|
mstewartgallus/linted | include/lntd/io.h | <reponame>mstewartgallus/linted
/*
* Copyright 2014, 2015 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#ifndef LNTD_IO_H
#define LNTD_IO_H
#include "lntd/error.h"
#include "lntd/ko.h"
#include "lntd/util.h"
#include <stdarg.h>
#include <stddef.h>
/**
* @file
*
* Abstracts over chunked input and output.
*/
struct lntd_async_pool;
struct lntd_async_task;
union lntd_async_ck;
struct lntd_io_task_poll;
struct lntd_io_task_read;
struct lntd_io_task_write;
lntd_error lntd_io_read_all(lntd_ko ko, size_t *bytes_wrote, void *buf,
size_t count);
/**
* The lntd_io_write_all function repeatedly writes to ko until of
* buf is written or an error occurs (except for EINTR).
*
* For example, a bit could be written and then ko could be closed and
* an error would be returned but some bytes would still have been
* written.
*
* @param ko The kernel object to be written to.
*
* @param bytes_wrote The amount written. Is set to no larger than
* count bytes and at least zero bytes. If 0
* then is not set.
*
* @param buf The buffer to be written from. Must be at least count
*bytes
* long.
*
* @param count The amount to write. No more than these many bytes is
* written.
*
* @returns Zero on success or an error code.
*
* @error EAGAIN The file descriptor has been marked nonblocking and
* one of the writes would block.
*
* @error EBADF ko is not a valid file descriptor or is not open for
* writing.
*
* @error EWOULDBLOCK Means the same as EAGAIN but may be a different
* value.
*
* @error EFAULT buf is not accessible.
*
* @error LNTD_ERROR_INVALID_PARAMETER ko is not writable or the file
*was
* opened with `O_DIRECT` and alignment restrictions
*weren't
* satisfied.
*
* @error EIO I/O error.
*
* @error ENOSPC No room for the data.
*
* @error EPIPE ko is a pipe or socket with a closed read end.
*
* @error EISDIR ko is a directory.
*/
lntd_error lntd_io_write_all(lntd_ko ko, size_t *bytes_wrote,
void const *buf, size_t count);
lntd_error lntd_io_write_string(lntd_ko ko, size_t *bytes_wrote_out,
char const *s);
lntd_error lntd_io_write_format(lntd_ko ko, size_t *bytes_wrote_out,
char const *s, ...)
LNTD_FORMAT(__printf__, 3, 4);
lntd_error lntd_io_write_va_list(lntd_ko ko, size_t *bytes_wrote_out,
char const *s, va_list list)
LNTD_FORMAT(__printf__, 3, 0);
lntd_error lntd_io_task_poll_create(struct lntd_io_task_poll **taskp,
void *data);
void lntd_io_task_poll_destroy(struct lntd_io_task_poll *task);
void lntd_io_task_poll_cancel(struct lntd_io_task_poll *task);
void lntd_io_task_poll_submit(struct lntd_async_pool *pool,
struct lntd_io_task_poll *task,
union lntd_async_ck task_ck,
void *userstate, lntd_ko ko, int flags);
void *lntd_io_task_poll_data(struct lntd_io_task_poll *task);
lntd_error lntd_io_task_read_create(struct lntd_io_task_read **taskp,
void *data);
void lntd_io_task_read_destroy(struct lntd_io_task_read *task);
void lntd_io_task_read_cancel(struct lntd_io_task_read *task);
void lntd_io_task_read_submit(struct lntd_async_pool *pool,
struct lntd_io_task_read *task,
union lntd_async_ck task_ck,
void *userstate, lntd_ko ko, char *buf,
size_t size);
void *lntd_io_task_read_data(struct lntd_io_task_read *task);
lntd_ko lntd_io_task_read_ko(struct lntd_io_task_read *task);
size_t lntd_io_task_read_bytes_read(struct lntd_io_task_read *task);
lntd_error lntd_io_task_write_create(struct lntd_io_task_write **taskp,
void *data);
void lntd_io_task_write_destroy(struct lntd_io_task_write *task);
void lntd_io_task_write_cancel(struct lntd_io_task_write *task);
void lntd_io_task_write_submit(struct lntd_async_pool *pool,
struct lntd_io_task_write *task,
union lntd_async_ck task_ck,
void *userstate, lntd_ko ko,
char const *buf, size_t size);
void *lntd_io_task_write_data(struct lntd_io_task_write *task);
void lntd_io_do_poll(struct lntd_async_pool *pool,
struct lntd_async_task *task);
void lntd_io_do_read(struct lntd_async_pool *pool,
struct lntd_async_task *task);
/**
* @warning Consumes pending SIGPIPEs
*/
void lntd_io_do_write(struct lntd_async_pool *pool,
struct lntd_async_task *task);
#endif /* LNTD_IO_H */
|
mstewartgallus/linted | src/trigger/trigger.c | <reponame>mstewartgallus/linted
/*
* Copyright 2015 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#define _GNU_SOURCE
#include "config.h"
#include "lntd/trigger.h"
#include "lntd/error.h"
#include "lntd/sched.h"
#include <errno.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#if defined HAVE_POSIX_API
#include <syscall.h>
#include <linux/futex.h>
#endif
static lntd_error wait_until_different(atomic_int const *uaddr, int val,
bool is_local);
static lntd_error hint_wakeup(atomic_int const *uaddr, bool is_local);
lntd_error lntd_trigger_create(struct lntd_trigger *trigger,
unsigned long flags)
{
if ((flags & ~LNTD_TRIGGER_PSHARED) != 0)
return LNTD_ERROR_INVALID_PARAMETER;
bool shared = (flags & LNTD_TRIGGER_PSHARED) != 0;
atomic_int zero = ATOMIC_VAR_INIT(0);
trigger->_triggered = zero;
trigger->_process_local = !shared;
return 0;
}
void lntd_trigger_destroy(struct lntd_trigger *trigger)
{
}
void lntd_trigger_set(struct lntd_trigger *trigger)
{
bool is_local = trigger->_process_local;
atomic_thread_fence(memory_order_release);
atomic_store_explicit(&trigger->_triggered, 1,
memory_order_relaxed);
hint_wakeup(&trigger->_triggered, is_local);
}
void lntd_trigger_wait(struct lntd_trigger *trigger)
{
bool is_local = trigger->_process_local;
wait_until_different(&trigger->_triggered, 0, is_local);
atomic_store_explicit(&trigger->_triggered, 0,
memory_order_release);
atomic_thread_fence(memory_order_acquire);
}
#if defined HAVE_POSIX_API
static lntd_error futex_wait(atomic_int const *uaddr, int val,
struct timespec const *timeout,
bool is_local);
static lntd_error futex_wake(unsigned *restrict wokeupp,
atomic_int const *uaddr, int val,
bool is_local);
static inline lntd_error wait_until_different(atomic_int const *uaddr,
int val, bool is_local)
{
return futex_wait(uaddr, val, NULL, is_local);
}
static inline lntd_error hint_wakeup(atomic_int const *uaddr,
bool is_local)
{
return futex_wake(NULL, uaddr, 1, is_local);
}
#else
static inline lntd_error wait_until_different(atomic_int const *uaddr,
int val, bool is_local)
{
for (;;) {
if (atomic_load_explicit(uaddr, memory_order_relaxed) !=
val)
return 0;
lntd_sched_light_yield();
}
atomic_thread_fence(memory_order_acquire);
}
static inline lntd_error hint_wakeup(atomic_int const *uaddr,
bool is_local)
{
return 0;
}
#endif
#if defined HAVE_POSIX_API
static inline lntd_error futex_wait(atomic_int const *uaddr, int val,
struct timespec const *timeout,
bool is_local)
{
int xx = syscall(
__NR_futex, (intptr_t)uaddr,
(intptr_t)(is_local ? FUTEX_WAIT_PRIVATE : FUTEX_WAIT),
(intptr_t)val, (intptr_t)timeout);
if (xx < 0) {
return errno;
}
return 0;
}
static inline lntd_error futex_wake(unsigned *restrict wokeupp,
atomic_int const *uaddr, int val,
bool is_local)
{
int xx = syscall(
__NR_futex, (intptr_t)uaddr,
(intptr_t)(is_local ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE),
(intptr_t)val);
if (xx < 0) {
return errno;
}
if (wokeupp != NULL) {
*wokeupp = xx;
}
return 0;
}
#endif
|
mstewartgallus/linted | src/error/error-windows.c | /*
* Copyright 2014, 2015 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#ifndef UNICODE
#define UNICODE
#endif
#define _UNICODE
#define WIN32_LEAN_AND_MEAN
#include "config.h"
#include "lntd/error.h"
#include "lntd/mem.h"
#include "lntd/utf.h"
#include "lntd/util.h"
#include <limits.h>
#include <string.h>
#include <windows.h>
static char const invalid_error_string[] = "invalid error number";
static char const out_of_memory_string[] =
"cannot print error, out of memory";
char const *lntd_error_string(lntd_error err_to_print)
{
lntd_error err;
if (FACILITY_WINDOWS == HRESULT_FACILITY(err_to_print))
err_to_print = HRESULT_CODE(err_to_print);
wchar_t *message;
if (0 ==
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
0, err_to_print,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(void *)&message, 0, 0)) {
err = HRESULT_FROM_WIN32(GetLastError());
if (LNTD_ERROR_OUT_OF_MEMORY == err)
return out_of_memory_string;
return invalid_error_string;
}
char *buffer;
{
char *xx;
err = lntd_utf_2_to_1(message, &xx);
if (err != 0)
goto free_message;
buffer = xx;
}
return buffer;
free_message:
LocalFree(message);
return out_of_memory_string;
}
void lntd_error_string_free(char const *str)
{
if (invalid_error_string == str)
return;
if (out_of_memory_string == str)
return;
lntd_mem_free((char *)str);
}
|
MathZtew/MZ-bike-controller | controller/lcd.h | <gh_stars>0
#include "Arduino.h"
#define BOARD_ID 0x65
#define ADDRESS 0x30
#define SET_BL 0x62
#define GET_BUT 0x05
#define LCD_CLR 0x60
#define LCD_WR 0x61
#define LCD_WRITE_WAIT 17
void lcdSetBlacklight(uint8_t value);
uint8_t readButtons();
void lcdClear();
void lcdGoToXY(uint8_t x, uint8_t y);
void lcdWriteChar(char character, uint8_t x, uint8_t y);
void lcdWrite(char* string);
void lcdWrite(int intVal);
void lcdWrite(float floatVal, uint8_t precision);
void lcdWrite(float floatVal, uint8_t precision, uint8_t size); |
janiex/TheRQMProject | HW/DSP2833x_EPwm.h | /*******************************************************************************
** **
** SRC-MODULE: DSP2833x_EPwm.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
// TI File $Revision: /main/1 $
// Checkin $Date: August 18, 2006 13:52:10 $
//###########################################################################
//
// FILE: DSP2833x_EPwm.h
//
// TITLE: DSP2833x Enhanced PWM Module Register Bit Definitions.
//
//###########################################################################
// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
// $Release Date: August 4, 2009 $
//###########################################################################
#ifndef DSP2833x_EPWM_H
#define DSP2833x_EPWM_H
#ifdef __cplusplus
extern "C" {
#endif
//----------------------------------------------------
// Time base control register bit definitions */
struct TBCTL_BITS { // bits description
uint16 CTRMODE:2; // 1:0 Counter Mode
uint16 PHSEN:1; // 2 Phase load enable
uint16 PRDLD:1; // 3 Active period load
uint16 SYNCOSEL:2; // 5:4 Sync output select
uint16 SWFSYNC:1; // 6 Software force sync pulse
uint16 HSPCLKDIV:3; // 9:7 High speed time pre-scale
uint16 CLKDIV:3; // 12:10 Timebase clock pre-scale
uint16 PHSDIR:1; // 13 Phase Direction
uint16 FREE_SOFT:2; // 15:14 Emulation mode
};
union TBCTL_REG {
uint16 all;
struct TBCTL_BITS bit;
};
//----------------------------------------------------
// Time base status register bit definitions */
struct TBSTS_BITS { // bits description
uint16 CTRDIR:1; // 0 Counter direction status
uint16 SYNCI:1; // 1 External input sync status
uint16 CTRMAX:1; // 2 Counter max latched status
uint16 rsvd1:13; // 15:3 reserved
};
union TBSTS_REG {
uint16 all;
struct TBSTS_BITS bit;
};
//----------------------------------------------------
// Compare control register bit definitions */
struct CMPCTL_BITS { // bits description
uint16 LOADAMODE:2; // 0:1 Active compare A
uint16 LOADBMODE:2; // 3:2 Active compare B
uint16 SHDWAMODE:1; // 4 Compare A block operating mode
uint16 rsvd1:1; // 5 reserved
uint16 SHDWBMODE:1; // 6 Compare B block operating mode
uint16 rsvd2:1; // 7 reserved
uint16 SHDWAFULL:1; // 8 Compare A Shadow registers full Status
uint16 SHDWBFULL:1; // 9 Compare B Shadow registers full Status
uint16 rsvd3:6; // 15:10 reserved
};
union CMPCTL_REG {
uint16 all;
struct CMPCTL_BITS bit;
};
//----------------------------------------------------
// Action qualifier register bit definitions */
struct AQCTL_BITS { // bits description
uint16 ZRO:2; // 1:0 Action Counter = Zero
uint16 PRD:2; // 3:2 Action Counter = Period
uint16 CAU:2; // 5:4 Action Counter = Compare A up
uint16 CAD:2; // 7:6 Action Counter = Compare A down
uint16 CBU:2; // 9:8 Action Counter = Compare B up
uint16 CBD:2; // 11:10 Action Counter = Compare B down
uint16 rsvd:4; // 15:12 reserved
};
union AQCTL_REG {
uint16 all;
struct AQCTL_BITS bit;
};
//----------------------------------------------------
// Action qualifier SW force register bit definitions */
struct AQSFRC_BITS { // bits description
uint16 ACTSFA:2; // 1:0 Action when One-time SW Force A invoked
uint16 OTSFA:1; // 2 One-time SW Force A output
uint16 ACTSFB:2; // 4:3 Action when One-time SW Force B invoked
uint16 OTSFB:1; // 5 One-time SW Force A output
uint16 RLDCSF:2; // 7:6 Reload from Shadow options
uint16 rsvd1:8; // 15:8 reserved
};
union AQSFRC_REG {
uint16 all;
struct AQSFRC_BITS bit;
};
//----------------------------------------------------
// Action qualifier continuous SW force register bit definitions */
struct AQCSFRC_BITS { // bits description
uint16 CSFA:2; // 1:0 Continuous Software Force on output A
uint16 CSFB:2; // 3:2 Continuous Software Force on output B
uint16 rsvd1:12; // 15:4 reserved
};
union AQCSFRC_REG {
uint16 all;
struct AQCSFRC_BITS bit;
};
// As of version 1.1
// Changed the MODE bit-field to OUT_MODE
// Added the bit-field IN_MODE
// This corresponds to changes in silicon as of F2833x devices
// Rev A silicon.
//----------------------------------------------------
// Dead-band generator control register bit definitions
struct DBCTL_BITS { // bits description
uint16 OUT_MODE:2; // 1:0 Dead Band Output Mode Control
uint16 POLSEL:2; // 3:2 Polarity Select Control
uint16 IN_MODE:2; // 5:4 Dead Band Input Select Mode Control
uint16 rsvd1:10; // 15:4 reserved
};
union DBCTL_REG {
uint16 all;
struct DBCTL_BITS bit;
};
//----------------------------------------------------
// Trip zone select register bit definitions
struct TZSEL_BITS { // bits description
uint16 CBC1:1; // 0 TZ1 CBC select
uint16 CBC2:1; // 1 TZ2 CBC select
uint16 CBC3:1; // 2 TZ3 CBC select
uint16 CBC4:1; // 3 TZ4 CBC select
uint16 CBC5:1; // 4 TZ5 CBC select
uint16 CBC6:1; // 5 TZ6 CBC select
uint16 rsvd1:2; // 7:6 reserved
uint16 OSHT1:1; // 8 One-shot TZ1 select
uint16 OSHT2:1; // 9 One-shot TZ2 select
uint16 OSHT3:1; // 10 One-shot TZ3 select
uint16 OSHT4:1; // 11 One-shot TZ4 select
uint16 OSHT5:1; // 12 One-shot TZ5 select
uint16 OSHT6:1; // 13 One-shot TZ6 select
uint16 rsvd2:2; // 15:14 reserved
};
union TZSEL_REG {
uint16 all;
struct TZSEL_BITS bit;
};
//----------------------------------------------------
// Trip zone control register bit definitions */
struct TZCTL_BITS { // bits description
uint16 TZA:2; // 1:0 TZ1 to TZ6 Trip Action On EPWMxA
uint16 TZB:2; // 3:2 TZ1 to TZ6 Trip Action On EPWMxB
uint16 rsvd:12; // 15:4 reserved
};
union TZCTL_REG {
uint16 all;
struct TZCTL_BITS bit;
};
//----------------------------------------------------
// Trip zone control register bit definitions */
struct TZEINT_BITS { // bits description
uint16 rsvd1:1; // 0 reserved
uint16 CBC:1; // 1 Trip Zones Cycle By Cycle Int Enable
uint16 OST:1; // 2 Trip Zones One Shot Int Enable
uint16 rsvd2:13; // 15:3 reserved
};
union TZEINT_REG {
uint16 all;
struct TZEINT_BITS bit;
};
//----------------------------------------------------
// Trip zone flag register bit definitions */
struct TZFLG_BITS { // bits description
uint16 INT:1; // 0 Global status
uint16 CBC:1; // 1 Trip Zones Cycle By Cycle Int
uint16 OST:1; // 2 Trip Zones One Shot Int
uint16 rsvd2:13; // 15:3 reserved
};
union TZFLG_REG {
uint16 all;
struct TZFLG_BITS bit;
};
//----------------------------------------------------
// Trip zone flag clear register bit definitions */
struct TZCLR_BITS { // bits description
uint16 INT:1; // 0 Global status
uint16 CBC:1; // 1 Trip Zones Cycle By Cycle Int
uint16 OST:1; // 2 Trip Zones One Shot Int
uint16 rsvd2:13; // 15:3 reserved
};
union TZCLR_REG {
uint16 all;
struct TZCLR_BITS bit;
};
//----------------------------------------------------
// Trip zone flag force register bit definitions */
struct TZFRC_BITS { // bits description
uint16 rsvd1:1; // 0 reserved
uint16 CBC:1; // 1 Trip Zones Cycle By Cycle Int
uint16 OST:1; // 2 Trip Zones One Shot Int
uint16 rsvd2:13; // 15:3 reserved
};
union TZFRC_REG {
uint16 all;
struct TZFRC_BITS bit;
};
//----------------------------------------------------
// Event trigger select register bit definitions */
struct ETSEL_BITS { // bits description
uint16 INTSEL:3; // 2:0 EPWMxINTn Select
uint16 INTEN:1; // 3 EPWMxINTn Enable
uint16 rsvd1:4; // 7:4 reserved
uint16 SOCASEL:3; // 10:8 Start of conversion A Select
uint16 SOCAEN:1; // 11 Start of conversion A Enable
uint16 SOCBSEL:3; // 14:12 Start of conversion B Select
uint16 SOCBEN:1; // 15 Start of conversion B Enable
};
union ETSEL_REG {
uint16 all;
struct ETSEL_BITS bit;
};
//----------------------------------------------------
// Event trigger pre-scale register bit definitions */
struct ETPS_BITS { // bits description
uint16 INTPRD:2; // 1:0 EPWMxINTn Period Select
uint16 INTCNT:2; // 3:2 EPWMxINTn Counter Register
uint16 rsvd1:4; // 7:4 reserved
uint16 SOCAPRD:2; // 9:8 EPWMxSOCA Period Select
uint16 SOCACNT:2; // 11:10 EPWMxSOCA Counter Register
uint16 SOCBPRD:2; // 13:12 EPWMxSOCB Period Select
uint16 SOCBCNT:2; // 15:14 EPWMxSOCB Counter Register
};
union ETPS_REG {
uint16 all;
struct ETPS_BITS bit;
};
//----------------------------------------------------
// Event trigger Flag register bit definitions */
struct ETFLG_BITS { // bits description
uint16 INT:1; // 0 EPWMxINTn Flag
uint16 rsvd1:1; // 1 reserved
uint16 SOCA:1; // 2 EPWMxSOCA Flag
uint16 SOCB:1; // 3 EPWMxSOCB Flag
uint16 rsvd2:12; // 15:4 reserved
};
union ETFLG_REG {
uint16 all;
struct ETFLG_BITS bit;
};
//----------------------------------------------------
// Event trigger Clear register bit definitions */
struct ETCLR_BITS { // bits description
uint16 INT:1; // 0 EPWMxINTn Clear
uint16 rsvd1:1; // 1 reserved
uint16 SOCA:1; // 2 EPWMxSOCA Clear
uint16 SOCB:1; // 3 EPWMxSOCB Clear
uint16 rsvd2:12; // 15:4 reserved
};
union ETCLR_REG {
uint16 all;
struct ETCLR_BITS bit;
};
//----------------------------------------------------
// Event trigger Force register bit definitions */
struct ETFRC_BITS { // bits description
uint16 INT:1; // 0 EPWMxINTn Force
uint16 rsvd1:1; // 1 reserved
uint16 SOCA:1; // 2 EPWMxSOCA Force
uint16 SOCB:1; // 3 EPWMxSOCB Force
uint16 rsvd2:12; // 15:4 reserved
};
union ETFRC_REG {
uint16 all;
struct ETFRC_BITS bit;
};
//----------------------------------------------------
// PWM chopper control register bit definitions */
struct PCCTL_BITS { // bits description
uint16 CHPEN:1; // 0 PWM chopping enable
uint16 OSHTWTH:4; // 4:1 One-shot pulse width
uint16 CHPFREQ:3; // 7:5 Chopping clock frequency
uint16 CHPDUTY:3; // 10:8 Chopping clock Duty cycle
uint16 rsvd1:5; // 15:11 reserved
};
union PCCTL_REG {
uint16 all;
struct PCCTL_BITS bit;
};
struct HRCNFG_BITS { // bits description
uint16 EDGMODE:2; // 1:0 Edge Mode select Bits
uint16 CTLMODE:1; // 2 Control mode Select Bit
uint16 HRLOAD:1; // 3 Shadow mode Select Bit
uint16 rsvd1:12; // 15:4 reserved
};
union HRCNFG_REG {
uint16 all;
struct HRCNFG_BITS bit;
};
struct TBPHS_HRPWM_REG { // bits description
uint16 TBPHSHR; // 15:0 Extension register for HRPWM Phase (8 bits)
uint16 TBPHS; // 31:16 Phase offset register
};
union TBPHS_HRPWM_GROUP {
uint32 all;
struct TBPHS_HRPWM_REG half;
};
struct CMPA_HRPWM_REG { // bits description
uint16 CMPAHR; // 15:0 Extension register for HRPWM compare (8 bits)
uint16 CMPA; // 31:16 Compare A reg
};
union CMPA_HRPWM_GROUP {
uint32 all;
struct CMPA_HRPWM_REG half;
};
struct EPWM_REGS {
union TBCTL_REG TBCTL; //
union TBSTS_REG TBSTS; //
union TBPHS_HRPWM_GROUP TBPHS; // Union of TBPHS:TBPHSHR
uint16 TBCTR; // Counter
uint16 TBPRD; // Period register set
uint16 rsvd1; //
union CMPCTL_REG CMPCTL; // Compare control
union CMPA_HRPWM_GROUP CMPA; // Union of CMPA:CMPAHR
uint16 CMPB; // Compare B reg
union AQCTL_REG AQCTLA; // Action qual output A
union AQCTL_REG AQCTLB; // Action qual output B
union AQSFRC_REG AQSFRC; // Action qual SW force
union AQCSFRC_REG AQCSFRC; // Action qualifier continuous SW force
union DBCTL_REG DBCTL; // Dead-band control
uint16 DBRED; // Dead-band rising edge delay
uint16 DBFED; // Dead-band falling edge delay
union TZSEL_REG TZSEL; // Trip zone select
uint16 rsvd2;
union TZCTL_REG TZCTL; // Trip zone control
union TZEINT_REG TZEINT; // Trip zone interrupt enable
union TZFLG_REG TZFLG; // Trip zone interrupt flags
union TZCLR_REG TZCLR; // Trip zone clear
union TZFRC_REG TZFRC; // Trip zone force interrupt
union ETSEL_REG ETSEL; // Event trigger selection
union ETPS_REG ETPS; // Event trigger pre-scaler
union ETFLG_REG ETFLG; // Event trigger flags
union ETCLR_REG ETCLR; // Event trigger clear
union ETFRC_REG ETFRC; // Event trigger force
union PCCTL_REG PCCTL; // PWM chopper control
uint16 rsvd3; //
union HRCNFG_REG HRCNFG; // HRPWM Config Reg
};
//---------------------------------------------------------------------------
// External References & Function Declarations:
//
extern volatile struct EPWM_REGS EPwm1Regs;
extern volatile struct EPWM_REGS EPwm2Regs;
extern volatile struct EPWM_REGS EPwm3Regs;
extern volatile struct EPWM_REGS EPwm4Regs;
extern volatile struct EPWM_REGS EPwm5Regs;
extern volatile struct EPWM_REGS EPwm6Regs;
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // end of DSP2833x_EPWM_H definition
//===========================================================================
// End of file.
//===========================================================================
/* EOF */
|
janiex/TheRQMProject | Schedule.c | /*******************************************************************************
** **
** SRC-MODULE: Schedule.c **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#include "Task.h"
#include "Common.h"
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
StatusType Schedule
(
void
)
{
/* \req OSEK_SYS_3.4 The system service StatusType Schedule ( void ) shall
** be defined */
/* \req OSEK_SYS_3.4.4 Possible return values in Standard mode is E_OK */
StatusType ret = E_OK;
TaskType nexttask;
TaskType actualtask;
/* \req OSEK_SYS_3.3.5 Extra possible return values in Extended mode are E_OS
** CALLEVEL, E_OS_RESOURCE */
#if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED)
if ( ( GetCallingContext() != CONTEXT_TASK ) &&
( GetCallingContext() != CONTEXT_SYS ) )
{
/* \req OSEK_SYS_3.3.5 Extra possible return values in Extended mode
** are E_OS_CALLEVEL, E_OS_RESOURCE */
ret = E_OS_CALLEVEL;
}
else if (GetRunningTask() != INVALID_TASK)
{
if ( TasksVar[GetRunningTask()].Resources != 0 )
{
/* \req OSEK_SYS_3.3.5 Extra possible return values in Extended mode
** are E_OS_CALLEVEL, E_OS_RESOURCE */
ret = E_OS_RESOURCE;
}
}
else
{
/* nothing to check Runngin Task is invalid */
}
if (ret == E_OK)
#endif
{
/* get actual running task */
actualtask = GetRunningTask();
/* get next task */
nexttask = GetNextTask();
/* while until one or boths are not more invalid tasks */
while ( ( actualtask == INVALID_TASK ) &&
( nexttask == INVALID_TASK) )
{
/* macro used to indicate the processor that we are in idle time */
//osekpause();
/* get next task */
nexttask = GetNextTask();
pRunningTask = NULL;
};
/* if the actual task is invalid */
if ( actualtask == INVALID_TASK )
{
/* set task state to running */
TasksVar[nexttask].Flags.State = RUNNING;
/* set as running task */
SetRunningTask(nexttask);
/* set actual context task */
SetActualContext(CONTEXT_TASK);
#if (HOOK_PRETASKHOOK == ENABLE)
PreTaskHook();
#endif /* #if (HOOK_PRETASKHOOK == ENABLE) */
/* jmp tp the next task */
pRunningTask = TasksVar[nexttask].pTopOfStack;
}
else
{
/* check priorities */
/* \req OSEK_SYS_3.4.1 If a task with a lower or equal priority than the
** ceiling priority of the internal resource and higher priority than
** the priority of the calling task is ready */
if ( TasksConst[nexttask].StaticPriority > TasksVar[actualtask].ActualPriority )
{
#if (HOOK_POSTTASKHOOK == ENABLE)
PostTaskHook();
#endif /* #if (HOOK_POSTTASKHOOK == ENABLE) */
/* \req OSEK_SYS_3.4.1.1 the internal resource of the task shall be
** released */
ReleaseInternalResources();
/* \req OSEK_SYS_3.4.1.2 the current task is put into the ready state */
TasksVar[actualtask].Flags.State = READY;
/* set the new task to running */
TasksVar[nexttask].Flags.State = RUNNING;
/* set as running task */
SetRunningTask(nexttask);
/* set as running task */
pRunningTask = TasksVar[nexttask].pTopOfStack;
#if (HOOK_PRETASKHOOK == ENABLE)
PreTaskHook();
#endif /* #if (HOOK_PRETASKHOOK == ENABLE) */
/* \req OSEK_SYS_3.4.1.3 its context is saved */
/* \req OSEK_SYS_3.4.1.4 and the higher-priority task is executed */
//SaveContext on the actualtask Krisitan TODO:
// load the context of the nexttask Krisitan TODO:
//CallTask(actualtask, nexttask);
}
else
{
/* \req OSEK_SYS_3.4.2 Otherwise the calling task is continued */
}
}
}
#if (HOOK_ERRORHOOK == ENABLE)
/* \req OSEK_ERR_1.3-4/xx The ErrorHook hook routine shall be called if a
** system service returns a StatusType value not equal to E_OK.*/
/* \req OSEK_ERR_1.3.1-4/xx The hook routine ErrorHook is not called if a
** system service is called from the ErrorHook itself. */
// if ( ( ret != E_OK ) && (ErrorHookRunning != 1))
// {
// SetError_Api(OSServiceId_Schedule);
// SetError_Ret(ret);
// SetError_Msg("Schedule Task returns != than E_OK");
// SetError_ErrorHook();
// }
#endif
return ret;
}
/* EOF */
|
janiex/TheRQMProject | ISO2631_All_GenerationTemplate_types.h | <filename>ISO2631_All_GenerationTemplate_types.h
/*
* File: ISO2631_All_GenerationTemplate_types.h
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_ISO2631_All_GenerationTemplate_types_h_
#define RTW_HEADER_ISO2631_All_GenerationTemplate_types_h_
#include "rtwtypes.h"
/* Parameters (auto storage) */
typedef struct Parameters_ISO2631_All_Generati_ Parameters_ISO2631_All_Generati;
#endif /* RTW_HEADER_ISO2631_All_GenerationTemplate_types_h_ */
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | ISO2631_All_GenerationTemplate.c | <filename>ISO2631_All_GenerationTemplate.c<gh_stars>0
/*
* File: ISO2631_All_GenerationTemplate.c
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "ISO2631_All_GenerationTemplate.h"
#include "ISO2631_All_GenerationTemplate_private.h"
#include "IO.h"
/*
//----------------------------------------
#ifdef __cplusplus
#pragma DATA_SECTION("GpioCtrlRegsFile")
#else
#pragma DATA_SECTION(GpioCtrlRegs,"GpioCtrlRegsFile");
#endif
volatile struct GPIO_CTRL_REGS GpioCtrlRegs;
//----------------------------------------
#ifdef __cplusplus
#pragma DATA_SECTION("GpioDataRegsFile")
#else
#pragma DATA_SECTION(GpioDataRegs,"GpioDataRegsFile");
#endif
volatile struct GPIO_DATA_REGS GpioDataRegs;
*/
#define EALLOW asm(" EALLOW")
#define EDIS asm(" EDIS")
//#define SWITCH_LED_ON() EALLOW;\
// GpioDataRegs.GPASET.bit.GPIO9 = 1;\
// EDIS
//
//#define SWITCH_LED_OFF() EALLOW;\
// GpioDataRegs.GPACLEAR.bit.GPIO9 = 1;\
// EDIS
#define cSWITCH ((real_T)6)
/* Block states (auto storage) */
D_Work_ISO2631_All_GenerationTe ISO2631_All_GenerationTem_DWork;
/* Debug variables */
real_T InputBuffer[10] = {0, 0.00188464031722077, 0.00628188735329749, 0.0131914790955888, 0.0226125130540358, 0.0345427920810054, 0.0489779328073037, 0.0659102376281471, 0.0853273320577452, 0.107210570603253};
real_T OutputBuffer[10];
real_T *pIn = &InputBuffer[0];
real_T *pOut = &OutputBuffer[0];
void Rte_IWrite_Runnable_BandPass_Step_FilterOut_FilterOut(real_T u)
{
*pOut++ = u;
}
real_T Rte_IRead_BandPass_Runnable_BandPass_Step_ISO2631_Ctrl_ISO2631_Ctrl(void)
{
return cSWITCH;
}
real_T Rte_IRead_BandPass_Runnable_BandPass_Step_ISO2631_in_ISO2631_in(void)
{
return *pIn++;
}
/* Model step function */
void Runnable_BandPass_Step(void)
{
real_T denAccum;
real_T denAccum_0;
real_T denAccum_1;
real_T denAccum_2;
real_T denAccum_3;
real_T denAccum_4;
real_T denAccum_5;
real_T denAccum_6;
real_T denAccum_7;
real_T denAccum_8;
real_T denAccum_9;
real_T rtb_TmpSignalConversionAtISO2_i;
real_T rtb_MultiportSwitch;
/* SignalConversion: '<Root>/TmpSignal ConversionAtISO2631_inOutport2' incorporates:
* Inport: '<Root>/ISO2631_in'
*/
rtb_TmpSignalConversionAtISO2_i =
Rte_IRead_Runnable_BandPass_Step_ISO2631_in_ISO2631_in();
/* DiscreteFilter: '<S2>/Band Pass Filter' */
denAccum = ((((rtb_TmpSignalConversionAtISO2_i -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[0]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator[2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[1]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[2]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[3]) /
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator[0];
/* DiscreteFilter: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
denAccum_0 = ((((((((ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator
[0] * denAccum +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator
[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[0])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator[
2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[1])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator
[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[2]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[3]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_g
[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele
[0]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_g
[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele
[1]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_g[
3] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[
2]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_g
[4] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele
[3]) /
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_g[0];
/* DiscreteFilter: '<S3>/Band Pass Filter' */
denAccum_1 = ((((rtb_TmpSignalConversionAtISO2_i -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_e
[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[0]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_e[2]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[1])
- ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_e
[3] * ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[2])
- ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_e[4]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[3]) /
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_e[0];
/* DiscreteFilter: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
denAccum_2 = ((((((ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_n
[0] * denAccum_1 +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_n
[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[0])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_n[
2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[1])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_n
[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[2]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_n[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[3]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_o[
1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[
0]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_o
[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o
[1]) /
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_o[0];
/* DiscreteFilter: '<S4>/Band Pass Filter' */
denAccum_3 = ((((rtb_TmpSignalConversionAtISO2_i -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_h
[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[0]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_h[2]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[1])
- ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_h
[3] * ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[2])
- ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_h[4]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[3]) /
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_h[0];
/* DiscreteFilter: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
denAccum_4 =
((((((((ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_e[0] *
denAccum_3 +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_e[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[0]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_e[2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[1]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_e[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[2]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_e[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[3]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_j[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[0]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_j[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[1]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_j[3] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[2]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_j[4] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[3]) /
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_j[0];
/* DiscreteFilter: '<S5>/Band Pass Filter' */
denAccum_5 = ((((rtb_TmpSignalConversionAtISO2_i -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_en[
1] * ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h
[0]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_en
[2] * ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h
[1]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_en[3]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[2]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_en[4]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[3]) /
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_en[0];
/* DiscreteFilter: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
denAccum_6 =
((((((ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_na[0] *
denAccum_5 +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_na[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[0]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_na[2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[1]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_na[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[2]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_na[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[3]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_a[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[0]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_a[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[1]) /
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_a[0];
/* DiscreteFilter: '<S6>/Band Pass Filter' */
denAccum_7 = ((((rtb_TmpSignalConversionAtISO2_i -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_hj[
1] * ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m
[0]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_hj
[2] * ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m
[1]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_hj[3]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[2]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_hj[4]
* ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[3]) /
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_hj[0];
/* DiscreteFilter: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
denAccum_8 = ((((((ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_d
[0] * denAccum_7 +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_d
[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[0])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_d[
2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[1])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_d
[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[2]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_d[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[3]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_fi[
1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[
0]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_fi
[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb
[1]) /
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_fi[0];
/* DiscreteFilter: '<S7>/Band Pass Filter' */
rtb_TmpSignalConversionAtISO2_i = ((((rtb_TmpSignalConversionAtISO2_i -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_b[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[0]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_b[2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[1]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_b[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[2]) -
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_b[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[3]) /
ISO2631_All_GenerationTemplat_P.BandPassFilter_Denominator_b[0];
/* DiscreteFilter: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
denAccum_9 = ((((((ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_i
[0] * rtb_TmpSignalConversionAtISO2_i +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_i
[1] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[0])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_i[
2] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[1])
+ ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_i
[3] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[2]) +
ISO2631_All_GenerationTemplat_P.BandPassFilter_Numerator_i[4] *
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[3]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_jz[
1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[
0]) -
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_jz
[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h
[1]) /
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_jz[0];
/* MultiPortSwitch: '<S1>/Multiport Switch' incorporates:
* Inport: '<Root>/ISO2631_Ctrl'
* SignalConversion: '<Root>/TmpSignal ConversionAtISO2631_CtrlOutport2'
*/
switch ((int16_T)Rte_IRead_Runnable_BandPass_Step_ISO2631_Ctrl_ISO2631_Ctrl())
{
case 1L:
rtb_MultiportSwitch =
(((ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_i[0] *
denAccum_0 +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_i[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[0]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_i[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[1]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_i[3] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[2]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_i[4] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[3];
break;
case 2L:
rtb_MultiportSwitch =
(ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_n[0] *
denAccum_2 +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_n[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[0]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_n[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[1];
break;
case 3L:
rtb_MultiportSwitch =
(((ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_e[0] *
denAccum_4 +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_e[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[0]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_e[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[1]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_e[3] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[2]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_e[4] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[3];
break;
case 4L:
rtb_MultiportSwitch =
(ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_k[0] *
denAccum_6 +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_k[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[0]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_k[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[1];
break;
case 5L:
rtb_MultiportSwitch =
(ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_fk[0] *
denAccum_8 +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_fk[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[0]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_fk[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[1];
break;
default:
rtb_MultiportSwitch =
(ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_ez[0] *
denAccum_9 +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_ez[1] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[0]) +
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_ez[2] *
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[1];
break;
}
/* SignalConversion: '<Root>/TmpSignal ConversionAtFilterOutInport2' */
Rte_IWrite_Runnable_BandPass_Step_FilterOut_FilterOut(rtb_MultiportSwitch);
/* Update for DiscreteFilter: '<S2>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[3] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[2];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[2] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[1];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[1] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[0];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[0] = denAccum;
/* Update for DiscreteFilter: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[3] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[2];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[2] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[1];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[1] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[0];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[0] =
denAccum_0;
/* Update for DiscreteFilter: '<S3>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[3] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[2];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[2] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[1];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[1] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[0];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[0] = denAccum_1;
/* Update for DiscreteFilter: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[1] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[0];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[0] =
denAccum_2;
/* Update for DiscreteFilter: '<S4>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[3] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[2];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[2] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[1];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[1] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[0];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[0] = denAccum_3;
/* Update for DiscreteFilter: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[3] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[2];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[2] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[1];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[1] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[0];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[0] =
denAccum_4;
/* Update for DiscreteFilter: '<S5>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[3] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[2];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[2] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[1];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[1] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[0];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[0] = denAccum_5;
/* Update for DiscreteFilter: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[1] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[0];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[0] =
denAccum_6;
/* Update for DiscreteFilter: '<S6>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[3] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[2];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[2] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[1];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[1] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[0];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[0] = denAccum_7;
/* Update for DiscreteFilter: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[1] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[0];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[0] =
denAccum_8;
/* Update for DiscreteFilter: '<S7>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[3] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[2];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[2] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[1];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[1] =
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[0];
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[0] =
rtb_TmpSignalConversionAtISO2_i;
/* Update for DiscreteFilter: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[1] =
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[0];
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[0] =
denAccum_9;
}
/* Model initialize function */
void Runnable_BandPass_Init(void)
{
/* InitializeConditions for DiscreteFilter: '<S2>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[0] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates;
/* InitializeConditions for DiscreteFilter: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[0] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAccele;
/* InitializeConditions for DiscreteFilter: '<S3>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[0] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_f;
/* InitializeConditions for DiscreteFilter: '<S2>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[1] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates;
/* InitializeConditions for DiscreteFilter: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[1] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAccele;
/* InitializeConditions for DiscreteFilter: '<S3>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[1] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_f;
/* InitializeConditions for DiscreteFilter: '<S2>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[2] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates;
/* InitializeConditions for DiscreteFilter: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[2] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAccele;
/* InitializeConditions for DiscreteFilter: '<S3>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[2] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_f;
/* InitializeConditions for DiscreteFilter: '<S2>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE[3] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates;
/* InitializeConditions for DiscreteFilter: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAccele[3] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAccele;
/* InitializeConditions for DiscreteFilter: '<S3>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_e[3] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_f;
/* InitializeConditions for DiscreteFilter: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[0] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_f;
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_o[1] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_f;
/* InitializeConditions for DiscreteFilter: '<S4>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[0] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_b;
/* InitializeConditions for DiscreteFilter: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[0] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_h;
/* InitializeConditions for DiscreteFilter: '<S5>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[0] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_e;
/* InitializeConditions for DiscreteFilter: '<S4>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[1] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_b;
/* InitializeConditions for DiscreteFilter: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[1] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_h;
/* InitializeConditions for DiscreteFilter: '<S5>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[1] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_e;
/* InitializeConditions for DiscreteFilter: '<S4>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[2] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_b;
/* InitializeConditions for DiscreteFilter: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[2] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_h;
/* InitializeConditions for DiscreteFilter: '<S5>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[2] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_e;
/* InitializeConditions for DiscreteFilter: '<S4>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_i[3] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_b;
/* InitializeConditions for DiscreteFilter: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_l[3] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcce_h;
/* InitializeConditions for DiscreteFilter: '<S5>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_h[3] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_e;
/* InitializeConditions for DiscreteFilter: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[0] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_gu;
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_j[1] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_gu;
/* InitializeConditions for DiscreteFilter: '<S6>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[0] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_d;
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[1] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_d;
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[2] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_d;
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_m[3] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_d;
/* InitializeConditions for DiscreteFilter: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[0] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_e5;
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcc_lb[1] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_e5;
/* InitializeConditions for DiscreteFilter: '<S7>/Band Pass Filter' */
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[0] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_o;
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[1] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_o;
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[2] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_o;
ISO2631_All_GenerationTem_DWork.BandPassFilter_DSTATE_a[3] =
ISO2631_All_GenerationTemplat_P.BandPassFilter_InitialStates_o;
/* InitializeConditions for DiscreteFilter: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[0] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_ey;
ISO2631_All_GenerationTem_DWork.weightingtransferfunctionAcce_h[1] =
ISO2631_All_GenerationTemplat_P.weightingtransferfunctionAcc_ey;
}
void InitPorts(void)
{
EALLOW;
// Set necessary pins as outputs
GpioCtrlRegs.GPADIR.all = 0;
GpioCtrlRegs.GPADIR.bit.GPIO9 = 1; // peripheral explorer: LED LD1 at GPIO9
GpioCtrlRegs.GPADIR.bit.GPIO11 = 1; // peripheral explorer: LED LD2 at GPIO11
GpioCtrlRegs.GPBDIR.all = 0; // GPIO63-32 as inputs
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // peripheral explorer: LED LD3 at GPIO34
GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1; // peripheral explorer: LED LD4 at GPIO49
//Switch off all LEDs
GpioDataRegs.GPACLEAR.bit.GPIO9 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO11 = 1;
GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;
GpioDataRegs.GPBCLEAR.bit.GPIO49 = 1;
EDIS;
}
void ProcessISO2631()
{
volatile int i;
InitPorts();
memset(
(D_Work_ISO2631_All_GenerationTe*)&ISO2631_All_GenerationTem_DWork,
0,
sizeof(ISO2631_All_GenerationTem_DWork)
);
Runnable_BandPass_Init();
for(i = 0; i< 10; i++)
{
EALLOW;
GpioDataRegs.GPASET.bit.GPIO9 = 1;
EDIS;
Runnable_BandPass_Step();
EALLOW;
GpioDataRegs.GPACLEAR.bit.GPIO9 = 1;
EDIS;
}
while(1)
{
i++;
}
}
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | ISO2631_All_GenerationTemplate_private.h | <filename>ISO2631_All_GenerationTemplate_private.h
/*
* File: ISO2631_All_GenerationTemplate_private.h
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_ISO2631_All_GenerationTemplate_private_h_
#define RTW_HEADER_ISO2631_All_GenerationTemplate_private_h_
#include "rtwtypes.h"
#ifndef __RTWTYPES_H__
#error This file requires rtwtypes.h to be included
#else
#ifdef TMWTYPES_PREVIOUSLY_INCLUDED
#error This file requires rtwtypes.h to be included before tmwtypes.h
#else
/* Check for inclusion of an incorrect version of rtwtypes.h */
#ifndef RTWTYPES_ID_C16S16I16L32N16F1
#error This code was generated with a different "rtwtypes.h" than the file included
#endif /* RTWTYPES_ID_C16S16I16L32N16F1 */
#endif /* TMWTYPES_PREVIOUSLY_INCLUDED */
#endif /* __RTWTYPES_H__ */
#endif /* RTW_HEADER_ISO2631_All_GenerationTemplate_private_h_ */
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | ISO2631_All_GenerationTemplate_data.c | <reponame>janiex/TheRQMProject
/*
* File: ISO2631_All_GenerationTemplate_data.c
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "ISO2631_All_GenerationTemplate.h"
#include "ISO2631_All_GenerationTemplate_private.h"
/* Block parameters (auto storage) */
Parameters_ISO2631_All_Generati ISO2631_All_GenerationTemplat_P = {
0.0, /* Expression: 0
* Referenced by: '<S2>/Band Pass Filter'
*/
/* Expression: [0.0638508113542868 1.33226762955019E-15 -0.127701622708578 4.2188474935756E-15 0.0638508113542855
]
* Referenced by: '<S2>/Band Pass Filter'
*/
{ 0.0638508113542868, 1.33226762955019E-15, -0.127701622708578,
4.2188474935756E-15, 0.0638508113542855 },
/* Expression: [1.0 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S2>/Band Pass Filter'
*/
{ 1.0, -3.16470636644551, 3.75293919582273, -2.01084465327318,
0.422613437162517 },
0.0, /* Expression: 0
* Referenced by: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
/* Expression: [0.0382312829345277 -0.0729444373075823 -0.0034621921267961 0.0729450727468253 -0.0347684553684901
]
* Referenced by: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 0.0382312829345277, -0.0729444373075823, -0.0034621921267961,
0.0729450727468253, -0.0347684553684901 },
/* Expression: [1.0 -3.85371908982878 5.57025894073329 -3.57917165034607 0.862634338641796
]
* Referenced by: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 1.0, -3.85371908982878, 5.57025894073329, -3.57917165034607,
0.862634338641796 },
0.0, /* Expression: 0
* Referenced by: '<S3>/Band Pass Filter'
*/
/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S3>/Band Pass Filter'
*/
{ 0.0638508113542868, 1.33226762955019E-15, -0.127701622708578,
4.2188474935756E-15, 0.0638508113542855 },
/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S3>/Band Pass Filter'
*/
{ 1.0, -3.16470636644551, 3.75293919582273, -2.01084465327318,
0.422613437162517 },
0.0, /* Expression: 0
* Referenced by: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
/* Expression: [0.00625998383111404 7.81740945390297e-05 -0.00618180973657412]
* Referenced by: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 0.00625998383111404, 7.81740945390297E-5, -0.00618180973657412 },
/* Expression: [1 -1.98009477313205 0.980251121321129]
* Referenced by: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 1.0, -1.98009477313205, 0.980251121321129 },
0.0, /* Expression: 0
* Referenced by: '<S4>/Band Pass Filter'
*/
/* Expression: [3.90490872548277e-06 1.33226762955019e-15 -7.80981745673870e-06 6.66133814775094e-15 3.90490872359539e-06]
* Referenced by: '<S4>/Band Pass Filter'
*/
{ 3.90490872548277E-6, 1.33226762955019E-15, -7.8098174567387E-6,
6.66133814775094E-15, 3.90490872359539E-6 },
/* Expression: [1 -3.99369112814028 5.98109324158920 -3.98111308623633 0.993710972791352]
* Referenced by: '<S4>/Band Pass Filter'
*/
{ 1.0, -3.99369112814028, 5.9810932415892, -3.98111308623633,
0.993710972791352 },
0.0, /* Expression: 0
* Referenced by: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
/* Expression: [6.16196311309381e-07 3.02496694359888e-10 -1.23209003710656e-06 -3.02301739196764e-10 6.15893909761134e-07]
* Referenced by: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 6.16196311309381E-7, 3.02496694359888E-10, -1.23209003710656E-6,
-3.02301739196764E-10, 6.15893909761134E-7 },
/* Expression: [1 -3.99738721075116 5.99216592735038 -3.99217021978984 0.997391503191591]
* Referenced by: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 1.0, -3.99738721075116, 5.99216592735038, -3.99217021978984,
0.997391503191591 },
0.0, /* Expression: 0
* Referenced by: '<S5>/Band Pass Filter'
*/
/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S5>/Band Pass Filter'
*/
{ 0.0638508113542868, 1.33226762955019E-15, -0.127701622708578,
4.2188474935756E-15, 0.0638508113542855 },
/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517
]
* Referenced by: '<S5>/Band Pass Filter'
*/
{ 1.0, -3.16470636644551, 3.75293919582273, -2.01084465327318,
0.422613437162517 },
0.0, /* Expression: 0
* Referenced by: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
/* Expression: [0.0247609605891664 0.00121410777362563 -0.0235468528155406]
* Referenced by: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 0.0247609605891664, 0.00121410777362563, -0.0235468528155406 },
/* Expression: [1 -1.92089271555639 0.923320931103639]
* Referenced by: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 1.0, -1.92089271555639, 0.923320931103639 },
0.0, /* Expression: 0
* Referenced by: '<S6>/Band Pass Filter'
*/
/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S6>/Band Pass Filter'
*/
{ 0.0638508113542868, 1.33226762955019E-15, -0.127701622708578,
4.2188474935756E-15, 0.0638508113542855 },
/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S6>/Band Pass Filter'
*/
{ 1.0, -3.16470636644551, 3.75293919582273, -2.01084465327318,
0.422613437162517 },
0.0, /* Expression: 0
* Referenced by: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
/* Expression: [0.00313579418517251 1.96410717046014e-05 -0.00311615311346891]
* Referenced by: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 0.00313579418517251, 1.96410717046014E-5, -0.00311615311346891 },
/* Expression: [1 -1.99003699198573 0.990076274129142]
* Referenced by: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 1.0, -1.99003699198573, 0.990076274129142 },
0.0, /* Expression: 0
* Referenced by: '<S7>/Band Pass Filter'
*/
/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S7>/Band Pass Filter'
*/
{ 0.0638508113542868, 1.33226762955019E-15, -0.127701622708578,
4.2188474935756E-15, 0.0638508113542855 },
/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S7>/Band Pass Filter'
*/
{ 1.0, -3.16470636644551, 3.75293919582273, -2.01084465327318,
0.422613437162517 },
0.0, /* Expression: 0
* Referenced by: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
/* Expression: [0.994541131125826 -1.96311895053930 0.969122822764292]
* Referenced by: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 0.994541131125826, -1.9631189505393, 0.969122822764292 },
/* Expression: [1 -1.96284301122498 0.963939893204438]
* Referenced by: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
{ 1.0, -1.96284301122498, 0.963939893204438 }
};
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | HW/DSP2833x_ECap.h | <gh_stars>0
/*******************************************************************************
** **
** SRC-MODULE: DSP2833x_ECap.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
// TI File $Revision: /main/1 $
// Checkin $Date: August 18, 2006 13:52:07 $
//###########################################################################
//
// FILE: DSP2833x_ECap.h
//
// TITLE: DSP2833x Enhanced Capture Module Register Bit Definitions.
//
//###########################################################################
// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
// $Release Date: August 4, 2009 $
//###########################################################################
#ifndef DSP2833x_ECAP_H
#define DSP2833x_ECAP_H
#ifdef __cplusplus
extern "C" {
#endif
//----------------------------------------------------
// Capture control register 1 bit definitions */
struct ECCTL1_BITS { // bits description
uint16 CAP1POL:1; // 0 Capture Event 1 Polarity select
uint16 CTRRST1:1; // 1 Counter Reset on Capture Event 1
uint16 CAP2POL:1; // 2 Capture Event 2 Polarity select
uint16 CTRRST2:1; // 3 Counter Reset on Capture Event 2
uint16 CAP3POL:1; // 4 Capture Event 3 Polarity select
uint16 CTRRST3:1; // 5 Counter Reset on Capture Event 3
uint16 CAP4POL:1; // 6 Capture Event 4 Polarity select
uint16 CTRRST4:1; // 7 Counter Reset on Capture Event 4
uint16 CAPLDEN:1; // 8 Enable Loading CAP1-4 regs on a Cap Event
uint16 PRESCALE:5; // 13:9 Event Filter prescale select
uint16 FREE_SOFT:2; // 15:14 Emulation mode
};
union ECCTL1_REG {
uint16 all;
struct ECCTL1_BITS bit;
};
// In V1.1 the STOPVALUE bit field was changed to
// STOP_WRAP. This correlated to a silicon change from
// F2833x Rev 0 to Rev A.
//----------------------------------------------------
// Capture control register 2 bit definitions */
struct ECCTL2_BITS { // bits description
uint16 CONT_ONESHT:1; // 0 Continuous or one-shot
uint16 STOP_WRAP:2; // 2:1 Stop value for one-shot, Wrap for continuous
uint16 REARM:1; // 3 One-shot re-arm
uint16 TSCTRSTOP:1; // 4 TSCNT counter stop
uint16 SYNCI_EN:1; // 5 Counter sync-in select
uint16 SYNCO_SEL:2; // 7:6 Sync-out mode
uint16 SWSYNC:1; // 8 SW forced counter sync
uint16 CAP_APWM:1; // 9 CAP/APWM operating mode select
uint16 APWMPOL:1; // 10 APWM output polarity select
uint16 rsvd1:5; // 15:11
};
union ECCTL2_REG {
uint16 all;
struct ECCTL2_BITS bit;
};
//----------------------------------------------------
// ECAP interrupt enable register bit definitions */
struct ECEINT_BITS { // bits description
uint16 rsvd1:1; // 0 reserved
uint16 CEVT1:1; // 1 Capture Event 1 Interrupt Enable
uint16 CEVT2:1; // 2 Capture Event 2 Interrupt Enable
uint16 CEVT3:1; // 3 Capture Event 3 Interrupt Enable
uint16 CEVT4:1; // 4 Capture Event 4 Interrupt Enable
uint16 CTROVF:1; // 5 Counter Overflow Interrupt Enable
uint16 CTR_EQ_PRD:1; // 6 Period Equal Interrupt Enable
uint16 CTR_EQ_CMP:1; // 7 Compare Equal Interrupt Enable
uint16 rsvd2:8; // 15:8 reserved
};
union ECEINT_REG {
uint16 all;
struct ECEINT_BITS bit;
};
//----------------------------------------------------
// ECAP interrupt flag register bit definitions */
struct ECFLG_BITS { // bits description
uint16 INT:1; // 0 Global Flag
uint16 CEVT1:1; // 1 Capture Event 1 Interrupt Flag
uint16 CEVT2:1; // 2 Capture Event 2 Interrupt Flag
uint16 CEVT3:1; // 3 Capture Event 3 Interrupt Flag
uint16 CEVT4:1; // 4 Capture Event 4 Interrupt Flag
uint16 CTROVF:1; // 5 Counter Overflow Interrupt Flag
uint16 CTR_EQ_PRD:1; // 6 Period Equal Interrupt Flag
uint16 CTR_EQ_CMP:1; // 7 Compare Equal Interrupt Flag
uint16 rsvd2:8; // 15:8 reserved
};
union ECFLG_REG {
uint16 all;
struct ECFLG_BITS bit;
};
//----------------------------------------------------
struct ECAP_REGS {
uint32 TSCTR; // Time stamp counter
uint32 CTRPHS; // Counter phase
uint32 CAP1; // Capture 1
uint32 CAP2; // Capture 2
uint32 CAP3; // Capture 3
uint32 CAP4; // Capture 4
uint16 rsvd1[8]; // reserved
union ECCTL1_REG ECCTL1; // Capture Control Reg 1
union ECCTL2_REG ECCTL2; // Capture Control Reg 2
union ECEINT_REG ECEINT; // ECAP interrupt enable
union ECFLG_REG ECFLG; // ECAP interrupt flags
union ECFLG_REG ECCLR; // ECAP interrupt clear
union ECEINT_REG ECFRC; // ECAP interrupt force
uint16 rsvd2[6]; // reserved
};
//---------------------------------------------------------------------------
// GPI/O External References & Function Declarations:
//
extern volatile struct ECAP_REGS ECap1Regs;
extern volatile struct ECAP_REGS ECap2Regs;
extern volatile struct ECAP_REGS ECap3Regs;
extern volatile struct ECAP_REGS ECap4Regs;
extern volatile struct ECAP_REGS ECap5Regs;
extern volatile struct ECAP_REGS ECap6Regs;
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // end of DSP2833x_ECAP_H definition
//===========================================================================
// End of file.
//===========================================================================
/* EOF */
|
janiex/TheRQMProject | ADXL345.h | <reponame>janiex/TheRQMProject
#include "OS_Types.h"
#include "DSP2833x_I2c.h"
#include "DSP2833x_Device.h"
#ifndef ADXL345_H_
#define ADXL345_H_
#define ADXL345_CHIP_ID 0xE5 // Chip ID should be 0xE5
#define ADXL345_DATA_FORMAT 0x31 // X,Y,Z format of the data
#define ADXL345_DATAX0 0x32 // R X-Axis Data 0.
#define ADXL345_DATAX1 0x33 // R X-Axis Data 1.
#define ADXL345_DATAY0 0x34 // R Y-Axis Data 0.
#define ADXL345_DATAY1 0x35 // R Y-Axis Data 1.
#define ADXL345_DATAZ0 0x36 // R Z-Axis Data 0.
#define ADXL345_DATAZ1 0x37 // R Z-Axis Data 1.
#define SLAVE_ADDR 0x1D //ADXL345 -> if ALT_ADDRESS pin is grounded!
#define CONF_16g_TEST_OFF 0x0B //SELF-TEST O
#define POWER_CTL 0x2D
#define DATA_FORMAT 0x31
#define Register_X0 0x32
#define Register_X1 0x33
#define Register_Y0 0x34
#define Register_Y1 0x35
#define Register_Z0 0x36
#define Register_Z1 0x37
#define Register_device_ID 0x00
/* ADXL345_POWER_CTL definition */
#define ADXL345_PCTL_LINK (1 << 5)
#define ADXL345_PCTL_AUTO_SLEEP (1 << 4)
#define ADXL345_PCTL_MEASURE (1 << 3)
#define ADXL345_PCTL_SLEEP (1 << 2)
#define ADXL345_PCTL_WAKEUP(x) ((x) & 0x3)
//--------------------------------------------
// Defines
//--------------------------------------------
// Error Messages
#define I2C_ERROR 0xFFFF
#define I2C_ARB_LOST_ERROR 0x0001
#define I2C_NACK_ERROR 0x0002
#define I2C_BUS_BUSY_ERROR 0x1000
#define I2C_STP_NOT_READY_ERROR 0x5555
#define I2C_NO_FLAGS 0xAAAA
#define I2C_SUCCESS 0x0000
// Clear Status Flags
#define I2C_CLR_AL_BIT 0x0001
#define I2C_CLR_NACK_BIT 0x0002
#define I2C_CLR_ARDY_BIT 0x0004
#define I2C_CLR_RRDY_BIT 0x0008
#define I2C_CLR_SCD_BIT 0x0020
// Interrupt Source Messages
#define I2C_NO_ISRC 0x0000
#define I2C_ARB_ISRC 0x0001
#define I2C_NACK_ISRC 0x0002
#define I2C_ARDY_ISRC 0x0003
#define I2C_RX_ISRC 0x0004
#define I2C_TX_ISRC 0x0005
#define I2C_SCD_ISRC 0x0006
#define I2C_AAS_ISRC 0x0007
// I2CMSG structure defines
#define I2C_NO_STOP 0
#define I2C_YES_STOP 1
#define I2C_RECEIVE 0
#define I2C_TRANSMIT 1
#define I2C_MAX_BUFFER_SIZE 16
// I2C Slave State defines
#define I2C_NOTSLAVE 0
#define I2C_ADDR_AS_SLAVE 1
#define I2C_ST_MSG_READY 2
// I2C Slave Receiver messages defines
#define I2C_SND_MSG1 1
#define I2C_SND_MSG2 2
// I2C State defines
#define I2C_IDLE 0
#define I2C_SLAVE_RECEIVER 1
#define I2C_SLAVE_TRANSMITTER 2
#define I2C_MASTER_RECEIVER 3
#define I2C_MASTER_TRANSMITTER 4
// I2C Message Commands for I2CMSG struct
#define I2C_MSGSTAT_INACTIVE 0x0000
#define I2C_MSGSTAT_SEND_WITHSTOP 0x0010
#define I2C_MSGSTAT_WRITE_BUSY 0x0011
#define I2C_MSGSTAT_SEND_NOSTOP 0x0020
#define I2C_MSGSTAT_SEND_NOSTOP_BUSY 0x0021
#define I2C_MSGSTAT_RESTART 0x0022
#define I2C_MSGSTAT_READ_BUSY 0x0023
// Generic defines
#define I2C_TRUE 1
#define I2C_FALSE 0
#define I2C_YES 1
#define I2C_NO 0
#define I2C_DUMMY_BYTE 0
//--------------------------------------------
// Structures
//--------------------------------------------
// I2C Message Structure
struct I2CMSG {
uint16 MsgStatus; // Word stating what state msg is in:
// I2C_MSGCMD_INACTIVE = do not send msg
// I2C_MSGCMD_BUSY = msg start has been sent,
// awaiting stop
// I2C_MSGCMD_SEND_WITHSTOP = command to send
// master trans msg complete with a stop bit
// I2C_MSGCMD_SEND_NOSTOP = command to send
// master trans msg without the stop bit
// I2C_MSGCMD_RESTART = command to send a restart
// as a master receiver with a stop bit
uint16 SlaveAddress; // I2C address of slave msg is intended for
uint16 NumOfBytes; // Num of valid bytes in (or to be put in MsgBuffer)
uint16 MemoryHighAddr; // EEPROM address of data associated with msg (high byte)
uint16 MemoryLowAddr; // EEPROM address of data associated with msg (low byte)
uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data - max that
// MAX_BUFFER_SIZE can be is 16 due to
// the FIFO's
};
//*****************************************************************************
// Function Prototypes
//*****************************************************************************
void I2C_Init(void);
void I2C_Write(uint16 reg_address, uint16 data);
uint16 I2C_Read(uint16 reg_address);
void InitI2CGpio(void);
#endif /*ADXL345_H_*/
|
janiex/TheRQMProject | ISO2631_All_GenerationTemplate.h | <gh_stars>0
/*
* File: ISO2631_All_GenerationTemplate.h
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_ISO2631_All_GenerationTemplate_h_
#define RTW_HEADER_ISO2631_All_GenerationTemplate_h_
#ifndef ISO2631_All_GenerationTemplate_COMMON_INCLUDES_
# define ISO2631_All_GenerationTemplate_COMMON_INCLUDES_
#include "rtwtypes.h"
#include "Rte_BandPass.h"
#endif /* ISO2631_All_GenerationTemplate_COMMON_INCLUDES_ */
#include "ISO2631_All_GenerationTemplate_types.h"
/* Macros for accessing real-time model data structure */
#ifndef rtmGetErrorStatus
# define rtmGetErrorStatus(rtm) ((void*) 0)
#endif
#ifndef rtmSetErrorStatus
# define rtmSetErrorStatus(rtm, val) ((void) 0)
#endif
#ifndef rtmGetStopRequested
# define rtmGetStopRequested(rtm) ((void*) 0)
#endif
#define ISO2631_All_GenerationTemplate_M (ISO2631_All_GenerationTempla_M)
/* Block states (auto storage) for system '<Root>' */
typedef struct tag_D_Work_ISO2631_All_Generati {
real_T BandPassFilter_DSTATE[4]; /* '<S2>/Band Pass Filter' */
real_T weightingtransferfunctionAccele[4];/* '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
real_T BandPassFilter_DSTATE_e[4]; /* '<S3>/Band Pass Filter' */
real_T weightingtransferfunctionAcce_o[2];/* '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
real_T BandPassFilter_DSTATE_i[4]; /* '<S4>/Band Pass Filter' */
real_T weightingtransferfunctionAcce_l[4];/* '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
real_T BandPassFilter_DSTATE_h[4]; /* '<S5>/Band Pass Filter' */
real_T weightingtransferfunctionAcce_j[2];/* '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
real_T BandPassFilter_DSTATE_m[4]; /* '<S6>/Band Pass Filter' */
real_T weightingtransferfunctionAcc_lb[2];/* '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
real_T BandPassFilter_DSTATE_a[4]; /* '<S7>/Band Pass Filter' */
real_T weightingtransferfunctionAcce_h[2];/* '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)' */
} D_Work_ISO2631_All_GenerationTe;
/* Parameters (auto storage) */
struct Parameters_ISO2631_All_Generati_ {
real_T BandPassFilter_InitialStates; /* Expression: 0
* Referenced by: '<S2>/Band Pass Filter'
*/
real_T BandPassFilter_Numerator[5]; /* Expression: [0.0638508113542868 1.33226762955019E-15 -0.127701622708578 4.2188474935756E-15 0.0638508113542855
]
* Referenced by: '<S2>/Band Pass Filter'
*/
real_T BandPassFilter_Denominator[5];/* Expression: [1.0 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S2>/Band Pass Filter'
*/
real_T weightingtransferfunctionAccele;/* Expression: 0
* Referenced by: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_i[5];/* Expression: [0.0382312829345277 -0.0729444373075823 -0.0034621921267961 0.0729450727468253 -0.0347684553684901
]
* Referenced by: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_g[5];/* Expression: [1.0 -3.85371908982878 5.57025894073329 -3.57917165034607 0.862634338641796
]
* Referenced by: '<S2>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T BandPassFilter_InitialStates_f;/* Expression: 0
* Referenced by: '<S3>/Band Pass Filter'
*/
real_T BandPassFilter_Numerator_n[5];/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S3>/Band Pass Filter'
*/
real_T BandPassFilter_Denominator_e[5];/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S3>/Band Pass Filter'
*/
real_T weightingtransferfunctionAcce_f;/* Expression: 0
* Referenced by: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_n[3];/* Expression: [0.00625998383111404 7.81740945390297e-05 -0.00618180973657412]
* Referenced by: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_o[3];/* Expression: [1 -1.98009477313205 0.980251121321129]
* Referenced by: '<S3>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T BandPassFilter_InitialStates_b;/* Expression: 0
* Referenced by: '<S4>/Band Pass Filter'
*/
real_T BandPassFilter_Numerator_e[5];/* Expression: [3.90490872548277e-06 1.33226762955019e-15 -7.80981745673870e-06 6.66133814775094e-15 3.90490872359539e-06]
* Referenced by: '<S4>/Band Pass Filter'
*/
real_T BandPassFilter_Denominator_h[5];/* Expression: [1 -3.99369112814028 5.98109324158920 -3.98111308623633 0.993710972791352]
* Referenced by: '<S4>/Band Pass Filter'
*/
real_T weightingtransferfunctionAcce_h;/* Expression: 0
* Referenced by: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_e[5];/* Expression: [6.16196311309381e-07 3.02496694359888e-10 -1.23209003710656e-06 -3.02301739196764e-10 6.15893909761134e-07]
* Referenced by: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_j[5];/* Expression: [1 -3.99738721075116 5.99216592735038 -3.99217021978984 0.997391503191591]
* Referenced by: '<S4>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T BandPassFilter_InitialStates_e;/* Expression: 0
* Referenced by: '<S5>/Band Pass Filter'
*/
real_T BandPassFilter_Numerator_na[5];/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S5>/Band Pass Filter'
*/
real_T BandPassFilter_Denominator_en[5];/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517
]
* Referenced by: '<S5>/Band Pass Filter'
*/
real_T weightingtransferfunctionAcc_gu;/* Expression: 0
* Referenced by: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_k[3];/* Expression: [0.0247609605891664 0.00121410777362563 -0.0235468528155406]
* Referenced by: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcce_a[3];/* Expression: [1 -1.92089271555639 0.923320931103639]
* Referenced by: '<S5>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T BandPassFilter_InitialStates_d;/* Expression: 0
* Referenced by: '<S6>/Band Pass Filter'
*/
real_T BandPassFilter_Numerator_d[5];/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S6>/Band Pass Filter'
*/
real_T BandPassFilter_Denominator_hj[5];/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S6>/Band Pass Filter'
*/
real_T weightingtransferfunctionAcc_e5;/* Expression: 0
* Referenced by: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcc_fk[3];/* Expression: [0.00313579418517251 1.96410717046014e-05 -0.00311615311346891]
* Referenced by: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcc_fi[3];/* Expression: [1 -1.99003699198573 0.990076274129142]
* Referenced by: '<S6>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T BandPassFilter_InitialStates_o;/* Expression: 0
* Referenced by: '<S7>/Band Pass Filter'
*/
real_T BandPassFilter_Numerator_i[5];/* Expression: [0.0638508113542868 1.33226762955019e-15 -0.127701622708578 4.21884749357560e-15 0.0638508113542855]
* Referenced by: '<S7>/Band Pass Filter'
*/
real_T BandPassFilter_Denominator_b[5];/* Expression: [1 -3.16470636644551 3.75293919582273 -2.01084465327318 0.422613437162517]
* Referenced by: '<S7>/Band Pass Filter'
*/
real_T weightingtransferfunctionAcc_ey;/* Expression: 0
* Referenced by: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcc_ez[3];/* Expression: [0.994541131125826 -1.96311895053930 0.969122822764292]
* Referenced by: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
real_T weightingtransferfunctionAcc_jz[3];/* Expression: [1 -1.96284301122498 0.963939893204438]
* Referenced by: '<S7>/weighting transfer function (Acceleration-velocity transition + Upward step filter)'
*/
};
/* Block parameters (auto storage) */
extern Parameters_ISO2631_All_Generati ISO2631_All_GenerationTemplat_P;
/* Block states (auto storage) */
extern D_Work_ISO2631_All_GenerationTe ISO2631_All_GenerationTem_DWork;
/* Model step and init functions */
extern void Runnable_BandPass_Step(void);
extern void Runnable_BandPass_Init(void);
/*-
* The generated code includes comments that allow you to trace directly
* back to the appropriate location in the model. The basic format
* is <system>/block_name, where system is the system number (uniquely
* assigned by Simulink) and block_name is the name of the block.
*
* Use the MATLAB hilite_system command to trace the generated code back
* to the model. For example,
*
* hilite_system('<S3>') - opens system 3
* hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
*
* Here is the system hierarchy for this model
*
* '<Root>' : ISO2631_All_GenerationTemplate
* '<S1>' : ISO2631_All_GenerationTemplate/ISO 2631
* '<S2>' : ISO2631_All_GenerationTemplate/ISO 2631/ISO2631 - Type1 Wk
* '<S3>' : ISO2631_All_GenerationTemplate/ISO 2631/ISO2631-Type2 Wd
* '<S4>' : ISO2631_All_GenerationTemplate/ISO 2631/ISO2631-Type3 Wf
* '<S5>' : ISO2631_All_GenerationTemplate/ISO 2631/ISO2631-Type4 Wc
* '<S6>' : ISO2631_All_GenerationTemplate/ISO 2631/ISO2631-Type5 We
* '<S7>' : ISO2631_All_GenerationTemplate/ISO 2631/ISO2631-Type6 Wj
*/
#endif /* RTW_HEADER_ISO2631_All_GenerationTemplate_h_ */
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | RTE/Rte_BandPass.h | /*
* File: Rte_BandPass.h
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_Rte_BandPass_h_
#define RTW_HEADER_Rte_BandPass_h_
/*
*
* This file contains dummy implementations of the AUTOSAR functions
* used by this model for testing the code generated from Simulink.
* Simulink invokes the generated code through its S-Function API.
* Note that this file is replaced with the real implementation
* when deploying the generated code outside of Simulink.
*
*/
#include <string.h>
#include "Rte_Type.h"
#include "Compiler.h"
#define Rte_IWrite_Runnable_BandPass_Step_FilterOut_FilterOut Rte_IWrite_BandPass_Runnable_BandPass_Step_FilterOut_FilterOut
void Rte_IWrite_Runnable_BandPass_Step_FilterOut_FilterOut(real_T u);
#define Rte_IRead_Runnable_BandPass_Step_ISO2631_Ctrl_ISO2631_Ctrl Rte_IRead_BandPass_Runnable_BandPass_Step_ISO2631_Ctrl_ISO2631_Ctrl
real_T Rte_IRead_Runnable_BandPass_Step_ISO2631_Ctrl_ISO2631_Ctrl(void);
#define Rte_IRead_Runnable_BandPass_Step_ISO2631_in_ISO2631_in Rte_IRead_BandPass_Runnable_BandPass_Step_ISO2631_in_ISO2631_in
real_T Rte_IRead_Runnable_BandPass_Step_ISO2631_in_ISO2631_in(void);
#endif /* RTW_HEADER_Rte_BandPass_h_ */
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | RTE/Rte_Type.h | /*
* File: Rte_Type.h
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_Rte_Type_h_
#define RTW_HEADER_Rte_Type_h_
#include "rtwtypes.h"
/*
*
* This file contains dummy implementations of the AUTOSAR functions
* used by this model for testing the code generated from Simulink.
* Simulink invokes the generated code through its S-Function API.
* Note that this file is replaced with the real implementation
* when deploying the generated code outside of Simulink.
*
*/
#ifndef _DEFINED_TYPEDEF_FOR_Boolean_
#define _DEFINED_TYPEDEF_FOR_Boolean_
typedef boolean_T Boolean;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_Double_
#define _DEFINED_TYPEDEF_FOR_Double_
typedef real_T Double;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_Float_
#define _DEFINED_TYPEDEF_FOR_Float_
typedef real32_T Float;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_SInt16_
#define _DEFINED_TYPEDEF_FOR_SInt16_
typedef int16_T SInt16;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_SInt32_
#define _DEFINED_TYPEDEF_FOR_SInt32_
typedef int32_T SInt32;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_SInt4_
#define _DEFINED_TYPEDEF_FOR_SInt4_
typedef int8_T SInt4;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_SInt8_
#define _DEFINED_TYPEDEF_FOR_SInt8_
typedef int8_T SInt8;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_UInt16_
#define _DEFINED_TYPEDEF_FOR_UInt16_
typedef uint16_T UInt16;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_UInt32_
#define _DEFINED_TYPEDEF_FOR_UInt32_
typedef uint32_T UInt32;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_UInt4_
#define _DEFINED_TYPEDEF_FOR_UInt4_
typedef uint8_T UInt4;
#endif
#ifndef _DEFINED_TYPEDEF_FOR_UInt8_
#define _DEFINED_TYPEDEF_FOR_UInt8_
typedef uint8_T UInt8;
#endif
typedef uint8_T Rte_Instance;
#endif /* RTW_HEADER_Rte_Type_h_ */
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | HW/Identification.h | <gh_stars>0
#define MAGIC_NUMBER 30511208
|
janiex/TheRQMProject | Include/Std_types.h | <gh_stars>0
/*******************************************************************************
** **
** SRC-MODULE: Std_types.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#ifndef STD_TYPES_
#define STD_TYPES_
/**********************************************************************************************************************
* INCLUDES
*********************************************************************************************************************/
# include "Platform_Types.h"
# include "Compiler.h"
/**********************************************************************************************************************
* STANDARD CONSTANTS
*********************************************************************************************************************/
# define STD_HIGH ((uint8)1u) /* Physical state 5V or 3.3V */
# define STD_LOW ((uint8)0u) /* Physical state 0V */
# define STD_ACTIVE 1u /* Logical state active */
# define STD_IDLE 0u /* Logical state idle */
# define STD_ON 1u
# define STD_OFF 0u
#ifdef _QAC_
#define STD_RET_TYPE_CAST (uint8)
#else
#define STD_RET_TYPE_CAST
#endif
/* This typedef has been added for OSEK compliance */
# ifndef STATUSTYPEDEFINED
# define STATUSTYPEDEFINED
# define E_OK (STD_RET_TYPE_CAST 0u)
typedef unsigned char StatusType; /* OSEK compliance */
# endif
# define E_NOT_OK (STD_RET_TYPE_CAST 1u)
# define E_INVALIDARG (STD_RET_TYPE_CAST 2u)
# define E_FALSE (STD_RET_TYPE_CAST 3u)
# define E_PENDING (STD_RET_TYPE_CAST 4u)
# define E_POINTER (STD_RET_TYPE_CAST 5u)
# define NOT_IMPLEMENTED (STD_RET_TYPE_CAST 5u)
typedef uint16 Std_ReturnType;
#endif /*STD_TYPES_*/
/* EOF */
|
janiex/TheRQMProject | UserTasks.c | <reponame>janiex/TheRQMProject
/*******************************************************************************
** **
** SRC-MODULE: UserTasks.c **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#include "Task.h"
/*... Include necessary user includes */
#include "ADXL345.h"
/*****************************************************************************
* Task Name: Task_IDLE_code **
*****************************************************************************/
void Task_IDLE_code(void)
{
while(1)
{} /* Never ending task */
} /* End of Task_IDLE_code */
/*****************************************************************************
* Task Name: TASK_ACC **
*****************************************************************************/
signed short X_axis;
signed short Y_axis;
signed short Z_axis;
signed short X_axis;
float X_Data;
float Y_Data;
float Z_Data;
void TASK_ACC_code(void)
{
signed char tempL;
signed char tempH;
signed short temp;
tempL = I2C_Read(ADXL345_DATAX0);
tempH = I2C_Read(ADXL345_DATAX1);
X_axis = ((tempH<<8) | tempL);
X_axis = (X_axis<<2)/4;
X_Data = X_axis * (float)3.9;
tempL = I2C_Read(ADXL345_DATAY0);
tempH = I2C_Read(ADXL345_DATAY1);
Y_axis = ((tempH<<8) | tempL);
Y_axis = (Y_axis<<2)/4;
Y_Data = Y_axis * (float)3.9;
tempL = I2C_Read(ADXL345_DATAZ0);
tempH = I2C_Read(ADXL345_DATAZ1);
Z_axis = ((tempH<<8) | tempL);
Z_axis = (Z_axis<<2)/4;
Z_Data = Z_axis * (float)3.9;
TerminateTsk();
} /* End of TASK_ACC */
/*****************************************************************************
* Task Name: TASK_ISO2631 **
*****************************************************************************/
void TASK_ISO2631_code(void)
{
TerminateTsk();
} /* End of TASK_ISO2631 */
/*****************************************************************************
* Task Name: TASK_Init **
*****************************************************************************/
static unsigned char ReadID = 0;
void TASK_Init_code(void)
{
I2C_Init();
InitI2CGpio();
ReadID = I2C_Read(Register_device_ID);
if(ADXL345_CHIP_ID != ReadID)
{
while(1);
}
I2C_Write(POWER_CTL,ADXL345_PCTL_MEASURE);
I2C_Write(DATA_FORMAT,CONF_16g_TEST_OFF);
TerminateTsk();
} /* End of TASK_Init */
/* EOF */
|
janiex/TheRQMProject | Include/Alarm.h | <gh_stars>0
/*******************************************************************************
** **
** SRC-MODULE: Alarm.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#ifndef ALARM_H_
#define ALARM_H_
#include "OS_Types.h"
typedef struct {
CallbackType CallbackFunction;
TaskType TaskID;
#if(0 != EVENT_ENABLED)
EventMaskType Event;
#endif
CounterType Counter;
} AlarmActionInfoType;
/** \brief Alarm Variable Type */
typedef struct {
AlarmStateType AlarmState;
AlarmTimeType AlarmTime;
AlarmCycleTimeType AlarmCycleTime;
} AlarmVarType;
/** \brief Alarm Constant Type */
typedef struct {
CounterType Counter;
AlarmActionType AlarmAction;
AlarmActionInfoType AlarmActionInfo;
} AlarmConstType;
/** \brief Auto Start Alarm Type */
typedef struct {
AppModeType Mode;
AlarmType Alarm;
AlarmTimeType AlarmTime;
AlarmCycleTimeType AlarmCycleTime;
} AutoStartAlarmType;
/************************************************************************************
* EXPORTED FUNCTION *
************************************************************************************/
extern AlarmVarType AlarmsVar[];
extern const AlarmConstType AlarmsConst[];
extern AlarmIncrementType IncrementAlarm(AlarmType AlarmID, AlarmIncrementType Increment);
extern StatusType SetRelAlarm
(
AlarmType AlarmID,
TickType Increment,
TickType Cycle
);
extern StatusType CancelAlarm
(
AlarmType AlarmID
);
extern StatusType GetAlarm
(
AlarmType AlarmID,
TickRefType Tick
);
extern StatusType SetAbsAlarm
(
AlarmType AlarmID,
TickType Start,
TickType Cycle
);
#endif /*ALARM_H_*/
/* EOF */
|
janiex/TheRQMProject | InitHW.c | <reponame>janiex/TheRQMProject
/*******************************************************************************
** **
** SRC-MODULE: InitHW.c **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#include "Std_Types.h"
#include "DSP2833x_Device.h"
#include "HW_Config.h"
#include "DefaultISR.h"
struct CPUTIMER_VARS CpuTimer2;
/**********************************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************************/
static void InitPieCtrl(void);
static void InitSysCtrl(void);
static void DisableDog(void);
static void InitPll(uint16 val, uint16 divsel);
static void InitPeripheralClocks(void);
static void InitPieVectTable(void);
static void InitCpuTimers(void);
static void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float32 Freq, float32 Period);
void InitHW(void)
{
/* Step 1. Initialize System Control: */
/* PLL, WatchDog, enable Peripheral Clocks */
InitSysCtrl();
// Step 2. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected registers
// PieVectTable.TINT0 = &cpu_timer0_isr;
// PieVectTable.XINT13 = &cpu_timer1_isr;
PieVectTable.TINT2 = &os_time_tick;
EDIS; // This is needed to disable write to EALLOW protected registers
// Step 3. Initialize the Device Peripheral. This function can be
// found in DSP2833x_CpuTimers.c
}
//---------------------------------------------------------------------------
// ConfigCpuTimer:
//---------------------------------------------------------------------------
// This function initializes the selected timer to the period specified
// by the "Freq" and "Period" parameters. The "Freq" is entered as "MHz"
// and the period in "uSeconds". The timer is held in the stopped state
// after configuration.
//
void SetupTimerInterrupt(void)
{
InitCpuTimers(); // For this example, only initialize the Cpu Timers
// Configure CPU-Timer 0, 1, and 2 to interrupt every second:
// 150MHz CPU Freq, 1 msecond Period (in uSeconds)
ConfigCpuTimer(&CpuTimer2, 150, 1000);
// To ensure precise timing, use write-only instructions to write to the entire register. Therefore, if any
// of the configuration bits are changed in ConfigCpuTimer and InitCpuTimers (in DSP2833x_CpuTimers.h), the
// below settings must also be updated.
CpuTimer2Regs.TCR.all = 0x4001; // Use write-only instruction to set TSS bit = 0
// Step 4. User specific code, enable interrupts:
// Enable CPU int 14, which is connected to CPU-Timer 2:
IER |= M_INT14;
// Enable TINT0 in the PIE: Group 1 interrupt 7
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
}
static void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float32 Freq, float32 Period)
{
uint32 temp;
// Initialize timer period:
Timer->CPUFreqInMHz = Freq;
Timer->PeriodInUSec = Period;
temp = (long) (Freq * Period);
Timer->RegsAddr->PRD.all = temp;
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
Timer->RegsAddr->TPR.all = 0;
Timer->RegsAddr->TPRH.all = 0;
// Initialize timer control register:
Timer->RegsAddr->TCR.bit.TSS = 1; // 1 = Stop timer, 0 = Start/Restart Timer
Timer->RegsAddr->TCR.bit.TRB = 1; // 1 = reload timer
Timer->RegsAddr->TCR.bit.SOFT = 1;
Timer->RegsAddr->TCR.bit.FREE = 1; // Timer Free Run
Timer->RegsAddr->TCR.bit.TIE = 1; // 0 = Disable/ 1 = Enable Timer Interrupt
// Reset interrupt counter:
Timer->InterruptCount = 0;
}
//---------------------------------------------------------------------------
// InitCpuTimers:
//---------------------------------------------------------------------------
// This function initializes all three CPU timers to a known state.
//
static void InitCpuTimers(void)
{
// CpuTimer2 is reserved for DSP BIOS & other RTOS
// Do not use this timer if you ever plan on integrating
// DSP-BIOS or another realtime OS.
// Initialize address pointers to respective timer registers:
CpuTimer2.RegsAddr = &CpuTimer2Regs;
// Initialize timer period to maximum:
CpuTimer2Regs.PRD.all = 0xFFFFFFFF;
// Make sure timers are stopped:
CpuTimer2Regs.TCR.bit.TSS = 1;
// Reload all counter register with period value:
CpuTimer2Regs.TCR.bit.TRB = 1;
// Reset interrupt counters:
CpuTimer2.InterruptCount = 0;
}
static void InitPieVectTable(void)
{
uint16 i;
uint32 *Source = (void *) &PieVectTableInit;
uint32 *Dest = (void *) &PieVectTable;
EALLOW;
for(i=0; i < 128; i++)
*Dest++ = *Source++;
EDIS;
// Enable the PIE Vector Table
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
}
static void InitPieCtrl(void)
{
// Disable Interrupts at the CPU level:
DINT;
// Disable the PIE
PieCtrlRegs.PIECTRL.bit.ENPIE = 0;
// Clear all PIEIER registers:
PieCtrlRegs.PIEIER1.all = 0;
PieCtrlRegs.PIEIER2.all = 0;
PieCtrlRegs.PIEIER3.all = 0;
PieCtrlRegs.PIEIER4.all = 0;
PieCtrlRegs.PIEIER5.all = 0;
PieCtrlRegs.PIEIER6.all = 0;
PieCtrlRegs.PIEIER7.all = 0;
PieCtrlRegs.PIEIER8.all = 0;
PieCtrlRegs.PIEIER9.all = 0;
PieCtrlRegs.PIEIER10.all = 0;
PieCtrlRegs.PIEIER11.all = 0;
PieCtrlRegs.PIEIER12.all = 0;
// Clear all PIEIFR registers:
PieCtrlRegs.PIEIFR1.all = 0;
PieCtrlRegs.PIEIFR2.all = 0;
PieCtrlRegs.PIEIFR3.all = 0;
PieCtrlRegs.PIEIFR4.all = 0;
PieCtrlRegs.PIEIFR5.all = 0;
PieCtrlRegs.PIEIFR6.all = 0;
PieCtrlRegs.PIEIFR7.all = 0;
PieCtrlRegs.PIEIFR8.all = 0;
PieCtrlRegs.PIEIFR9.all = 0;
PieCtrlRegs.PIEIFR10.all = 0;
PieCtrlRegs.PIEIFR11.all = 0;
PieCtrlRegs.PIEIFR12.all = 0;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
static void InitSysCtrl(void)
{
// Disable the watchdog
DisableDog();
// Initialize the PLL control: PLLCR and DIVSEL
// DSP28_PLLCR and DSP28_DIVSEL are defined in DSP2833x_Examples.h
InitPll(DSP28_PLLCR,DSP28_DIVSEL);
// Initialize the peripheral clocks
InitPeripheralClocks();
}
static void DisableDog(void)
{
EALLOW;
SysCtrlRegs.WDCR= 0x0068;
EDIS;
}
//---------------------------------------------------------------------------
// Example: InitPll:
//---------------------------------------------------------------------------
// This function initializes the PLLCR register.
static void DELAY_US(uint16 a)
{
volatile uint32 counter = 0xFFFFF;
do{
counter--;
}while(counter != 0);
}
static void InitPll(uint16 val, uint16 divsel)
{
// Make sure the PLL is not running in limp mode
if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 0)
{
// Missing external clock has been detected
// Replace this line with a call to an appropriate
// SystemShutdown(); function.
asm(" ESTOP0");
}
// DIVSEL MUST be 0 before PLLCR can be changed from
// 0x0000. It is set to 0 by an external reset XRSn
// This puts us in 1/4
if (SysCtrlRegs.PLLSTS.bit.DIVSEL != 0)
{
EALLOW;
SysCtrlRegs.PLLSTS.bit.DIVSEL = 0;
EDIS;
}
// Change the PLLCR
if (SysCtrlRegs.PLLCR.bit.DIV != val)
{
EALLOW;
// Before setting PLLCR turn off missing clock detect logic
SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1;
SysCtrlRegs.PLLCR.bit.DIV = val;
EDIS;
// Optional: Wait for PLL to lock.
// During this time the CPU will switch to OSCCLK/2 until
// the PLL is stable. Once the PLL is stable the CPU will
// switch to the new PLL value.
//
// This time-to-lock is monitored by a PLL lock counter.
//
// Code is not required to sit and wait for the PLL to lock.
// However, if the code does anything that is timing critical,
// and requires the correct clock be locked, then it is best to
// wait until this switching has completed.
// Wait for the PLL lock bit to be set.
// The watchdog should be disabled before this loop, or fed within
// the loop via ServiceDog().
// Uncomment to disable the watchdog
DisableDog();
while(SysCtrlRegs.PLLSTS.bit.PLLLOCKS != 1)
{
// Uncomment to service the watchdog
// ServiceDog();
}
EALLOW;
SysCtrlRegs.PLLSTS.bit.MCLKOFF = 0;
EDIS;
}
// If switching to 1/2
if((divsel == 1)||(divsel == 2))
{
EALLOW;
SysCtrlRegs.PLLSTS.bit.DIVSEL = divsel;
EDIS;
}
// NOTE: ONLY USE THIS SETTING IF PLL IS BYPASSED (I.E. PLLCR = 0) OR OFF
// If switching to 1/1
// * First go to 1/2 and let the power settle
// The time required will depend on the system, this is only an example
// * Then switch to 1/1
if(divsel == 3)
{
EALLOW;
SysCtrlRegs.PLLSTS.bit.DIVSEL = 2;
DELAY_US(50L);
SysCtrlRegs.PLLSTS.bit.DIVSEL = 3;
EDIS;
}
}
//--------------------------------------------------------------------------
// Example: InitPeripheralClocks:
//---------------------------------------------------------------------------
// This function initializes the clocks to the peripheral modules.
// First the high and low clock prescalers are set
// Second the clocks are enabled to each peripheral.
// To reduce power, leave clocks to unused peripherals disabled
//
// Note: If a peripherals clock is not enabled then you cannot
// read or write to the registers for that peripheral
static void InitPeripheralClocks(void)
{
EALLOW;
// HISPCP/LOSPCP prescale register settings, normally it will be set to default values
SysCtrlRegs.HISPCP.all = 0x0001;
SysCtrlRegs.LOSPCP.all = 0x0002;
// XCLKOUT to SYSCLKOUT ratio. By default XCLKOUT = 1/4 SYSCLKOUT
// XTIMCLK = SYSCLKOUT/2
XintfRegs.XINTCNF2.bit.XTIMCLK = 1;
// XCLKOUT = XTIMCLK/2
XintfRegs.XINTCNF2.bit.CLKMODE = 1;
// Enable XCLKOUT
XintfRegs.XINTCNF2.bit.CLKOFF = 0;
// Peripheral clock enables set for the selected peripherals.
// If you are not using a peripheral leave the clock off
// to save on power.
//
// Note: not all peripherals are available on all 2833x derivates.
// Refer to the datasheet for your particular device.
//
// This function is not written to be an example of efficient code.
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // ADC
SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1; // I2C
SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 1; // SCI-A
SysCtrlRegs.PCLKCR0.bit.SCIBENCLK = 1; // SCI-B
SysCtrlRegs.PCLKCR0.bit.SCICENCLK = 1; // SCI-C
SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1; // SPI-A
SysCtrlRegs.PCLKCR0.bit.MCBSPAENCLK = 1; // McBSP-A
SysCtrlRegs.PCLKCR0.bit.MCBSPBENCLK = 1; // McBSP-B
SysCtrlRegs.PCLKCR0.bit.ECANAENCLK=1; // eCAN-A
SysCtrlRegs.PCLKCR0.bit.ECANBENCLK=1; // eCAN-B
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Disable TBCLK within the ePWM
SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // ePWM1
SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // ePWM2
SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // ePWM3
SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1; // ePWM4
SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 1; // ePWM5
SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 1; // ePWM6
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Enable TBCLK within the ePWM
SysCtrlRegs.PCLKCR1.bit.ECAP3ENCLK = 1; // eCAP3
SysCtrlRegs.PCLKCR1.bit.ECAP4ENCLK = 1; // eCAP4
SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK = 1; // eCAP5
SysCtrlRegs.PCLKCR1.bit.ECAP6ENCLK = 1; // eCAP6
SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 1; // eCAP1
SysCtrlRegs.PCLKCR1.bit.ECAP2ENCLK = 1; // eCAP2
SysCtrlRegs.PCLKCR1.bit.EQEP1ENCLK = 1; // eQEP1
SysCtrlRegs.PCLKCR1.bit.EQEP2ENCLK = 1; // eQEP2
SysCtrlRegs.PCLKCR3.bit.CPUTIMER0ENCLK = 1; // CPU Timer 0
SysCtrlRegs.PCLKCR3.bit.CPUTIMER1ENCLK = 1; // CPU Timer 1
SysCtrlRegs.PCLKCR3.bit.CPUTIMER2ENCLK = 1; // CPU Timer 2
SysCtrlRegs.PCLKCR3.bit.DMAENCLK = 1; // DMA Clock
SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1; // XTIMCLK
SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1; // GPIO input clock
EDIS;
}
/* EOF */
|
janiex/TheRQMProject | HW/DSP2833x_Xintf.h | /*******************************************************************************
** **
** SRC-MODULE: DSP2833x_Xintf.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
// TI File $Revision: /main/4 $
// Checkin $Date: July 27, 2009 13:57:25 $
//###########################################################################
//
// FILE: DSP2833x_Xintf.h
//
// TITLE: DSP2833x Device External Interface Register Definitions.
//
//###########################################################################
// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
// $Release Date: August 4, 2009 $
//###########################################################################
#ifndef DSP2833x_XINTF_H
#define DSP2833x_XINTF_H
#ifdef __cplusplus
extern "C" {
#endif
// XINTF timing register bit definitions:
struct XTIMING_BITS { // bits description
uint16 XWRTRAIL:2; // 1:0 Write access trail timing
uint16 XWRACTIVE:3; // 4:2 Write access active timing
uint16 XWRLEAD:2; // 6:5 Write access lead timing
uint16 XRDTRAIL:2; // 8:7 Read access trail timing
uint16 XRDACTIVE:3; // 11:9 Read access active timing
uint16 XRDLEAD:2; // 13:12 Read access lead timing
uint16 USEREADY:1; // 14 Extend access using HW waitstates
uint16 READYMODE:1; // 15 Ready mode
uint16 XSIZE:2; // 17:16 XINTF bus width - must be written as 11b
uint16 rsvd1:4; // 21:18 reserved
uint16 X2TIMING:1; // 22 Double lead/active/trail timing
uint16 rsvd3:9; // 31:23 reserved
};
union XTIMING_REG {
uint32 all;
struct XTIMING_BITS bit;
};
// XINTF control register bit definitions:
struct XINTCNF2_BITS { // bits description
uint16 WRBUFF:2; // 1:0 Write buffer depth
uint16 CLKMODE:1; // 2 Ratio for XCLKOUT with respect to XTIMCLK
uint16 CLKOFF:1; // 3 Disable XCLKOUT
uint16 rsvd1:2; // 5:4 reserved
uint16 WLEVEL:2; // 7:6 Current level of the write buffer
uint16 rsvd2:1; // 8 reserved
uint16 HOLD:1; // 9 Hold enable/disable
uint16 HOLDS:1; // 10 Current state of HOLDn input
uint16 HOLDAS:1; // 11 Current state of HOLDAn output
uint16 rsvd3:4; // 15:12 reserved
uint16 XTIMCLK:3; // 18:16 Ratio for XTIMCLK
uint16 rsvd4:13; // 31:19 reserved
};
union XINTCNF2_REG {
uint32 all;
struct XINTCNF2_BITS bit;
};
// XINTF bank switching register bit definitions:
struct XBANK_BITS { // bits description
uint16 BANK:3; // 2:0 Zone for which banking is enabled
uint16 BCYC:3; // 5:3 XTIMCLK cycles to add
uint16 rsvd:10; // 15:6 reserved
};
union XBANK_REG {
uint16 all;
struct XBANK_BITS bit;
};
struct XRESET_BITS {
uint16 XHARDRESET:1;
uint16 rsvd1:15;
};
union XRESET_REG {
uint16 all;
struct XRESET_BITS bit;
};
//---------------------------------------------------------------------------
// XINTF Register File:
//
struct XINTF_REGS {
union XTIMING_REG XTIMING0;
uint32 rsvd1[5];
union XTIMING_REG XTIMING6;
union XTIMING_REG XTIMING7;
uint32 rsvd2[2];
union XINTCNF2_REG XINTCNF2;
uint32 rsvd3;
union XBANK_REG XBANK;
uint16 rsvd4;
uint16 XREVISION;
uint16 rsvd5[2];
union XRESET_REG XRESET;
};
//---------------------------------------------------------------------------
// XINTF External References & Function Declarations:
//
extern volatile struct XINTF_REGS XintfRegs;
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // end of DSP2833x_XINTF_H definition
//===========================================================================
// No more.
//===========================================================================
/* EOF */
|
janiex/TheRQMProject | Alarm.c | /*******************************************************************************
** **
** SRC-MODULE: Alarm.c **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#include "Alarm.h"
#include "Counter.h"
#include "Task.h"
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
#if (ALARMS_COUNT != 0)
AlarmIncrementType IncrementAlarm(AlarmType AlarmID, AlarmIncrementType Increment)
{
AlarmIncrementType RestIncrements;
AlarmIncrementType AlarmCount;
CounterIncrementType CounterIncrement;
/* init arlarms count */
AlarmCount = 0;
/* check if the increment is smaller than the expiration time */
if ( AlarmsVar[AlarmID].AlarmTime > Increment )
{
/* decrement the alarm*/
AlarmsVar[AlarmID].AlarmTime -= Increment;
/* alarm doesn't expires now */
RestIncrements = AlarmsVar[AlarmID].AlarmTime;
}
else
{
/* increment is graeter or equal than the alarm time, the alarm may
expire one or more times */
/* check if new alarm time has to be set */
if(AlarmsVar[AlarmID].AlarmCycleTime == 0)
{
/* in case of a non cyclic alarm */
/* alarm has expires 1 time */
AlarmCount = 1;
/* set alarm to 0 */
AlarmsVar[AlarmID].AlarmTime = 0;
/* disable alarm */
AlarmsVar[AlarmID].AlarmState = 0;
/* set rest increments to zero */
RestIncrements = 0;
}
else
{
/* the alarm is cyclic */
/* decrement alarm */
while ( AlarmsVar[AlarmID].AlarmTime <= Increment )
{
/* add cycle time */
AlarmsVar[AlarmID].AlarmTime += AlarmsVar[AlarmID].AlarmCycleTime;
/* increment Alarms expiration times */
AlarmCount++;
}
/* decrement the increments of this alarm */
AlarmsVar[AlarmID].AlarmTime -= Increment;
/* store the rest increments */
RestIncrements = AlarmsVar[AlarmID].AlarmTime;
}
if (AlarmsConst[AlarmID].AlarmAction == INCREMENT)
{
/* call counter function */
CounterIncrement = IncrementCounter(AlarmsConst[AlarmID].AlarmActionInfo.Counter, AlarmCount);
/* re-calculate the rest of the increments */
RestIncrements += AlarmsVar[AlarmID].AlarmCycleTime * ( CounterIncrement-1 );
}
else
{
/* execute the alarm so many times as needed */
for ( ;AlarmCount > 0; AlarmCount--)
{
/* check alarm actions differents to INCREMENT */
switch(AlarmsConst[AlarmID].AlarmAction)
{
case ACTIVATETASK:
/* activate task */
ActivateTask(AlarmsConst[AlarmID].AlarmActionInfo.TaskID);
break;
case ALARMCALLBACK:
/* callback */
if(AlarmsConst[AlarmID].AlarmActionInfo.CallbackFunction != NULL)
{
AlarmsConst[AlarmID].AlarmActionInfo.CallbackFunction();
}
break;
#if (EVENT_ENABLED == ENABLED)
case SETEVENT:
// TODO: Kristian enable this, when task is ready.
/* set event */
// SetEvent(AlarmsConst[AlarmID].AlarmActionInfo.TaskID, AlarmsConst[AlarmID].AlarmActionInfo.Event);
break;
#endif /* #if (EVENT_ENABLED == ENABLED) */
default:
/* some error */
/* possibly TODO, report an error */
break;
}
}
}
}
return RestIncrements;
}
#endif /* #if (ALARMS_COUNT != 0) */
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
StatusType SetRelAlarm
(
AlarmType AlarmID,
TickType Increment,
TickType Cycle
)
{
/* \req OSEK_SYS_3.21 The system service StatusType
** SetRelAlarm ( AlarmType AlarmID, TickType Increment, TickType Cycle )
** shall be defined */
/* \req OSEK_SYS_3.21.3-1/2 Possible return values in Standard mode are
** E_OK, E_OS_STATE */
StatusType ret = E_OK;
#if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED)
/* check if the alarm id is in range */
if(AlarmID >= ALARMS_COUNT)
{
/* \req OSEK_SYS_3.21.4-1/2 Extra possible return values in Extended mode are
** E_OS_ID, E_OS_VALUE */
ret = E_OS_ID;
}
/* check that increment and cycle are in range */
else if( (Increment > CountersConst[AlarmsConst[AlarmID].Counter].MaxAllowedValue) ||
( ( Cycle != 0 ) &&
( (Cycle > CountersConst[AlarmsConst[AlarmID].Counter].MaxAllowedValue) ||
(Cycle < CountersConst[AlarmsConst[AlarmID].Counter].MinCycle) ) ) )
{
/* \req OSEK_SYS_3.21.4-2/2 Extra possible return values in Extended mode are
** E_OS_ID, E_OS_VALUE */
ret = E_OS_VALUE;
}
else
#endif
/* check if the alarm is disable */
if(AlarmsVar[AlarmID].AlarmState != 0)
{
/* \req OSEK_SYS_3.21.3-2/2 Possible return values in Standard mode are
** E_OK, E_OS_STATE */
ret = E_OS_STATE;
}
else
{
IntSecure_Start();
/* enable alarm */
AlarmsVar[AlarmID].AlarmState = 1;
/* set alarm */
AlarmsVar[AlarmID].AlarmTime = Increment;
AlarmsVar[AlarmID].AlarmCycleTime = Cycle;
IntSecure_End();
}
#if (HOOK_ERRORHOOK == ENABLE)
/* \req OSEK_ERR_1.3-13/xx The ErrorHook hook routine shall be called if a
** system service returns a StatusType value not equal to E_OK.*/
/* \req OSEK_ERR_1.3.1-13/xx The hook routine ErrorHook is not called if a
** system service is called from the ErrorHook itself. */
// if ( ( ret != E_OK ) && (ErrorHookRunning != 1))
// {
// SetError_Api(OSServiceId_SetRelAlarm);
// SetError_Param1(AlarmID);
// SetError_Param2(Increment);
// SetError_Param3(Cycle);
// SetError_Ret(ret);
// SetError_Msg("SetRelAlarm returns != than E_OK");
// SetError_ErrorHook();
// }
#endif
return ret;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
StatusType SetAbsAlarm
(
AlarmType AlarmID,
TickType Start,
TickType Cycle
)
{
/* \req OSEK_SYS_3.22 The system service StatusType
** SetAbsAlarm ( AlarmType AlarmID, TickType Start, TickType Cycle )
** shall be defined */
/* \req OSEK_SYS_3.22.3-1/2 Possible return values in Standard mode are E_OK,
** E_OS_STATE */
StatusType ret = E_OK;
#if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED)
/* check if the alarm id is in range */
if(AlarmID >= ALARMS_COUNT)
{
/* \req OSEK_SYS_3.22.4-1/2 Extra possible return values in Extended mode
** are E_OS_ID, E_OS_VALUE */
ret = E_OS_ID;
}
/* check that increment and cycle are in range */
else if( (Start > CountersConst[AlarmsConst[AlarmID].Counter].MaxAllowedValue) ||
( ( Cycle != 0 ) &&
( (Cycle > CountersConst[AlarmsConst[AlarmID].Counter].MaxAllowedValue) ||
(Cycle < CountersConst[AlarmsConst[AlarmID].Counter].MinCycle) ) ) )
{
/* \req OSEK_SYS_3.22.4-2/2 Extra possible return values in Extended mode
** are E_OS_ID, E_OS_VALUE */
ret = E_OS_VALUE;
}
else
#endif
/* check if the alarm is disable */
if(AlarmsVar[AlarmID].AlarmState != 0)
{
/* \req OSEK_SYS_3.22.3-2/2 Possible return values in Standard mode are E_OK,
** E_OS_STATE */
ret = E_OS_STATE;
}
else
{
IntSecure_Start();
/* enable alarm */
AlarmsVar[AlarmID].AlarmState = 1;
/* set abs alarm */
AlarmsVar[AlarmID].AlarmTime = GetCounter(AlarmsConst[AlarmID].Counter) + Start;
AlarmsVar[AlarmID].AlarmCycleTime = Cycle;
IntSecure_End();
}
#if (HOOK_ERRORHOOK == ENABLE)
/* \req OSEK_ERR_1.3-14/xx The ErrorHook hook routine shall be called if a
** system service returns a StatusType value not equal to E_OK.*/
/* \req OSEK_ERR_1.3.1-14/xx The hook routine ErrorHook is not called if a
** system service is called from the ErrorHook itself. */
// if ( ( ret != E_OK ) && (ErrorHookRunning != 1))
// {
// SetError_Api(OSServiceId_SetAbsAlarm);
// SetError_Param1(AlarmID);
// SetError_Param2(Start);
// SetError_Param3(Cycle);
// SetError_Ret(ret);
// SetError_Msg("SetAbsAlarm returns != than E_OK");
// SetError_ErrorHook();
// }
#endif
return ret;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
StatusType GetAlarmBase
(
AlarmType AlarmID,
AlarmBaseRefType Info
)
{
/* \req OSEK_SYS_3.19 The system service StatusType
** GetAlarmBase ( AlarmType AlarmID, AlarmBaseRefType Info )
** shall be defined. */
/* \req OSEK_SYS_3.19.2 Possible return values in Standard mode is E_OK */
StatusType ret = E_OK;
CounterType counter;
#if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED)
/* check that the AlarmID is in range */
if(AlarmID >= ALARMS_COUNT)
{
/* \req OSEK_SYS_3.19.: Extra possible return values in Extended mode
** is E_OS_ID */
ret = E_OS_ID;
}
else
#endif
{
/* get counter of this alarm */
counter = AlarmsConst[AlarmID].Counter;
/* \req OSEK_SYS_3.19.1 The system service GetAlarmBase reads the alarm base
** characteristics. The return value Info is a structure in which the
** information of data type AlarmBaseType is stored */
Info->maxallowedvalue = CountersConst[counter].MaxAllowedValue;
Info->ticksperbase = CountersConst[counter].TicksPerBase;
Info->mincycle = CountersConst[counter].MinCycle;
}
#if ( (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED) && \
(HOOK_ERRORHOOK == ENABLE) )
/* \req OSEK_ERR_1.3-12/xx The ErrorHook hook routine shall be called if a
** system service returns a StatusType value not equal to E_OK.*/
/* \req OSEK_ERR_1.3.1-12/xx The hook routine ErrorHook is not called if a
** system service is called from the ErrorHook itself. */
if ( ( ret != E_OK ) && (ErrorHookRunning != 1))
{
SetError_Api(OSServiceId_GetAlarmBase);
SetError_Param1(AlarmID);
SetError_Param2((uint32)Info);
SetError_Ret(ret);
SetError_Msg("GetAlarmBase returns != than E_OK");
SetError_ErrorHook();
}
#endif
return ret;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
StatusType GetAlarm
(
AlarmType AlarmID,
TickRefType Tick
)
{
/* \req OSEK_SYS_3.20 The system service StatusType
** GetAlarm ( AlarmType AlarmID, TickRefType Tick) shall be defined */
/* \req OSEK_SYS_3.20.2 Possible return values in Standard mode is E_OK */
StatusType ret = E_OK;
#if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED)
/* check if it handle of a valid AlarmID */
if (AlarmID >= ALARMS_COUNT)
{
/* \req OSEK_SYS_3.20.3-1/2 Extra possible return values in Extended mode
** are E_OS_NOFUNC, E_OS_ID */
ret = E_OS_ID;
}
else
#endif /* #if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED) */
/* check if the alarm is running */
if(AlarmsVar[AlarmID].AlarmState == 0)
{
/* \req OSEK_SYS_3.20.3-2/2 Extra possible return values in Extended mode
** are E_OS_NOFUNC, E_OS_ID */
ret = E_OS_NOFUNC;
}
else
{
/* \req OSEK_SYS_3.20.1 The system service GetAlarm shall return the
** relative value in ticks before the alarm AlarmID expires */
*Tick = AlarmsVar[AlarmID].AlarmTime;
}
#if (HOOK_ERRORHOOK == ENABLE)
/* \req OSEK_ERR_1.3-12/xx The ErrorHook hook routine shall be called if a
** system service returns a StatusType value not equal to E_OK.*/
/* \req OSEK_ERR_1.3.1-12/xx The hook routine ErrorHook is not called if a
** system service is called from the ErrorHook itself. */
// if ( ( ret != E_OK ) && (ErrorHookRunning != 1))
// {
// SetError_Api(OSServiceId_GetAlarm);
// SetError_Param1(AlarmID);
// SetError_Param2((uint32)Tick);
// SetError_Ret(ret);
// SetError_Msg("GetAlarm returns != than E_OK");
// SetError_ErrorHook();
// }
#endif /* #if (HOOK_ERRORHOOK == ENABLE) */
return ret;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
StatusType CancelAlarm
(
AlarmType AlarmID
)
{
/* \req OSEK_SYS_3.23 The system service StatusType
** CancelAlarm ( AlarmType AlarmID ) shall be defined */
/* \req OSEK_SYS_3.23.2-1/2 Possible return values in Standard mode are
** E_OK, E_OS_NOFUNC */
StatusType ret = E_OK;
#if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED)
/* check if alarm id is in the valid range */
if(AlarmID >= ALARMS_COUNT)
{
/* \req SEK_SYS_3.23.3: Extra possible return values in Extended mode ar
** E_OS_ID */
ret = E_OS_ID;
}
else
#endif
if(AlarmsVar[AlarmID].AlarmState == 0)
{
/* \req OSEK_SYS_3.23.2-2/2 Possible return values in Standard mode are
** E_OK, E_OS_NOFUNC */
ret = E_OS_NOFUNC;
}
else
{
/* \req OSEK_SYS_3.23.1 The system service shall cancel the alarm AlarmID */
AlarmsVar[AlarmID].AlarmState = 0;
}
#if (HOOK_ERRORHOOK == ENABLE)
/* \req OSEK_ERR_1.3-15/xx The ErrorHook hook routine shall be called if a
** system service returns a StatusType value not equal to E_OK.*/
/* \req OSEK_ERR_1.3.1-15/xx The hook routine ErrorHook is not called if a
** system service is called from the ErrorHook itself. */
// if ( ( ret != E_OK ) && (ErrorHookRunning != 1))
// {
// SetError_Api(OSServiceId_CancelAlarm);
// SetError_Param1(AlarmID);
// SetError_Ret(ret);
// SetError_Msg("CancelAlarm returns != than E_OK");
// SetError_ErrorHook();
// }
#endif
return ret;
}
/* EOF */
|
janiex/TheRQMProject | Include/Platform_Types.h | /*******************************************************************************
** **
** SRC-MODULE: Platform_Types.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#ifndef PLATFORM_TYPES_H_
#define PLATFORM_TYPES_H_
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/**********************************************************************************************************************
* GLOBAL DATA TYPES AND STRUCTURES
*********************************************************************************************************************/
typedef unsigned char boolean; /* for use with TRUE/FALSE */
typedef unsigned char BYTE; /* The smallest Byte like type */
typedef signed char sint16; /* -128 .. +127 */
typedef unsigned char uint16; /* 0 .. 255 */
typedef signed long sint32; /* -2147483648 .. +2147483647 */
typedef unsigned long uint32; /* 0 .. 4294967295 */
typedef signed long long sint64; /* \brief 64-bit unsigned integer */
typedef unsigned long long uint64;
/* The optimized AUTOSAR integer data types
(<typename>_least) shall have at least the size given by the type name, but the
types shall be implemented in a way that the best performance on the specific
platform is achieved. `Best performance' is defined in this context as `least processor
cycles for variable access as possible'. Example: on a TC1796, uint8_least is
mapped to unsigned int (32 bit) because access to this type requires less
processor cycles than e.g. unsigned char (8 bit). */
typedef unsigned long uint8_least; /* At least 8 bit */
typedef signed long sint8_least; /* At least 7 bit + 1 bit sign */
typedef unsigned long uint16_least; /* At least 16 bit */
typedef signed long sint16_least; /* At least 15 bit + 1 bit sign */
typedef unsigned long uint32_least; /* At least 32 bit */
typedef signed long sint32_least; /* At least 31 bit + 1 bit sign */
typedef float float32; /* IEEE 32-bit 1.19 209 290e-38 .. 3.40 282 35e+38 */
typedef long double float64; /* IEEE 64-bit 2.22 507 385e-308 .. 1.79 769 313e+308 */
#endif /*PLATFORM_TYPES_H_*/
/* EOF */
|
janiex/TheRQMProject | HW/DSP2833x_XIntrupt.h | <filename>HW/DSP2833x_XIntrupt.h
/*******************************************************************************
** **
** SRC-MODULE: DSP2833x_XIntrupt.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#include "Identification.h"
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
// TI File $Revision: /main/1 $
// Checkin $Date: August 18, 2006 13:52:39 $
//###########################################################################
//
// FILE: DSP2833x_XIntrupt.h
//
// TITLE: DSP2833x Device External Interrupt Register Definitions.
//
//###########################################################################
// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
// $Release Date: August 4, 2009 $
//###########################################################################
#ifndef DSP2833x_XINTRUPT_H
#define DSP2833x_XINTRUPT_H
#ifdef __cplusplus
extern "C" {
#endif
//---------------------------------------------------------------------------
struct XINTCR_BITS {
uint16 ENABLE:1; // 0 enable/disable
uint16 rsvd1:1; // 1 reserved
uint16 POLARITY:2; // 3:2 pos/neg, both triggered
uint16 rsvd2:12; //15:4 reserved
};
union XINTCR_REG {
uint16 all;
struct XINTCR_BITS bit;
};
struct XNMICR_BITS {
uint16 ENABLE:1; // 0 enable/disable
uint16 SELECT:1; // 1 Timer 1 or XNMI connected to int13
uint16 POLARITY:2; // 3:2 pos/neg, or both triggered
uint16 rsvd2:12; // 15:4 reserved
};
union XNMICR_REG {
uint16 all;
struct XNMICR_BITS bit;
};
//---------------------------------------------------------------------------
// External Interrupt Register File:
//
struct XINTRUPT_REGS {
union XINTCR_REG XINT1CR;
union XINTCR_REG XINT2CR;
union XINTCR_REG XINT3CR;
union XINTCR_REG XINT4CR;
union XINTCR_REG XINT5CR;
union XINTCR_REG XINT6CR;
union XINTCR_REG XINT7CR;
union XNMICR_REG XNMICR;
uint16 XINT1CTR;
uint16 XINT2CTR;
uint16 rsvd[5];
uint16 XNMICTR;
};
//---------------------------------------------------------------------------
// External Interrupt References & Function Declarations:
//
extern volatile struct XINTRUPT_REGS XIntruptRegs;
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // end of DSP2833x_XINTF_H definition
//===========================================================================
// End of file.
//===========================================================================
/* EOF */
|
janiex/TheRQMProject | RTE/Compiler.h | /*
* File: Compiler.h
*
* Real-Time Workshop code generated for Simulink model ISO2631_All_GenerationTemplate.
*
* Model version : 1.17
* Real-Time Workshop file version : 7.6 (R2010b) 03-Aug-2010
* Real-Time Workshop file generated on : Sat Sep 06 13:19:54 2014
* TLC version : 7.6 (Jul 13 2010)
* C/C++ source code generated on : Sat Sep 06 13:19:55 2014
*
* Target selection: autosar.tlc
* Embedded hardware selection: Texas Instruments->C2000
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_Compiler_h_
#define RTW_HEADER_Compiler_h_
/*
*
* This file contains dummy implementations of the AUTOSAR functions
* used by this model for testing the code generated from Simulink.
* Simulink invokes the generated code through its S-Function API.
* Note that this file is replaced with the real implementation
* when deploying the generated code outside of Simulink.
*
*/
/*
*
* This header file specifies macros for the abstraction of compiler specific
* keywords used for addressing data and code within declarations and
* definitions. This is used to overcome problems caused by the limited 16 bit
* addressing range.
*
* For SIL/PIL macros behave as identity operators.
*
*/
/* Compiler Abstractions for PC */
#define FUNC(type, memclass) type
#define P2VAR(ptrtype, memclass, ptrclass) ptrtype *
#define P2CONST(ptrtype, memclass, ptrclass) const ptrtype *
#define CONST(consttype, memclass) const consttype
#define VAR( type, memclass ) type
#endif /* RTW_HEADER_Compiler_h_ */
/*
* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
|
janiex/TheRQMProject | Include/OS_gen.h | /*******************************************************************************
** **
** SRC-MODULE: OS_gen.h **
** **
** Copyright (C) none (open standard) **
** **
** TARGET : Delfino TMS320F28335 **
** **
** COMPILER : CCS **
** **
** PROJECT : Open Source OSEK **
** **
** AUTHOR : <NAME> **
** **
** PURPOSE : Scientific Research **
** **
** REMARKS : None **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Organization **
** -------- ------------------------- -----------------------------------**
** KD <NAME> TU-Sofia **
** **
*******************************************************************************/
/*******************************************************************************
** This file is genereted on: 9.3.2017 22:04:47 **
** **
*******************************************************************************/
#if(MAGIC_NUMBER != 30511208)
#error "Inplausible genereted source files"
#endif /* (MAGIC_NUMBER != 30511208 */
#ifndef OS_GEN_H_
#define OS_GEN_H_
#include "Counter.h"
#include "OS_Cfg.h"
#include "Alarm.h"
#include "Task.h"
extern void TASK_ACC_code(void);
extern void TASK_ISO2631_code(void);
extern void TASK_Init_code(void);
extern void Task_IDLE_code(void);
uint16 TaskStack0[StackSizeTask0];
uint16 TaskStack1[StackSizeTask1];
uint16 TaskStack2[StackSizeTask2];
uint16 TaskIdleStack[64];
volatile uint16 SystemStack[SystemStackSize];
/******************************************************************************
* TIMER_A associated counters *
******************************************************************************/
CounterType Timer_A_Counters[COOUNTERS_FOR_TIMER_A]=
{
/* Counters connected to TIMER_A */
COUNTER_SYS,
};
/******************************************************************************
* COUNTERS DATA *
******************************************************************************/
/* these alarms have to be incremented with COUNTER_SYS*/
const AlarmType COUNTER_SYS_LIST[COUNTER_SYS_ALARMS_COUNT]=
{
ALARM_ACC,
ALARM_ISO2631,
};
/******************************************************************************
* Variable descriptors for the counters *
******************************************************************************/
CounterVarType CountersVar[COUNTER_COUNT]=
{
/* COUNTER_SYS */
{0},
};
/******************************************************************************
* Constant descriptors for the counters *
******************************************************************************/
const CounterConstType CountersConst[COUNTER_COUNT]=
{
/* COUNTER_SYS */
{
COUNTER_SYS_ALARMS_COUNT, /* number of alarms associated with the counter*/
(AlarmType*)COUNTER_SYS_LIST,
1000000, /* max allowed value */
1, /* min cycle */
1000, /*ticks per base */
},
};
/******************************************************************************
* Variable descriptors for the alarms *
******************************************************************************/
AlarmVarType AlarmsVar[ALARMS_COUNT]=
{
{
/* ALARM_ACC */
(AlarmStateType)0, /* Alarm state */
(AlarmTimeType)0, /* Alarm Time */
(AlarmCycleTimeType)0, /*Alarm Cyclic Time*/
},
{
/* ALARM_ISO2631 */
(AlarmStateType)0, /* Alarm state */
(AlarmTimeType)0, /* Alarm Time */
(AlarmCycleTimeType)0, /*Alarm Cyclic Time*/
},
};
/******************************************************************************
* Constant descriptors for the alarms *
******************************************************************************/
const AlarmConstType AlarmsConst[ALARMS_COUNT]=
{
/* ALARM_ACC */
COUNTER_SYS, /* Associated Counter */
ACTIVATETASK, /* Alarm action */
{
(CallbackType )NULL, /* no callback */
TASK_ACC, /* Task associated with the alarm */
#if(0 != EVENT_ENABLED)
(EventMaskType)0, /* No Event is assiciated with the alarm */
#endif /* (0 != EVENT_ENABLED) */
(AlarmType)0, /* Reserved field... */
},
/* ALARM_ISO2631 */
COUNTER_SYS, /* Associated Counter */
ACTIVATETASK, /* Alarm action */
{
(CallbackType )NULL, /* no callback */
TASK_ISO2631, /* Task associated with the alarm */
#if(0 != EVENT_ENABLED)
(EventMaskType)0, /* No Event is assiciated with the alarm */
#endif /* (0 != EVENT_ENABLED) */
(AlarmType)0, /* Reserved field... */
},
};
/******************************************************************************
* Constant descriptors for auto-start alarms *
******************************************************************************/
const AutoStartAlarmType AutoStartAlarm[ALARM_AUTOSTART_COUNT]=
{
/* ALARM_ACC is set to autostart */
{
0, /* Active for this application mode */
ALARM_ACC, /* Alarm ID */
5, /* Alarm Time */
5, /* Cyclic Period */
},
/* ALARM_ISO2631 is set to autostart */
{
0, /* Active for this application mode */
ALARM_ISO2631, /* Alarm ID */
23, /* Alarm Time */
20, /* Cyclic Period */
},
};
/******************************************************************************
* Constant descriptors for the TASKS *
******************************************************************************/
const TaskConstType TasksConst[TASKS_COUNT] =
{
/* TASK_ACC */
{
TASK_ACC_code, /* Task entry point */
(StackPtrType )&TaskStack0, /* Pointer to Task's stack area*/
StackSizeTask0, /* stack size */
2, /*Task Priority (90) */
1, /* task max activations */
{
0, /* BASIC Task */
0, /* NON Pre-emptive Task */
0, /* Task initial state - SUSPENDED */
}, /* task const flags */
(EventMaskType)0,/* Task's events mask */
0,/* Task's resource mask */
},
/* TASK_ISO2631 */
{
TASK_ISO2631_code, /* Task entry point */
(StackPtrType )&TaskStack1, /* Pointer to Task's stack area*/
StackSizeTask1, /* stack size */
1, /*Task Priority (50) */
1, /* task max activations */
{
0, /* BASIC Task */
0, /* NON Pre-emptive Task */
0, /* Task initial state - SUSPENDED */
}, /* task const flags */
(EventMaskType)0,/* Task's events mask */
0,/* Task's resource mask */
},
/* TASK_Init */
{
TASK_Init_code, /* Task entry point */
(StackPtrType )&TaskStack2, /* Pointer to Task's stack area*/
StackSizeTask2, /* stack size */
3, /*Task Priority (99) */
1, /* task max activations */
{
0, /* BASIC Task */
0, /* NON Pre-emptive Task */
0, /* Task initial state - SUSPENDED */
}, /* task const flags */
(EventMaskType)0,/* Task's events mask */
0,/* Task's resource mask */
},
/* Task_IDLE */
{
Task_IDLE_code, /* Task entry point */
(StackPtrType )&TaskIdleStack, /* Pointer to Task's stack area*/
64, /* stack size */
0, /* Idle task has lowest pirority in the system - 0 */
1, /* task max activations */
{
0, /* BASIC Task */
1, /* Idle Task is always pre-emptive */
0, /* Idle task initial state - SUSPENDED */
}, /* task const flags */
(EventMaskType)0,/* No events for Idle Task */
0/* No Resources for Idle Task */
}
};
/******************************************************************************
* Variable descriptors for the TASKS *
******************************************************************************/
TaskVariableType TasksVar[TASKS_COUNT]; /* Initialized during the start-up phase */
/******************************************************************************
* Static queue for tasks in READY state *
******************************************************************************/
TaskType ReadyList0[1];
TaskType ReadyList1[1];
TaskType ReadyList2[1];
TaskType ReadyList3[1];
ReadyVarType ReadyVar[TASKS_COUNT]=
{
{
0, /* List Start - empty */
0 /* List Count - empty */
},
{
0, /* List Start - empty */
0 /* List Count - empty */
},
{
0, /* List Start - empty */
0 /* List Count - empty */
},
{
0, /* List Start - empty */
0 /* List Count - empty */
},
};
const ReadyConstType ReadyConst[TASKS_COUNT] =
{
{
1, /* Length of this ready list */
ReadyList3, /* Pointer to the Ready List */
},
{
1, /* Length of this ready list */
ReadyList2, /* Pointer to the Ready List */
},
{
1, /* Length of this ready list */
ReadyList1, /* Pointer to the Ready List */
},
{
1, /* Length of this ready list */
ReadyList0, /* Pointer to the Ready List */
},
};
/******************************************************************************
* Constant descriptors for the auto-start TASKS *
******************************************************************************/
const TaskType AutoStartReadyList[TASKS_AUTOSTART_COUNT] =
{
TASK_Init,
Task_IDLE
};
const AutoStartType AutoStart[OS_NUMBER_OF_MODES] =
{
TASKS_AUTOSTART_COUNT,
AutoStartReadyList
};
#endif /* OS_GEN_H_ */
/* EOF */
|
janiex/TheRQMProject | ADXL345.c | <filename>ADXL345.c<gh_stars>0
//#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
//#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "ADXL345.h"
#ifdef __cplusplus
#pragma DATA_SECTION("I2caRegsFile")
#else
#pragma DATA_SECTION(I2caRegs,"I2caRegsFile");
#endif
volatile struct I2C_REGS I2caRegs;
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
void InitI2CGpio(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.all = 0; // GPIO15 ... GPIO0 = General Puropse I/O
GpioCtrlRegs.GPAMUX2.all = 0; // GPIO31 ... GPIO16 = General Purpose I/O
GpioCtrlRegs.GPBMUX1.all = 0; // GPIO47 ... GPIO32 = General Purpose I/O
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // GPIO32 = I2C - SDA
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // GPIO33 = I2C - SCL
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0; // Enable pull-up for GPIO32 (SDAA)
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0; // Enable pull-up for GPIO33 (SCLA)
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input GPIO32 (SDAA)
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input GPIO33 (SCLA)
GpioCtrlRegs.GPBMUX2.all = 0; // GPIO63 ... GPIO48 = General Purpose I/O
GpioCtrlRegs.GPCMUX1.all = 0; // GPIO79 ... GPIO64 = General Purpose I/O
GpioCtrlRegs.GPCMUX2.all = 0; // GPIO87 ... GPIO80 = General Purpose I/O
GpioCtrlRegs.GPADIR.all = 0; // GPIO0 to 31 as inputs
GpioCtrlRegs.GPADIR.bit.GPIO9 = 1; // GPIO9 = LED LD1
GpioCtrlRegs.GPADIR.bit.GPIO11 = 1; // GpIO11 = LED LD2
GpioCtrlRegs.GPBDIR.all = 0; // GPIO63-32 as inputs
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // peripheral explorer: LED LD3 at GPIO34
GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1; // peripheral explorer: LED LD4 at GPIO49
GpioCtrlRegs.GPCDIR.all = 0; // GPIO87-64 as inputs
EDIS;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
void I2C_Init(void)
{
// Initialize I2C
I2caRegs.I2CMDR.all = 0x0020;
I2caRegs.I2CSAR = SLAVE_ADDR;// Slave address - EEPROM control code
/*****************************************************************************
The I2C module clock determines the frequency at which the I2C module operates.
A pro-grammable pre-scaler in the I2C module divides down the I2C input clock to
produce the module clock. To specify the divide-down value, initialize the IPSC
field of the pre-scaler register, I2CPSC. The resulting frequency should be in
the range of 7 - 12 MHz and is given by:
I2C_MODULE_CLOCK = SYSCLKOUT/(IPSC+1)
10MHz = 150MHz/(14+1)
******************************************************************************/
// Default - For 150MHz SYSCLKOUT
I2caRegs.I2CPSC.all = 14; // Prescaler - need 7-12 Mhz on module clk (150/15 = 10MHz)
/*********************************************************************************************
* 150MHz 50KHz 100KHz 400KHz
* ICCL / ICCH 95/95 45/45 10/5
* *******************************************************************************************/
I2caRegs.I2CCLKL = 700; // NOTE: must be non zero
I2caRegs.I2CCLKH = 700; // NOTE: must be non zero
I2caRegs.I2CMDR.all = 0x0020; // Take I2C out of reset
// Stop I2C when suspended
// I2caRegs.I2CMDR.all = 0000 0010 0000 0000
I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT,
return;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
void I2C_Write(uint16 reg_address, uint16 data)
{
I2caRegs.I2CSTR.bit.SCD = 1;
I2caRegs.I2CMDR.bit.IRS = 1; // reset I2C
I2caRegs.I2CSAR = SLAVE_ADDR; // I2C slave address
while (I2caRegs.I2CSTR.bit.BB == 1); // still busy?
I2caRegs.I2CCNT = 2; // assume register address = 1 byte, and data is 1 byte
I2caRegs.I2CDXR = reg_address; // register address of the sensor (1 byte)
I2caRegs.I2CDXR = data; // data to be sent (1 byte)
I2caRegs.I2CMDR.all = 0x2E20; // start, stop, no rm, reset i2c
I2caRegs.I2CMDR.bit.STP = 1; // stop bit when CNT=0
while(!I2caRegs.I2CSTR.bit.SCD); // wait for STOP condition
return;
}
/*******************************************************************************
** **
** FUNC-NAME : **
** **
** DESCRIPTION : **
** **
** PRECONDITIONS : **
** **
** PARAMETER : **
** **
** RETURN : **
** **
** REMARKS : **
** **
*******************************************************************************/
uint16 I2C_Read(uint16 reg_address)
{
uint16 tempdata;
I2caRegs.I2CMDR.bit.IRS = 1; // reset I2C
// Make sure I2C is not busy and has stopped
I2caRegs.I2CMDR.bit.IRS = 1; // reset I2C
while (I2caRegs.I2CSTR.bit.BB == 1); // busy loop
I2caRegs.I2CSTR.bit.SCD = 1; // Clear the SCD bit (stop condition bit)
while(I2caRegs.I2CMDR.bit.STP == 1); // stop bit loop
I2caRegs.I2CSAR = SLAVE_ADDR; // I2C slave address
while (I2caRegs.I2CSTR.bit.BB == 1); // still busy?
I2caRegs.I2CMDR.all = 0x2620; // start, no stop bit, master, tx, reset I2C
I2caRegs.I2CCNT = 1; // assume register address is one byte
I2caRegs.I2CDXR = reg_address; // register address of the sensor (1 byte)
while(!I2caRegs.I2CSTR.bit.ARDY); // all ready?
I2caRegs.I2CMDR.all = 0x2C20; // start, stop bit when CNT =0, master, rx, reset I2C
I2caRegs.I2CCNT = 1; // only read one byte data
if(I2caRegs.I2CSTR.bit.NACK == 1)
{
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT; // 0x0002
}
I2caRegs.I2CMDR.bit.STP = 1; // stop bit when CNT=0
while(!I2caRegs.I2CSTR.bit.SCD); // stop bit detected?
tempdata = I2caRegs.I2CDRR; // read one byte data
return(tempdata);
}
// EOF
|
wonderful89/KSCrash | Source/KSCrash/Recording/Monitors/KSCrashMonitor_MachException.c | //
// KSCrashMonitor_MachException.c
//
// Created by <NAME> on 2012-02-04.
//
// Copyright (c) 2012 <NAME>. 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 remain in place
// in this source code.
//
// 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.
//
#include "KSCrashMonitor_MachException.h"
#include "KSCrashMonitorContext.h"
#include "KSCPU.h"
#include "KSID.h"
#include "KSThread.h"
#include "KSSystemCapabilities.h"
#include "KSStackCursor_MachineContext.h"
//#define KSLogger_LocalLevel TRACE
#include "KSLogger.h"
#if KSCRASH_HAS_MACH
#include <mach/mach.h>
#include <pthread.h>
#include <signal.h>
// ============================================================================
#pragma mark - Constants -
// ============================================================================
static const char* kThreadPrimary = "KSCrash Exception Handler (Primary)";
static const char* kThreadSecondary = "KSCrash Exception Handler (Secondary)";
#if __LP64__
#define MACH_ERROR_CODE_MASK 0xFFFFFFFFFFFFFFFF
#else
#define MACH_ERROR_CODE_MASK 0xFFFFFFFF
#endif
// ============================================================================
#pragma mark - Types -
// ============================================================================
/** A mach exception message (according to ux_exception.c, xnu-1699.22.81).
*/
#pragma pack(4)
typedef struct
{
/** Mach header. */
mach_msg_header_t header;
// Start of the kernel processed data.
/** Basic message body data. */
mach_msg_body_t body;
/** The thread that raised the exception. */
mach_msg_port_descriptor_t thread;
/** The task that raised the exception. */
mach_msg_port_descriptor_t task;
// End of the kernel processed data.
/** Network Data Representation. */
NDR_record_t NDR;
/** The exception that was raised. */
exception_type_t exception;
/** The number of codes. */
mach_msg_type_number_t codeCount;
/** Exception code and subcode. */
// ux_exception.c defines this as mach_exception_data_t for some reason.
// But it's not actually a pointer; it's an embedded array.
// On 32-bit systems, only the lower 32 bits of the code and subcode
// are valid.
mach_exception_data_type_t code[0];
/** Padding to avoid RCV_TOO_LARGE. */
char padding[512];
} MachExceptionMessage;
#pragma pack()
/** A mach reply message (according to ux_exception.c, xnu-1699.22.81).
*/
#pragma pack(4)
typedef struct
{
/** Mach header. */
mach_msg_header_t header;
/** Network Data Representation. */
NDR_record_t NDR;
/** Return code. */
kern_return_t returnCode;
} MachReplyMessage;
#pragma pack()
// ============================================================================
#pragma mark - Globals -
// ============================================================================
static volatile bool g_isEnabled = false;
static KSCrash_MonitorContext g_monitorContext;
static KSStackCursor g_stackCursor;
static bool g_isHandlingCrash = false;
/** Holds exception port info regarding the previously installed exception
* handlers.
*/
static struct
{
exception_mask_t masks[EXC_TYPES_COUNT];
exception_handler_t ports[EXC_TYPES_COUNT];
exception_behavior_t behaviors[EXC_TYPES_COUNT];
thread_state_flavor_t flavors[EXC_TYPES_COUNT];
mach_msg_type_number_t count;
} g_previousExceptionPorts;
/** Our exception port. */
static mach_port_t g_exceptionPort = MACH_PORT_NULL;
/** Primary exception handler thread. */
static pthread_t g_primaryPThread;
static thread_t g_primaryMachThread;
/** Secondary exception handler thread in case crash handler crashes. */
static pthread_t g_secondaryPThread;
static thread_t g_secondaryMachThread;
static char g_primaryEventID[37];
static char g_secondaryEventID[37];
// ============================================================================
#pragma mark - Utility -
// ============================================================================
/** Restore the original mach exception ports.
*/
static void restoreExceptionPorts(void)
{
KSLOG_DEBUG("Restoring original exception ports.");
if(g_previousExceptionPorts.count == 0)
{
KSLOG_DEBUG("Original exception ports were already restored.");
return;
}
const task_t thisTask = mach_task_self();
kern_return_t kr;
// Reinstall old exception ports.
for(mach_msg_type_number_t i = 0; i < g_previousExceptionPorts.count; i++)
{
KSLOG_TRACE("Restoring port index %d", i);
kr = task_set_exception_ports(thisTask,
g_previousExceptionPorts.masks[i],
g_previousExceptionPorts.ports[i],
g_previousExceptionPorts.behaviors[i],
g_previousExceptionPorts.flavors[i]);
if(kr != KERN_SUCCESS)
{
KSLOG_ERROR("task_set_exception_ports: %s",
mach_error_string(kr));
}
}
KSLOG_DEBUG("Exception ports restored.");
g_previousExceptionPorts.count = 0;
}
#define EXC_UNIX_BAD_SYSCALL 0x10000 /* SIGSYS */
#define EXC_UNIX_BAD_PIPE 0x10001 /* SIGPIPE */
#define EXC_UNIX_ABORT 0x10002 /* SIGABRT */
static int signalForMachException(exception_type_t exception, mach_exception_code_t code)
{
switch(exception)
{
case EXC_ARITHMETIC:
return SIGFPE;
case EXC_BAD_ACCESS:
return code == KERN_INVALID_ADDRESS ? SIGSEGV : SIGBUS;
case EXC_BAD_INSTRUCTION:
return SIGILL;
case EXC_BREAKPOINT:
return SIGTRAP;
case EXC_EMULATION:
return SIGEMT;
case EXC_SOFTWARE:
{
switch (code)
{
case EXC_UNIX_BAD_SYSCALL:
return SIGSYS;
case EXC_UNIX_BAD_PIPE:
return SIGPIPE;
case EXC_UNIX_ABORT:
return SIGABRT;
case EXC_SOFT_SIGNAL:
return SIGKILL;
}
break;
}
}
return 0;
}
static exception_type_t machExceptionForSignal(int sigNum)
{
switch(sigNum)
{
case SIGFPE:
return EXC_ARITHMETIC;
case SIGSEGV:
return EXC_BAD_ACCESS;
case SIGBUS:
return EXC_BAD_ACCESS;
case SIGILL:
return EXC_BAD_INSTRUCTION;
case SIGTRAP:
return EXC_BREAKPOINT;
case SIGEMT:
return EXC_EMULATION;
case SIGSYS:
return EXC_UNIX_BAD_SYSCALL;
case SIGPIPE:
return EXC_UNIX_BAD_PIPE;
case SIGABRT:
// The Apple reporter uses EXC_CRASH instead of EXC_UNIX_ABORT
return EXC_CRASH;
case SIGKILL:
return EXC_SOFT_SIGNAL;
}
return 0;
}
// ============================================================================
#pragma mark - Handler -
// ============================================================================
/** Our exception handler thread routine.
* Wait for an exception message, uninstall our exception port, record the
* exception information, and write a report.
*/
static void* handleExceptions(void* const userData)
{
MachExceptionMessage exceptionMessage = {{0}};
MachReplyMessage replyMessage = {{0}};
char* eventID = g_primaryEventID;
const char* threadName = (const char*) userData;
pthread_setname_np(threadName);
/// 如果当前是第二个线程,则将其挂起,这里的含义是什么?
if(threadName == kThreadSecondary)
{
KSLOG_DEBUG("This is the secondary thread. Suspending.");
thread_suspend((thread_t)ksthread_self());
eventID = g_secondaryEventID;
KSLOG_DEBUG("[debug] 挂起之后还能执行吗 --> 不能,需要下面进行激活");
} else {
KSLOG_DEBUG("[debug] This is the primary thread. 继续往下执行.");
}
/// 循环读取注册好的异常端口信息
for(;;)
{
KSLOG_DEBUG("Waiting for mach exception");
// Wait for a message.
kern_return_t kr = mach_msg(&exceptionMessage.header,
MACH_RCV_MSG,
0,
sizeof(exceptionMessage),
g_exceptionPort,
MACH_MSG_TIMEOUT_NONE,
MACH_PORT_NULL);
/// 获取到信息后则代表发生了 Mach 层异常,跳出 for 循环,组装数据
if(kr == KERN_SUCCESS)
{
break;
}
// Loop and try again on failure.
KSLOG_ERROR("mach_msg: %s", mach_error_string(kr));
}
KSLOG_DEBUG("Trapped mach exception code 0x%llx, subcode 0x%llx",
exceptionMessage.code[0], exceptionMessage.code[1]);
if(g_isEnabled)
{
thread_act_array_t threads = NULL;
mach_msg_type_number_t numThreads = 0;
/// 挂起所有的线程
ksmc_suspendEnvironment(&threads, &numThreads);
g_isHandlingCrash = true;
/// 通知发生了异常
kscm_notifyFatalExceptionCaptured(true);
KSLOG_DEBUG("Exception handler is installed. Continuing exception handling.");
// Switch to the secondary thread if necessary, or uninstall the handler
// to avoid a death loop.
if(ksthread_self() == g_primaryMachThread)
{
KSLOG_DEBUG("This is the primary exception thread. Activating secondary thread.");
// TODO: This was put here to avoid a freeze. Does secondary thread ever fire?
/// 这里恢复第二个Mach处理线程, 并恢复原始的异常端口
bool isDebug = false;
if (isDebug) {
restoreExceptionPorts();
}
if(thread_resume(g_secondaryMachThread) != KERN_SUCCESS)
{
KSLOG_DEBUG("Could not activate secondary thread. Restoring original exception ports.");
}
}
else
{
KSLOG_DEBUG("This is the secondary exception thread.");// Restoring original exception ports.");
// restoreExceptionPorts();
}
// Fill out crash information
/// 组装异常所需要的方案现场信息
KSLOG_DEBUG("Fetching machine state.");
KSMC_NEW_CONTEXT(machineContext);
KSCrash_MonitorContext* crashContext = &g_monitorContext;
crashContext->offendingMachineContext = machineContext;
kssc_initCursor(&g_stackCursor, NULL, NULL);
if(ksmc_getContextForThread(exceptionMessage.thread.name, machineContext, true))
{
kssc_initWithMachineContext(&g_stackCursor, KSSC_MAX_STACK_DEPTH, machineContext);
KSLOG_TRACE("Fault address %p, instruction address %p",
kscpu_faultAddress(machineContext), kscpu_instructionAddress(machineContext));
if(exceptionMessage.exception == EXC_BAD_ACCESS)
{
crashContext->faultAddress = kscpu_faultAddress(machineContext);
}
else
{
crashContext->faultAddress = kscpu_instructionAddress(machineContext);
}
}
KSLOG_DEBUG("Filling out context.");
crashContext->crashType = KSCrashMonitorTypeMachException;
crashContext->eventID = eventID;
crashContext->registersAreValid = true;
crashContext->mach.type = exceptionMessage.exception;
crashContext->mach.code = exceptionMessage.code[0] & (int64_t)MACH_ERROR_CODE_MASK;
crashContext->mach.subcode = exceptionMessage.code[1] & (int64_t)MACH_ERROR_CODE_MASK;
if(crashContext->mach.code == KERN_PROTECTION_FAILURE && crashContext->isStackOverflow)
{
// A stack overflow should return KERN_INVALID_ADDRESS, but
// when a stack blasts through the guard pages at the top of the stack,
// it generates KERN_PROTECTION_FAILURE. Correct for this.
crashContext->mach.code = KERN_INVALID_ADDRESS;
}
/// 将mach异常的异常码转换为 signal 的异常码
crashContext->signal.signum = signalForMachException(crashContext->mach.type, crashContext->mach.code);
crashContext->stackCursor = &g_stackCursor;
kscm_handleException(crashContext);
KSLOG_DEBUG("Crash handling complete. Restoring original handlers.");
g_isHandlingCrash = false;
/// 恢复所有线程
ksmc_resumeEnvironment(threads, numThreads);
}
KSLOG_DEBUG("Replying to mach exception message.");
// Send a reply saying "I didn't handle this exception".
/// 响应mach异常-发送一个回复消息:我没有处理这个异常
replyMessage.header = exceptionMessage.header;
replyMessage.NDR = exceptionMessage.NDR;
replyMessage.returnCode = KERN_FAILURE;
mach_msg(&replyMessage.header,
MACH_SEND_MSG,
sizeof(replyMessage),
0,
MACH_PORT_NULL,
MACH_MSG_TIMEOUT_NONE,
MACH_PORT_NULL);
return NULL;
}
// ============================================================================
#pragma mark - API -
// ============================================================================
/// 卸载异常处理程序
static void uninstallExceptionHandler()
{
KSLOG_DEBUG("Uninstalling mach exception handler.");
// NOTE: Do not deallocate the exception port. If a secondary crash occurs
// it will hang the process.
/// 注意:不要释放异常处理端口,因为如果第二个crash发生,将会挂起进程。
restoreExceptionPorts();
thread_t thread_self = (thread_t)ksthread_self();
/// 取消第一个异常处理线程
if(g_primaryPThread != 0 && g_primaryMachThread != thread_self)
{
KSLOG_DEBUG("Canceling primary exception thread.");
if(g_isHandlingCrash)
{
thread_terminate(g_primaryMachThread);
}
else
{
pthread_cancel(g_primaryPThread);
}
g_primaryMachThread = 0;
g_primaryPThread = 0;
}
/// 取消第二个异常处理线程
if(g_secondaryPThread != 0 && g_secondaryMachThread != thread_self)
{
KSLOG_DEBUG("Canceling secondary exception thread.");
if(g_isHandlingCrash)
{
thread_terminate(g_secondaryMachThread);
}
else
{
pthread_cancel(g_secondaryPThread);
}
g_secondaryMachThread = 0;
g_secondaryPThread = 0;
}
g_exceptionPort = MACH_PORT_NULL;
KSLOG_DEBUG("Mach exception handlers uninstalled.");
}
/// mach 层的异常处理函数-安装器
static bool installExceptionHandler()
{
KSLOG_DEBUG("Installing mach exception handler.");
bool attributes_created = false;
pthread_attr_t attr;
kern_return_t kr;
int error;
const task_t thisTask = mach_task_self();
exception_mask_t mask = EXC_MASK_BAD_ACCESS |
EXC_MASK_BAD_INSTRUCTION |
EXC_MASK_ARITHMETIC |
EXC_MASK_SOFTWARE |
EXC_MASK_BREAKPOINT;
KSLOG_DEBUG("Backing up original exception ports.");
/// 为了备份,先获取原来的异常端口。主要是获取到结构体 【g_previousExceptionPorts】中。
/// mask 屏蔽为表示获取的类型。
kr = task_get_exception_ports(thisTask,
mask,
g_previousExceptionPorts.masks,
&g_previousExceptionPorts.count,
g_previousExceptionPorts.ports,
g_previousExceptionPorts.behaviors,
g_previousExceptionPorts.flavors);
if(kr != KERN_SUCCESS)
{
/// 获取原来的端口不成功,直接跳转到失败
KSLOG_ERROR("task_get_exception_ports: %s", mach_error_string(kr));
goto failed;
}
/// 判断我们自己的异常端口是否存在,如果不存在先创建,并做一些初始化
if(g_exceptionPort == MACH_PORT_NULL)
{
KSLOG_DEBUG("Allocating new port with receive rights.");
kr = mach_port_allocate(thisTask,
MACH_PORT_RIGHT_RECEIVE,
&g_exceptionPort);
if(kr != KERN_SUCCESS)
{
KSLOG_ERROR("mach_port_allocate: %s", mach_error_string(kr));
goto failed;
}
KSLOG_DEBUG("Adding send rights to port.");
/// 为异常处理端口申请权限:MACH_MSG_TYPE_MAKE_SEND(接收多次的权限)
kr = mach_port_insert_right(thisTask,
g_exceptionPort,
g_exceptionPort,
MACH_MSG_TYPE_MAKE_SEND);
if(kr != KERN_SUCCESS)
{
KSLOG_ERROR("mach_port_insert_right: %s", mach_error_string(kr));
goto failed;
}
}
KSLOG_DEBUG("Installing port as exception handler.");
/// 当前任务设置上自己的处理端口
kr = task_set_exception_ports(thisTask,
mask,
g_exceptionPort,
(int)(EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES),
THREAD_STATE_NONE);
if(kr != KERN_SUCCESS)
{
KSLOG_ERROR("task_set_exception_ports: %s", mach_error_string(kr));
goto failed;
}
KSLOG_DEBUG("Creating secondary exception thread (suspended).");
/// 这里创建一个挂起的新的线程。用于第二层的异常处理。handleExceptions 是异常处理函数
pthread_attr_init(&attr);
attributes_created = true;
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // 另一个PTHREAD_CREATE_JOINABLE
error = pthread_create(&g_secondaryPThread,
&attr,
&handleExceptions,
(void*)kThreadSecondary);
if(error != 0)
{
KSLOG_ERROR("pthread_create_suspended_np: %s", strerror(error));
goto failed;
}
/// 获取g_secondaryPThread 对应的mach线程结构。[pthread_t的类型转换成mach_port_t类型]
g_secondaryMachThread = pthread_mach_thread_np(g_secondaryPThread);
/// 设置到保留线程数组【g_reservedThreads】中
ksmc_addReservedThread(g_secondaryMachThread);
/// 创建基础的异常处理线程(第一层)
KSLOG_DEBUG("Creating primary exception thread.");
error = pthread_create(&g_primaryPThread,
&attr,
&handleExceptions,
(void*)kThreadPrimary);
if(error != 0)
{
KSLOG_ERROR("pthread_create: %s", strerror(error));
goto failed;
}
pthread_attr_destroy(&attr);
g_primaryMachThread = pthread_mach_thread_np(g_primaryPThread);
/// 同上:将对应的mach线程保存到保留线程数组【g_reservedThreads】中
ksmc_addReservedThread(g_primaryMachThread);
KSLOG_DEBUG("Mach exception handler installed.");
return true;
failed:
KSLOG_DEBUG("Failed to install mach exception handler.");
if(attributes_created)
{
pthread_attr_destroy(&attr);
}
uninstallExceptionHandler();
return false;
}
static void setEnabled(bool isEnabled)
{
if(isEnabled != g_isEnabled)
{
g_isEnabled = isEnabled;
if(isEnabled)
{
ksid_generate(g_primaryEventID);
ksid_generate(g_secondaryEventID);
if(!installExceptionHandler())
{
return;
}
}
else
{
uninstallExceptionHandler();
}
}
}
static bool isEnabled()
{
return g_isEnabled;
}
static void addContextualInfoToEvent(struct KSCrash_MonitorContext* eventContext)
{
if(eventContext->crashType == KSCrashMonitorTypeSignal)
{
eventContext->mach.type = machExceptionForSignal(eventContext->signal.signum);
}
else if(eventContext->crashType != KSCrashMonitorTypeMachException)
{
eventContext->mach.type = EXC_CRASH;
}
}
#endif
KSCrashMonitorAPI* kscm_machexception_getAPI()
{
static KSCrashMonitorAPI api =
{
#if KSCRASH_HAS_MACH
.setEnabled = setEnabled,
.isEnabled = isEnabled,
.addContextualInfoToEvent = addContextualInfoToEvent
#endif
};
return &api;
}
|
wonderful89/KSCrash | iOS/Simple-Example/ViewController.h | <reponame>wonderful89/KSCrash<gh_stars>0
//
// ViewController.h
// Simple-Example
//
#import <UIKit/UIKit.h>
#import <KSCrash/KSCrash.h>
@interface ViewController : UIViewController
@end
|
wonderful89/KSCrash | iOS/KSCrash/NSZombieBase.h | //
// NSZombieBase.h
// KSCrash-iOS
//
// Created by qianzhao on 2021/8/18.
// Copyright © 2021 <NAME>. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSZombieBase : NSObject
@end
NS_ASSUME_NONNULL_END
|
wonderful89/KSCrash | Source/KSCrash/Recording/KSCrashReport.c | //
// KSCrashReport.m
//
// Created by <NAME> on 2012-01-28.
//
// Copyright (c) 2012 <NAME>. 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 remain in place
// in this source code.
//
// 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.
//
#include "KSCrashReport.h"
#include "KSCrashReportFields.h"
#include "KSCrashReportWriter.h"
#include "KSDynamicLinker.h"
#include "KSFileUtils.h"
#include "KSJSONCodec.h"
#include "KSCPU.h"
#include "KSMemory.h"
#include "KSMach.h"
#include "KSThread.h"
#include "KSObjC.h"
#include "KSSignalInfo.h"
#include "KSCrashMonitor_Zombie.h"
#include "KSString.h"
#include "KSCrashReportVersion.h"
#include "KSStackCursor_Backtrace.h"
#include "KSStackCursor_MachineContext.h"
#include "KSSystemCapabilities.h"
#include "KSCrashCachedData.h"
//#define KSLogger_LocalLevel TRACE
#include "KSLogger.h"
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
// ============================================================================
#pragma mark - Constants -
// ============================================================================
/** Default number of objects, subobjects, and ivars to record from a memory loc */
#define kDefaultMemorySearchDepth 15
/** How far to search the stack (in pointer sized jumps) for notable data. */
#define kStackNotableSearchBackDistance 20
#define kStackNotableSearchForwardDistance 10
/** How much of the stack to dump (in pointer sized jumps). */
#define kStackContentsPushedDistance 20
#define kStackContentsPoppedDistance 10
#define kStackContentsTotalDistance (kStackContentsPushedDistance + kStackContentsPoppedDistance)
/** The minimum length for a valid string. */
#define kMinStringLength 4
// ============================================================================
#pragma mark - JSON Encoding -
// ============================================================================
#define getJsonContext(REPORT_WRITER) ((KSJSONEncodeContext*)((REPORT_WRITER)->context))
/** Used for writing hex string values. */
static const char g_hexNybbles[] =
{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
// ============================================================================
#pragma mark - Runtime Config -
// ============================================================================
typedef struct
{
/** If YES, introspect memory contents during a crash.
* Any Objective-C objects or C strings near the stack pointer or referenced by
* cpu registers or exceptions will be recorded in the crash report, along with
* their contents.
*/
bool enabled;
/** List of classes that should never be introspected.
* Whenever a class in this list is encountered, only the class name will be recorded.
*/
const char** restrictedClasses;
int restrictedClassesCount;
} KSCrash_IntrospectionRules;
static const char* g_userInfoJSON;
static KSCrash_IntrospectionRules g_introspectionRules;
static KSReportWriteCallback g_userSectionWriteCallback;
#pragma mark Callbacks
static void addBooleanElement(const KSCrashReportWriter* const writer, const char* const key, const bool value)
{
ksjson_addBooleanElement(getJsonContext(writer), key, value);
}
static void addFloatingPointElement(const KSCrashReportWriter* const writer, const char* const key, const double value)
{
ksjson_addFloatingPointElement(getJsonContext(writer), key, value);
}
static void addIntegerElement(const KSCrashReportWriter* const writer, const char* const key, const int64_t value)
{
ksjson_addIntegerElement(getJsonContext(writer), key, value);
}
static void addUIntegerElement(const KSCrashReportWriter* const writer, const char* const key, const uint64_t value)
{
ksjson_addUIntegerElement(getJsonContext(writer), key, value);
}
static void addStringElement(const KSCrashReportWriter* const writer, const char* const key, const char* const value)
{
ksjson_addStringElement(getJsonContext(writer), key, value, KSJSON_SIZE_AUTOMATIC);
}
static void addTextFileElement(const KSCrashReportWriter* const writer, const char* const key, const char* const filePath)
{
const int fd = open(filePath, O_RDONLY);
if(fd < 0)
{
KSLOG_ERROR("Could not open file %s: %s", filePath, strerror(errno));
return;
}
if(ksjson_beginStringElement(getJsonContext(writer), key) != KSJSON_OK)
{
KSLOG_ERROR("Could not start string element");
goto done;
}
char buffer[512];
int bytesRead;
for(bytesRead = (int)read(fd, buffer, sizeof(buffer));
bytesRead > 0;
bytesRead = (int)read(fd, buffer, sizeof(buffer)))
{
if(ksjson_appendStringElement(getJsonContext(writer), buffer, bytesRead) != KSJSON_OK)
{
KSLOG_ERROR("Could not append string element");
goto done;
}
}
done:
ksjson_endStringElement(getJsonContext(writer));
close(fd);
}
static void addDataElement(const KSCrashReportWriter* const writer,
const char* const key,
const char* const value,
const int length)
{
ksjson_addDataElement(getJsonContext(writer), key, value, length);
}
static void beginDataElement(const KSCrashReportWriter* const writer, const char* const key)
{
ksjson_beginDataElement(getJsonContext(writer), key);
}
static void appendDataElement(const KSCrashReportWriter* const writer, const char* const value, const int length)
{
ksjson_appendDataElement(getJsonContext(writer), value, length);
}
static void endDataElement(const KSCrashReportWriter* const writer)
{
ksjson_endDataElement(getJsonContext(writer));
}
static void addUUIDElement(const KSCrashReportWriter* const writer, const char* const key, const unsigned char* const value)
{
if(value == NULL)
{
ksjson_addNullElement(getJsonContext(writer), key);
}
else
{
char uuidBuffer[37];
const unsigned char* src = value;
char* dst = uuidBuffer;
for(int i = 0; i < 4; i++)
{
*dst++ = g_hexNybbles[(*src>>4)&15];
*dst++ = g_hexNybbles[(*src++)&15];
}
*dst++ = '-';
for(int i = 0; i < 2; i++)
{
*dst++ = g_hexNybbles[(*src>>4)&15];
*dst++ = g_hexNybbles[(*src++)&15];
}
*dst++ = '-';
for(int i = 0; i < 2; i++)
{
*dst++ = g_hexNybbles[(*src>>4)&15];
*dst++ = g_hexNybbles[(*src++)&15];
}
*dst++ = '-';
for(int i = 0; i < 2; i++)
{
*dst++ = g_hexNybbles[(*src>>4)&15];
*dst++ = g_hexNybbles[(*src++)&15];
}
*dst++ = '-';
for(int i = 0; i < 6; i++)
{
*dst++ = g_hexNybbles[(*src>>4)&15];
*dst++ = g_hexNybbles[(*src++)&15];
}
ksjson_addStringElement(getJsonContext(writer), key, uuidBuffer, (int)(dst - uuidBuffer));
}
}
static void addJSONElement(const KSCrashReportWriter* const writer,
const char* const key,
const char* const jsonElement,
bool closeLastContainer)
{
int jsonResult = ksjson_addJSONElement(getJsonContext(writer),
key,
jsonElement,
(int)strlen(jsonElement),
closeLastContainer);
if(jsonResult != KSJSON_OK)
{
char errorBuff[100];
snprintf(errorBuff,
sizeof(errorBuff),
"Invalid JSON data: %s",
ksjson_stringForError(jsonResult));
ksjson_beginObject(getJsonContext(writer), key);
ksjson_addStringElement(getJsonContext(writer),
KSCrashField_Error,
errorBuff,
KSJSON_SIZE_AUTOMATIC);
ksjson_addStringElement(getJsonContext(writer),
KSCrashField_JSONData,
jsonElement,
KSJSON_SIZE_AUTOMATIC);
ksjson_endContainer(getJsonContext(writer));
}
}
static void addJSONElementFromFile(const KSCrashReportWriter* const writer,
const char* const key,
const char* const filePath,
bool closeLastContainer)
{
ksjson_addJSONFromFile(getJsonContext(writer), key, filePath, closeLastContainer);
}
static void beginObject(const KSCrashReportWriter* const writer, const char* const key)
{
ksjson_beginObject(getJsonContext(writer), key);
}
static void beginArray(const KSCrashReportWriter* const writer, const char* const key)
{
ksjson_beginArray(getJsonContext(writer), key);
}
static void endContainer(const KSCrashReportWriter* const writer)
{
ksjson_endContainer(getJsonContext(writer));
}
static void addTextLinesFromFile(const KSCrashReportWriter* const writer, const char* const key, const char* const filePath)
{
char readBuffer[1024];
KSBufferedReader reader;
if(!ksfu_openBufferedReader(&reader, filePath, readBuffer, sizeof(readBuffer)))
{
return;
}
char buffer[1024];
beginArray(writer, key);
{
for(;;)
{
int length = sizeof(buffer);
ksfu_readBufferedReaderUntilChar(&reader, '\n', buffer, &length);
if(length <= 0)
{
break;
}
buffer[length - 1] = '\0';
ksjson_addStringElement(getJsonContext(writer), NULL, buffer, KSJSON_SIZE_AUTOMATIC);
}
}
endContainer(writer);
ksfu_closeBufferedReader(&reader);
}
static int addJSONData(const char* restrict const data, const int length, void* restrict userData)
{
KSBufferedWriter* writer = (KSBufferedWriter*)userData;
const bool success = ksfu_writeBufferedWriter(writer, data, length);
return success ? KSJSON_OK : KSJSON_ERROR_CANNOT_ADD_DATA;
}
// ============================================================================
#pragma mark - Utility -
// ============================================================================
/** Check if a memory address points to a valid null terminated UTF-8 string.
*
* @param address The address to check.
*
* @return true if the address points to a string.
*/
static bool isValidString(const void* const address)
{
if((void*)address == NULL)
{
return false;
}
char buffer[500];
if((uintptr_t)address+sizeof(buffer) < (uintptr_t)address)
{
// Wrapped around the address range.
return false;
}
if(!ksmem_copySafely(address, buffer, sizeof(buffer)))
{
return false;
}
return ksstring_isNullTerminatedUTF8String(buffer, kMinStringLength, sizeof(buffer));
}
/** Get the backtrace for the specified machine context.
*
* This function will choose how to fetch the backtrace based on the crash and
* machine context. It may store the backtrace in backtraceBuffer unless it can
* be fetched directly from memory. Do not count on backtraceBuffer containing
* anything. Always use the return value.
*
* @param crash The crash handler context.
*
* @param machineContext The machine context.
*
* @param cursor The stack cursor to fill.
*
* @return True if the cursor was filled.
*/
static bool getStackCursor(const KSCrash_MonitorContext* const crash,
const struct KSMachineContext* const machineContext,
KSStackCursor *cursor)
{
if(ksmc_getThreadFromContext(machineContext) == ksmc_getThreadFromContext(crash->offendingMachineContext))
{
*cursor = *((KSStackCursor*)crash->stackCursor);
return true;
}
kssc_initWithMachineContext(cursor, KSSC_STACK_OVERFLOW_THRESHOLD, machineContext);
return true;
}
// ============================================================================
#pragma mark - Report Writing -
// ============================================================================
/** Write the contents of a memory location.
* Also writes meta information about the data.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param address The memory address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeMemoryContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t address,
int* limit);
/** Write a string to the report.
* This will only print the first child of the array.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param objectAddress The object's address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeNSStringContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t objectAddress,
__unused int* limit)
{
const void* object = (const void*)objectAddress;
char buffer[200];
if(ksobjc_copyStringContents(object, buffer, sizeof(buffer)))
{
writer->addStringElement(writer, key, buffer);
}
}
/** Write a URL to the report.
* This will only print the first child of the array.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param objectAddress The object's address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeURLContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t objectAddress,
__unused int* limit)
{
const void* object = (const void*)objectAddress;
char buffer[200];
if(ksobjc_copyStringContents(object, buffer, sizeof(buffer)))
{
writer->addStringElement(writer, key, buffer);
}
}
/** Write a date to the report.
* This will only print the first child of the array.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param objectAddress The object's address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeDateContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t objectAddress,
__unused int* limit)
{
const void* object = (const void*)objectAddress;
writer->addFloatingPointElement(writer, key, ksobjc_dateContents(object));
}
/** Write a number to the report.
* This will only print the first child of the array.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param objectAddress The object's address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeNumberContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t objectAddress,
__unused int* limit)
{
const void* object = (const void*)objectAddress;
writer->addFloatingPointElement(writer, key, ksobjc_numberAsFloat(object));
}
/** Write an array to the report.
* This will only print the first child of the array.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param objectAddress The object's address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeArrayContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t objectAddress,
int* limit)
{
const void* object = (const void*)objectAddress;
uintptr_t firstObject;
if(ksobjc_arrayContents(object, &firstObject, 1) == 1)
{
writeMemoryContents(writer, key, firstObject, limit);
}
}
/** Write out ivar information about an unknown object.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param objectAddress The object's address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeUnknownObjectContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t objectAddress,
int* limit)
{
(*limit)--;
const void* object = (const void*)objectAddress;
KSObjCIvar ivars[10];
int8_t s8;
int16_t s16;
int sInt;
int32_t s32;
int64_t s64;
uint8_t u8;
uint16_t u16;
unsigned int uInt;
uint32_t u32;
uint64_t u64;
float f32;
double f64;
bool b;
void* pointer;
writer->beginObject(writer, key);
{
if(ksobjc_isTaggedPointer(object))
{
writer->addIntegerElement(writer, "tagged_payload", (int64_t)ksobjc_taggedPointerPayload(object));
}
else
{
const void* class = ksobjc_isaPointer(object);
int ivarCount = ksobjc_ivarList(class, ivars, sizeof(ivars)/sizeof(*ivars));
*limit -= ivarCount;
for(int i = 0; i < ivarCount; i++)
{
KSObjCIvar* ivar = &ivars[i];
switch(ivar->type[0])
{
case 'c':
ksobjc_ivarValue(object, ivar->index, &s8);
writer->addIntegerElement(writer, ivar->name, s8);
break;
case 'i':
ksobjc_ivarValue(object, ivar->index, &sInt);
writer->addIntegerElement(writer, ivar->name, sInt);
break;
case 's':
ksobjc_ivarValue(object, ivar->index, &s16);
writer->addIntegerElement(writer, ivar->name, s16);
break;
case 'l':
ksobjc_ivarValue(object, ivar->index, &s32);
writer->addIntegerElement(writer, ivar->name, s32);
break;
case 'q':
ksobjc_ivarValue(object, ivar->index, &s64);
writer->addIntegerElement(writer, ivar->name, s64);
break;
case 'C':
ksobjc_ivarValue(object, ivar->index, &u8);
writer->addUIntegerElement(writer, ivar->name, u8);
break;
case 'I':
ksobjc_ivarValue(object, ivar->index, &uInt);
writer->addUIntegerElement(writer, ivar->name, uInt);
break;
case 'S':
ksobjc_ivarValue(object, ivar->index, &u16);
writer->addUIntegerElement(writer, ivar->name, u16);
break;
case 'L':
ksobjc_ivarValue(object, ivar->index, &u32);
writer->addUIntegerElement(writer, ivar->name, u32);
break;
case 'Q':
ksobjc_ivarValue(object, ivar->index, &u64);
writer->addUIntegerElement(writer, ivar->name, u64);
break;
case 'f':
ksobjc_ivarValue(object, ivar->index, &f32);
writer->addFloatingPointElement(writer, ivar->name, f32);
break;
case 'd':
ksobjc_ivarValue(object, ivar->index, &f64);
writer->addFloatingPointElement(writer, ivar->name, f64);
break;
case 'B':
ksobjc_ivarValue(object, ivar->index, &b);
writer->addBooleanElement(writer, ivar->name, b);
break;
case '*':
case '@':
case '#':
case ':':
ksobjc_ivarValue(object, ivar->index, &pointer);
writeMemoryContents(writer, ivar->name, (uintptr_t)pointer, limit);
break;
default:
KSLOG_DEBUG("%s: Unknown ivar type [%s]", ivar->name, ivar->type);
}
}
}
}
writer->endContainer(writer);
}
static bool isRestrictedClass(const char* name)
{
if(g_introspectionRules.restrictedClasses != NULL)
{
for(int i = 0; i < g_introspectionRules.restrictedClassesCount; i++)
{
if(strcmp(name, g_introspectionRules.restrictedClasses[i]) == 0)
{
return true;
}
}
}
return false;
}
static void writeZombieIfPresent(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t address)
{
#if KSCRASH_HAS_OBJC
const void* object = (const void*)address;
const char* zombieClassName = kszombie_className(object);
if(zombieClassName != NULL)
{
writer->addStringElement(writer, key, zombieClassName);
}
#endif
}
static bool writeObjCObject(const KSCrashReportWriter* const writer,
const uintptr_t address,
int* limit)
{
#if KSCRASH_HAS_OBJC
const void* object = (const void*)address;
switch(ksobjc_objectType(object))
{
case KSObjCTypeClass:
writer->addStringElement(writer, KSCrashField_Type, KSCrashMemType_Class);
writer->addStringElement(writer, KSCrashField_Class, ksobjc_className(object));
return true;
case KSObjCTypeObject:
{
writer->addStringElement(writer, KSCrashField_Type, KSCrashMemType_Object);
const char* className = ksobjc_objectClassName(object);
writer->addStringElement(writer, KSCrashField_Class, className);
if(!isRestrictedClass(className))
{
switch(ksobjc_objectClassType(object))
{
case KSObjCClassTypeString:
writeNSStringContents(writer, KSCrashField_Value, address, limit);
return true;
case KSObjCClassTypeURL:
writeURLContents(writer, KSCrashField_Value, address, limit);
return true;
case KSObjCClassTypeDate:
writeDateContents(writer, KSCrashField_Value, address, limit);
return true;
case KSObjCClassTypeArray:
if(*limit > 0)
{
writeArrayContents(writer, KSCrashField_FirstObject, address, limit);
}
return true;
case KSObjCClassTypeNumber:
writeNumberContents(writer, KSCrashField_Value, address, limit);
return true;
case KSObjCClassTypeDictionary:
case KSObjCClassTypeException:
// TODO: Implement these.
if(*limit > 0)
{
writeUnknownObjectContents(writer, KSCrashField_Ivars, address, limit);
}
return true;
case KSObjCClassTypeUnknown:
if(*limit > 0)
{
writeUnknownObjectContents(writer, KSCrashField_Ivars, address, limit);
}
return true;
}
}
break;
}
case KSObjCTypeBlock:
writer->addStringElement(writer, KSCrashField_Type, KSCrashMemType_Block);
const char* className = ksobjc_objectClassName(object);
writer->addStringElement(writer, KSCrashField_Class, className);
return true;
case KSObjCTypeUnknown:
break;
}
#endif
return false;
}
/** Write the contents of a memory location.
* Also writes meta information about the data.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param address The memory address.
*
* @param limit How many more subreferenced objects to write, if any.
*/
static void writeMemoryContents(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t address,
int* limit)
{
(*limit)--;
const void* object = (const void*)address;
writer->beginObject(writer, key);
{
writer->addUIntegerElement(writer, KSCrashField_Address, address);
writeZombieIfPresent(writer, KSCrashField_LastDeallocObject, address);
if(!writeObjCObject(writer, address, limit))
{
if(object == NULL)
{
writer->addStringElement(writer, KSCrashField_Type, KSCrashMemType_NullPointer);
}
else if(isValidString(object))
{
writer->addStringElement(writer, KSCrashField_Type, KSCrashMemType_String);
writer->addStringElement(writer, KSCrashField_Value, (const char*)object);
}
else
{
writer->addStringElement(writer, KSCrashField_Type, KSCrashMemType_Unknown);
}
}
}
writer->endContainer(writer);
}
static bool isValidPointer(const uintptr_t address)
{
if(address == (uintptr_t)NULL)
{
return false;
}
#if KSCRASH_HAS_OBJC
if(ksobjc_isTaggedPointer((const void*)address))
{
if(!ksobjc_isValidTaggedPointer((const void*)address))
{
return false;
}
}
#endif
return true;
}
static bool isNotableAddress(const uintptr_t address)
{
if(!isValidPointer(address))
{
return false;
}
const void* object = (const void*)address;
#if KSCRASH_HAS_OBJC
if(kszombie_className(object) != NULL)
{
return true;
}
if(ksobjc_objectType(object) != KSObjCTypeUnknown)
{
return true;
}
#endif
if(isValidString(object))
{
return true;
}
return false;
}
/** Write the contents of a memory location only if it contains notable data.
* Also writes meta information about the data.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param address The memory address.
*/
static void writeMemoryContentsIfNotable(const KSCrashReportWriter* const writer,
const char* const key,
const uintptr_t address)
{
if(isNotableAddress(address))
{
int limit = kDefaultMemorySearchDepth;
writeMemoryContents(writer, key, address, &limit);
}
}
/** Look for a hex value in a string and try to write whatever it references.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param string The string to search.
*/
static void writeAddressReferencedByString(const KSCrashReportWriter* const writer,
const char* const key,
const char* string)
{
uint64_t address = 0;
if(string == NULL || !ksstring_extractHexValue(string, (int)strlen(string), &address))
{
return;
}
int limit = kDefaultMemorySearchDepth;
writeMemoryContents(writer, key, (uintptr_t)address, &limit);
}
#pragma mark Backtrace
/** Write a backtrace to the report.
*
* @param writer The writer to write the backtrace to.
*
* @param key The object key, if needed.
*
* @param stackCursor The stack cursor to read from.
*/
static void writeBacktrace(const KSCrashReportWriter* const writer,
const char* const key,
KSStackCursor* stackCursor)
{
writer->beginObject(writer, key);
{
writer->beginArray(writer, KSCrashField_Contents);
{
while(stackCursor->advanceCursor(stackCursor))
{
writer->beginObject(writer, NULL);
{
if(stackCursor->symbolicate(stackCursor))
{
if(stackCursor->stackEntry.imageName != NULL)
{
writer->addStringElement(writer, KSCrashField_ObjectName, ksfu_lastPathEntry(stackCursor->stackEntry.imageName));
}
writer->addUIntegerElement(writer, KSCrashField_ObjectAddr, stackCursor->stackEntry.imageAddress);
if(stackCursor->stackEntry.symbolName != NULL)
{
writer->addStringElement(writer, KSCrashField_SymbolName, stackCursor->stackEntry.symbolName);
}
writer->addUIntegerElement(writer, KSCrashField_SymbolAddr, stackCursor->stackEntry.symbolAddress);
}
writer->addUIntegerElement(writer, KSCrashField_InstructionAddr, stackCursor->stackEntry.address);
}
writer->endContainer(writer);
}
}
writer->endContainer(writer);
writer->addIntegerElement(writer, KSCrashField_Skipped, 0);
}
writer->endContainer(writer);
}
#pragma mark Stack
/** Write a dump of the stack contents to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param machineContext The context to retrieve the stack from.
*
* @param isStackOverflow If true, the stack has overflowed.
*/
static void writeStackContents(const KSCrashReportWriter* const writer,
const char* const key,
const struct KSMachineContext* const machineContext,
const bool isStackOverflow)
{
uintptr_t sp = kscpu_stackPointer(machineContext);
if((void*)sp == NULL)
{
return;
}
uintptr_t lowAddress = sp + (uintptr_t)(kStackContentsPushedDistance * (int)sizeof(sp) * kscpu_stackGrowDirection() * -1);
uintptr_t highAddress = sp + (uintptr_t)(kStackContentsPoppedDistance * (int)sizeof(sp) * kscpu_stackGrowDirection());
if(highAddress < lowAddress)
{
uintptr_t tmp = lowAddress;
lowAddress = highAddress;
highAddress = tmp;
}
writer->beginObject(writer, key);
{
writer->addStringElement(writer, KSCrashField_GrowDirection, kscpu_stackGrowDirection() > 0 ? "+" : "-");
writer->addUIntegerElement(writer, KSCrashField_DumpStart, lowAddress);
writer->addUIntegerElement(writer, KSCrashField_DumpEnd, highAddress);
writer->addUIntegerElement(writer, KSCrashField_StackPtr, sp);
writer->addBooleanElement(writer, KSCrashField_Overflow, isStackOverflow);
uint8_t stackBuffer[kStackContentsTotalDistance * sizeof(sp)];
int copyLength = (int)(highAddress - lowAddress);
if(ksmem_copySafely((void*)lowAddress, stackBuffer, copyLength))
{
writer->addDataElement(writer, KSCrashField_Contents, (void*)stackBuffer, copyLength);
}
else
{
writer->addStringElement(writer, KSCrashField_Error, "Stack contents not accessible");
}
}
writer->endContainer(writer);
}
/** Write any notable addresses near the stack pointer (above and below).
*
* @param writer The writer.
*
* @param machineContext The context to retrieve the stack from.
*
* @param backDistance The distance towards the beginning of the stack to check.
*
* @param forwardDistance The distance past the end of the stack to check.
*/
static void writeNotableStackContents(const KSCrashReportWriter* const writer,
const struct KSMachineContext* const machineContext,
const int backDistance,
const int forwardDistance)
{
uintptr_t sp = kscpu_stackPointer(machineContext);
if((void*)sp == NULL)
{
return;
}
uintptr_t lowAddress = sp + (uintptr_t)(backDistance * (int)sizeof(sp) * kscpu_stackGrowDirection() * -1);
uintptr_t highAddress = sp + (uintptr_t)(forwardDistance * (int)sizeof(sp) * kscpu_stackGrowDirection());
if(highAddress < lowAddress)
{
uintptr_t tmp = lowAddress;
lowAddress = highAddress;
highAddress = tmp;
}
uintptr_t contentsAsPointer;
char nameBuffer[40];
for(uintptr_t address = lowAddress; address < highAddress; address += sizeof(address))
{
if(ksmem_copySafely((void*)address, &contentsAsPointer, sizeof(contentsAsPointer)))
{
sprintf(nameBuffer, "stack@%p", (void*)address);
writeMemoryContentsIfNotable(writer, nameBuffer, contentsAsPointer);
}
}
}
#pragma mark Registers
/** Write the contents of all regular registers to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param machineContext The context to retrieve the registers from.
*/
static void writeBasicRegisters(const KSCrashReportWriter* const writer,
const char* const key,
const struct KSMachineContext* const machineContext)
{
char registerNameBuff[30];
const char* registerName;
writer->beginObject(writer, key);
{
const int numRegisters = kscpu_numRegisters();
for(int reg = 0; reg < numRegisters; reg++)
{
registerName = kscpu_registerName(reg);
if(registerName == NULL)
{
snprintf(registerNameBuff, sizeof(registerNameBuff), "r%d", reg);
registerName = registerNameBuff;
}
writer->addUIntegerElement(writer, registerName,
kscpu_registerValue(machineContext, reg));
}
}
writer->endContainer(writer);
}
/** Write the contents of all exception registers to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param machineContext The context to retrieve the registers from.
*/
static void writeExceptionRegisters(const KSCrashReportWriter* const writer,
const char* const key,
const struct KSMachineContext* const machineContext)
{
char registerNameBuff[30];
const char* registerName;
writer->beginObject(writer, key);
{
const int numRegisters = kscpu_numExceptionRegisters();
for(int reg = 0; reg < numRegisters; reg++)
{
registerName = kscpu_exceptionRegisterName(reg);
if(registerName == NULL)
{
snprintf(registerNameBuff, sizeof(registerNameBuff), "r%d", reg);
registerName = registerNameBuff;
}
writer->addUIntegerElement(writer,registerName,
kscpu_exceptionRegisterValue(machineContext, reg));
}
}
writer->endContainer(writer);
}
/** Write all applicable registers.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param machineContext The context to retrieve the registers from.
*/
static void writeRegisters(const KSCrashReportWriter* const writer,
const char* const key,
const struct KSMachineContext* const machineContext)
{
writer->beginObject(writer, key);
{
writeBasicRegisters(writer, KSCrashField_Basic, machineContext);
if(ksmc_hasValidExceptionRegisters(machineContext))
{
writeExceptionRegisters(writer, KSCrashField_Exception, machineContext);
}
}
writer->endContainer(writer);
}
/** Write any notable addresses contained in the CPU registers.
*
* @param writer The writer.
*
* @param machineContext The context to retrieve the registers from.
*/
static void writeNotableRegisters(const KSCrashReportWriter* const writer,
const struct KSMachineContext* const machineContext)
{
char registerNameBuff[30];
const char* registerName;
const int numRegisters = kscpu_numRegisters();
for(int reg = 0; reg < numRegisters; reg++)
{
registerName = kscpu_registerName(reg);
if(registerName == NULL)
{
snprintf(registerNameBuff, sizeof(registerNameBuff), "r%d", reg);
registerName = registerNameBuff;
}
writeMemoryContentsIfNotable(writer,
registerName,
(uintptr_t)kscpu_registerValue(machineContext, reg));
}
}
#pragma mark Thread-specific
/** Write any notable addresses in the stack or registers to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param machineContext The context to retrieve the registers from.
*/
static void writeNotableAddresses(const KSCrashReportWriter* const writer,
const char* const key,
const struct KSMachineContext* const machineContext)
{
writer->beginObject(writer, key);
{
writeNotableRegisters(writer, machineContext);
writeNotableStackContents(writer,
machineContext,
kStackNotableSearchBackDistance,
kStackNotableSearchForwardDistance);
}
writer->endContainer(writer);
}
/** Write information about a thread to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param crash The crash handler context.
*
* @param machineContext The context whose thread to write about.
*
* @param shouldWriteNotableAddresses If true, write any notable addresses found.
*/
static void writeThread(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const crash,
const struct KSMachineContext* const machineContext,
const int threadIndex,
const bool shouldWriteNotableAddresses)
{
bool isCrashedThread = ksmc_isCrashedContext(machineContext);
KSThread thread = ksmc_getThreadFromContext(machineContext);
// KSLOG_DEBUG("Writing thread %x (index %d). is crashed: %d", thread, threadIndex, isCrashedThread);
KSStackCursor stackCursor;
bool hasBacktrace = getStackCursor(crash, machineContext, &stackCursor);
writer->beginObject(writer, key);
{
if(hasBacktrace)
{
writeBacktrace(writer, KSCrashField_Backtrace, &stackCursor);
}
if(ksmc_canHaveCPUState(machineContext))
{
writeRegisters(writer, KSCrashField_Registers, machineContext);
}
writer->addIntegerElement(writer, KSCrashField_Index, threadIndex);
const char* name = ksccd_getThreadName(thread);
if(name != NULL)
{
writer->addStringElement(writer, KSCrashField_Name, name);
}
name = ksccd_getQueueName(thread);
if(name != NULL)
{
writer->addStringElement(writer, KSCrashField_DispatchQueue, name);
}
writer->addBooleanElement(writer, KSCrashField_Crashed, isCrashedThread);
writer->addBooleanElement(writer, KSCrashField_CurrentThread, thread == ksthread_self());
if(isCrashedThread)
{
writeStackContents(writer, KSCrashField_Stack, machineContext, stackCursor.state.hasGivenUp);
if(shouldWriteNotableAddresses)
{
writeNotableAddresses(writer, KSCrashField_NotableAddresses, machineContext);
}
}
}
writer->endContainer(writer);
}
/** Write information about all threads to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param crash The crash handler context.
*/
static void writeAllThreads(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const crash,
bool writeNotableAddresses)
{
const struct KSMachineContext* const context = crash->offendingMachineContext;
KSThread offendingThread = ksmc_getThreadFromContext(context);
int threadCount = ksmc_getThreadCount(context);
KSMC_NEW_CONTEXT(machineContext);
// Fetch info for all threads.
writer->beginArray(writer, key);
{
KSLOG_DEBUG("Writing %d threads.", threadCount);
for(int i = 0; i < threadCount; i++)
{
KSThread thread = ksmc_getThreadAtIndex(context, i);
if(thread == offendingThread)
{
writeThread(writer, NULL, crash, context, i, writeNotableAddresses);
}
else
{
ksmc_getContextForThread(thread, machineContext, false);
writeThread(writer, NULL, crash, machineContext, i, writeNotableAddresses);
}
}
}
writer->endContainer(writer);
}
#pragma mark Global Report Data
/** Write information about a binary image to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param index Which image to write about.
*/
static void writeBinaryImage(const KSCrashReportWriter* const writer,
const char* const key,
const int index)
{
KSBinaryImage image = {0};
if(!ksdl_getBinaryImage(index, &image))
{
return;
}
writer->beginObject(writer, key);
{
writer->addUIntegerElement(writer, KSCrashField_ImageAddress, image.address);
writer->addUIntegerElement(writer, KSCrashField_ImageVmAddress, image.vmAddress);
writer->addUIntegerElement(writer, KSCrashField_ImageSize, image.size);
writer->addStringElement(writer, KSCrashField_Name, image.name);
writer->addUUIDElement(writer, KSCrashField_UUID, image.uuid);
writer->addIntegerElement(writer, KSCrashField_CPUType, image.cpuType);
writer->addIntegerElement(writer, KSCrashField_CPUSubType, image.cpuSubType);
writer->addUIntegerElement(writer, KSCrashField_ImageMajorVersion, image.majorVersion);
writer->addUIntegerElement(writer, KSCrashField_ImageMinorVersion, image.minorVersion);
writer->addUIntegerElement(writer, KSCrashField_ImageRevisionVersion, image.revisionVersion);
if(image.crashInfoMessage != NULL)
{
writer->addStringElement(writer, KSCrashField_ImageCrashInfoMessage, image.crashInfoMessage);
}
if(image.crashInfoMessage2 != NULL)
{
writer->addStringElement(writer, KSCrashField_ImageCrashInfoMessage2, image.crashInfoMessage2);
}
}
writer->endContainer(writer);
}
/** Write information about all images to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*/
static void writeBinaryImages(const KSCrashReportWriter* const writer, const char* const key)
{
const int imageCount = ksdl_imageCount();
writer->beginArray(writer, key);
{
for(int iImg = 0; iImg < imageCount; iImg++)
{
writeBinaryImage(writer, NULL, iImg);
}
}
writer->endContainer(writer);
}
/** Write information about system memory to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*/
static void writeMemoryInfo(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const monitorContext)
{
writer->beginObject(writer, key);
{
writer->addUIntegerElement(writer, KSCrashField_Size, monitorContext->System.memorySize);
writer->addUIntegerElement(writer, KSCrashField_Usable, monitorContext->System.usableMemory);
writer->addUIntegerElement(writer, KSCrashField_Free, monitorContext->System.freeMemory);
}
writer->endContainer(writer);
}
/** Write information about the error leading to the crash to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param crash The crash handler context.
*/
static void writeError(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const crash)
{
writer->beginObject(writer, key);
{
#if KSCRASH_HOST_APPLE
writer->beginObject(writer, KSCrashField_Mach);
{
const char* machExceptionName = ksmach_exceptionName(crash->mach.type);
const char* machCodeName = crash->mach.code == 0 ? NULL : ksmach_kernelReturnCodeName(crash->mach.code);
writer->addUIntegerElement(writer, KSCrashField_Exception, (unsigned)crash->mach.type);
if(machExceptionName != NULL)
{
writer->addStringElement(writer, KSCrashField_ExceptionName, machExceptionName);
}
writer->addUIntegerElement(writer, KSCrashField_Code, (unsigned)crash->mach.code);
if(machCodeName != NULL)
{
writer->addStringElement(writer, KSCrashField_CodeName, machCodeName);
}
writer->addUIntegerElement(writer, KSCrashField_Subcode, (size_t)crash->mach.subcode);
}
writer->endContainer(writer);
#endif
writer->beginObject(writer, KSCrashField_Signal);
{
const char* sigName = kssignal_signalName(crash->signal.signum);
const char* sigCodeName = kssignal_signalCodeName(crash->signal.signum, crash->signal.sigcode);
writer->addUIntegerElement(writer, KSCrashField_Signal, (unsigned)crash->signal.signum);
if(sigName != NULL)
{
writer->addStringElement(writer, KSCrashField_Name, sigName);
}
writer->addUIntegerElement(writer, KSCrashField_Code, (unsigned)crash->signal.sigcode);
if(sigCodeName != NULL)
{
writer->addStringElement(writer, KSCrashField_CodeName, sigCodeName);
}
}
writer->endContainer(writer);
writer->addUIntegerElement(writer, KSCrashField_Address, crash->faultAddress);
if(crash->crashReason != NULL)
{
writer->addStringElement(writer, KSCrashField_Reason, crash->crashReason);
}
// Gather specific info.
switch(crash->crashType)
{
case KSCrashMonitorTypeMainThreadDeadlock:
writer->addStringElement(writer, KSCrashField_Type, KSCrashExcType_Deadlock);
break;
case KSCrashMonitorTypeMachException:
writer->addStringElement(writer, KSCrashField_Type, KSCrashExcType_Mach);
break;
case KSCrashMonitorTypeCPPException:
{
writer->addStringElement(writer, KSCrashField_Type, KSCrashExcType_CPPException);
writer->beginObject(writer, KSCrashField_CPPException);
{
writer->addStringElement(writer, KSCrashField_Name, crash->CPPException.name);
}
writer->endContainer(writer);
break;
}
case KSCrashMonitorTypeNSException:
{
writer->addStringElement(writer, KSCrashField_Type, KSCrashExcType_NSException);
writer->beginObject(writer, KSCrashField_NSException);
{
writer->addStringElement(writer, KSCrashField_Name, crash->NSException.name);
writer->addStringElement(writer, KSCrashField_UserInfo, crash->NSException.userInfo);
writeAddressReferencedByString(writer, KSCrashField_ReferencedObject, crash->crashReason);
}
writer->endContainer(writer);
break;
}
case KSCrashMonitorTypeSignal:
writer->addStringElement(writer, KSCrashField_Type, KSCrashExcType_Signal);
break;
case KSCrashMonitorTypeUserReported:
{
writer->addStringElement(writer, KSCrashField_Type, KSCrashExcType_User);
writer->beginObject(writer, KSCrashField_UserReported);
{
writer->addStringElement(writer, KSCrashField_Name, crash->userException.name);
if(crash->userException.language != NULL)
{
writer->addStringElement(writer, KSCrashField_Language, crash->userException.language);
}
if(crash->userException.lineOfCode != NULL)
{
writer->addStringElement(writer, KSCrashField_LineOfCode, crash->userException.lineOfCode);
}
if(crash->userException.customStackTrace != NULL)
{
writer->addJSONElement(writer, KSCrashField_Backtrace, crash->userException.customStackTrace, true);
}
}
writer->endContainer(writer);
break;
}
case KSCrashMonitorTypeSystem:
case KSCrashMonitorTypeApplicationState:
case KSCrashMonitorTypeZombie:
KSLOG_ERROR("Crash monitor type 0x%x shouldn't be able to cause events!", crash->crashType);
break;
}
}
writer->endContainer(writer);
}
/** Write information about app runtime, etc to the report.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param monitorContext The event monitor context.
*/
static void writeAppStats(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const monitorContext)
{
writer->beginObject(writer, key);
{
writer->addBooleanElement(writer, KSCrashField_AppActive, monitorContext->AppState.applicationIsActive);
writer->addBooleanElement(writer, KSCrashField_AppInFG, monitorContext->AppState.applicationIsInForeground);
writer->addIntegerElement(writer, KSCrashField_LaunchesSinceCrash, monitorContext->AppState.launchesSinceLastCrash);
writer->addIntegerElement(writer, KSCrashField_SessionsSinceCrash, monitorContext->AppState.sessionsSinceLastCrash);
writer->addFloatingPointElement(writer, KSCrashField_ActiveTimeSinceCrash, monitorContext->AppState.activeDurationSinceLastCrash);
writer->addFloatingPointElement(writer, KSCrashField_BGTimeSinceCrash, monitorContext->AppState.backgroundDurationSinceLastCrash);
writer->addIntegerElement(writer, KSCrashField_SessionsSinceLaunch, monitorContext->AppState.sessionsSinceLaunch);
writer->addFloatingPointElement(writer, KSCrashField_ActiveTimeSinceLaunch, monitorContext->AppState.activeDurationSinceLaunch);
writer->addFloatingPointElement(writer, KSCrashField_BGTimeSinceLaunch, monitorContext->AppState.backgroundDurationSinceLaunch);
}
writer->endContainer(writer);
}
/** Write information about this process.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*/
static void writeProcessState(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const monitorContext)
{
writer->beginObject(writer, key);
{
if(monitorContext->ZombieException.address != 0)
{
writer->beginObject(writer, KSCrashField_LastDeallocedNSException);
{
writer->addUIntegerElement(writer, KSCrashField_Address, monitorContext->ZombieException.address);
writer->addStringElement(writer, KSCrashField_Name, monitorContext->ZombieException.name);
writer->addStringElement(writer, KSCrashField_Reason, monitorContext->ZombieException.reason);
writeAddressReferencedByString(writer, KSCrashField_ReferencedObject, monitorContext->ZombieException.reason);
}
writer->endContainer(writer);
}
}
writer->endContainer(writer);
}
/** Write basic report information.
*
* @param writer The writer.
*
* @param key The object key, if needed.
*
* @param type The report type.
*
* @param reportID The report ID.
*/
static void writeReportInfo(const KSCrashReportWriter* const writer,
const char* const key,
const char* const type,
const char* const reportID,
const char* const processName)
{
writer->beginObject(writer, key);
{
struct timeval tp;
gettimeofday(&tp, NULL);
int64_t microseconds = ((int64_t)tp.tv_sec) * 1000000 + tp.tv_usec;
writer->addStringElement(writer, KSCrashField_Version, KSCRASH_REPORT_VERSION);
writer->addStringElement(writer, KSCrashField_ID, reportID);
writer->addStringElement(writer, KSCrashField_ProcessName, processName);
writer->addIntegerElement(writer, KSCrashField_Timestamp, microseconds);
writer->addStringElement(writer, KSCrashField_Type, type);
}
writer->endContainer(writer);
}
static void writeRecrash(const KSCrashReportWriter* const writer,
const char* const key,
const char* crashReportPath)
{
writer->addJSONFileElement(writer, key, crashReportPath, true);
}
#pragma mark Setup
/** Prepare a report writer for use.
*
* @oaram writer The writer to prepare.
*
* @param context JSON writer contextual information.
*/
static void prepareReportWriter(KSCrashReportWriter* const writer, KSJSONEncodeContext* const context)
{
writer->addBooleanElement = addBooleanElement;
writer->addFloatingPointElement = addFloatingPointElement;
writer->addIntegerElement = addIntegerElement;
writer->addUIntegerElement = addUIntegerElement;
writer->addStringElement = addStringElement;
writer->addTextFileElement = addTextFileElement;
writer->addTextFileLinesElement = addTextLinesFromFile;
writer->addJSONFileElement = addJSONElementFromFile;
writer->addDataElement = addDataElement;
writer->beginDataElement = beginDataElement;
writer->appendDataElement = appendDataElement;
writer->endDataElement = endDataElement;
writer->addUUIDElement = addUUIDElement;
writer->addJSONElement = addJSONElement;
writer->beginObject = beginObject;
writer->beginArray = beginArray;
writer->endContainer = endContainer;
writer->context = context;
}
// ============================================================================
#pragma mark - Main API -
// ============================================================================
void kscrashreport_writeRecrashReport(const KSCrash_MonitorContext* const monitorContext, const char* const path)
{
char writeBuffer[1024];
KSBufferedWriter bufferedWriter;
static char tempPath[KSFU_MAX_PATH_LENGTH];
strncpy(tempPath, path, sizeof(tempPath) - 10);
strncpy(tempPath + strlen(tempPath) - 5, ".old", 5);
KSLOG_INFO("Writing recrash report to %s", path);
if(rename(path, tempPath) < 0)
{
KSLOG_ERROR("Could not rename %s to %s: %s", path, tempPath, strerror(errno));
}
if(!ksfu_openBufferedWriter(&bufferedWriter, path, writeBuffer, sizeof(writeBuffer)))
{
return;
}
ksccd_freeze();
KSJSONEncodeContext jsonContext;
jsonContext.userData = &bufferedWriter;
KSCrashReportWriter concreteWriter;
KSCrashReportWriter* writer = &concreteWriter;
prepareReportWriter(writer, &jsonContext);
ksjson_beginEncode(getJsonContext(writer), true, addJSONData, &bufferedWriter);
writer->beginObject(writer, KSCrashField_Report);
{
writeRecrash(writer, KSCrashField_RecrashReport, tempPath);
ksfu_flushBufferedWriter(&bufferedWriter);
if(remove(tempPath) < 0)
{
KSLOG_ERROR("Could not remove %s: %s", tempPath, strerror(errno));
}
writeReportInfo(writer,
KSCrashField_Report,
KSCrashReportType_Minimal,
monitorContext->eventID,
monitorContext->System.processName);
ksfu_flushBufferedWriter(&bufferedWriter);
writer->beginObject(writer, KSCrashField_Crash);
{
writeError(writer, KSCrashField_Error, monitorContext);
ksfu_flushBufferedWriter(&bufferedWriter);
int threadIndex = ksmc_indexOfThread(monitorContext->offendingMachineContext,
ksmc_getThreadFromContext(monitorContext->offendingMachineContext));
writeThread(writer,
KSCrashField_CrashedThread,
monitorContext,
monitorContext->offendingMachineContext,
threadIndex,
false);
ksfu_flushBufferedWriter(&bufferedWriter);
}
writer->endContainer(writer);
}
writer->endContainer(writer);
ksjson_endEncode(getJsonContext(writer));
ksfu_closeBufferedWriter(&bufferedWriter);
ksccd_unfreeze();
}
static void writeSystemInfo(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const monitorContext)
{
writer->beginObject(writer, key);
{
writer->addStringElement(writer, KSCrashField_SystemName, monitorContext->System.systemName);
writer->addStringElement(writer, KSCrashField_SystemVersion, monitorContext->System.systemVersion);
writer->addStringElement(writer, KSCrashField_Machine, monitorContext->System.machine);
writer->addStringElement(writer, KSCrashField_Model, monitorContext->System.model);
writer->addStringElement(writer, KSCrashField_KernelVersion, monitorContext->System.kernelVersion);
writer->addStringElement(writer, KSCrashField_OSVersion, monitorContext->System.osVersion);
writer->addBooleanElement(writer, KSCrashField_Jailbroken, monitorContext->System.isJailbroken);
writer->addStringElement(writer, KSCrashField_BootTime, monitorContext->System.bootTime);
writer->addStringElement(writer, KSCrashField_AppStartTime, monitorContext->System.appStartTime);
writer->addStringElement(writer, KSCrashField_ExecutablePath, monitorContext->System.executablePath);
writer->addStringElement(writer, KSCrashField_Executable, monitorContext->System.executableName);
writer->addStringElement(writer, KSCrashField_BundleID, monitorContext->System.bundleID);
writer->addStringElement(writer, KSCrashField_BundleName, monitorContext->System.bundleName);
writer->addStringElement(writer, KSCrashField_BundleVersion, monitorContext->System.bundleVersion);
writer->addStringElement(writer, KSCrashField_BundleShortVersion, monitorContext->System.bundleShortVersion);
writer->addStringElement(writer, KSCrashField_AppUUID, monitorContext->System.appID);
writer->addStringElement(writer, KSCrashField_CPUArch, monitorContext->System.cpuArchitecture);
writer->addIntegerElement(writer, KSCrashField_CPUType, monitorContext->System.cpuType);
writer->addIntegerElement(writer, KSCrashField_CPUSubType, monitorContext->System.cpuSubType);
writer->addIntegerElement(writer, KSCrashField_BinaryCPUType, monitorContext->System.binaryCPUType);
writer->addIntegerElement(writer, KSCrashField_BinaryCPUSubType, monitorContext->System.binaryCPUSubType);
writer->addStringElement(writer, KSCrashField_TimeZone, monitorContext->System.timezone);
writer->addStringElement(writer, KSCrashField_ProcessName, monitorContext->System.processName);
writer->addIntegerElement(writer, KSCrashField_ProcessID, monitorContext->System.processID);
writer->addIntegerElement(writer, KSCrashField_ParentProcessID, monitorContext->System.parentProcessID);
writer->addStringElement(writer, KSCrashField_DeviceAppHash, monitorContext->System.deviceAppHash);
writer->addStringElement(writer, KSCrashField_BuildType, monitorContext->System.buildType);
writer->addIntegerElement(writer, KSCrashField_Storage, (int64_t)monitorContext->System.storageSize);
writeMemoryInfo(writer, KSCrashField_Memory, monitorContext);
writeAppStats(writer, KSCrashField_AppStats, monitorContext);
}
writer->endContainer(writer);
}
static void writeDebugInfo(const KSCrashReportWriter* const writer,
const char* const key,
const KSCrash_MonitorContext* const monitorContext)
{
writer->beginObject(writer, key);
{
if(monitorContext->consoleLogPath != NULL)
{
addTextLinesFromFile(writer, KSCrashField_ConsoleLog, monitorContext->consoleLogPath);
}
}
writer->endContainer(writer);
}
void kscrashreport_writeStandardReport(const KSCrash_MonitorContext* const monitorContext, const char* const path)
{
KSLOG_INFO("Writing crash report to %s", path);
char writeBuffer[1024];
KSBufferedWriter bufferedWriter;
if(!ksfu_openBufferedWriter(&bufferedWriter, path, writeBuffer, sizeof(writeBuffer)))
{
return;
}
ksccd_freeze();
KSJSONEncodeContext jsonContext;
jsonContext.userData = &bufferedWriter;
KSCrashReportWriter concreteWriter;
KSCrashReportWriter* writer = &concreteWriter;
prepareReportWriter(writer, &jsonContext);
ksjson_beginEncode(getJsonContext(writer), true, addJSONData, &bufferedWriter);
writer->beginObject(writer, KSCrashField_Report);
{
writeReportInfo(writer,
KSCrashField_Report,
KSCrashReportType_Standard,
monitorContext->eventID,
monitorContext->System.processName);
ksfu_flushBufferedWriter(&bufferedWriter);
writeBinaryImages(writer, KSCrashField_BinaryImages);
ksfu_flushBufferedWriter(&bufferedWriter);
writeProcessState(writer, KSCrashField_ProcessState, monitorContext);
ksfu_flushBufferedWriter(&bufferedWriter);
writeSystemInfo(writer, KSCrashField_System, monitorContext);
ksfu_flushBufferedWriter(&bufferedWriter);
writer->beginObject(writer, KSCrashField_Crash);
{
writeError(writer, KSCrashField_Error, monitorContext);
ksfu_flushBufferedWriter(&bufferedWriter);
writeAllThreads(writer,
KSCrashField_Threads,
monitorContext,
g_introspectionRules.enabled);
ksfu_flushBufferedWriter(&bufferedWriter);
}
writer->endContainer(writer);
if(g_userInfoJSON != NULL)
{
addJSONElement(writer, KSCrashField_User, g_userInfoJSON, false);
ksfu_flushBufferedWriter(&bufferedWriter);
}
else
{
writer->beginObject(writer, KSCrashField_User);
}
/// 用户设置的写回调在这里处理
if(g_userSectionWriteCallback != NULL)
{
ksfu_flushBufferedWriter(&bufferedWriter);
if (monitorContext->currentSnapshotUserReported == false) {
g_userSectionWriteCallback(writer);
}
}
writer->endContainer(writer);
ksfu_flushBufferedWriter(&bufferedWriter);
writeDebugInfo(writer, KSCrashField_Debug, monitorContext);
}
writer->endContainer(writer);
ksjson_endEncode(getJsonContext(writer));
ksfu_closeBufferedWriter(&bufferedWriter);
ksccd_unfreeze();
}
void kscrashreport_setUserInfoJSON(const char* const userInfoJSON)
{
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
KSLOG_TRACE("set userInfoJSON to %p", userInfoJSON);
pthread_mutex_lock(&mutex);
if(g_userInfoJSON != NULL)
{
free((void*)g_userInfoJSON);
}
if(userInfoJSON == NULL)
{
g_userInfoJSON = NULL;
}
else
{
g_userInfoJSON = strdup(userInfoJSON);
}
pthread_mutex_unlock(&mutex);
}
void kscrashreport_setIntrospectMemory(bool shouldIntrospectMemory)
{
g_introspectionRules.enabled = shouldIntrospectMemory;
}
void kscrashreport_setDoNotIntrospectClasses(const char** doNotIntrospectClasses, int length)
{
const char** oldClasses = g_introspectionRules.restrictedClasses;
int oldClassesLength = g_introspectionRules.restrictedClassesCount;
const char** newClasses = NULL;
int newClassesLength = 0;
if(doNotIntrospectClasses != NULL && length > 0)
{
newClassesLength = length;
newClasses = malloc(sizeof(*newClasses) * (unsigned)newClassesLength);
if(newClasses == NULL)
{
KSLOG_ERROR("Could not allocate memory");
return;
}
for(int i = 0; i < newClassesLength; i++)
{
newClasses[i] = strdup(doNotIntrospectClasses[i]);
}
}
g_introspectionRules.restrictedClasses = newClasses;
g_introspectionRules.restrictedClassesCount = newClassesLength;
if(oldClasses != NULL)
{
for(int i = 0; i < oldClassesLength; i++)
{
free((void*)oldClasses[i]);
}
free(oldClasses);
}
}
void kscrashreport_setUserSectionWriteCallback(const KSReportWriteCallback userSectionWriteCallback)
{
KSLOG_TRACE("Set userSectionWriteCallback to %p", userSectionWriteCallback);
g_userSectionWriteCallback = userSectionWriteCallback;
}
|
manub686/axwifi | wifi54/dstmacaddr.c | /**
Atomix project, dstmacaddr.c, TODO: insert summary here
Copyright (c) 2015 Stanford University
Released under the Apache License v2.0. See the LICENSE file for details.
Author(s): <NAME>
*/
#include <osl/inc/swpform.h>
Uint8 trace_mac_addr[] = {0x00, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0x00, 0x00};
|
manub686/axwifi | samples/debug64.rate54000.snr25.nmsgs2.msglen500.scale1.41.txpkt.dat_trace_skip_0_ns_4640.c | <reponame>manub686/axwifi
#include <osl/inc/swpform.h>
#pragma DATA_SECTION(trace_skip_0_ns_4640, ".trace");
#pragma DATA_ALIGN(trace_skip_0_ns_4640, 8);
Int16 trace_skip_0_ns_4640[] = {
167, -367,
570, 429,
-702, 361,
268, 6,
99, 126,
-407, 305,
-135, -102,
107, 170,
1112, 214,
861, 116,
-420, -442,
944, -104,
226, -614,
-20, -119,
222, -246,
-64, -30,
-39, 117,
463, 258,
438, -45,
441, 12,
209, 315,
-375, 403,
223, 68,
507, 268,
152, -227,
322, 493,
226, -206,
-94, -239,
91, 167,
-245, -20,
276, -493,
-357, 335,
-332, 216,
-252, 512,
-915, 92,
447, 219,
101, -358,
-235, 578,
426, 737,
-532, -119,
-32, -216,
-75, 311,
99, -353,
97, 48,
-269, -42,
-9, 257,
-51, -612,
195, 38,
340, 81,
345, -551,
-268, -49,
24, 196,
-377, -397,
-346, -93,
-2, 61,
476, -162,
-239, 489,
115, 239,
-70, -180,
347, 103,
-339, 351,
10, 77,
172, 173,
342, 200,
480, 230,
27, -411,
-464, -210,
-231, -110,
-330, -497,
731, -436,
-191, 111,
233, 112,
-60, 287,
276, 114,
-238, -238,
-436, -5,
-442, -223,
152, 270,
-55, -470,
-61, 267,
441, 155,
91, 240,
61, -180,
494, 61,
-250, -13,
217, -470,
260, 151,
-76, 138,
67, -231,
-362, 386,
-357, -549,
33, -128,
225, -122,
804, -222,
-207, -206,
58, 150,
-26, -272,
-601, 21,
-136, -132,
-558, -40,
261, 601,
-276, -168,
31, 275,
-169, 12,
94, 10,
-187, -591,
152, 317,
230, 48,
532, -135,
-60, 12,
-665, -34,
-261, 570,
421, -344,
-333, -175,
299, 82,
39, 576,
447, 80,
-610, 345,
-61, 234,
-375, 224,
904, 400,
257, 712,
429, 46,
-329, -90,
-146, 58,
-85, -94,
341, -719,
-86, -36,
218, 52,
-638, -114,
-110, -67,
-256, 384,
-490, 26,
158, -9,
88, -206,
10, -173,
-415, -31,
351, 40,
109, 121,
-93, 508,
7, 422,
-81, -372,
-544, 546,
-89, -306,
-258, 799,
-304, 62,
-360, -136,
-166, -628,
-623, -124,
300, 479,
162, -128,
-6, -140,
-11, -408,
-248, -365,
317, -180,
-41, 112,
-222, -641,
420, 207,
-70, -150,
-183, 250,
-91, -1,
-264, -138,
-348, 156,
785, 157,
515, 630,
96, -405,
-391, -218,
-269, -380,
-55, -177,
246, -157,
-414, -137,
-724, -146,
-450, -159,
104, -74,
122, 133,
140, 346,
-41, -113,
57, 568,
-148, 271,
268, 379,
-423, -305,
141, -568,
-264, 102,
-104, 107,
172, -529,
323, -462,
-347, 109,
392, 322,
205, 422,
-21, -285,
-61, 188,
-68, 191,
-94, -10,
7, -327,
16, -343,
257, 230,
475, -523,
145, -92,
-65, 44,
1798, 1943,
-9177, 51,
-1259, -5908,
10248, -774,
6509, -224,
9995, -329,
-779, -5744,
-9153, 216,
2914, 3842,
113, -8906,
-5520, -945,
-1047, 10102,
523, 7161,
-1154, 10388,
-5625, -1352,
-58, -9176,
2842, 3538,
-9294, -314,
-1025, -5385,
10428, -903,
6337, 90,
9622, -1132,
-441, -6043,
-8850, -170,
3136, 3790,
-305, -9274,
-5613, -1235,
-931, 10409,
86, 6700,
-963, 9685,
-5337, -605,
285, -8889,
2818, 2966,
-9529, 331,
-1170, -5590,
9795, -493,
6314, -392,
9957, -1009,
-1881, -5219,
-9376, 138,
3593, 3386,
-169, -8694,
-5184, -1072,
-773, 9612,
-9, 6900,
-825, 9817,
-5961, -840,
137, -9415,
3706, 2719,
-9203, -131,
-926, -5067,
9725, -1011,
6404, -47,
10025, -789,
-807, -5109,
-9350, 210,
3133, 3127,
792, -9499,
-6177, -758,
-189, 9304,
105, 6049,
-571, 10182,
-5992, -800,
-20, -9631,
3121, 3374,
-9102, 309,
-1459, -5843,
10099, -904,
6037, 498,
9973, -1035,
-736, -5894,
-9132, 212,
3544, 3033,
476, -9345,
-5677, -812,
-802, 9936,
-294, 6295,
-1293, 9632,
-5187, -1194,
163, -9552,
3190, 3019,
-8951, 710,
-754, -5429,
10062, -1053,
6803, -40,
10242, -806,
-865, -5389,
-9448, 262,
3004, 3546,
534, -9341,
-5976, -829,
-890, 9760,
-606, 5836,
-565, 9775,
-5207, -498,
163, -9344,
3185, 3525,
-10007, 350,
-759, -5660,
9271, -287,
5693, 272,
9978, -601,
-1234, -5757,
-9106, -38,
3417, 3408,
430, -8861,
-5690, -948,
-742, 10485,
31, 6374,
-625, 10176,
-5308, -938,
442, -8894,
3166, 3105,
-9280, 153,
-626, -5944,
9293, -788,
6257, 28,
9558, -718,
-1058, -5370,
-9032, -45,
3464, 3413,
-152, -8422,
-5621, -1139,
-839, 10243,
-91, 6234,
-788, 9670,
-5350, -1288,
-126, -9055,
3152, 3217,
-9897, 435,
-583, -5534,
9757, -1247,
6040, -62,
9874, -905,
-1383, -5284,
-9240, -213,
3033, 2634,
840, -9091,
-5121, -1181,
-1658, 9800,
137, 6585,
-1317, 9958,
-5554, -888,
214, -8866,
3439, 3538,
-9319, 164,
-449, -5640,
9803, -1253,
6516, 98,
10159, -163,
-913, -5149,
-8960, 233,
3307, 2866,
-81, -9615,
-6036, -1104,
-304, 8789,
-188, 6544,
-850, 10339,
-5300, -905,
198, -9336,
-4124, 2024,
711, -6937,
6355, -7561,
-5946, -7739,
-463, -3747,
5478, 4965,
-8781, 1696,
-8570, 1005,
-2772, 10983,
-4024, 1324,
-4232, -5852,
4392, -1180,
5792, -6328,
-9407, -4142,
-4018, -2626,
2678, -6616,
4076, 4748,
8223, 246,
-1459, -10906,
3519, 1003,
2028, 4733,
-8784, 3384,
367, 7848,
3620, -253,
6934, 1577,
-2993, 6928,
-7443, 3956,
4463, 6187,
1717, -1741,
6479, -6035,
2871, 7499,
-531, 8236,
10796, -313,
-534, -7552,
2452, -7634,
6468, 5569,
1407, 2076,
3643, -5732,
-7838, -3636,
-2708, -7117,
7018, -1655,
3802, -184,
223, -8254,
-9999, -2974,
1389, -4142,
3951, -961,
-1533, 11373,
8664, -603,
4267, -4298,
2966, 6721,
-3840, 2281,
-8786, 4670,
5771, 6176,
4645, 828,
-4665, 5251,
-3888, -1708,
-2189, -10383,
-8589, -666,
-9045, -1781,
5138, -5055,
-537, 3912,
-6559, 8351,
6338, 7773,
871, 6461,
-10913, 19,
1046, -6422,
6428, -7212,
-5842, -7591,
-99, -3371,
5795, 5891,
-9101, 615,
-8334, 1052,
-2524, 10414,
-3749, 1078,
-4020, -5829,
4170, -542,
5319, -6420,
-9599, -4249,
-3863, -2232,
3031, -6947,
4256, 4230,
8566, -124,
-1398, -11287,
3763, 819,
1830, 4012,
-9771, 3233,
540, 7791,
3708, -640,
7309, 1687,
-2803, 7406,
-7843, 3569,
4151, 6224,
843, -1989,
6446, -5853,
2962, 8033,
-374, 9106,
10545, 264,
-552, -8189,
2849, -7748,
6442, 5813,
1775, 2125,
3972, -6287,
-7464, -4311,
-3007, -7269,
6862, -2023,
3246, 407,
-156, -8276,
-9722, -3693,
1831, -4517,
4383, -954,
-1474, 11808,
8197, -223,
4611, -4205,
2822, 6901,
-3951, 2811,
-8974, 5283,
5860, 6196,
4542, 935,
-3969, 5458,
-4140, -1298,
-2631, -10440,
-8443, -1257,
-8972, -1199,
5193, -5475,
-11, 3786,
-6081, 8089,
6333, 7870,
958, 6972,
-10967, 10,
928, -7221,
6531, -7838,
-6598, -7843,
-110, -3967,
5421, 5087,
-8848, 1159,
-7960, 1211,
-2632, 10590,
-4165, 2063,
-4749, -5102,
5132, -654,
6002, -6102,
-9176, -4911,
-3709, -2343,
2631, -7149,
4448, 3860,
8348, 1270,
-1431, -11101,
4122, 835,
2573, 4083,
-9900, 3325,
-508, 7374,
3364, -507,
6460, 1969,
-2806, 7413,
-8079, 3330,
4103, 5962,
1640, -1991,
6872, -5747,
3005, 7228,
196, 8468,
5827, 2654,
1432, 3109,
-1179, 2284,
9024, -5382,
-3818, -8294,
-4264, -4636,
7719, -1651,
11400, -1006,
7681, -8697,
-671, -4770,
-3245, 1975,
1836, -6136,
90, -1579,
-3894, 8842,
7961, 10666,
4207, 11333,
-11311, -316,
3788, -11804,
8755, -10916,
-3835, -8793,
25, 1935,
2040, 6167,
-3412, -2265,
-193, 4321,
7595, 8371,
11023, 1291,
7904, 1585,
-4350, 4761,
-3516, 8282,
8419, 6194,
-539, -1864,
1694, -3737,
-127, -4776,
-10936, -2498,
7801, -1823,
5603, -3692,
-7438, 5211,
-3261, -1796,
-6594, -12225,
-1641, 3799,
-7401, 3913,
-5293, -9435,
4458, -3763,
-1340, -1355,
2032, -1338,
-2369, 6001,
-701, 1969,
1855, -2314,
-6317, 403,
2408, 2300,
-1402, -2201,
-1915, -5937,
2189, 891,
-1948, 1709,
5137, 3609,
-5116, 9279,
-8087, -4137,
-2378, -3889,
-6535, 12228,
-3342, 1627,
-7174, -4883,
5376, 3239,
7714, 2206,
-11197, 2515,
-509, 4375,
1594, 3577,
-709, 2419,
8905, -6361,
-3251, -8402,
-4644, -4798,
7705, -1389,
10494, -1223,
7495, -8779,
-245, -5552,
-3283, 2316,
1884, -5596,
344, -2167,
-3648, 9618,
8513, 10271,
4321, 10809,
-5923, 1380,
4548, 1563,
-8475, -4139,
-11389, 2711,
-3975, 7148,
285, 1127,
-3298, -1207,
-6254, -2032,
3032, 4284,
4165, 2728,
-6610, 1856,
-14819, 5301,
-12379, 2788,
-2572, 7242,
-910, -149,
-4891, -2269,
-99, -5624,
2609, -8842,
-1398, 13072,
-1451, -116,
662, -18026,
517, 323,
4413, -8459,
5638, -6883,
1337, 11942,
731, 8732,
968, 1265,
-4237, -372,
-4562, 4947,
1156, 1460,
-1376, -217,
-1275, 1300,
1867, -3768,
5518, 107,
11947, 662,
5176, -889,
2473, 6228,
1691, 661,
-4050, -10157,
6916, -8976,
250, 3925,
-12985, 6704,
101, 1798,
4357, 1088,
2738, -14,
5967, 3286,
8414, 2975,
1644, 1109,
-5205, 1593,
2177, 97,
-2366, 665,
-2451, -7120,
9222, -6217,
4665, -1774,
1696, -7768,
-6526, -8108,
-2383, -3526,
11776, 9567,
1010, 3948,
5520, -9163,
8634, 3100,
-2791, 4215,
-471, -5534,
-3915, -2022,
-2092, 3092,
4202, 1512,
-8815, -4363,
-11353, 2990,
-4181, 7723,
-3, 1454,
-2946, -1583,
-6052, -2322,
2614, 3555,
4445, 2450,
-6841, 2571,
-14361, 4946,
-12139, 3048,
-1970, 6937,
-1070, -596,
-4861, -2604,
2655, -3850,
-8873, 1292,
-4498, 2829,
-5915, -462,
-2021, -5818,
6041, 5207,
5464, 10061,
9214, -1477,
1379, 2902,
3050, 3925,
6910, 3371,
-2929, 6879,
-1629, 4778,
769, 1661,
8291, -1995,
3573, 3408,
-5312, -6,
6580, 116,
1048, 14101,
-7342, 5255,
933, 5290,
3799, 7095,
1400, -5129,
2457, -6192,
5331, -3344,
2317, 1105,
-5211, -1410,
-4769, -5072,
-5743, -1261,
-5707, -5784,
4217, 5211,
7251, 9854,
-990, -2180,
-3956, -1352,
325, -385,
5502, -2212,
4943, -1054,
-1679, -4674,
-991, -8360,
-8314, -5167,
-11609, -1688,
525, -6224,
1106, 1059,
8977, 8522,
7845, 531,
-8027, -1548,
-2253, 5584,
4873, 3029,
2490, -5799,
-2986, 7085,
-8359, 5318,
-5728, -8313,
-4439, 77,
6004, -7688,
4320, -9115,
-3014, -1041,
-3828, -14956,
-5529, -6768,
5714, 446,
-2164, -2856,
-10790, 2215,
1555, -5915,
-3365, 126,
2448, 5423,
5567, -1987,
-9054, 1812,
-4313, 3036,
-5823, -882,
-1722, -5914,
6102, 5046,
5084, 9923,
9718, -1818,
1889, 2352,
3384, 3427,
6503, 3077,
-2581, 7274,
-2225, 4870,
689, 1940,
8609, -1406,
3506, 4169,
-4394, 5796,
-8609, 1362,
-3236, 1031,
1574, -738,
1353, 4306,
-578, 8049,
5725, 6649,
-90, -6240,
-3349, -15169,
4322, 3242,
-6185, -4174,
354, -10690,
6719, 2088,
-5920, -6072,
2858, -3555,
-2790, -1442,
-7380, -5282,
5480, -241,
1196, -2521,
6807, -4425,
11846, -10547,
-2117, -6992,
-6726, -1508,
4368, -3543,
5499, 4560,
106, 2194,
4128, 5006,
982, 10488,
-536, 1606,
-1767, 3838,
-8904, -1608,
-3368, -5818,
-4483, -747,
3664, -1107,
15529, -1601,
-274, -12386,
-2990, -6414,
1931, 3784,
-520, -4823,
-526, 1632,
-6492, 6613,
-701, -4951,
59, -4419,
-4908, 4956,
-1050, 4788,
-3296, -696,
-3732, -2085,
-886, 2563,
734, 3934,
5266, -160,
1975, -605,
-3377, 1287,
5879, 2699,
13809, 2476,
-958, -5771,
-3503, 622,
-367, 8368,
-10531, 6497,
-5439, 10267,
-2899, 1321,
-2722, -1242,
5461, 4478,
3413, -2361,
3097, 8091,
-3263, 11341,
-8864, 1894,
-3529, 1676,
1261, -846,
1401, 4308,
-1142, 6658,
5592, 6848,
390, -6132,
-3649, -15315,
4354, 4066,
-5829, -5079,
700, -10978,
6686, 1644,
-6203, -6510,
3189, -2417,
-2852, -625,
-5867, -912,
-819, 8648,
-1434, 4940,
2853, -4731,
5474, 9797,
-2862, 8139,
-4309, -4330,
-473, 3483,
-2377, 4626,
6849, -4496,
7062, -3845,
-7064, 1024,
-4359, -4909,
1053, 502,
-4104, 6847,
-826, -681,
-1519, 1668,
-3319, -3419,
3807, -10945,
1458, 4458,
6153, 8792,
10626, -4789,
659, -6033,
3746, 1494,
3023, 3611,
-5404, 102,
-3802, -2035,
-4416, 491,
58, -2864,
8500, -301,
9437, 3001,
-116, -9400,
-7889, -6135,
1414, 6352,
2292, -4874,
-2791, -254,
-4060, 6387,
-2624, 6413,
6835, 8868,
4388, -6643,
-4134, 2911,
1452, 9611,
4403, -8023,
3211, 3671,
3664, 939,
3873, -5263,
-1940, 3850,
1102, -7378,
4169, -10455,
-2478, -3507,
3670, -947,
-3180, -5572,
-10202, -4444,
-379, 3604,
-2858, -7909,
3105, -12045,
8586, 4316,
-8061, 10382,
-7870, -1136,
591, -10564,
5495, 6734,
2001, 7062,
-13773, -4617,
-12850, 3517,
-3326, 4455,
-1213, 7918,
-1737, 5228,
2447, -4470,
5535, 10327,
-2604, 8652,
-3623, -4802,
-612, 3109,
-1894, 5078,
6832, -4091,
6872, -3724,
-7307, 1438,
-4373, -5647,
263, -334,
-4410, 7187,
-265, -952,
1569, -124,
-1742, -1039,
-8991, 2576,
-1584, 73,
-4006, -1976,
5355, -2967,
5061, -3299,
-4126, 711,
-1518, -1451,
-5292, -3016,
5916, -8777,
14572, 2455,
4274, 10415,
10483, -4036,
2415, -3064,
-13078, -6057,
-5474, -2343,
-818, 10837,
788, 1131,
5222, -4656,
1416, -1298,
282, -1122,
-1106, 3864,
-3992, 5329,
-4173, -7849,
-3343, -11167,
-2798, 499,
3577, -5764,
1903, -4509,
-6685, 1937,
-998, -316,
1529, 10121,
-4429, 3102,
-2853, -4994,
3661, 2235,
2429, 3163,
-8855, 10306,
-4136, -321,
14680, -4585,
5976, 429,
-6958, -3424,
-1880, 14028,
2532, 5331,
-489, -5827,
-6886, 7778,
-506, -3172,
6457, -2106,
2324, 4925,
5819, -4851,
2517, -2775,
-2761, 6239,
4771, 837,
95, -8261,
-3259, 10415,
2459, 12028,
-1467, -142,
2622, 5838,
2574, -4559,
-1300, -3217,
3552, -2709,
1599, -9367,
5019, 7925,
-2726, 2658,
-12013, -7986,
2824, -1953,
-1487, -1217,
-8783, 2778,
-1393, 131,
-4502, -1976,
4872, -3659,
4273, -3170,
-4499, 805,
-1386, -1313,
-5258, -3713,
5845, -8703,
15358, 2214,
4959, 10496,
10135, -4171,
2579, -4039,
-12335, -5027,
-3295, -3210,
-2300, 1001,
-5499, -151,
-2256, -984,
-523, 8683,
540, 687,
-5185, 160,
-4696, 3559,
-744, 1160,
-11, -1169,
4258, -5776,
5534, 2547,
13380, -3146,
9940, -4702,
538, 8489,
3036, -6638,
-1519, -1732,
261, 11805,
-1628, 63,
-7616, -4284,
5230, -790,
-1790, -1929,
-8489, -4472,
-1287, 3869,
-7925, 5819,
836, -2829,
-1405, 4731,
-10099, 1822,
2532, 3164,
-1405, 2170,
-1826, -8182,
7462, -2101,
1447, -367,
4278, 1167,
1834, -7590,
718, -16430,
14239, -105,
2637, 2317,
-5280, 5972,
11504, 3413,
12529, -4074,
-3437, 4692,
-11279, -3719,
-1855, -2451,
5280, -621,
-1891, -13568,
698, -5311,
9719, -932,
4514, -375,
1924, -30,
705, -189,
-9620, 1481,
-5185, -685,
8556, 7000,
2913, 8056,
-11292, 6077,
-3006, 7751,
10431, -4009,
-513, 611,
-9715, 6086,
-71, -4179,
3080, -4254,
-8421, 3448,
-9926, 2274,
-29, -3852,
-2387, 1700,
-5231, -298,
-2045, -646,
-298, 8725,
120, -22,
-4698, -102,
-3927, 4013,
-1082, 505,
720, -1069,
4091, -5575,
5567, 2329,
13017, -2822,
10491, -3957,
97, 8517,
2570, -5544,
4450, -2668,
8787, -1687,
-4389, -861,
-4404, 6317,
745, -259,
-623, -6381,
-1306, 1971,
-3683, 4624,
863, 1770,
-3708, 6757,
-7891, -1964,
-5550, -10539,
-8970, 379,
1065, 3671,
-1743, -294,
-4380, -3317,
5239, -4951,
-6707, 1378,
-3723, -7313,
1289, -9473,
-6041, 7091,
6408, 9661,
4816, 2116,
2972, -4337,
6752, 528,
1479, 183,
5729, -9587,
4430, 510,
-4063, -3937,
-5177, -3827,
-4466, 7916,
-1691, -6617,
4376, -9577,
9493, -7775,
6579, -8077,
627, 4503,
1523, 1909,
2519, 1018,
-1923, -200,
-10534, -1066,
-8010, 4375,
-893, -6081,
-2972, -4011,
-654, 9789,
5581, 5757,
2708, 3296,
-2232, 2507,
1058, -5106,
2346, -3824,
3998, 7184,
1296, 4112,
-5433, -1654,
-1576, 2725,
138, -52,
-1074, -1201,
-2189, 1777,
-5614, 3766,
5235, 6675,
-375, -1513,
-7246, -7272,
6504, 6096,
2480, 15261,
2713, 3587,
9711, -7113,
9887, -2444,
8581, -1723,
-4660, -1108,
-4678, 6537,
1946, -33,
-430, -6344,
-903, 2000,
-4537, 3692,
1129, 2400,
-3321, 6634,
-8396, -1740,
-5910, -9905,
-8950, 1322,
1554, 2277,
-1145, -1394,
-4494, -3729,
1659, -2667,
-7405, -1981,
3011, 280,
3012, 111,
-3312, 285,
-1419, 7188,
-4884, 4049,
-2805, -253,
-8552, -2979,
-3047, -6018,
6045, 29,
-4476, -4504,
272, -8923,
1972, 6250,
-6046, 8683,
-2472, -1926,
-4287, -2496,
4825, 4952,
4888, 1228,
-8928, -8573,
-797, -2414,
7744, 10868,
4262, 10263,
-1341, -447,
-3816, -6813,
2876, -1874,
3094, 1815,
-1744, 665,
-5650, 6885,
-5201, 3418,
-3396, -6518,
-169, -666,
133, 1810,
-6808, -2300,
-5961, -4539,
-13231, -2775,
-13302, 1731,
9815, 109,
10687, 3888,
1580, -2206,
1214, -18085,
734, 2465,
-1783, 14775,
-2365, 52,
174, 7032,
-2968, 447,
2276, -6321,
9857, 7584,
2171, -2856,
2126, -11253,
2460, -4512,
6253, -13333,
7166, -10478,
-1157, -1310,
4056, -2569,
3415, 9238,
4213, 13611,
11043, -645,
1284, -992,
279, 6522,
3339, 6725,
-1481, 4739,
-508, -3766,
4148, -4563,
-939, 995,
-7008, -1933,
3164, 306,
3442, 648,
-3451, -181,
-2166, 7274,
-4707, 4321,
-3252, -141,
-7788, -2423,
-3461, -6490,
6560, 875,
-4806, -4634,
130, -9107,
1785, 5852,
-6128, 9510,
-2087, -2493,
948, -2934,
4525, 12209,
8155, 2205,
-4940, -5246,
-3274, -2723,
4368, -6957,
-4961, -2562,
-9524, 6631,
-6288, 1086,
-5299, -11853,
-7630, -4772,
8034, 10458,
13811, 9011,
-4057, 1824,
7375, -7116,
12069, -7615,
-8169, -1467,
-6507, -2237,
3088, -2725,
8199, 3943,
5913, 1037,
1004, -10361,
5905, -5380,
5855, 4070,
-1527, 58,
967, -3290,
-2022, 3463,
-6256, 3776,
8361, -3053,
7321, 2908,
-7706, 2640,
4913, 4743,
1932, 12216,
-10337, -4932,
3046, -4817,
-1916, 5983,
-8313, -164,
-1710, 5154,
2346, 913,
6785, -571,
-3382, -1002,
-5544, -6579,
215, 5019,
296, 1199,
3380, -2529,
-5982, -3729,
-4223, -11101,
4694, -3562,
-1805, -9350,
-429, -2369,
832, 10647,
-5190, 1878,
-2601, 3537,
-2502, 4520,
2644, 9646,
9059, 3903,
-6273, -12612,
-8167, 1865,
4006, 3968,
-4322, 762,
-3285, 1418,
2418, -8431,
-2306, 3817,
6366, 1484,
7062, -2896,
4912, 11778,
8510, 3096,
-4642, -5172,
-3179, -2811,
4850, -6851,
-5200, -2735,
-9817, 6212,
-6258, 1258,
-5643, -12362,
-7873, -4558,
8457, 11060,
13483, 9012,
-4762, 1606,
7443, -6699,
11768, -7591,
-5704, -6109,
-3671, 6829,
-2462, 54,
-2832, 472,
-6032, -2345,
-10627, -8465,
-12651, -4687,
-6812, -4258,
1533, -676,
-5577, 674,
-70, 10629,
10874, 9017,
3380, -6899,
1814, 1084,
-2867, 776,
-3361, 6096,
-574, 16314,
-5979, 2032,
672, -2388,
3565, -8980,
4657, -1468,
5469, 4060,
2643, -6112,
8510, 1889,
3460, -5174,
764, -8662,
1309, 3895,
-1031, -3200,
4715, -3149,
-3808, -2627,
-1131, 319,
3688, 2003,
-3086, -861,
6973, 9017,
2749, -428,
1790, -3282,
11563, 14944,
-4498, 3569,
-6960, -4554,
3814, 4870,
8820, 6583,
13008, 1178,
-3377, -3706,
-8693, 2173,
3628, 10156,
-3819, 3764,
-4098, -5734,
4423, 2529,
-2513, 3853,
4781, -1566,
3586, 4509,
-13314, -2291,
-4958, -8902,
-5967, -1794,
-7631, -2984,
5784, -5830,
1087, -542,
8014, -5724,
6083, -10475,
-9866, 9263,
36, 6597,
2680, -9899,
735, 4081,
3625, -4383,
-2537, -10606,
-3428, 7377,
-2319, 1194,
-2780, -459,
-5874, -2014,
-10439, -9241,
-12453, -4476,
-6957, -4298,
1743, -413,
-4984, 683,
209, 10856,
10988, 8185,
2728, -6857,
1455, 1161,
-2702, 1107,
-3578, 6477,
-922, 8611,
5676, 4024,
5911, 1524,
10112, 7414,
10395, 5916,
9379, 1381,
2350, 2718,
79, 2526,
6276, 368,
-1485, -3625,
-3691, 944,
-3319, 10250,
-538, -4497,
4041, -12392,
-6658, -3639,
-3799, -5852,
-1150, 2069,
-6873, 7446,
3165, -1850,
7417, 2702,
-588, 7359,
-6109, 2862,
-3929, 2310,
-2394, 3956,
-10146, -1789,
-4385, -1559,
-1189, 2138,
-624, -7753,
1391, -6704,
-5817, 4521,
-4322, -5305,
-4463, -12066,
-3990, -6477,
11214, -3516,
371, 7883,
-8050, 13013,
8513, -4082,
-635, -10373,
-4566, -284,
6827, 1869,
6023, 406,
7595, 5908,
-613, 5552,
-6595, -6507,
3798, -9171,
1013, 4201,
-2444, 3483,
-549, -1441,
4223, 3712,
8136, -4378,
-3261, 1195,
-5426, 9153,
-5928, -2699,
-8465, -5570,
2575, -7823,
965, 183,
3667, 7458,
5068, -10919,
-1132, -3602,
8022, 6238,
-5073, -5073,
-13706, 1204,
1020, 5267,
-3357, -1805,
-747, 2376,
5880, 3585,
5153, 1916,
10188, 7148,
9411, 6184,
9850, 918,
2117, 2461,
-295, 1869,
6505, -64,
-1505, -3760,
-3743, 942,
-3240, 10654,
-1052, -4150,
4429, -12437,
-6366, -3139,
-3817, -4886,
-4526, 5136,
-803, 3287,
7492, 1172,
-3551, 6475,
3161, -3340,
5117, 341,
-2154, 3709,
4938, 1534,
9021, 1114,
-1372, 2966,
-9013, 5777,
-3878, 218,
220, 10567,
298, 6207,
-1371, -7763,
8144, 1056,
14026, -3422,
-3385, -4746,
-4968, 1507,
10038, -6160,
6637, 509,
-5736, 2028,
-8175, -4719,
-749, 2870,
-804, 6146,
-1668, -4695,
317, -7033,
-2973, 5841,
3556, 7564,
1925, 5223,
-11832, 4704,
-7094, 5164,
3242, 4564,
7986, -2461,
5302, -3504,
-6612, -14573,
-6483, -12914,
4151, 7341,
1114, -3084,
2688, -9887,
5593, -483,
-6764, -8217,
-38, -5825,
9471, 5188,
2944, 4829,
9463, 2967,
-418, -60,
-9713, -6728,
760, -5969,
-3086, -3886,
-2255, -7300,
3959, 7224,
8844, 7647,
5582, -4066,
-4581, 8557,
-3085, 1361,
-7326, -6107,
-2307, -6484,
3342, -12111,
-7891, 8155,
-5280, 8910,
-9337, -1354,
-4579, -1314,
7216, -2041,
-6557, 7937,
-474, 3395,
7756, 1563,
-3288, 6402,
3515, -3136,
4943, 114,
-2421, 3179,
4379, 1422,
9230, 1045,
-1153, 3018,
-8687, 5524,
-4404, 61,
512, 9946,
763, 6269,
-1992, -7847,
8111, 1874,
13596, -2191,
3017, 4380,
-2551, 8191,
-1256, -4531,
-1932, -3968,
-3279, 2494,
4662, -685,
2558, 6952,
-8523, 4842,
4202, 2555,
12510, 5983,
-3986, -3921,
-4217, 3991,
533, -2227,
1475, -12833,
12377, 7723,
2005, -276,
-5748, -6801,
375, 4621,
-13863, -3198,
-10209, 1910,
1984, 6503,
-4206, -167,
-1179, -212,
-3889, 1023,
-2099, 2360,
7317, 962,
167, 4038,
-3451, 571,
549, 934,
3188, 8713,
6582, 765,
8005, -2697,
3442, 3178,
600, 4372,
4925, -569,
-2796, -6778,
-1957, -3045,
4219, -3546,
-8078, -4740,
-3716, -2057,
1407, -5903,
-3230, 1779,
2851, 5194,
7448, 803,
3604, 1332,
-7445, -806,
-6140, -1753,
-1174, -5284,
-8099, -3068,
-4935, -2294,
-7570, -1687,
-5338, 4164,
8140, -6054,
446, -7214,
-1195, -2143,
3744, -11059,
-1795, 2739,
-4824, 16439,
-4804, 2236,
12160, -5560,
10308, -4618,
-9215, -1923,
2416, 746,
12888, -534,
3510, 3679,
-2250, 7336,
-1241, -4281,
-1821, -3764,
-2570, 3116,
4932, -259,
2774, 7346,
-8300, 5297,
3283, 3216,
12509, 6672,
-4340, -4121,
-5121, 4111,
1149, -2533,
1510, -12965,
12321, 7533,
832, -348,
545, 2198,
-415, -1227,
-787, -4921,
2388, -5308,
-2069, 1942,
3850, -2817,
2069, 1293,
-12642, 6240,
-3576, 2447,
5552, 8200,
1183, -1698,
7637, -8113,
14561, 5192,
6239, 11624,
-6693, 7126,
1235, 7695,
9079, 6662,
-2016, -3172,
1409, 286,
7841, 6034,
3162, 1226,
-5428, 1116,
-7379, -9395,
-3598, -9243,
-6252, 1218,
394, 836,
3330, -535,
-8002, -926,
7801, 9808,
12973, 8677,
-5614, -7602,
-11627, 1198,
-12097, 4316,
-3884, 1917,
-4415, 4698,
-6926, -630,
3708, -6789,
2057, -6621,
2639, -362,
5838, -715,
2246, -2080,
4800, -1169,
3214, -9608,
-1442, -7475,
-4130, -1861,
-713, -5693,
2403, -897,
204, 5302,
3782, 1602,
-2021, 4217,
-3101, 5838,
11166, -6354,
5885, -6083,
-1011, -1020,
-2219, -3179,
-6090, 6027,
2596, -6757,
-2544, -9224,
-4458, 8671,
3581, -3590,
-8958, -975,
-7179, 5017,
3144, -8063,
-58, -395,
390, 2441,
-707, -1242,
-449, -5233,
2401, -5606,
-1834, 2341,
4183, -2870,
2043, 1392,
-12432, 6296,
-3115, 2537,
4623, 8524,
860, -1682,
8087, -8207,
14159, 5381,
5956, 12191,
-7309, 6822,
1330, 1980,
18041, 1653,
1897, 7752,
1648, -539,
2883, 7029,
-7040, 3897,
425, 1550,
-990, 2657,
-5223, -4159,
-571, 4421,
-1939, 3806,
1762, 3104,
-4139, 4321,
-5074, -964,
7403, -931,
1364, -5831,
988, -3523,
15700, -523,
5314, 2200,
-7968, -3385,
-4715, -5591,
-1304, 12611,
-117, 1442,
-404, -11323,
-939, 7147,
280, 7324,
-948, 1013,
-6010, -2169,
-7733, -7155,
-7806, -9020,
936, -8195,
-1741, -3108,
-15141, -10088,
502, -5681,
10581, 3292,
154, 3280,
-819, 432,
-9870, -7395,
-7874, 3887,
3237, 11387,
-3859, -2922,
4249, -8568,
7557, -2438,
-3143, 7894,
-1542, -3579,
-686, -6225,
-526, 2934,
509, -4059,
-2886, -1501,
-5892, -417,
-8162, 1081,
-164, 3692,
5957, -1573,
5591, 5875,
8329, 4391,
4455, 2083,
421, -1674,
-3021, 174,
-546, 12420,
10614, -6134,
2853, -6083,
2529, 7479,
9948, -3000,
-7703, -801,
958, -2778,
18232, 2196,
1397, 7565,
2317, -1073,
2822, 7766,
-7889, 3869,
175, 2144,
-1527, 2747,
-5739, -5100,
-461, 4581,
-1464, 4137,
1444, 2719,
-4220, 4119,
-5662, 100,
7209, -747,
170, -5690,
-814, 252,
-1528, 556,
9056, 5432,
6506, 145,
4599, 3345,
-3215, 2976,
-6000, -18367,
-1884, -10476,
-2047, 752,
7252, -10056,
-1682, -3678,
-3370, -4316,
16194, -7077,
7247, 6939,
-7892, 4418,
-1761, 238,
11329, -17,
1763, -8648,
-14849, -10940,
-2861, 1311,
-1420, 9878,
-1671, 3730,
8707, -2905,
4058, -6700,
1036, 827,
-6054, 10892,
-3701, 1136,
-1053, -5260,
-8304, -3350,
4928, 2038,
7555, 1838,
-6574, -2141,
688, -811,
442, -6119,
-9021, 3992,
2507, 9898,
11205, -4340,
5185, 3243,
7058, 1805,
-2080, -5707,
-11805, -4605,
-524, -4319,
-2488, 2924,
-3736, -4408,
89, 3171,
-3054, 9869,
659, -7358,
-2636, 4374,
1071, 5131,
7357, -5861,
-1603, 2241,
-2897, -4118,
-846, -76,
-5020, 3653,
-7162, -981,
-487, 4348,
8936, 659,
3763, 1289,
-57, 1534,
-5019, 876,
-5407, 11323,
3956, 7908,
148, 1453,
-634, 5892,
-3616, 2305,
-1427, 1068,
8895, 5343,
7104, -37,
4645, 2668,
-2483, 3168,
-5715, -17836,
-1438, -10108,
-1893, 1392,
6790, -10763,
-1190, -3281,
-3365, -4881,
15575, -7182,
7249, 6967,
-7939, 4347,
-2396, 219,
9590, 2332,
2868, 4848,
-7834, 3763,
3445, 2647,
2120, 807,
-783, -1552,
-6525, 587,
-9664, 6045,
5686, 1200,
5315, -4490,
1551, -2562,
9076, -3488,
6256, -226,
-849, -3642,
-3796, -9633,
1434, -1225,
2499, 7738,
-8381, 5465,
-2370, -2039,
11356, -4153,
6160, -3936,
4493, 785,
5653, 2520,
2841, -2980,
2721, 818,
-5375, 5054,
-6995, -1572,
-5359, -2462,
-7595, -2255,
11774, -2212,
13537, -5490,
-1180, -2993,
7415, 2957,
5229, -3653,
1476, -73,
3910, 6547,
-4333, -3367,
-4323, -739,
-1005, 9079,
-4044, 4901,
-5863, 1701,
-6713, 7713,
-3866, 1629,
-8897, -9518,
-11320, 3408,
294, 7041,
6886, -5970,
422, 2369,
-2149, 6403,
-3645, -2896,
-7070, -116,
-4279, -4558,
-2422, -9131,
-1172, 4112,
-2398, 3309,
-5631, -6661,
1305, -1420,
-3944, -2323,
-2429, -4151,
10877, 10908,
2880, 6853,
3660, -7110,
5444, -5246,
-4374, 829,
7825, 3732,
3113, 4706,
-7362, 3842,
4003, 3090,
2079, 1360,
-1134, -1685,
-6971, 390,
-9594, 6277,
5858, 1271,
6147, -4829,
1024, -3244,
8943, -3735,
6232, -67,
-663, -3456,
-4230, -10275,
1128, -888,
-2726, 3253,
1498, 4792,
4538, 4775,
-6004, 8547,
-1841, 6625,
-2519, -2475,
2431, -1966,
6111, 297,
3594, 3671,
3117, -2878,
-3058, -7356,
3987, -7209,
-2222, -8547,
-1110, 303,
6306, 489,
-11988, -2365,
-862, 7500,
12778, 12401,
-2626, 10622,
-9337, -1615,
-12691, -10901,
-5677, -186,
3469, 6365,
2766, 5532,
5254, 5266,
3139, 533,
-1067, 1599,
2988, 3115,
8511, -2016,
-628, -1921,
-151, 7471,
5108, 7825,
-3765, 2223,
-1101, 2221,
697, -5067,
-1162, -10259,
174, 2863,
-8392, 5441,
-692, 833,
440, 6395,
-3587, 879,
3535, -8218,
-2716, -3154,
2979, -1640,
8950, -8763,
-1747, -5883,
-2222, -115,
-4873, -3782,
-6532, -5674,
-2234, -1614,
-29, -4961,
5680, -246,
6847, -660,
-6584, -14271,
-1673, 1374,
11419, 10242,
-3539, -9713,
-1203, -4846,
6457, 6068,
-10968, -1107,
-1102, -7646,
7729, -227,
3738, 9144,
3438, 2177,
-7091, -1621,
2213, 5057,
4355, 4674,
-6112, 8738,
-1701, 6979,
-2911, -2551,
2707, -1973,
6166, 982,
3376, 3322,
2586, -2341,
-2243, -7195,
3670, -7587,
-1718, -8902,
-486, -302,
6264, 409,
-12086, -2153,
312, 8366,
4189, -3335,
4129, -4073,
-1435, 9488,
2114, 6517,
984, 5943,
-6577, 1584,
-2260, -5351,
1128, -8864,
866, -1437,
396, -428,
-6235, -3496,
-81, 4042,
6545, -3607,
-1631, -4417,
2116, -1736,
325, -3027,
368, 9674,
12535, 8327,
1229, 2512,
-7790, -1446,
-2406, -12079,
-3027, 327,
1820, 10620,
5057, 1636,
4495, -952,
1329, 7045,
-1397, 6908,
3332, 1305,
-1992, -352,
-4600, -4617,
-6670, -998,
-11277, 1017,
2446, 4769,
8830, 5008,
-189, -5698,
-6958, 8949,
-8746, 10778,
-2136, -6531,
-1248, 2503,
493, -743,
2220, -9150,
3145, -2799,
5644, 3766,
1775, 2511,
-3624, -4352,
-593, 5462,
8374, -2113,
5608, -3567,
-11733, 6463,
-2174, -7511,
6333, 1593,
-7172, -220,
2043, -11473,
6079, 494,
-6434, -8841,
-10225, -8834,
-6835, 369,
1491, 7407,
2490, 12751,
1469, -8395,
5602, -7239,
4863, -4672,
3017, -5270,
1952, 8533,
4011, -2868,
4087, -3283,
-1300, 8985,
1920, 6395,
548, 5592,
-6812, 938,
-2405, -5757,
1217, -8690,
1395, -1937,
384, -729,
-7159, -2629,
-407, 4132,
6460, -3601,
-1878, -4882,
1256, -1447,
-23, -1471,
-569, -957,
134, -287,
-54, -452,
507, -66,
-423, 334,
302, 160,
45, -138,
26, -506,
223, -166,
371, -369,
-333, 134,
410, -182,
-376, 440,
-334, -36,
-209, -472,
229, 25,
-333, 223,
104, -154,
128, 192,
48, 105,
172, 120,
-365, -102,
313, -40,
35, -42,
227, -40,
-306, -453,
16, -6,
273, -370,
315, 40,
-26, -363,
-576, 424,
-341, 255,
68, -168,
247, 642,
144, 354,
-190, 265,
698, -644,
22, -393,
269, -218,
-129, -102,
-347, -408,
213, 204,
323, -163,
566, -51,
-164, -171,
-506, -27,
503, 427,
82, -569,
-350, -299,
-174, -146,
-251, 172,
361, -318,
184, -163,
75, 219,
75, -382,
-255, 326,
309, 106,
108, 177,
-81, -5,
-57, -310,
-32, -497,
-276, 48,
230, 222,
433, 225,
769, -27,
157, 512,
-256, 58,
62, -125,
-313, 33,
-191, -191,
-205, 214,
-259, 484,
118, 323,
-347, 77,
207, -423,
247, -198,
323, 125,
-6, -24,
192, 430,
561, 205,
16, -446,
-55, 197,
551, 208,
-780, 544,
-142, 27,
756, 82,
-147, -490,
-174, -143,
-381, -464,
247, -46,
-656, -242,
-249, -400,
176, -1,
0, -261,
194, 394,
39, 692,
212, 47,
-400, 88,
68, -609,
-487, 466,
244, -194,
-97, 122,
204, -63,
-167, 107,
102, -27,
328, 41,
-615, -331,
-581, 41,
-570, -463,
264, -34,
126, 57,
-218, -87,
466, 101,
43, 275,
-493, -496,
-317, -452,
-431, -193,
297, 133,
-187, 107,
-364, -110,
-179, 180,
-260, 646,
265, -335,
148, -263,
94, -569,
129, 42,
13, 247,
-295, -115,
168, 339,
-255, -72,
-333, 76,
-334, 315,
270, 183,
305, 98,
-547, 443,
-46, -284,
78, -144,
-190, 92,
237, -111,
79, -175,
-48, 224,
-173, -158,
210, 123,
264, -57,
146, -135,
-75, 142,
286, 90,
-282, -614,
45, -105,
434, -335,
-59, 35,
-262, -223,
604, -4,
-77, 390,
137, 529,
-250, 248,
89, -497,
145, 456,
1, 334,
101, 79,
374, 756,
-437, -143,
64, 558,
-619, -344,
9, -123,
600, -365,
293, 175,
-2, 113,
-105, -202,
164, -437,
329, -839,
5, -296,
502, -446,
-254, 206,
-621, 335,
-233, -622,
-62, -543,
-116, -149,
-263, 295,
416, 390,
-502, 457,
-153, -123,
-301, -204,
-147, -321,
-207, 171,
149, 238,
-324, -476,
-255, -43,
31, -165,
337, 187,
-577, 356,
560, 373,
-273, 152,
201, -130,
326, -148,
411, -365,
-161, 362,
8, -279,
-50, -605,
-188, -257,
84, 451,
111, 79,
-110, -114,
41, 64,
831, 121,
-2, 136,
221, -56,
-144, 710,
-164, 329,
-107, -770,
176, -296,
-249, -10,
-576, 155,
17, -89,
-136, -14,
87, -101,
26, -409,
227, 662,
280, -61,
-412, 723,
-474, -277,
156, -80,
95, -407,
-292, -266,
385, 280,
10, 235,
38, -272,
85, 47,
234, -137,
474, 257,
-81, -239,
-538, 484,
315, -482,
-288, 90,
387, -470,
-183, -226,
464, -334,
-251, 481,
-346, -51,
297, 101,
-424, -448,
212, -298,
136, 108,
-45, -32,
-106, 205,
640, 360,
-116, -286,
-59, -302,
-292, 142,
-253, -38,
-181, 4,
531, -275,
-121, -295,
-215, 139,
-139, 485,
222, -108,
-409, 345,
195, 426,
-414, 333,
-41, 471,
-568, 112,
167, -502,
215, -256,
-214, -48,
99, -451,
51, -163,
360, 396,
40, -243,
323, 63,
-36, 87,
-202, 574,
-12, -78,
-62, 201,
274, -383,
-17, -273,
-262, 102,
-48, 163,
370, -147,
-129, 85,
-205, -209,
306, 179,
31, -218,
-113, 78,
-230, 110,
-460, 445,
48, -345,
-99, 66,
99, -537,
-453, 39,
411, 244,
151, -332,
-487, -64,
329, 382,
-183, 515,
94, 1,
68, 462,
-273, -49,
-890, -272,
166, -32,
-106, -542,
-186, -257,
130, -193,
-214, 429,
209, 69,
47, 635,
-308, 138,
260, 110,
148, -70,
389, -277,
-277, 53,
-278, -117,
97, -484,
207, 160,
257, -51,
2, 81,
-73, -162,
203, 213,
611, -186,
275, 111,
26, 208,
-179, -39,
155, -286,
-150, 74,
74, 335,
242, -677,
287, 35,
183, 44,
428, 109,
576, -118,
-590, 105,
-553, -172,
-287, 79,
-621, 357,
-111, -28,
-105, -336,
78, -32,
89, 135,
-213, -84,
-253, 516,
247, -137,
-119, -132,
-426, 507,
3, 93,
63, 166,
-128, 415,
206, -204,
70, -58,
-66, 270,
-14, -248,
142, 74,
-137, -362,
-328, 158,
-48, 695,
40, -51,
158, -125,
-9, 516,
-142, -292,
185, -117,
-35, -10,
251, 189,
-28, -339,
-2, -301,
-29, 95,
-286, -59,
-288, -521,
-299, -536,
555, -538,
-62, 6,
292, 141,
109, 207,
578, -330,
288, -625,
-381, 184,
-102, -26,
277, -6,
90, -126,
704, -97,
-15, 591,
-482, -48,
138, 159,
-283, -675,
15, -462,
335, -243,
96, 46,
93, 112,
-61, 780,
-46, -546,
-32, -537,
-870, -87,
122, -270,
308, -323,
-403, 296,
-473, -133,
193, 146,
-469, 63,
-522, -498,
245, 238,
-203, -80,
387, -206,
1202, 1556,
-9425, 285,
-864, -5131,
10124, -850,
6559, -536,
10012, -623,
-1011, -5645,
-9414, 737,
3356, 3397,
43, -9030,
-5344, -1045,
-544, 9691,
-699, 6187,
-321, 9550,
-5671, -1195,
572, -8866,
3689, 3021,
-9690, 145,
-884, -4991,
11030, -1037,
6347, -63,
10104, -667,
-836, -5413,
-8840, 307,
3546, 3089,
-131, -9289,
-5611, -436,
-775, 10581,
-18, 6403,
-94, 9712,
-5338, -968,
299, -9413,
2947, 2984,
-9640, -451,
-692, -5957,
9891, -891,
6616, -201,
9694, -471,
-661, -6050,
-9798, -126,
3694, 3363,
426, -9088,
-5440, -1076,
-1243, 9641,
-124, 5677,
-803, 9805,
-5099, -793,
-158, -9271,
3610, 2781,
-8373, 460,
-1093, -5246,
10098, -941,
6210, 26,
9419, -859,
-482, -5419,
-9018, 403,
3048, 3095,
198, -8740,
-5546, -1295,
-1336, 9853,
-896, 6165,
-897, 9746,
-5618, -1453,
-16, -8871,
2944, 3231,
-9799, 124,
-1101, -5445,
10003, -1103,
6084, -115,
10093, -603,
-1024, -5495,
-9265, 322,
2763, 3411,
-75, -8914,
-5347, -1106,
-1128, 9721,
50, 6532,
-267, 9660,
-5227, -574,
486, -9568,
3941, 3546,
-8868, 669,
-816, -5875,
10559, -515,
6133, 161,
9741, -846,
-312, -5549,
-9093, 105,
3194, 3481,
306, -9435,
-5557, -1129,
-973, 10913,
-120, 6909,
-1054, 10291,
-5768, -641,
145, -9242,
3028, 2666,
-8786, 104,
-866, -5238,
10270, -673,
6370, 499,
9927, -502,
-548, -5334,
-8777, -8,
3217, 3119,
689, -9075,
-5327, -1086,
-767, 9814,
681, 6866,
-405, 9911,
-5193, -1431,
288, -9916,
3040, 3283,
-9270, 14,
-373, -5598,
9324, -925,
6216, 12,
9894, -1199,
-893, -5483,
-9788, -519,
3371, 2917,
390, -9356,
-5767, -853,
-963, 10039,
-377, 6808,
-377, 10476,
-5359, -801,
85, -9491,
2919, 3373,
-9203, 553,
-416, -5124,
10038, -850,
6524, -453,
9580, -1283,
-888, -5588,
-8993, 325,
2778, 3024,
514, -9722,
-4708, -529,
-1366, 9812,
-642, 6725,
-905, 10089,
-5239, -1345,
138, -9217,
3158, 3416,
-9232, -50,
-1270, -5691,
9442, -782,
6906, -323,
10044, -1094,
-1309, -5062,
-8899, 56,
2804, 3348,
125, -9386,
-5244, -1419,
-1143, 9804,
-109, 6239,
-873, 10015,
-4868, -1096,
306, -8920,
-3967, 964,
786, -6683,
6307, -7547,
-6000, -7727,
-284, -3728,
4988, 5669,
-8802, 1302,
-8527, 1056,
-2196, 10667,
-3638, 1848,
-3867, -6043,
5050, -1808,
5929, -6498,
-8560, -4470,
-4349, -2266,
2466, -6937,
3830, 4386,
8599, 494,
-1561, -11393,
3997, 726,
1171, 4009,
-9481, 2751,
-12, 8175,
3297, -606,
6440, 1321,
-2908, 7420,
-8104, 3996,
3658, 6042,
1415, -1779,
6942, -5538,
2654, 7962,
-574, 8324,
10988, 82,
-15, -8560,
2632, -7280,
6606, 5549,
1025, 1586,
3867, -6309,
-7838, -4063,
-2707, -7799,
7038, -2202,
3927, 822,
186, -7997,
-9299, -3590,
2180, -3749,
4270, -1339,
-1435, 11678,
8300, -376,
3971, -4596,
2417, 7267,
-3887, 2566,
-9497, 4550,
5878, 6665,
4950, 1075,
-4174, 5468,
-3842, -2175,
-2436, -10763,
-8504, -943,
-8879, -1095,
5523, -5086,
-224, 4037,
-7227, 8127,
6243, 7833,
917, 7270,
-10595, -181,
1286, -6798,
6102, -7194,
-6170, -7627,
-122, -3703,
5169, 5002,
-8869, 1420,
-8506, 741,
-2399, 10354,
-3862, 1253,
-4413, -5610,
4524, -1060,
6032, -6083,
-9220, -4486,
-3549, -3092,
2286, -6720,
4173, 4048,
8755, 350,
-1130, -10440,
3770, 905,
1771, 4143,
-9121, 3659,
483, 7702,
3319, 106,
7303, 1680,
-2466, 7661,
-7956, 3681,
4101, 6653,
1172, -1573,
6780, -5986,
2691, 8318,
361, 8302,
10952, 251,
-411, -8333,
2767, -7751,
6560, 6404,
2116, 1466,
4369, -6586,
-8003, -3595,
-2322, -8075,
6790, -1549,
3688, 691,
-104, -8480,
-9729, -3313,
2205, -4267,
4329, -752,
-1540, 11004,
8843, -36,
4365, -4595,
2664, 7191,
-4430, 2856,
-9003, 4179,
5282, 6081,
4542, 1002,
-3909, 5052,
-3827, -1235,
-2714, -10060,
-8621, -949,
-8797, -1786,
5302, -5087,
-728, 4445,
-6781, 8417,
5843, 7551,
834, 7076,
-11428, 418,
1075, -6745,
6082, -7414,
-6750, -8110,
361, -3699,
5906, 5090,
-9131, 1192,
-8509, 866,
-1833, 10708,
-4104, 1344,
-3671, -5960,
5104, -1411,
5749, -6866,
-9261, -4334,
-3462, -2853,
2795, -6664,
4161, 4735,
8435, 203,
-1840, -10975,
4137, 1942,
2183, 3976,
-9372, 3442,
-167, 7923,
3827, 63,
6583, 1680,
-2044, 7272,
-8584, 4053,
3966, 6108,
1712, -2157,
6496, -6446,
2777, 7312,
-154, 8221,
5838, 2424,
1542, 3821,
-507, 2318,
8597, -5480,
-3282, -8475,
-4169, -4701,
7516, -1522,
10957, -809,
7835, -8398,
-660, -4411,
-3233, 1661,
2066, -5197,
377, -2113,
-3497, 8496,
8321, 10114,
3916, 11203,
-10824, 405,
3964, -11509,
8238, -10340,
-3417, -9135,
519, 2326,
1945, 5760,
-2680, -2395,
-989, 5409,
7710, 8428,
10738, 1355,
8210, 1801,
-4128, 4885,
-3348, 8833,
8916, 5765,
-255, -1978,
1887, -4087,
-630, -4737,
-10924, -1976,
6808, -2036,
5282, -3480,
-7755, 5451,
-3674, -2576,
-5997, -12132,
-1855, 3657,
-7107, 4130,
-4922, -9254,
4518, -3822,
-2244, -1615,
1582, -1122,
-2119, 5843,
-1640, 1881,
2159, -2638,
-6449, -23,
2222, 2374,
-267, -1964,
-2336, -5474,
1431, 761,
-1596, 1320,
4873, 3137,
-5209, 9456,
-7887, -3895,
-1618, -3884,
-6783, 12336,
-3543, 1969,
-7471, -5386,
4993, 3403,
8194, 2619,
-11233, 2662,
420, 4218,
1493, 3024,
-380, 2026,
8418, -5758,
-3055, -9034,
-3879, -4414,
8026, -1062,
10050, -952,
7915, -8463,
-511, -4499,
-3214, 2374,
1590, -5971,
-445, -2202,
-3427, 8959,
8184, 11049,
4007, 10764,
-6235, 1960,
5188, 959,
-8201, -4611,
-11806, 2852,
-4108, 7730,
63, 1332,
-3784, -1082,
-5867, -1862,
2648, 3580,
4554, 3115,
-7320, 2283,
-15427, 5197,
-11750, 3731,
-2147, 6929,
-1182, -173,
-4782, -2116,
168, -5304,
2464, -9380,
-2168, 13280,
-2005, -181,
951, -17954,
226, 360,
3709, -7639,
5163, -7104,
1074, 11241,
1355, 8994,
1047, 1330,
-4586, -123,
-4554, 4922,
676, 1614,
-699, -609,
-1409, 1088,
1537, -3750,
6002, 481,
11819, 565,
5070, -757,
2804, 5597,
2359, 1181,
-3292, -9674,
7374, -9305,
345, 3161,
-12751, 6320,
-25, 1626,
5461, 274,
2712, -66,
6101, 3609,
8417, 3150,
951, 1196,
-5023, 1456,
2092, 320,
-2235, -148,
-1877, -6905,
9501, -5806,
4114, -1834,
699, -8315,
-6424, -7895,
-2133, -3199,
11856, 10218,
316, 4313,
5857, -9288,
9086, 3201,
-3766, 3426,
164, -5623,
-3496, -1944,
-927, 3018,
4291, 1304,
-8485, -4210,
-11663, 2368,
-3896, 7478,
-309, 1429,
-3033, -966,
-6408, -1862,
2304, 4187,
4035, 2608,
-6910, 2168,
-15298, 4502,
-12527, 3221,
-2205, 7363,
-919, -337,
-4689, -1893,
2687, -3675,
-8367, 1289,
-4220, 2992,
-6507, -834,
-1367, -5444,
6128, 4724,
5374, 9995,
8822, -1447,
1218, 2639,
3314, 3349,
6711, 2783,
-3214, 6911,
-2557, 4718,
1772, 1755,
8800, -1023,
3825, 3689,
-4917, 941,
6595, 1004,
1122, 13574,
-7676, 5216,
1501, 4802,
2852, 7072,
1970, -5430,
1583, -6102,
5301, -3487,
2639, 1675,
-5389, -1603,
-5409, -4265,
-5108, -1147,
-5180, -4999,
4305, 5251,
7817, 8418,
-773, -2908,
-3149, -414,
411, -592,
5833, -2211,
4544, -578,
-2415, -4251,
-801, -7983,
-9270, -5148,
-11421, -1766,
311, -5772,
1261, 1050,
8007, 9175,
8357, 646,
-8290, -1637,
-2495, 6320,
5149, 2464,
2936, -5549,
-3440, 6635,
-8553, 5488,
-5300, -8935,
-4002, 539,
5877, -7076,
5703, -8920,
-2562, -624,
-3779, -14901,
-5020, -6736,
5222, -538,
-2392, -1976,
-11347, 2547,
1861, -5348,
-3265, 316,
2335, 5014,
5969, -1955,
-8246, 756,
-3960, 2653,
-6265, -839,
-1970, -5865,
6003, 5217,
5669, 10097,
9343, -1694,
1012, 2231,
3632, 3503,
7076, 2890,
-2749, 7475,
-2275, 4721,
419, 2012,
8536, -1147,
4387, 3856,
-4186, 5978,
-9426, 1666,
-2914, 1444,
1526, -543,
1565, 4246,
-608, 7318,
5045, 7286,
-48, -5129,
-3860, -15405,
4324, 3606,
-5665, -4643,
742, -11398,
5865, 1666,
-5426, -6185,
2845, -2564,
-2687, -1156,
-7552, -5411,
5542, -82,
1292, -2874,
6539, -4628,
11261, -10662,
-2672, -6796,
-6778, -1675,
5215, -3796,
5639, 4620,
-110, 1698,
2984, 5245,
1039, 10419,
-300, 1473,
-2004, 2944,
-8261, -1932,
-2715, -5846,
-4462, -483,
3243, -1353,
15499, -1533,
-411, -12903,
-3005, -6640,
1922, 4401,
638, -5615,
-344, 1817,
-7506, 6894,
-1127, -5438,
500, -4311,
-5045, 4035,
-919, 5175,
-3033, -386,
-4025, -2572,
-1101, 1811,
776, 3847,
5662, 161,
2481, -697,
-3689, 1349,
6357, 3268,
14163, 2114,
-817, -5223,
-3148, 544,
500, 7713,
-10499, 6626,
-5042, 10634,
-2975, 1352,
-2447, -600,
5425, 4153,
3947, -1628,
3647, 8345,
-2663, 10847,
-8761, 1808,
-3536, 1283,
1398, -731,
669, 4306,
-931, 6773,
5150, 6981,
477, -6758,
-3552, -14690,
4285, 3469,
-5593, -4293,
173, -10714,
6621, 1405,
-6139, -6761,
2644, -2928,
-2464, -891,
-5021, -622,
-1510, 9088,
-1242, 5235,
3167, -5867,
5322, 9835,
-2853, 8653,
-3358, -4708,
-473, 3809,
-2287, 4969,
6656, -5369,
6972, -2869,
-6558, 1325,
-4270, -5933,
348, -131,
-4155, 6971,
-423, -907,
-947, 781,
-3338, -3902,
3585, -10787,
895, 4350,
5800, 8769,
11368, -4067,
489, -5174,
3573, 1943,
3170, 3921,
-4871, -834,
-3587, -2530,
-3779, -329,
95, -2350,
8355, -682,
9260, 3507,
373, -9045,
-7912, -5579,
1161, 6459,
1590, -4939,
-2987, 176,
-3399, 7059,
-2516, 6659,
7462, 9643,
3749, -6078,
-3883, 3393,
1571, 8741,
5000, -8478,
3457, 3269,
3314, 1526,
3404, -5358,
-1692, 4341,
1590, -7125,
4437, -10088,
-1559, -2975,
3800, -819,
-3084, -4930,
-10975, -4400,
-94, 3423,
-2627, -8054,
3727, -11960,
9074, 4598,
-7230, 10793,
-7900, -1045,
560, -9882,
5676, 6462,
2111, 7043,
-14053, -4708,
-12402, 3635,
-4250, 4146,
-1186, 8713,
-1522, 5381,
2354, -4913,
5692, 10130,
-2441, 8268,
-2915, -4390,
-625, 3677,
-2108, 5031,
6986, -4790,
7392, -3198,
-6271, 876,
-4129, -5573,
735, -182,
-3737, 7294,
-503, -703,
1363, -246,
-2574, -547,
-9191, 3398,
-1216, -492,
-4059, -1644,
5532, -3051,
4626, -3666,
-4051, -355,
-1005, -1011,
-5475, -3209,
6469, -8186,
15255, 2663,
3790, 10729,
10195, -3597,
2402, -3630,
-12786, -6151,
-5738, -2142,
-938, 10831,
1166, 1074,
5299, -5145,
1927, -1475,
-96, -1091,
-933, 4132,
-4078, 4731,
-3932, -7200,
-3451, -10915,
-3015, 495,
3814, -4969,
1807, -5352,
-6572, 1552,
-1030, -298,
2394, 10084,
-4751, 2581,
-2865, -5150,
3838, 2058,
2175, 3146,
-9625, 10137,
-3674, -188,
14175, -4201,
5143, -655,
-7137, -3136,
-2187, 13946,
2775, 4174,
-697, -5669,
-6458, 7912,
-700, -3744,
6275, -1984,
2144, 4747,
5973, -4823,
2455, -3847,
-2803, 5612,
4859, 1315,
-319, -7498,
-2603, 10763,
1931, 12216,
-2213, 295,
2470, 5561,
2928, -5092,
-1208, -3402,
2506, -2494,
2189, -8997,
5320, 7787,
-3241, 3031,
-12473, -7289,
2781, -2350,
-2408, -483,
-8753, 3384,
-846, -163,
-4012, -1966,
4870, -3298,
4759, -4075,
-4540, 1103,
-1149, -1098,
-5093, -2851,
6061, -8209,
15117, 2373,
4677, 10228,
9838, -4108,
2956, -3622,
-13113, -5027,
-2690, -3418,
-2323, 1629,
-4949, -567,
-2573, -196,
-377, 9016,
366, -66,
-4912, 828,
-4093, 3544,
-698, 591,
323, -1288,
4201, -5937,
6164, 2579,
13195, -2873,
10769, -3482,
214, 8972,
2441, -5852,
-1617, -1885,
-404, 12075,
-1494, -60,
-7901, -3943,
5399, -734,
-2431, -1924,
-8839, -5298,
-673, 3553,
-7917, 5060,
373, -1926,
-2189, 4392,
-10915, 2320,
3039, 3025,
-1340, 2539,
-1046, -8102,
7161, -1899,
986, -476,
5121, 1353,
1870, -7821,
1064, -16763,
14094, -542,
2618, 2053,
-5483, 5921,
10329, 3499,
11640, -4552,
-3404, 4586,
-10641, -3878,
-2090, -2412,
5358, -651,
-1865, -12934,
1345, -5654,
9654, -407,
4061, -953,
2333, -433,
733, -386,
-10598, 856,
-5449, -858,
8624, 7682,
2360, 8170,
-11568, 6309,
-3025, 7662,
10827, -4519,
-430, 567,
-9372, 6145,
-594, -3506,
2830, -4688,
-8784, 3306,
-9790, 2964,
-147, -4101,
-2767, 1076,
-4394, -698,
-1846, -955,
-188, 8587,
957, 291,
-5706, 313,
-4393, 3935,
-924, 1198,
183, -841,
3823, -5969,
5808, 2090,
12607, -2967,
10771, -4241,
529, 8911,
2447, -6380,
4067, -1781,
8385, -1693,
-4484, -428,
-4938, 6319,
1007, -712,
-667, -6776,
-1608, 1925,
-4225, 3764,
1426, 2093,
-3382, 6412,
-8216, -1668,
-5684, -10000,
-8621, 609,
1728, 3209,
-1294, -961,
-4590, -4172,
5338, -6185,
-6657, 833,
-2904, -6653,
1603, -8699,
-5764, 7142,
6655, 9178,
4739, 2320,
2230, -4113,
7094, 1216,
2318, 1019,
5715, -8934,
4136, 366,
-3464, -3452,
-4711, -4668,
-4773, 7546,
-920, -6365,
4518, -9856,
9208, -7980,
6383, -7314,
1051, 4644,
1683, 1769,
2365, 768,
-2647, 533,
-11280, -1134,
-8154, 4125,
-1515, -6275,
-2467, -3901,
-94, 9780,
5464, 5977,
2566, 3646,
-2249, 2582,
1076, -5224,
2761, -3472,
3540, 6869,
1812, 4276,
-5984, -1309,
-1471, 3500,
-475, -490,
-1243, -1362,
-2527, 2205,
-6265, 3452,
5519, 6658,
-78, -1309,
-7820, -7611,
6623, 6236,
2626, 15445,
2948, 3776,
9748, -6981,
9840, -2862,
9390, -1959,
-4298, -207,
-5112, 6893,
1871, -944,
-858, -7079,
-1412, 1804,
-3816, 4680,
1540, 2180,
-3518, 7058,
-7970, -1979,
-4964, -10155,
-9735, 1004,
1029, 2851,
-863, -781,
-4708, -3460,
1918, -2503,
-6963, -2199,
3735, -10,
2821, 488,
-3698, -402,
-2178, 7617,
-4734, 4065,
-2973, -119,
-8327, -2973,
-3084, -6295,
6064, 253,
-4477, -4693,
772, -9401,
1930, 5798,
-6243, 8816,
-2421, -2595,
-5303, -3326,
4835, 4982,
5323, 871,
-9824, -8406,
-620, -2533,
7337, 10939,
4634, 10155,
-2127, 246,
-4429, -6326,
2733, -1576,
2780, 1380,
-1944, 274,
-5866, 6226,
-4207, 3129,
-2408, -5733,
-612, -1716,
603, 2002,
-6615, -2269,
-5107, -4239,
-12882, -2866,
-12923, 1746,
10395, 630,
10828, 3637,
1568, -2578,
1094, -17702,
289, 2889,
-1365, 14573,
-3161, -351,
312, 6918,
-2628, 330,
2334, -6258,
9809, 8199,
2096, -3022,
2433, -11243,
2034, -4029,
6014, -12054,
7823, -9803,
-1378, -1298,
5224, -2482,
3627, 8659,
3748, 13799,
11141, -1519,
690, -1587,
261, 6624,
3797, 6847,
-2555, 4515,
-1206, -3868,
4128, -5007,
-868, 1172,
-7060, -1966,
2800, -60,
3483, 48,
-3208, -463,
-2193, 7508,
-5030, 4419,
-2729, -178,
-8271, -2801,
-3778, -6205,
6425, -221,
-4378, -4800,
9, -9311,
2393, 6099,
-6718, 9026,
-2967, -2430,
1140, -2946,
4458, 11949,
8471, 2595,
-4635, -4984,
-3109, -2500,
4206, -6443,
-5074, -2802,
-9724, 5730,
-6122, 612,
-5512, -12109,
-8259, -4175,
7668, 10113,
13185, 9154,
-4067, 1689,
7233, -6687,
11656, -7087,
-8534, -1603,
-6731, -1329,
2983, -2601,
8511, 3818,
6409, 947,
628, -10933,
5740, -4618,
4892, 4080,
-1321, 952,
1083, -3366,
-2211, 3833,
-7764, 4267,
8252, -3680,
7266, 2883,
-8102, 3235,
5863, 4344,
1775, 12107,
-10945, -4300,
2638, -4747,
-2402, 6158,
-8434, 490,
-1724, 5394,
2622, 616,
6696, -952,
-4064, -1252,
-5484, -6319,
217, 4619,
509, 1300,
3336, -1338,
-6292, -3279,
-5093, -10814,
4511, -3907,
-2179, -9431,
77, -2416,
322, 10560,
-5371, 1766,
-2243, 3664,
-3339, 3398,
2530, 10266,
9307, 2926,
-5669, -12483,
-8352, 2610,
3809, 3397,
-3381, 1504,
-3267, 1151,
2638, -9009,
-2368, 4042,
6966, 1090,
6790, -2459,
4471, 11153,
8704, 2437,
-3803, -4585,
-3064, -2571,
4204, -6711,
-5741, -2527,
-10443, 5983,
-5536, 600,
-5826, -13038,
-7755, -4134,
8100, 9949,
12831, 9405,
-3758, 1146,
7480, -6568,
12362, -6983,
-5521, -5744,
-3547, 7112,
-2506, 1272,
-2721, 71,
-5746, -2502,
-10987, -8889,
-12693, -4564,
-6815, -4067,
1376, -329,
-5402, 157,
-458, 11147,
10553, 8870,
3014, -7164,
1433, 1191,
-2647, 164,
-3659, 6992,
-770, 16093,
-5136, 1679,
1588, -3196,
4275, -9132,
4943, -2383,
5976, 4244,
3175, -6353,
8508, 1497,
3525, -5266,
925, -8597,
1504, 4415,
-1647, -2973,
3782, -3575,
-3578, -2482,
-886, 403,
3712, 1797,
-3090, -655,
6940, 9081,
3210, -517,
1110, -2688,
11197, 14694,
-4225, 4290,
-6352, -4654,
3051, 5143,
8287, 6732,
12647, 1688,
-2968, -3989,
-8727, 1472,
2750, 10457,
-3977, 3262,
-4260, -6192,
4453, 2043,
-2846, 3683,
5065, -1791,
4325, 5611,
-13220, -2647,
-5278, -9675,
-6170, -1527,
-7325, -2604,
5584, -6014,
1162, 282,
7826, -5904,
6533, -11174,
-9808, 9098,
339, 6940,
2104, -9835,
233, 4410,
3340, -5107,
-3179, -9888,
-3495, 7313,
-1931, 984,
-2684, -574,
-5762, -2303,
-10397, -8676,
-11862, -4931,
-6763, -3695,
1644, -861,
-5039, 303,
-53, 11130,
10522, 8367,
3271, -6970,
1510, 643,
-2715, 358,
-3274, 7107,
-166, 8900,
5649, 3353,
4858, 1701,
10130, 7238,
10262, 7051,
10143, 1626,
2164, 2301,
30, 2418,
6833, 655,
-1508, -3627,
-3296, 144,
-4236, 10061,
-613, -4671,
4557, -12381,
-6171, -3342,
-3717, -4934,
-1694, 1702,
-6659, 7743,
2971, -2280,
7609, 2622,
-168, 7032,
-6273, 2654,
-2941, 1798,
-2384, 3942,
-9569, -1790,
-4765, -1966,
-18, 3073,
-1473, -7647,
1200, -7042,
-6544, 4921,
-5120, -5386,
-4873, -12264,
-3497, -6882,
11322, -4330,
-51, 7716,
-7767, 12992,
8188, -4238,
-221, -10623,
-5094, 276,
6743, 2284,
6359, 713,
7407, 5568,
-139, 4801,
-6715, -6139,
3168, -9183,
1082, 3601,
-2115, 3343,
-1249, -1288,
4074, 3580,
7872, -4023,
-3407, 1043,
-5078, 9071,
-5542, -1586,
-8222, -5647,
2129, -8473,
1159, 988,
4276, 8016,
5276, -10072,
-1393, -3653,
8158, 6584,
-5736, -4875,
-13320, 1664,
549, 5743,
-3390, -2366,
-307, 2731,
6135, 4228,
6178, 1931,
10365, 6944,
9558, 5766,
10253, 910,
1836, 2476,
248, 1811,
6589, -269,
-1733, -4081,
-3637, 1038,
-3957, 9522,
-1143, -4115,
4419, -12431,
-5662, -3636,
-3932, -5554,
-3622, 4775,
-900, 3069,
8388, 1570,
-3398, 6245,
3833, -3082,
5388, 485,
-2392, 3720,
4011, 1069,
9404, 1309,
-1704, 2592,
-9399, 4990,
-3696, 395,
-32, 10399,
231, 6464,
-1378, -7929,
8955, 1641,
14996, -3400,
-4588, -4356,
-4884, 1955,
10162, -5703,
6569, 828,
-4727, 2133,
-7810, -4768,
-639, 2534,
-1272, 5673,
-1704, -5515,
52, -7153,
-2815, 5597,
4361, 7606,
1550, 5219,
-11798, 4789,
-7725, 5681,
3213, 3713,
7866, -2597,
5568, -3112,
-6826, -14356,
-6821, -13301,
4197, 6760,
1626, -3161,
2222, -9531,
5371, -108,
-6978, -8763,
892, -6257,
9815, 5420,
2507, 5029,
9202, 3360,
-952, 113,
-9710, -6537,
1198, -6602,
-3195, -2794,
-2209, -7054,
4300, 7336,
8133, 7214,
6159, -4393,
-3837, 8172,
-2837, 1123,
-6928, -6494,
-3652, -7160,
2468, -11749,
-7587, 8156,
-5117, 8583,
-9157, -1313,
-4714, -517,
7426, -1311,
-6797, 7666,
-644, 2672,
8118, 1460,
-3114, 6070,
4320, -2841,
4928, 297,
-2817, 3516,
4493, 1198,
9307, 1009,
-1423, 2783,
-9362, 5132,
-4249, 327,
698, 9722,
1064, 6974,
-1816, -7791,
8562, 1396,
13860, -2008,
2395, 4252,
-2790, 8212,
-966, -4694,
-2198, -4189,
-2470, 3187,
4937, -249,
2297, 7342,
-8928, 5553,
3297, 2410,
12654, 6353,
-4488, -4103,
-5027, 4228,
1165, -2082,
1671, -12872,
12103, 7222,
2007, -1145,
-6377, -6917,
-218, 5175,
-14432, -3733,
-10146, 1788,
1703, 6320,
-2912, -971,
-838, -417,
-4088, 1469,
-1715, 2083,
7330, 544,
-242, 3296,
-2788, 1458,
486, 802,
3850, 7644,
6658, 777,
7711, -3346,
4091, 3015,
1457, 4103,
5571, -392,
-2858, -6977,
-1281, -2658,
4382, -3431,
-8192, -4005,
-4128, -2024,
2372, -5676,
-2718, 1795,
2275, 4875,
7678, 792,
3418, 1061,
-6951, -279,
-6228, -1712,
-756, -4907,
-8421, -3112,
-4402, -2090,
-8242, -1990,
-5212, 3656,
7356, -6794,
542, -8433,
-702, -2560,
3335, -11074,
-1717, 2560,
-5129, 15437,
-5290, 2264,
12069, -6530,
9553, -3811,
-9185, -1779,
2774, 1074,
13122, -1009,
2248, 4136,
-2269, 8132,
-1183, -4640,
-1836, -3795,
-2616, 2505,
5314, -194,
2418, 7555,
-8739, 5094,
3727, 2999,
12726, 5558,
-4358, -3936,
-4426, 4225,
895, -2243,
959, -12854,
12114, 7431,
658, -311,
301, 2017,
-476, -1773,
49, -5312,
1889, -5767,
-1967, 3005,
4283, -2157,
2380, 1581,
-12725, 6605,
-3640, 2234,
5207, 8089,
1068, -1842,
7275, -8282,
15038, 5899,
5840, 11725,
-6954, 6782,
837, 7782,
9003, 7101,
-2121, -3196,
1107, 971,
8061, 5241,
2650, 849,
-5307, 920,
-7546, -9967,
-3444, -9094,
-6330, 1840,
570, 498,
3208, -731,
-7697, -264,
7067, 10703,
13026, 8451,
-5366, -7904,
-10765, 672,
-11974, 4315,
-3909, 2037,
-4481, 4273,
-6753, -539,
4573, -5939,
1378, -6150,
1817, -23,
5378, -818,
3131, -1219,
5588, -1076,
2555, -9772,
-1453, -7418,
-4242, -1370,
-1049, -5806,
3304, -820,
-111, 5070,
4257, 972,
-2421, 4032,
-3038, 6493,
11244, -6158,
5251, -6076,
-454, -691,
-2810, -2802,
-6233, 5858,
2583, -6791,
-2444, -9112,
-4856, 8657,
2994, -3480,
-8397, -1052,
-7425, 5366,
3490, -7172,
-436, 29,
262, 2388,
-749, -993,
-810, -5047,
2041, -5431,
-2264, 2246,
4291, -2743,
2333, 1862,
-12441, 6023,
-3586, 2919,
5203, 7545,
739, -1756,
7738, -8726,
14832, 5666,
5645, 11219,
-7456, 7058,
712, 2048,
18423, 1771,
2043, 7806,
1619, -525,
2482, 7285,
-7381, 3870,
4, 2319,
-1153, 2292,
-5009, -4798,
-656, 4006,
-2262, 3851,
1375, 2436,
-3988, 4391,
-5091, -192,
7548, -623,
829, -5776,
2052, -3596,
15299, -413,
5487, 2316,
-8013, -3011,
-5400, -6467,
-1150, 12278,
-83, 1394,
-52, -11824,
-1494, 7234,
231, 7440,
-954, 1136,
-5800, -2310,
-7671, -7507,
-7638, -9610,
1480, -8370,
-1694, -3069,
-14918, -9333,
610, -5370,
10926, 3515,
1591, 3098,
-788, 33,
-10295, -6976,
-7879, 4379,
3781, 11049,
-4072, -2438,
4103, -8261,
7411, -2367,
-3630, 7142,
-1444, -3680,
-895, -6323,
-730, 2580,
180, -4299,
-3286, -1252,
-6235, -335,
-8536, 1125,
55, 3252,
5861, -1947,
5460, 5797,
8413, 4480,
4370, 1758,
379, -1071,
-3639, 451,
-788, 12897,
10658, -5954,
3271, -5986,
2436, 7842,
10202, -2945,
-7114, -780,
1313, -3118,
18911, 1924,
1785, 7851,
884, -697,
2819, 7439,
-7681, 3814,
943, 1639,
-1368, 2952,
-5314, -4493,
-623, 4127,
-1225, 4263,
1591, 2707,
-4351, 4378,
-5566, -141,
7325, -792,
981, -5851,
-334, -588,
-1379, 159,
8945, 5433,
6222, 68,
3751, 2771,
-3161, 2672,
-5998, -18048,
-1637, -10005,
-2130, 940,
6055, -10223,
-1804, -3765,
-3081, -4237,
16039, -6883,
6818, 6828,
-7557, 3943,
-2159, 1041,
11052, -326,
1629, -9147,
-15184, -10566,
-2565, 1812,
-1169, 10071,
-1782, 3543,
8304, -2684,
4430, -6822,
862, 1452,
-5407, 11017,
-3299, 1191,
153, -5025,
-7996, -3691,
5102, 1401,
7803, 2108,
-6677, -2256,
670, -400,
1174, -6131,
-9062, 3977,
2431, 9171,
11041, -4928,
5664, 3259,
7010, 1362,
-2472, -5534,
-11107, -4329,
-750, -4857,
-2952, 3356,
-2929, -4240,
840, 2824,
-2726, 10541,
399, -7441,
-2221, 4300,
1120, 4875,
7162, -6261,
-2178, 1728,
-2535, -4649,
-707, -554,
-4581, 3217,
-7170, -772,
-12, 5034,
8746, 1320,
3333, 589,
996, 1462,
-5222, 1103,
-5543, 10760,
3487, 7941,
-425, 1715,
-864, 5614,
-3629, 2272,
-1965, 419,
8413, 4882,
6257, -180,
4603, 2821,
-2830, 3285,
-5125, -17872,
-1841, -10471,
-1659, 1504,
6979, -10112,
-1721, -3354,
-3449, -4505,
16279, -7140,
7180, 6787,
-8013, 4883,
-1504, 103,
9757, 1472,
3090, 4210,
-7856, 4027,
3256, 3044,
1888, 420,
-730, -1451,
-6730, 528,
-9397, 6126,
6135, 1489,
5876, -3996,
1145, -3196,
8684, -2905,
6311, 314,
-1539, -3417,
-3688, -10432,
452, -494,
2323, 8033,
-8259, 5070,
-2217, -2129,
11542, -4768,
6272, -3165,
3971, 1007,
4953, 2501,
3162, -2621,
3162, 1203,
-5320, 4645,
-6626, -1951,
-5094, -2649,
-7214, -2182,
11863, -2241,
13383, -4583,
-1631, -3598,
7069, 3162,
5684, -3919,
1195, -118,
4216, 7030,
-4511, -3766,
-4038, -235,
-1261, 8886,
-4045, 4636,
-5873, 1461,
-6242, 7460,
-3747, 1912,
-8223, -9598,
-11376, 2797,
897, 8004,
7553, -5814,
172, 2360,
-2206, 6114,
-3261, -3549,
-7601, -745,
-4427, -4497,
-3105, -8851,
-856, 3176,
-2364, 2779,
-5303, -6934,
957, -1843,
-4044, -2556,
-2359, -4131,
11565, 11040,
3157, 6930,
3497, -7029,
5567, -5760,
-5039, 759,
7768, 3899,
3332, 4454,
-7789, 3572,
3894, 3168,
2125, 154,
-520, -2105,
-6718, 356,
-9536, 5759,
5837, 790,
5517, -3839,
2145, -2843,
8109, -3174,
6073, -821,
-1622, -3575,
-4381, -10147,
258, -1123,
-2247, 3619,
1723, 4893,
4298, 4407,
-6338, 8995,
-2087, 5981,
-2956, -1902,
1631, -1876,
5661, 1330,
3652, 3600,
2679, -2728,
-2202, -6948,
3896, -7082,
-2445, -8761,
-985, -551,
6049, -30,
-12456, -2386,
-838, 7938,
13021, 12679,
-2791, 10728,
-9447, -1735,
-12715, -11468,
-5515, -547,
3329, 6085,
2217, 5594,
5541, 5545,
2923, 296,
-1886, 2306,
2686, 3118,
7152, -2188,
-992, -1184,
-283, 7461,
5617, 8196,
-3271, 1709,
-1438, 2361,
-28, -5261,
-720, -10227,
-553, 3263,
-8203, 5720,
-630, 871,
854, 6297,
-3295, 877,
4226, -8128,
-3207, -3316,
2492, -2239,
9582, -9239,
-1937, -5795,
-3014, -153,
-4884, -4379,
-6730, -5583,
-2134, -1374,
-285, -5362,
5167, -1131,
6950, -804,
-6103, -14672,
-1843, 1832,
11527, 10605,
-2551, -10242,
-1917, -5013,
5654, 7224,
-11046, -1272,
-678, -7191,
7923, -189,
3268, 9925,
3521, 2265,
-6920, -1833,
2363, 5153,
4631, 4991,
-5756, 8990,
-1304, 6733,
-2712, -2442,
1989, -1933,
5484, 444,
3475, 3693,
3005, -3157,
-1926, -7475,
3781, -7282,
-2010, -8194,
-1211, -572,
6140, -175,
-12316, -2291,
924, 7774,
4043, -3212,
4018, -3453,
-1585, 9158,
1317, 6678,
898, 5933,
-6797, 1550,
-2798, -5677,
693, -8118,
1487, -1410,
301, -1210,
-6905, -3734,
-118, 3901,
5614, -3608,
-1885, -4900,
2148, -716,
59, -2950,
777, 10357,
12492, 8076,
1183, 2470,
-8001, -1725,
-2711, -11597,
-3550, 489,
1017, 11384,
4895, 1948,
5197, -553,
1069, 7572,
-1039, 7024,
4123, 1391,
-1793, -521,
-4043, -4873,
-6015, -1043,
-11375, 762,
2518, 4788,
9163, 5723,
574, -5985,
-6470, 8565,
-8628, 10729,
-1803, -6991,
-1007, 2683,
413, -425,
2568, -8940,
2377, -3370,
5950, 3853,
1336, 2951,
-3203, -4080,
-877, 4884,
9313, -2293,
4462, -4013,
-12072, 6317,
-1440, -7665,
6989, 1634,
-6888, 21,
2547, -11938,
6932, 316,
-6713, -9010,
-10781, -8677,
-6644, -65,
1274, 7211,
2842, 11654,
1274, -8135,
5795, -7189,
5446, -4136,
3256, -5687,
2059, 8751,
3657, -2817,
3516, -3821,
-1388, 9074,
835, 5964,
410, 5573,
-7029, 1579,
-2477, -6506,
937, -9004,
1725, -627,
421, -532,
-7305, -3410,
-75, 4401,
6394, -4271,
-1567, -4207,
1479, -552,
79, -1838,
369, -85,
70, 136,
25, -269,
-103, -199,
-120, -161,
329, -46,
-165, -202,
-15, 186,
-321, 29,
188, 429,
77, -235,
137, 301,
-8, 168,
-231, 200,
-27, -28,
-399, -26,
-105, -415,
717, 365,
520, -59,
270, 123,
136, 232,
257, -78,
121, 51,
290, -135,
375, 364,
-317, -283,
-59, 405,
-8, 324,
-173, 459,
-309, 89,
395, 450,
208, -19,
-283, -49,
-327, -132,
133, 141,
-214, -129,
-373, -18,
-77, -79,
-263, -66,
264, -661,
717, -73,
-529, -531,
260, 100,
131, 230,
-262, -217,
299, 215,
-276, 133,
-585, 4,
-349, 546,
180, 240,
128, -10,
312, 218,
153, 202,
392, 524,
-623, -432,
-95, 227,
-113, 63,
-18, -281,
332, -516,
-210, -277,
78, -30,
-594, 127,
-285, 209,
292, -99,
-542, -72,
440, 210,
-150, 258,
164, 374,
-366, -590,
235, -375,
0, 89,
390, 327,
-170, -278,
-229, -90,
-235, -142,
614, -21,
-103, -141,
-500, 235,
295, -482,
8, 628,
-111, -424,
161, 314,
276, 360,
-198, -52,
34, 56,
-97, -140,
-180, 244,
148, 100,
224, 72,
-426, 267,
345, -26,
46, 374,
-73, -7,
-494, 216,
-80, 24,
-22, 160,
32, 56,
-136, 183,
288, -130,
487, 373,
387, -105,
-72, 114,
104, -353,
126, 429,
-193, 263,
-4, -93,
-183, -276,
21, -117,
501, 119,
-58, 133,
-227, 210,
428, -171,
271, 13,
-163, -52,
-229, -191,
439, 260,
10, 112,
58, -106,
109, -124,
-196, -9,
339, -216,
732, -278,
-773, -22,
62, -123,
294, -91,
-247, 139,
28, 545,
53, -254,
-186, 582,
220, 42,
378, -210,
69, 202,
115, 122,
-170, -168,
348, 39,
-28, -446,
137, -796,
365, 95,
-92, -337,
-60, 197,
28, 187,
-69, 317,
-394, 201,
150, 240,
-448, -86,
-95, 697,
-438, 83,
405, 124,
27, 410,
149, -324,
-82, 942,
493, -378,
-126, 444,
358, 415,
358, -208,
-163, -613,
133, -284,
39, 50,
658, 144,
-309, 98,
-493, -146,
97, -18,
-301, 556,
-183, 134,
103, -66,
-404, 6,
333, 298,
131, -99,
442, 260,
-97, -250,
284, -221,
-348, -249,
75, -565,
349, 444,
-202, 385,
27, -213,
508, 164,
-244, 421,
-345, -266,
290, -304,
-7, -129,
-342, 304,
-278, 89,
108, -50,
76, 342,
-109, -341,
71, -326,
175, 6,
-227, 116,
-99, 98,
-226, -293,
417, -127,
-398, -79,
502, 59,
-177, 47,
-1, 68,
298, -232,
229, 175,
-106, 326,
276, -62,
};
|
manub686/axwifi | wifirx54mc/trace.c | <filename>wifirx54mc/trace.c
/**
Atomix project, trace.c, TODO: insert summary here
Copyright (c) 2015 Stanford University
Released under the Apache License v2.0. See the LICENSE file for details.
Author(s): <NAME>
*/
#include <osl/inc/swpform.h>
Int16 trace_skip_0_ns_780[] = {
340, 480,
-99, -550,
61, 143,
-345, 772,
350, 276,
-519, -944,
-662, 570,
414, -306,
-301, -25,
889, 534,
282, 130,
-188, -142,
109, -116,
107, 489,
841, -345,
-241, -109,
310, 607,
-760, 165,
69, -258,
857, 398,
760, 230,
159, 62,
242, -708,
192, -819,
238, 10,
262, -727,
458, 229,
-150, 193,
599, 378,
319, 33,
302, 535,
157, 514,
249, 47,
-103, -61,
162, -190,
-67, 859,
-64, -2,
-135, -21,
232, 458,
-436, 230,
-337, 727,
-105, -486,
-630, -743,
-379, 232,
-135, -385,
-15, -190,
221, 576,
-233, -272,
-149, 328,
49, -259,
-771, -555,
-284, -511,
-624, -117,
179, -223,
-956, 442,
33, 10,
-4, 1017,
-417, -284,
-205, 481,
-463, -242,
726, 435,
578, 474,
110, -105,
62, 77,
220, -127,
-705, -104,
-157, -273,
-285, -141,
-316, 906,
559, 721,
-505, 413,
-123, 134,
100, 587,
283, -169,
-633, -676,
479, 303,
715, -72,
-462, -648,
-325, -131,
-90, -572,
-894, 596,
407, -332,
-424, 49,
131, -345,
392, -154,
193, 65,
298, -444,
470, 224,
170, 131,
86, 410,
-182, -670,
-61, -1086,
-372, 73,
-320, 90,
-320, -153,
69, 353,
4, 107,
-182, -261,
-816, 532,
-306, -333,
-560, 304,
309, 319,
-538, 175,
-403, 236,
-109, 130,
237, -442,
-47, -653,
-167, 292,
139, 506,
-258, 593,
-501, -405,
71, -509,
-344, -30,
225, 338,
126, -299,
378, -124,
398, 110,
862, -83,
168, 96,
-43, 439,
365, -756,
868, 310,
638, -711,
-120, -287,
412, 230,
-86, -655,
-762, 325,
-89, -21,
120, 379,
-493, 188,
387, -827,
-88, -469,
-9, -279,
304, 590,
485, 394,
-608, 220,
690, 55,
-91, 143,
46, 758,
54, -566,
-117, -107,
-143, -326,
131, 53,
252, 610,
-271, 191,
-431, -38,
-318, -210,
-176, -120,
318, -406,
-425, -613,
-189, -280,
315, -220,
323, 357,
-633, -428,
-581, -3,
198, -651,
-319, -108,
-565, 452,
-541, -452,
106, -432,
-288, 469,
-427, -164,
-163, 404,
419, -56,
671, 1096,
181, 341,
-42, -61,
-334, 283,
-728, -105,
-921, -265,
279, 416,
44, -55,
44, 816,
984, -12,
-121, -835,
-357, -172,
635, 191,
-243, -154,
-401, -555,
478, 9,
224, 341,
79, -65,
-108, -105,
224, 224,
379, -12,
-530, 84,
35, -584,
-432, 260,
-297, 19,
232, 294,
-322, -173,
847, 243,
-1, -212,
696, -12,
240, -667,
89, 259,
-349, -291,
-106, -134,
-243, -348,
1527, 1319,
-9885, -608,
-1196, -6097,
9731, -1263,
6380, -207,
10190, -1521,
-461, -5484,
-9537, 72,
3309, 2908,
475, -9551,
-5238, -447,
-940, 9553,
730, 6699,
-867, 9960,
-5037, -292,
-125, -9468,
3533, 3233,
-8667, 232,
-1034, -6397,
10433, -795,
6975, 711,
9454, -763,
-806, -5397,
-8645, 782,
3078, 3592,
443, -9890,
-4990, -636,
-811, 9292,
-40, 7132,
-573, 9893,
-5681, -1085,
75, -8895,
3117, 2715,
-9188, -12,
-856, -5271,
10399, -813,
5617, 28,
9784, -614,
-1254, -5910,
-9066, 138,
2832, 3143,
-70, -9452,
-5532, -671,
-712, 9640,
215, 6685,
-1070, 9814,
-5144, 215,
183, -9407,
3833, 3490,
-8973, 337,
-676, -4796,
9784, -245,
7545, -352,
9764, -823,
-273, -4672,
-8710, 268,
2879, 2593,
487, -9169,
-4856, -169,
-1312, 9835,
198, 5635,
-965, 10313,
-5657, -964,
-453, -8948,
3220, 2465,
-9046, -86,
-1371, -5789,
9756, -1042,
6515, -584,
9630, -1624,
-1121, -5840,
-9578, 999,
3132, 3247,
-155, -9286,
-5223, -293,
-218, 10218,
216, 7233,
-926, 9660,
-5032, -809,
-232, -9218,
2744, 3529,
-9137, 57,
-1764, -5210,
10249, -908,
6418, 362,
9922, -1279,
-956, -5698,
-8370, 129,
2577, 3037,
241, -9117,
-5606, -1127,
-612, 9993,
-37, 6801,
-1135, 9909,
-5306, -1160,
256, -9415,
3771, 3212,
-9281, 149,
-216, -5733,
9751, -1387,
6503, 317,
9135, -848,
-706, -5470,
-8640, -92,
2913, 2938,
211, -8969,
-4259, -1205,
-1149, 10649,
-279, 6500,
-1744, 10458,
-4998, -934,
-758, -9038,
3696, 2567,
-8953, 362,
-751, -6202,
10435, -696,
5773, 16,
9481, -994,
-1480, -5619,
-9144, -12,
2959, 2967,
-666, -9291,
-5170, -1268,
-1116, 9533,
205, 6880,
-1232, 8855,
-5397, -841,
843, -9194,
3134, 3324,
-9473, 666,
-1120, -5281,
9890, -1480,
6542, -137,
9937, -1020,
-1280, -5532,
-9349, 583,
3828, 3484,
680, -9284,
-5819, -1176,
-929, 10229,
305, 6598,
-721, 10545,
-5306, -694,
-533, -9520,
3689, 3611,
-9488, 196,
-1201, -5562,
10206, 16,
6634, -492,
10098, -293,
-295, -5326,
-9649, 169,
2677, 2982,
416, -8963,
-5207, -1298,
-968, 9847,
182, 6536,
-1228, 10112,
-5279, -1012,
108, -9355,
-3292, 1199,
704, -7030,
6101, -7231,
-6034, -7626,
-72, -3765,
4937, 4915,
-8484, 1772,
-8774, 1184,
-2350, 10481,
-4009, 1501,
-4583, -5876,
5280, -610,
6145, -6508,
-9405, -4059,
-4239, -2720,
2612, -6474,
4521, 4284,
7899, -331,
-1894, -11336,
3947, 154,
1670, 4489,
-9688, 3808,
140, 7487,
4088, -409,
7323, 1832,
-3001, 7213,
-8239, 4588,
4631, 6031,
1587, -1650,
6533, -6185,
2677, 7916,
336, 8393,
10378, 383,
-946, -8087,
2937, -7200,
6756, 5589,
2078, 2217,
4152, -6375,
-7867, -4106,
-2747, -7451,
6950, -1414,
3389, 856,
-17, -8357,
-10581, -3226,
1822, -4391,
3967, -352,
-1625, 10905,
8032, -543,
4668, -3538,
2097, 7202,
-3658, 3735,
-9029, 5081,
5946, 6704,
5069, 818,
-4704, 5073,
-4451, -1738,
-2469, -10832,
-8685, -693,
-9251, -2026,
5620, -5882,
-513, 3370,
-6274, 6977,
5608, 7304,
816, 6886,
-10343, -274,
692, -6831,
7073, -7275,
-6409, -7557,
-210, -3449,
5759, 5449,
-8487, 1321,
-8153, 1241,
-2399, 10256,
-3482, 1287,
-4066, -6052,
5157, -1209,
5757, -6469,
-8567, -4741,
-4128, -3633,
2544, -6648,
4018, 4222,
8298, 1030,
-1088, -10405,
4169, 1827,
1621, 3683,
-8770, 3008,
-176, 8027,
3467, 968,
6814, 2038,
-2086, 7423,
-8261, 4012,
3942, 6076,
1147, -1519,
7009, -5754,
3130, 7652,
214, 8315,
11026, 385,
-399, -8428,
2102, -7801,
7473, 6143,
2131, 1868,
4750, -5790,
-7537, -3514,
-2832, -7300,
7400, -1780,
3363, 268,
434, -8216,
-9429, -2717,
1916, -3701,
3922, -1022,
-1616, 11929,
8898, 272,
3536, -4444,
2351, 6222,
-4362, 2432,
-9093, 4011,
5644, 6208,
4591, 1150,
-4869, 5473,
-3998, -1765,
-2630, -10399,
-8632, -667,
-9687, -1389,
6141, -5527,
-303, 4551,
-6073, 6935,
5424, 7331,
978, 6943,
-10791, -364,
679, -6862,
5619, -6599,
-6381, -8876,
550, -3989,
5347, 4883,
-9347, 1785,
-9213, 1759,
-2676, 11161,
-3282, 1057,
-4498, -5622,
4714, -852,
5665, -6749,
-8867, -4624,
-4157, -3077,
3088, -6549,
4271, 3860,
8372, 524,
-2176, -11401,
4012, 789,
1807, 4376,
-9500, 3337,
446, 8013,
4066, -312,
7597, 2019,
-2648, 7273,
-8006, 4157,
4098, 5785,
1761, -2512,
6632, -4858,
2580, 7735,
-362, 9288,
4645, 951,
5852, 2638,
3382, -2107,
992, 1406,
6074, -2512,
7047, -3097,
5020, -1722,
8411, -3132,
-659, -5109,
579, -2605,
2681, 510,
-3555, -4336,
-4465, 1212,
-12380, -1875,
5181, -1015,
2759, 13742,
-19125, -537,
3368, -14783,
4251, 1403,
-12416, 974,
-4393, -539,
-3483, 3828,
1641, -1093,
113, 2388,
-964, 4460,
7742, 2709,
5474, 1881,
6158, 2386,
6107, 2852,
711, -1127,
3268, 1735,
5305, -2367,
-2050, -2142,
-4718, 11612,
-1050, 3717,
-8224, 1116,
1801, 8805,
13282, -2934,
-2596, -4326,
-8117, 3186,
-7440, 5537,
727, 1946,
9070, -6483,
3497, -1878,
6754, 5750,
352, 3595,
-6234, 3716,
-5177, -652,
-11135, 315,
-5171, 152,
-4931, -4275,
-19, -4026,
6890, -5158,
3284, 1103,
9551, 6623,
2057, -2162,
-7585, -4755,
-8087, -2834,
-2582, 4569,
13102, 2012,
313, -8564,
-8534, -1508,
-339, -3908,
-5030, -11044,
-1473, 2893,
5982, 2804,
3212, -1430,
88, 1751,
6259, -3122,
6058, -2605,
5709, -1799,
6880, -3034,
-994, -4956,
123, -2272,
2683, 818,
-3260, -3497,
-5412, 954,
-11907, -664,
4618, -1595,
2762, 14066,
-12009, -924,
2523, -5431,
-10441, 1006,
-6972, 9011,
-3464, 1356,
-2485, -3120,
90, -4454,
-2711, -896,
397, 3926,
-558, 2717,
-3256, 1511,
-11107, -4381,
-12183, -5705,
-631, 4243,
-119, 4893,
-796, 4639,
2040, -2699,
7262, -9764,
1215, 9014,
-1314, 111,
7201, -18191,
-1214, 1464,
1463, 374,
11165, -6892,
3461, 5226,
802, 8481,
-3611, 6827,
-5404, 4121,
243, -1490,
2396, 3766,
8163, 5624,
5459, -1881,
-4847, -5117,
-1444, 6162,
10228, 7347,
6662, -2300,
4483, 7798,
5570, 5911,
-6442, -9084,
1440, -2529,
-975, 7582,
-16717, 5596,
1532, 300,
6546, -2378,
2884, -520,
-242, -14,
-1585, 3044,
7743, 8987,
1302, 3010,
-4235, 1482,
-4268, 2619,
-1294, -12544,
5917, -12288,
-2334, 294,
3009, -2370,
-3520, -8574,
-9225, -5489,
3276, 5151,
-4381, 746,
5667, -9239,
11714, 394,
96, 5147,
5664, -7996,
-5529, -6890,
-4314, -830,
2326, -6204,
-10271, -426,
-6692, 9334,
-3293, 702,
-1690, -3742,
-241, -3403,
-3481, -206,
720, 3876,
15, 2332,
-3456, 1918,
-11122, -4466,
-11094, -6495,
-1518, 4598,
-154, 5130,
-1770, 4238,
1208, -1303,
-295, 714,
322, -1186,
-553, 107,
697, 125,
-129, -371,
158, 560,
-32, -593,
377, 371,
473, 281,
-636, -372,
198, 374,
-42, -10,
-272, -738,
348, -514,
-492, -220,
806, -737,
62, -575,
242, -35,
-220, -34,
-140, -115,
187, 585,
342, 68,
-217, 442,
319, -146,
249, -517,
158, 42,
263, -855,
-130, -1035,
-479, -420,
562, 90,
-507, 298,
-745, 161,
680, 383,
643, -314,
-70, -128,
103, -52,
-180, 113,
134, -345,
158, 142,
-917, 83,
-901, -331,
95, -217,
-506, 756,
-85, -131,
245, -98,
339, 28,
-45, 149,
-353, -206,
-48, 160,
-348, 266,
-613, 370,
-190, 506,
293, -129,
-216, -397,
-91, -348,
-33, -181,
-460, 359,
856, 226,
-232, 924,
-298, -13,
249, -762,
97, -565,
-283, -626,
737, -562,
-296, -209,
-131, -585,
433, -764,
-105, 33,
-45, 273,
211, 196,
-196, -281,
236, 3,
284, 747,
439, 261,
827, -37,
376, 256,
-211, -103,
670, -9,
-665, 381,
315, 148,
-64, 17,
152, -306,
-394, -240,
-142, -77,
199, -269,
1189, -680,
-602, -138,
317, 1034,
140, 343,
-150, -184,
-341, -140,
544, -713,
545, 380,
380, 149,
210, 346,
196, 778,
-544, 142,
-202, -205,
-256, 318,
-495, -895,
};
|
manub686/axwifi | wifi54/configurator.c | /**
Atomix project, configurator.c, TODO: insert summary here
Copyright (c) 2015 Stanford University
Released under the Apache License v2.0. See the LICENSE file for details.
Author(s): <NAME>
*/
#include <stdio.h>
#include <arpa/inet.h>
int main() {
unsigned int ns = 400000;
unsigned int f_ns = htonl(ns);
FILE *f = fopen("orsys.conf", "wb");
printf("ns =%08x\n", ns);
printf("f_ns=%08x\n", f_ns);
fwrite(&f_ns, 4, 1, f);
fclose(f);
return 0;
}
|
manub686/axwifi | wifirx6m/setup.c | /**
Atomix project, setup.c, TODO: insert summary here
Copyright (c) 2015 Stanford University
Released under the Apache License v2.0. See the LICENSE file for details.
Author(s): <NAME>
*/
void app_wifirx6m_setup() {
WIFILIB_genDerotTable();
WIFILIB_genTwiddleFactors();
vitdec_profile_init();
}
void app_wifirx6m_setup_once() {
vcp2_initOnce();
vcp2_initPerUse(0,0,0,0);
}
|
imefGames/Poplin | Poplin/include/poplin/core/serialization/serializer.h | <reponame>imefGames/Poplin
#pragma once
#include <poplin/core/reflection/typeinfo.h>
#include <json.hpp>
namespace Poplin
{
namespace Serializer
{
void LoadObject(void* objectPtr, const TypeInfo& type, const nlohmann::json& data);
}
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/systems/logiccomponentupdatersystem.h | #pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/system.h>
namespace Poplin
{
class LogicComponent;
class LogicComponentUpdatersSystem : public System
{
public:
LogicComponentUpdatersSystem(SystemUpdater& updater);
private:
void UpdateLogicComponent(f32 deltaTime, LogicComponent& logicComponent);
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/system.h | #pragma once
namespace Poplin
{
class SystemUpdater;
class System
{
public:
System(SystemUpdater& updater);
virtual ~System();
private:
SystemUpdater& m_Updater;
};
} |
imefGames/Poplin | Poplin/include/poplin/graphics/ecs/components/cameracomponent.h | <filename>Poplin/include/poplin/graphics/ecs/components/cameracomponent.h
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/componentdescriptor.h>
#include <glm/glm.hpp>
#include <imgui/imgui.h>
namespace Poplin
{
class Texture;
class CameraComponent
{
public:
CameraComponent();
glm::mat4 ComputeProjection() const;
glm::vec2 TopLeft;
glm::vec2 BottomRight;
f32 Near;
f32 Far;
};
static const PropertyInfo g_CameraComponentPropertiesInfo[]
{
{ 0, "TopLeft", 0, EPropertyType::Vector2, EPropertyVisibility::Public },
{ 1, "BottomRight", 8, EPropertyType::Vector2, EPropertyVisibility::Public },
{ 2, "Near", 16, EPropertyType::F32, EPropertyVisibility::Public },
{ 3, "Far", 20, EPropertyType::F32, EPropertyVisibility::Public }
};
static const TypeInfo g_CameraComponentTypeInfo
(
96315,
"Camera",
sizeof(CameraComponent),
g_CameraComponentPropertiesInfo,
sizeof(g_CameraComponentPropertiesInfo) / sizeof(PropertyInfo),
nullptr
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<CameraComponent>()
{
return &g_CameraComponentTypeInfo;
}
}
} |
imefGames/Poplin | Sandbox/debugtoolssystem.h | <gh_stars>0
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/system.h>
namespace Poplin
{
class PropertyInfo;
class TransformComponent;
class DebugToolsSystem : public System
{
public:
DebugToolsSystem(SystemUpdater& updater);
private:
static void EditComponentProperty(void* componentAddress, const PropertyInfo& propertyInfo);
void UpdateDebugTools(f32 deltaTime);
void DisplayAssetsWindow();
void DisplayWorldWindow();
};
} |
imefGames/Poplin | Poplin/include/poplin/graphics/assets/textureasset.h | <gh_stars>0
#pragma once
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/asset/managedasset.h>
#include <poplin/graphics/texture.h>
#include <string>
namespace Poplin
{
class TextureAsset : public ManagedAsset
{
private:
void OnAssetLoaded() override;
public:
std::string FilePath;
std::shared_ptr<Texture> Texture;
};
static const PropertyInfo g_TextureAssetPropertiesInfo[]
{
{ 0, "FilePath", offsetof(TextureAsset, FilePath), EPropertyType::String, EPropertyVisibility::Public }
};
static const TypeInfo g_TextureAssetTypeInfo
(
11111,
"Texture Asset",
sizeof(TextureAsset),
g_TextureAssetPropertiesInfo,
sizeof(g_TextureAssetPropertiesInfo) / sizeof(PropertyInfo),
Reflection::InstantiateType<TextureAsset>,
TypeInfo::Flags::IsManagedAsset
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<TextureAsset>()
{
return &g_TextureAssetTypeInfo;
}
}
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/systemupdater.h | #pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/entityregistry.h>
#include <vector>
namespace Poplin
{
class System;
class SystemUpdater
{
public:
~SystemUpdater();
void UpdateSystems(f32 deltaTime, EntityRegistry& registry) const;
template <class SystemType, class ... Components>
void RegisterSystemUpdate(SystemType* caller, void (SystemType::*updateFunction)(f32, Components&...))
{
m_Updaters.push_back(new UpdaterImpl(caller, updateFunction));
}
void UnregisterAllSystemUpdates(System* caller);
private:
class Updater
{
public:
virtual void Invoke(f32 deltaTime, EntityRegistry& registry) const = 0;
virtual const System* GetCaller() const = 0;
};
template <class SystemType, class ... Components>
class UpdaterImpl : public Updater
{
public:
UpdaterImpl(SystemType* caller, void (SystemType::*updateFunction)(f32, Components&...))
: m_Caller{ caller }
, m_UpdateFunction{ updateFunction }
{
}
void Invoke(f32 deltaTime, EntityRegistry& registry) const override
{
registry.ForEach<Components...>([deltaTime, this](Components&... components)
{
(m_Caller->*m_UpdateFunction)(deltaTime, components...);
});
}
const System* GetCaller() const override
{
return m_Caller;
}
private:
SystemType* m_Caller;
void (SystemType::*m_UpdateFunction)(f32, Components&...);
};
template <class SystemType>
class UpdaterImpl<SystemType> : public Updater
{
public:
UpdaterImpl(SystemType* caller, void (SystemType::*updateFunction)(f32))
: m_Caller{ caller }
, m_UpdateFunction{ updateFunction }
{
}
void Invoke(f32 deltaTime, EntityRegistry& registry) const override
{
(m_Caller->*m_UpdateFunction)(deltaTime);
}
const System* GetCaller() const override
{
return m_Caller;
}
private:
SystemType* m_Caller;
void (SystemType::*m_UpdateFunction)(f32);
};
std::vector<Updater*> m_Updaters;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/components/entitymetadatacomponent.h | <gh_stars>0
#pragma once
#include <string>
#include <vector>
namespace Poplin
{
class TypeInfo;
class EntityMetaDataComponent
{
public:
EntityMetaDataComponent();
std::string Name;
std::vector<const TypeInfo*> OwnedComponentTypes;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/input/input.h | <reponame>imefGames/Poplin
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/input/keycodes.hpp>
#include <poplin/engine/input/mousecodes.hpp>
#include <glm/glm.hpp>
namespace Poplin
{
namespace Input
{
bool IsKeyDown(EKeyCode key);
bool IsKeyUp(EKeyCode key);
bool IsKeyPressed(EKeyCode key);
bool IsKeyReleased(EKeyCode key);
glm::vec2 GetMousePosition();
f32 GetMouseScroll();
bool IsMouseButtonDown(EMouseCode mouseButton);
bool IsMouseButtonUp(EMouseCode mouseButton);
bool IsMouseButtonPressed(EMouseCode mouseButton);
bool IsMouseButtonReleased(EMouseCode mouseButton);
}
} |
imefGames/Poplin | Poplin/include/poplin/graphics/renderer.h | #pragma once
#include <glm/glm.hpp>
#include <poplin/core/singleton.hpp>
#include <memory>
namespace Poplin
{
class Shader;
class SpriteComponent;
class Texture;
class VertexArray;
class Renderer : public Singleton<Renderer>
{
friend class RenderSystem;
public:
Renderer();
~Renderer();
void BeginFrame();
void EndFrame();
void DrawSprite(const glm::mat4& modelTransform, const SpriteComponent& sprite);
private:
glm::mat4 m_CameraView;
glm::mat4 m_CameraProjection;
std::shared_ptr<Texture> m_MissingTexture;
std::shared_ptr<Shader> m_DefaultSpriteShader;
std::shared_ptr<VertexArray> m_DefaultSpriteModel;
};
} |
imefGames/Poplin | Sandbox/playerbehaviorcomponent.h | <filename>Sandbox/playerbehaviorcomponent.h
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/components/logiccomponent.h>
#include <poplin/engine/input/input.h>
#include <poplin/physics/ecs/components/rigidbodycomponent.h>
namespace Poplin
{
class PlayerBehaviorComponent : public LogicComponentBehavior
{
public:
void Update(f32 deltaTime) override
{
if (m_Entity.HasComponent<RigidBodyComponent>())
{
RigidBodyComponent& rigidBody{ m_Entity.GetComponent<RigidBodyComponent>() };
glm::vec2 velocity{ rigidBody.GetLinearVelocity() };
if (Input::IsKeyDown(Input::EKeyCode::ArrowLeft))
{
velocity.x = -Speed;
}
if (Input::IsKeyDown(Input::EKeyCode::ArrowRight))
{
velocity.x = Speed;
}
if (std::fabs(velocity.y) <= 0.01f && Input::IsKeyDown(Input::EKeyCode::ArrowUp))
{
velocity.y -= 5.0f;
}
rigidBody.SetLinearVelocity(velocity);
}
}
f32 Speed{ 1.0f };
};
static const PropertyInfo g_PlayerBehaviorComponentPropertiesInfo[]
{
{ 0, "Speed", offsetof(PlayerBehaviorComponent, Speed), EPropertyType::F32, EPropertyVisibility::Public },
};
static const TypeInfo g_PlayerBehaviorComponentTypeInfo
(
1369882,
"PlayerBehavior",
sizeof(PlayerBehaviorComponent),
g_PlayerBehaviorComponentPropertiesInfo,
sizeof(g_PlayerBehaviorComponentPropertiesInfo) / sizeof(PropertyInfo),
nullptr
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<PlayerBehaviorComponent>()
{
return &g_PlayerBehaviorComponentTypeInfo;
}
}
} |
imefGames/Poplin | Poplin/include/poplin/graphics/vertexarray.h | #pragma once
#include <poplin/core/types.hpp>
#include <poplin/graphics/vertexbuffer.h>
#include <memory>
#include <vector>
namespace Poplin
{
class VertexArray
{
public:
VertexArray();
~VertexArray();
inline u32 GetTriangleCount() const { return m_TriangleCount; }
inline void SetTriangleCount(u32 count){ m_TriangleCount = count; }
void AddVertexBuffer(std::shared_ptr<VertexBuffer> vertexBuffer);
void Bind();
void Unbind();
private:
std::vector<std::shared_ptr<VertexBuffer>> m_Entries;
u32 m_TriangleCount;
u32 m_ArrayID;
};
} |
imefGames/Poplin | Poplin/include/poplin/core/reflection/typeinfo.h | #pragma once
#include <poplin/core/reflection/propertyinfo.h>
#include <functional>
namespace Poplin
{
using TypeID = u64;
class TypeInfo
{
public:
using TypeCreationCallback = void* (*)();
enum class Flags : u8
{
None = 0x00,
IsManagedAsset = 0x01
};
TypeInfo(TypeID typeID, const char* typeName, u32 typeSize, const PropertyInfo* properties, u32 propertyCount, TypeCreationCallback typeCreationCallback, Flags flags = Flags::None);
inline TypeID GetTypeID() const { return m_TypeID; }
inline const char* GetTypeName() const { return m_TypeName; }
inline u32 GetTypeSize() const { return m_TypeSize; }
void* InstantiateType() const;
inline bool IsAManagedAsset() const { return (u8)m_Flags & (u8)Flags::IsManagedAsset; }
const PropertyInfo* GetProperty(PropertyID propertyID) const;
void ForEachProperty(const std::function<void(const PropertyInfo&)>& propertyVisitor) const;
private:
TypeID m_TypeID;
const char* m_TypeName; //TODO: Debug only?
const PropertyInfo* m_Properties;
TypeCreationCallback m_TypeCreationCallback;
u32 m_PropertyCount;
u32 m_TypeSize;
Flags m_Flags;
};
namespace Reflection
{
template <class T>
static const TypeInfo* GetTypeInfo()
{
return nullptr;
}
template <class T>
void* InstantiateType()
{
return new T{};
}
}
} |
imefGames/Poplin | Poplin/include/poplin/core/reflection/enuminfo.h | <gh_stars>0
#pragma once
#include <poplin/core/types.hpp>
#include <utility>
namespace Poplin
{
using EnumID = u32;
class EnumInfo
{
public:
struct EnumEntry
{
EnumEntry(u32 value, const char* name)
: Value{ value }
, Name{ name }
{
}
u32 Value;
const char* Name;
};
EnumInfo(EnumID enumID, const EnumEntry* values, u32 valueCount);
EnumID GetEnumID() const { return m_EnumID; }
u32 GetValueCount() const { return m_ValueCount; }
const EnumEntry* GetRawValues() const { return m_Values; }
template <typename T>
const char* GetValueName(T value) const
{
return GetValueNameInternal(static_cast<u32>(value));
}
private:
const char* GetValueNameInternal(u32 value) const;
const EnumEntry* m_Values;
u32 m_ValueCount;
EnumID m_EnumID;
};
namespace Enums
{
template <typename T>
static const EnumInfo* GetEnumInfo()
{
return nullptr;
}
}
} |
imefGames/Poplin | Sandbox/serializer.h | #pragma once
#include <string>
namespace Poplin
{
class Entity;
class Universe;
class World;
namespace Serializer
{
void SaveUniverse(const Universe& universe, const std::string& filePath);
void SaveWorld(const World& world);
void LoadUniverse(Universe& universe, const std::string& filePath);
void LoadWorld(World& world, const std::string& worldName);
}
} |
imefGames/Poplin | Poplin/include/poplin/physics/ecs/systems/physicssystem.h | #pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/system.h>
namespace Poplin
{
class RigidBodyComponent;
class TransformComponent;
class PhysicsSystem : public System
{
public:
PhysicsSystem(SystemUpdater& updater);
private:
void PreWorldUpdate(f32 deltaTime, TransformComponent& transform, RigidBodyComponent& rigidBody);
void UpdateWorld(f32 deltaTime);
void PostWorldUpdate(f32 deltaTime, TransformComponent& transform, RigidBodyComponent& rigidBody);
};
} |
imefGames/Poplin | Sandbox/scrollmessagecomponent.h | <gh_stars>0
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/components/logiccomponent.h>
#include <poplin/engine/input/input.h>
#include <poplin/graphics/ecs/components/spritecomponent.h>
namespace Poplin
{
class ScrollMessageComponent : public LogicComponentBehavior
{
public:
void Update(f32 deltaTime) override
{
if (m_Entity.HasComponent<SpriteComponent>())
{
SpriteComponent& sprite{ m_Entity.GetComponent<SpriteComponent>() };
sprite.UVOffset.x += Speed * deltaTime;
}
}
f32 Speed{ 0.1f };
};
static const PropertyInfo g_ScrollMessageComponentPropertiesInfo[]
{
{ 0, "Speed", offsetof(ScrollMessageComponent, Speed), EPropertyType::F32, EPropertyVisibility::Public },
};
static const TypeInfo g_ScrollMessageComponentTypeInfo
(
15623,
"ScrollMessage",
sizeof(ScrollMessageComponent),
g_ScrollMessageComponentPropertiesInfo,
sizeof(g_ScrollMessageComponentPropertiesInfo) / sizeof(PropertyInfo),
nullptr
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<ScrollMessageComponent>()
{
return &g_ScrollMessageComponentTypeInfo;
}
}
} |
imefGames/Poplin | Poplin/include/poplin/graphics/ecs/components/spritecomponent.h | <filename>Poplin/include/poplin/graphics/ecs/components/spritecomponent.h
#pragma once
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/componentdescriptor.h>
#include <glm/glm.hpp>
#include <imgui/imgui.h>
namespace Poplin
{
class TextureAsset;
class SpriteComponent
{
public:
SpriteComponent();
std::shared_ptr<TextureAsset> SpriteTexture;
glm::vec2 UVRepeat;
glm::vec2 UVOffset;
};
static const PropertyInfo g_SpriteComponentPropertiesInfo[]
{
{ 0, "SpriteTexture", 0, EPropertyType::TypeInstancePointer, EPropertyVisibility::Public, 11111, PropertyInfo::Flags::IsManagedAsset },
{ 1, "UVRepeat", sizeof(std::shared_ptr<TextureAsset>) + 0, EPropertyType::Vector2, EPropertyVisibility::Public },
{ 2, "UVOffset", sizeof(std::shared_ptr<TextureAsset>) + 8, EPropertyType::Vector2, EPropertyVisibility::Public }
};
static const TypeInfo g_SpriteComponentTypeInfo
(
1468,
"Sprite",
sizeof(SpriteComponent),
g_SpriteComponentPropertiesInfo,
sizeof(g_SpriteComponentPropertiesInfo) / sizeof(PropertyInfo),
nullptr
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<SpriteComponent>()
{
return &g_SpriteComponentTypeInfo;
}
}
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/components/transformcomponent.h | #pragma once
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/componentdescriptor.h>
#include <glm/glm.hpp>
#include <imgui/imgui.h>
namespace Poplin
{
class TransformComponent
{
public:
TransformComponent();
glm::mat4 ComputeGlobalTransform() const;
glm::vec3 Position;
glm::vec3 Rotation;
glm::vec3 Scale;
glm::vec3 Origin;
//TODO: local transform
};
static const PropertyInfo g_TransformComponentPropertiesInfo[]
{
{ 0, "Position", 0, EPropertyType::Vector3, EPropertyVisibility::Public },
{ 1, "Rotation", 12, EPropertyType::Vector3, EPropertyVisibility::Public },
{ 2, "Scale", 24, EPropertyType::Vector3, EPropertyVisibility::Public },
{ 3, "Origin", 36, EPropertyType::Vector3, EPropertyVisibility::Public }
};
static const TypeInfo g_TransformComponentTypeInfo
(
1234,
"Transform",
sizeof(TransformComponent),
g_TransformComponentPropertiesInfo,
sizeof(g_TransformComponentPropertiesInfo) / sizeof(PropertyInfo),
nullptr
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<TransformComponent>()
{
return &g_TransformComponentTypeInfo;
}
}
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/componentdescriptor.h | <reponame>imefGames/Poplin
#pragma once
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/entity.h>
#include <functional>
#include <string>
namespace Poplin
{
class Entity;
class ComponentDescriptor
{
public:
ComponentDescriptor(const std::string& name,
const std::function<const TypeInfo*()>& getComponentTypeInfo,
const std::function<bool(Entity& entity)>& hasFunction,
const std::function<void*(Entity& entity)>& getComponentAddress,
const std::function<void(Entity& entity)>& addFunction,
const std::function<void(Entity& entity)>& removeFunction);
inline const std::string& GetName() const { return m_Name; }
const TypeInfo* GetComponentTypeInfo() const;
bool EntityHasComponent(Entity& entity) const;
void* GetComponentAddress(Entity& entity) const;
void AddComponentToEntity(Entity& entity) const;
void RemoveComponentFromEntity(Entity& entity) const;
private:
std::string m_Name;
std::function<const TypeInfo* ()> m_GetComponentTypeInfo;
std::function<bool(Entity& entity)> m_HasComponent;
std::function<void* (Entity& entity)> m_GetComponentAddress;
std::function<void(Entity& entity)> m_AddComponent;
std::function<void(Entity& entity)> m_RemoveComponent;
};
namespace ComponentDescriptorUtils
{
template <class T>
static bool HasComponent(Entity& entity)
{
return entity.HasComponent<T>();
}
template <class T>
static void* GetComponentAddress(Entity& entity)
{
return &entity.GetComponent<T>();
}
template <class T>
static void AddComponent(Entity& entity)
{
entity.AddComponent<T>();
}
template <class T>
static void RemoveComponent(Entity& entity)
{
entity.RemoveComponent<T>();
}
template <class T>
ComponentDescriptor* CreateComponentDescriptor(const std::string& name)
{
return new ComponentDescriptor{ name, &Reflection::GetTypeInfo<T>, &HasComponent<T>, &GetComponentAddress<T>, &AddComponent<T>, &RemoveComponent<T> };
}
}
} |
imefGames/Poplin | Sandbox/sandboxreflectedtypes.h | #pragma once
#include <poplin/core/reflection/enuminfo.h>
#include <poplin/core/reflection/typeinfo.h>
#include <map>
namespace Poplin
{
namespace Reflection
{
void RegisterGameTypes(std::map<TypeID, const TypeInfo*>& types);
void RegisterGameEnums(std::map<EnumID, const EnumInfo*>& enums);
}
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/entityregistry.h | <gh_stars>0
#pragma once
#include <entt/entt.hpp>
#include <functional>
namespace Poplin
{
class Entity;
class EntityRegistry
{
friend class Entity;
public:
Entity CreateEntity();
void ForEachEntity(const std::function<void(Entity)>& function) const;
void ClearAllEntities();
template <class ... Components>
void ForEach(const std::function<void(Components&...)>& function)
{
entt::view<entt::exclude_t<>, Components...> view{ m_Registry.view<Components...>() };
view.each(function);
}
private:
entt::registry m_Registry;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/componentdescriptorregistry.h | #pragma once
#include <poplin/core/singleton.hpp>
#include <poplin/core/types.hpp>
#include <vector>
namespace Poplin
{
class ComponentDescriptor;
class TypeInfo;
class ComponentDescriptorRegistry : public Singleton<ComponentDescriptorRegistry>
{
public:
ComponentDescriptorRegistry();
~ComponentDescriptorRegistry();
const ComponentDescriptor* GetComponentDescriptorForType(const TypeInfo& typeInfo) const;
inline const std::vector<ComponentDescriptor*>& GetComponentDescriptors() const { return m_ComponentDescriptors; }
private:
std::vector<ComponentDescriptor*> m_ComponentDescriptors;
};
} |
imefGames/Poplin | Poplin/include/poplin/core/reflection/reflectedtyperegistry.h | #pragma once
#include <poplin/core/singleton.hpp>
#include <poplin/core/reflection/enuminfo.h>
#include <poplin/core/reflection/typeinfo.h>
#include <map>
namespace Poplin
{
class ReflectedTypeRegistry : public Singleton<ReflectedTypeRegistry>
{
public:
ReflectedTypeRegistry();
~ReflectedTypeRegistry();
const TypeInfo* FindTypeInfo(TypeID typeID) const;
const EnumInfo* FindEnumInfo(EnumID enumID) const;
private:
std::map<TypeID, const TypeInfo*> m_TypeMap;
std::map<EnumID, const EnumInfo*> m_EnumMap;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/universe.h | <gh_stars>0
#pragma once
#include <poplin/core/singleton.hpp>
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/systemupdater.h>
#include <vector>
namespace Poplin
{
class System;
class World;
class Universe : public Singleton<Universe>
{
public:
Universe();
~Universe();
void Update(f32 deltaTime);
World* CreateWorld();
void DestroyAllWorlds();
inline const std::vector<World*>& GetAllWorlds() const { return m_Worlds; }
World* GetCurrentWorld();
private:
SystemUpdater m_SystemUpdater;
std::vector<System*> m_Systems;
std::vector<World*> m_Worlds;
};
} |
imefGames/Poplin | Poplin/include/poplin/core/reflection/propertyinfo.h | #pragma once
#include <poplin/core/error.h>
#include <poplin/core/types.hpp>
#include <glm/glm.hpp>
#include <memory>
#include <string>
namespace Poplin
{
using PropertyID = u64;
enum class EPropertyType : u8
{
Unknown,
Bool,
U8,
U16,
U32,
U64,
S8,
S16,
S32,
S64,
F32,
Vector2,
Vector3,
Vector4,
String,
TypeInstance,
TypeInstancePointer
};
namespace PropertyUtils
{
template <typename T> static EPropertyType GetPropertyType(const T* b) { return EPropertyType::Unknown; }
static EPropertyType GetPropertyType(const bool*) { return EPropertyType::Bool; }
static EPropertyType GetPropertyType(const u8*) { return EPropertyType::U8; }
static EPropertyType GetPropertyType(const u16*) { return EPropertyType::U16; }
static EPropertyType GetPropertyType(const u32*) { return EPropertyType::U32; }
static EPropertyType GetPropertyType(const u64*) { return EPropertyType::U64; }
static EPropertyType GetPropertyType(const s8*) { return EPropertyType::S8; }
static EPropertyType GetPropertyType(const s16*) { return EPropertyType::S16; }
static EPropertyType GetPropertyType(const s32*) { return EPropertyType::S32; }
static EPropertyType GetPropertyType(const s64*) { return EPropertyType::S64; }
static EPropertyType GetPropertyType(const f32*) { return EPropertyType::F32; }
static EPropertyType GetPropertyType(const glm::vec2*) { return EPropertyType::Vector2; }
static EPropertyType GetPropertyType(const glm::vec3*) { return EPropertyType::Vector3; }
static EPropertyType GetPropertyType(const glm::vec4*) { return EPropertyType::Vector4; }
static EPropertyType GetPropertyType(const std::string*) { return EPropertyType::String; }
template <class T> static EPropertyType GetPropertyType(const std::shared_ptr<T>*) { return EPropertyType::TypeInstancePointer; }
}
enum class EPropertyVisibility : u8
{
Public,
Private,
Protected
};
class PropertyAccessor
{
public:
virtual void* GetPropertyAddress(void* typeAddress) const = 0;
virtual void SetPropertyAddress(void* typeAddress, const void* newValue) const = 0;
};
template <class Type, class PropertyType>
class PropertyAccessorImpl : public PropertyAccessor
{
using PropertyAccessorGetter = PropertyType& (*)(Type&);
using PropertyAccessorSetter = void (*)(Type&, const PropertyType&);
public:
PropertyAccessorImpl(PropertyAccessorGetter getter, PropertyAccessorSetter setter)
: m_Getter{ getter }
, m_Setter{ setter }
{
}
void* GetPropertyAddress(void* typeAddressRaw) const override
{
Type* typeAddress{ reinterpret_cast<Type*>(typeAddressRaw) };
return &(m_Getter(*typeAddress));
}
void SetPropertyAddress(void* typeAddressRaw, const void* newValueRaw) const override
{
Type* typeAddress{ reinterpret_cast<Type*>(typeAddressRaw) };
const PropertyType* newValue{ reinterpret_cast<const PropertyType*>(newValueRaw) };
m_Setter(*typeAddress, *newValue);
}
private:
PropertyAccessorGetter m_Getter;
PropertyAccessorSetter m_Setter;
};
class PropertyInfo
{
public:
enum class Flags : u8
{
None = 0x00,
IsEnum = 0x01,
IsManagedAsset = 0x02,
};
PropertyInfo(PropertyID id, const char* name, u32 offset, EPropertyType type, EPropertyVisibility visibility, u64 specificID = 0, Flags flags = Flags::None, PropertyAccessor* propertyAccessor = nullptr);
inline PropertyID GetID() const { return m_ID; }
inline u64 GetSpecificID() const { return m_SpecificID; }
inline const char* GetName() const { return m_Name; }
inline u32 GetOffset() const { return m_Offset; }
inline EPropertyType GetType() const { return m_Type; }
inline EPropertyVisibility GetVisibility() const { return m_Visibility; }
inline bool IsAnEnum() const { return (u8)m_Flags & (u8)Flags::IsEnum; }
inline bool IsAManagedAsset() const { return (u8)m_Flags & (u8)Flags::IsManagedAsset; }
template <class T>
T* GetPropertyAddressAs(void* typeAddress) const
{
T* propertyPtr{ (T*)GetPropertyAddress(typeAddress) };
PoplinWarning(PropertyUtils::GetPropertyType(propertyPtr) == m_Type, "Requested Property type does not match info.");
return propertyPtr;
}
template <class T>
void SetPropertyAddressAs(void* typeAddress, const T& newValue) const
{
PoplinWarning(PropertyUtils::GetPropertyType(&newValue) == m_Type, "Requested Property type does not match info.");
return SetPropertyAddress(typeAddress, &newValue, sizeof(T));
}
private:
void* GetPropertyAddress(void* typeAddress) const;
void SetPropertyAddress(void* typeAddress, const void* newValue, u32 valueSize) const;
PropertyID m_ID;
const char* m_Name;
u64 m_SpecificID;
u32 m_Offset;
EPropertyType m_Type;
EPropertyVisibility m_Visibility;
std::unique_ptr<PropertyAccessor> m_PropertyAccessor;
Flags m_Flags;
};
} |
imefGames/Poplin | Poplin/include/poplin/physics/physicscontactlistener.h | <reponame>imefGames/Poplin
#pragma once
#include <box2d/b2_world_callbacks.h>
namespace Poplin
{
class PhysicsContactListener : public b2ContactListener
{
void BeginContact(b2Contact* contact) override;
void EndContact(b2Contact* contact) override;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/gameengine.h | <filename>Poplin/include/poplin/engine/gameengine.h
#pragma once
#include <poplin/core/reflection/reflectedtyperegistry.h>
#include <poplin/engine/gameengineconfig.hpp>
#include <poplin/engine/gameenginestats.hpp>
#include <poplin/engine/asset/assetlocator.h>
#include <poplin/engine/ecs/componentdescriptorregistry.h>
#include <poplin/engine/ecs/universe.h>
#include <poplin/engine/window/applicationwindow.h>
#include <poplin/graphics/renderer.h>
namespace Poplin
{
class GameEngine
{
public:
GameEngine(const GameEngineConfig& config);
void RunGameLoop();
private:
ReflectedTypeRegistry m_ReflectedTypeRegistry;
ComponentDescriptorRegistry m_ComponentRegistry;
GameEngineConfig m_Config;
GameEngineStats m_Stats;
ApplicationWindow m_Window;
Renderer m_Renderer;
AssetLocator m_AssetLocator;
Universe m_Universe;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/world.h | <reponame>imefGames/Poplin
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/entityregistry.h>
#include <poplin/physics/physicsworld.h>
#include <string>
namespace Poplin
{
class SystemUpdater;
class World
{
public:
World();
~World();
void Update(const SystemUpdater& systemUpdater, f32 deltaTime);
Entity CreateEntity();
void ForEachEntity(const std::function<void(Entity)>& function) const;
void ClearAllEntities();
inline const std::string& GetName() const { return m_Name; }
inline const void SetName(std::string& name) { m_Name = name; }
inline PhysicsWorld& GetPhysicsWorld() { return m_PhysicsWorld; }
private:
EntityRegistry m_Registry;
PhysicsWorld m_PhysicsWorld;
std::string m_Name;
};
} |
imefGames/Poplin | Poplin/include/poplin/core/profiling/profilingtimer.h | <gh_stars>0
#pragma once
#include <chrono>
#include <string>
namespace Poplin
{
class ProfilingTimer
{
public:
ProfilingTimer(const std::string& logEntryName);
~ProfilingTimer();
private:
void Stop();
std::string m_LogEntryName;
std::chrono::steady_clock::time_point m_StartTime;
};
} |
imefGames/Poplin | Poplin/include/poplin/physics/physicsworld.h | #pragma once
#include <box2d/box2d.h>
#include <poplin/core/types.hpp>
#include <poplin/physics/physicscontactlistener.h>
namespace Poplin
{
class RigidBodyComponent;
class PhysicsWorld
{
friend class PhysicsSystem;
public:
PhysicsWorld();
void InitRigidBody(RigidBodyComponent& rigidBody);
void ShutdownRigidBody(RigidBodyComponent& rigidBody);
void ClearWorld();
private:
void Update(f32 deltaTime);
b2World m_B2World;
PhysicsContactListener m_ContactListener;
};
} |
imefGames/Poplin | Weaver/weaverecs.h | <reponame>imefGames/Poplin
#pragma once
#include <poplin/engine/ecs/componentdescriptor.h>
#include <poplin/engine/ecs/componentdescriptorregistry.h>
#include <poplin/engine/ecs/universe.h>
namespace Poplin
{
void RegisterEditorComponents(std::vector<ComponentDescriptor*>& components);
void RegisterEditorSystems(std::vector<System*>& systems, SystemUpdater& systemUpdater);
} |
imefGames/Poplin | Poplin/include/poplin/engine/asset/assetlocator.h | #pragma once
#include <poplin/core/singleton.hpp>
#include <poplin/engine/asset/managedasset.h>
#include <map>
#include <memory>
namespace Poplin
{
class AssetLocator : public Singleton<AssetLocator>
{
public:
AssetLocator();
~AssetLocator();
std::shared_ptr<ManagedAsset> FindAsset(AssetID assetID) const;
inline const std::map<AssetID, std::shared_ptr<ManagedAsset>>& GetAllLoadedAssets() const { return m_LoadedAssets; }
private:
std::map<AssetID, std::shared_ptr<ManagedAsset>> m_LoadedAssets;
};
} |
imefGames/Poplin | Poplin/include/poplin/graphics/loaders/modelloader.h | <gh_stars>0
#pragma once
#include <poplin/graphics/vertexarray.h>
#include <memory>
namespace Poplin::ModelLoader
{
std::shared_ptr<VertexArray> MakeUnitSquare();
} |
imefGames/Poplin | Poplin/include/poplin/core/error.h | #pragma once
#include <poplin/core/types.hpp>
namespace Poplin
{
namespace Error
{
enum class EErrorType
{
Warning,
Error,
Assert
};
void ReportError(EErrorType errorType, const Char* errorText);
}
}
#define PoplinWarning(condition, errorText)\
if (condition) {} else\
{\
Poplin::Error::ReportError(Poplin::Error::EErrorType::Warning, errorText);\
}
#define PoplinError(condition, errorText)\
if (condition) {}\
else\
{\
Poplin::Error::ReportError(Poplin::Error::EErrorType::Error, errorText); \
}
#define PoplinAssert(condition, errorText)\
if (condition) {}\
else\
{\
Poplin::Error::ReportError(Poplin::Error::EErrorType::Assert, errorText); \
} |
imefGames/Poplin | Poplin/include/poplin/physics/ecs/components/rigidbodycomponent.h | #pragma once
#include <box2d/box2d.h>
#include <glm/glm.hpp>
#include <imgui/imgui.h>
#include <poplin/core/types.hpp>
#include <poplin/core/reflection/enuminfo.h>
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/componentdescriptor.h>
#include <memory>
namespace Poplin
{
class RigidBodyComponent;
namespace RigidBodyComponentUtils
{
void InitRigidBody(RigidBodyComponent& rigidBody, Entity& entity);
void ShutdownRigidBody(RigidBodyComponent& rigidBody, Entity& entity);
}
class RigidBodyComponent
{
friend class PhysicsWorld;
friend class PhysicsSystem;
friend void RigidBodyComponentUtils::InitRigidBody(RigidBodyComponent&, Entity&);
friend void RigidBodyComponentUtils::ShutdownRigidBody(RigidBodyComponent&, Entity&);
public:
struct RigidBodyUserData
{
Entity m_Entity;
};
RigidBodyComponent();
glm::vec2 GetLinearVelocity() const;
void SetLinearVelocity(const glm::vec2& velocity);
static u32& GetRigidBodyType(RigidBodyComponent& rigidBody);
static void SetRigidBodyType(RigidBodyComponent& rigidBody, const u32& type);
static bool& GetRigidBodyFixedRotation(RigidBodyComponent& rigidBody);
static void SetRigidBodyFixedRotation(RigidBodyComponent& rigidBody, const bool& fixedRotation);
static bool& GetRigidBodyIsATrigger(RigidBodyComponent& rigidBody);
static void SetRigidBodyIsATrigger(RigidBodyComponent& rigidBody, const bool& isATrigger);
private:
std::unique_ptr<RigidBodyUserData> m_UserData;
b2Body* m_B2Body;
};
static const EnumInfo::EnumEntry g_RigidBodyTypeEnumValues[]
{
{ 0, "Static" },
{ 1, "Kinematic" },
{ 2, "Dynamic" }
};
static const EnumInfo g_RigidBodyTypeEnum{ 156941, g_RigidBodyTypeEnumValues, 3 };
namespace Enums
{
template <>
static const EnumInfo* GetEnumInfo<b2BodyType>()
{
return &g_RigidBodyTypeEnum;
}
}
static const PropertyInfo g_RigidBodyComponentPropertiesInfo[]
{
{ 0, "Type", u32Max, EPropertyType::U32, EPropertyVisibility::Public, 156941, PropertyInfo::Flags::IsEnum, new PropertyAccessorImpl<RigidBodyComponent, u32>(&RigidBodyComponent::GetRigidBodyType, &RigidBodyComponent::SetRigidBodyType) },
{ 1, "FixedRotation", u32Max, EPropertyType::Bool, EPropertyVisibility::Public, 0, PropertyInfo::Flags::None, new PropertyAccessorImpl<RigidBodyComponent, bool>(&RigidBodyComponent::GetRigidBodyFixedRotation, &RigidBodyComponent::SetRigidBodyFixedRotation) },
{ 2, "IsATrigger", u32Max, EPropertyType::Bool, EPropertyVisibility::Public, 0, PropertyInfo::Flags::None, new PropertyAccessorImpl<RigidBodyComponent, bool>(&RigidBodyComponent::GetRigidBodyIsATrigger, &RigidBodyComponent::SetRigidBodyIsATrigger) },
};
static const TypeInfo g_RigidBodyComponentTypeInfo
(
912,
"Rigid Body",
sizeof(RigidBodyComponent),
g_RigidBodyComponentPropertiesInfo,
sizeof(g_RigidBodyComponentPropertiesInfo) / sizeof(PropertyInfo),
nullptr
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<RigidBodyComponent>()
{
return &g_RigidBodyComponentTypeInfo;
}
}
namespace ComponentDescriptorUtils
{
//TODO: move elsewhere ?
template <>
static void AddComponent<RigidBodyComponent>(Entity& entity)
{
RigidBodyComponent& rigidBody{ entity.AddComponent<RigidBodyComponent>() };
RigidBodyComponentUtils::InitRigidBody(rigidBody, entity);
}
template <>
static void RemoveComponent<RigidBodyComponent>(Entity& entity)
{
RigidBodyComponent& rigidBody{ entity.GetComponent<RigidBodyComponent>() };
RigidBodyComponentUtils::ShutdownRigidBody(rigidBody, entity);
entity.RemoveComponent<RigidBodyComponent>();
}
}
} |
imefGames/Poplin | Poplin/include/poplin/engine/asset/managedasset.h | #pragma once
#include <poplin/core/singleton.hpp>
#include <poplin/core/types.hpp>
#include <poplin/core/reflection/typeinfo.h>
#include <string>
namespace Poplin
{
using AssetID = u64;
static const AssetID InvalidAssetID = u64Max;
class ManagedAsset
{
friend class AssetLocator;
public:
ManagedAsset();
~ManagedAsset() = default;
inline const std::string& GetName() const { return m_Name; }
inline const TypeInfo* GetTypeInfo() const { return m_TypeInfo; }
inline AssetID GetAssetID() const { return m_AssetID; }
protected:
virtual void OnAssetLoaded() {};
private:
inline void SetName(const std::string& name) { m_Name = name; }
inline void SetTypeInfo(const TypeInfo* typeInfo) { m_TypeInfo = typeInfo; }
inline void SetAssetID(AssetID assetID) { m_AssetID = assetID; }
std::string m_Name;
const TypeInfo* m_TypeInfo;
AssetID m_AssetID;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/components/logiccomponent.h | <filename>Poplin/include/poplin/engine/ecs/components/logiccomponent.h
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/componentdescriptor.h>
#include <poplin/engine/ecs/entity.h>
#include <memory>
namespace Poplin
{
class LogicComponentBehavior
{
friend class LogicComponent;
public:
virtual ~LogicComponentBehavior() = default;
virtual void Update(f32 deltaTime) = 0;
protected:
Entity m_Entity;
const TypeInfo* m_TypeInfo;
};
class LogicComponent
{
public:
LogicComponent();
LogicComponent(const Entity& entity);
bool HasBehaviorOfType(const TypeInfo* typeInfo) const;
LogicComponentBehavior* GetBehaviorOfType(const TypeInfo* typeInfo);
template <class T>
void AddBehavior()
{
m_Behavior = std::make_unique<T>();
m_Behavior->m_Entity = m_Entity;
m_Behavior->m_TypeInfo = Reflection::GetTypeInfo<T>();
}
template <class T>
void RemoveBehavior()
{
m_Behavior.reset();
}
void Update(f32 deltaTime);
private:
Entity m_Entity;
std::unique_ptr<LogicComponentBehavior> m_Behavior;
};
namespace ComponentDescriptorUtils
{
template <class T>
static bool HasLogicBehavior(Entity& entity)
{
bool hasLogicBehavior{ false };
if (entity.HasComponent<LogicComponent>())
{
LogicComponent& logicComponent{ entity.GetComponent<LogicComponent>() };
hasLogicBehavior = logicComponent.HasBehaviorOfType(Reflection::GetTypeInfo<T>());
}
return hasLogicBehavior;
}
template <class T>
static void* GetLogicBehaviorAddress(Entity& entity)
{
void* address{ nullptr };
if (entity.HasComponent<LogicComponent>())
{
LogicComponent& logicComponent{ entity.GetComponent<LogicComponent>() };
address = logicComponent.GetBehaviorOfType(Reflection::GetTypeInfo<T>());
}
return address;
}
template <class T>
static void AddLogicBehavior(Entity& entity)
{
if (!entity.HasComponent<LogicComponent>())
{
entity.AddComponent<LogicComponent>(entity);
}
//TODO if def in editor
EntityMetaDataComponent& metaData{ entity.GetComponent<EntityMetaDataComponent>() };
if (const TypeInfo* foundType = Reflection::GetTypeInfo<T>())
{
metaData.OwnedComponentTypes.push_back(foundType);
}
LogicComponent& logicComponent{ entity.GetComponent<LogicComponent>() };
logicComponent.AddBehavior<T>();
}
template <class T>
static void RemoveLogicBehavior(Entity& entity)
{
if (entity.HasComponent<LogicComponent>())
{
EntityMetaDataComponent& metaData{ entity.GetComponent<EntityMetaDataComponent>() };
const TypeInfo* typeToRemove{ Reflection::GetTypeInfo<T>() };
auto removeByID{ [typeToRemove](const TypeInfo* type) { return type->GetTypeID() == typeToRemove->GetTypeID(); } };
auto endIt{ std::remove_if(metaData.OwnedComponentTypes.begin(), metaData.OwnedComponentTypes.end(), removeByID) };
metaData.OwnedComponentTypes.erase(endIt, metaData.OwnedComponentTypes.end());
LogicComponent& logicComponent{ entity.GetComponent<LogicComponent>() };
logicComponent.RemoveBehavior<T>();
};
}
template <class T>
ComponentDescriptor* CreateLogicBehaviorDescriptor(const std::string& name)
{
return new ComponentDescriptor{ name, &Reflection::GetTypeInfo<T>, &HasLogicBehavior<T>, &GetLogicBehaviorAddress<T>, &AddLogicBehavior<T>, &RemoveLogicBehavior<T> };
}
}
} |
imefGames/Poplin | Poplin/include/poplin/graphics/loaders/shaderloader.h | <reponame>imefGames/Poplin<gh_stars>0
#pragma once
#include <poplin/graphics/shader.h>
#include <memory>
namespace Poplin::ShaderLoader
{
std::shared_ptr<Shader> LoadDefaultSpriteShader();
} |
imefGames/Poplin | Poplin/include/poplin/animation/ecs/components/animatorcomponent.h | #pragma once
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/componentdescriptor.h>
#include <imgui/imgui.h>
namespace Poplin
{
class AnimatorComponent
{
public:
AnimatorComponent();
f32 FrameElapsedTime;
f32 TimePerFrame;
u8 FrameCount;
u8 CurrentFrame;
u8 RowCount;
u8 CurrentRow;
bool IsPlaying;
bool LoopFrames;
};
static const PropertyInfo g_AnimatorComponentPropertiesInfo[]
{
{ 0, "Frame Elapsed Time", 0, EPropertyType::F32, EPropertyVisibility::Public },
{ 1, "Time Per Frame", 4, EPropertyType::F32, EPropertyVisibility::Public },
{ 2, "Frame Count", 8, EPropertyType::U8, EPropertyVisibility::Public },
{ 3, "Current Frame", 9, EPropertyType::U8, EPropertyVisibility::Public },
{ 4, "Row Count", 10, EPropertyType::U8, EPropertyVisibility::Public },
{ 5, "Current Row", 11, EPropertyType::U8, EPropertyVisibility::Public },
{ 6, "Is Playing", 12, EPropertyType::Bool, EPropertyVisibility::Public },
{ 7, "Loop Frames", 13, EPropertyType::Bool, EPropertyVisibility::Public }
};
static const TypeInfo g_AnimatorComponentTypeInfo
(
1432152,
"Animator",
sizeof(AnimatorComponent),
g_AnimatorComponentPropertiesInfo,
sizeof(g_AnimatorComponentPropertiesInfo) / sizeof(PropertyInfo),
nullptr
);
namespace Reflection
{
template <>
static const TypeInfo* GetTypeInfo<AnimatorComponent>()
{
return &g_AnimatorComponentTypeInfo;
}
}
} |
imefGames/Poplin | Poplin/include/poplin/graphics/shader.h | <reponame>imefGames/Poplin<filename>Poplin/include/poplin/graphics/shader.h<gh_stars>0
#pragma once
#include <glm/glm.hpp>
#include <poplin/core/types.hpp>
namespace Poplin
{
class Shader
{
public:
Shader(const Char* vertexSource, const Char* fragmentSource);
~Shader();
void Bind();
void Unbind();
void SetValue(const char* uniformName, s32 value);
void SetValue(const char* uniformName, f32 value);
void SetValue(const char* uniformName, const glm::vec2& vector);
void SetValue(const char* uniformName, const glm::vec3& vector);
void SetValue(const char* uniformName, const glm::vec4& vector);
void SetValue(const char* uniformName, const glm::mat4& matrix);
private:
u32 m_ProgramID;
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/ecs/entity.h | #pragma once
#include <poplin/core/types.hpp>
#include <poplin/core/reflection/typeinfo.h>
#include <poplin/engine/ecs/entityregistry.h>
#include <poplin/engine/ecs/components/entitymetadatacomponent.h>
namespace Poplin
{
class Entity
{
public:
Entity() = default;
Entity(EntityRegistry& registry, entt::entity entity);
inline u32 GetEntityID() const { return static_cast<u32>(m_Handle.entity()); }
template <class T>
bool HasComponent()
{
return m_Handle.has<T>();
}
template <class T>
T& GetComponent()
{
return m_Handle.get<T>();
}
template <class T, class... Args>
T& AddComponent(Args... args)
{
//TODO if def in editor
EntityMetaDataComponent& metaData{ GetComponent<EntityMetaDataComponent>() };
if (const TypeInfo* foundType = Reflection::GetTypeInfo<T>())
{
metaData.OwnedComponentTypes.push_back(foundType);
}
return m_Handle.emplace<T>(std::forward<Args>(args)...);
}
template <>
EntityMetaDataComponent& AddComponent<EntityMetaDataComponent>()
{
return m_Handle.emplace<EntityMetaDataComponent>();
}
template <class T>
void RemoveComponent()
{
EntityMetaDataComponent& metaData{ GetComponent<EntityMetaDataComponent>() };
const TypeInfo* typeToRemove{ Reflection::GetTypeInfo<T>() };
auto removeByID{ [typeToRemove](const TypeInfo* type) { return type->GetTypeID() == typeToRemove->GetTypeID(); } };
auto endIt{ std::remove_if(metaData.OwnedComponentTypes.begin(), metaData.OwnedComponentTypes.end(), removeByID) };
metaData.OwnedComponentTypes.erase(endIt, metaData.OwnedComponentTypes.end());
m_Handle.remove<T>();
}
private:
using EntityHandle = entt::basic_handle<entt::entity>;
EntityHandle m_Handle;
};
} |
imefGames/Poplin | Poplin/include/poplin/graphics/ecs/systems/rendersystem.h | #pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/system.h>
namespace Poplin
{
class CameraComponent;
class SpriteComponent;
class TransformComponent;
class RenderSystem : public System
{
public:
RenderSystem(SystemUpdater& updater);
private:
void UpdateCamera(f32 deltaTime, TransformComponent& transform, CameraComponent& camera);
void RenderSprite(f32 deltaTime, TransformComponent& transform, SpriteComponent& sprite);
};
} |
imefGames/Poplin | Poplin/src/engine/input/inputhandler.h | #pragma once
#include <poplin/core/types.hpp>
#include <poplin/core/singleton.hpp>
#include <poplin/engine/input/keycodes.hpp>
#include <poplin/engine/input/mousecodes.hpp>
#include <glm/glm.hpp>
namespace Poplin
{
class Window;
namespace Input
{
enum class EInputStates : u8
{
None = 0x00,
DownState = 0x01,
ChangeState = 0x02
};
class InputHandler : public Singleton<InputHandler>
{
friend class ApplicationWindow;
public:
InputHandler();
~InputHandler();
EInputStates GetKeyStates(EKeyCode key) const;
EInputStates GetMouseButtonStates(EMouseCode mouseButton) const;
inline const glm::vec2 GetMousePosition() const { return m_MousePosition; }
inline f32 GetMouseScroll() const { return m_MouseScroll; }
private:
void NotifyKeyStateChanged(EKeyCode key);
void NotifyKeyDownState(EKeyCode key, bool state);
void NotifyMouseButtonStateChanged(EMouseCode mouseButton);
void NotifyMouseButtonDownState(EMouseCode mouseButton, bool state);
void SetMousePosition(f32 mouseX, f32 mouseY);
inline void SetMouseScroll(f32 scroll) { m_MouseScroll = scroll; }
void ResetChangeStates();
EInputStates m_KeyStates[static_cast<u32>(EKeyCode::Count)];
EInputStates m_MouseButtonStates[static_cast<u32>(EMouseCode::Count)];
glm::vec2 m_MousePosition;
f32 m_MouseScroll;
};
}
} |
imefGames/Poplin | Poplin/include/poplin/animation/ecs/systems/animationsystem.h | <gh_stars>0
#pragma once
#include <poplin/core/types.hpp>
#include <poplin/engine/ecs/system.h>
namespace Poplin
{
class AnimatorComponent;
class SpriteComponent;
class AnimationSystem : public System
{
public:
AnimationSystem(SystemUpdater& updater);
private:
void UpdateAnimation(f32 deltaTime, AnimatorComponent& animator, SpriteComponent& sprite);
};
} |
imefGames/Poplin | Poplin/include/poplin/engine/window/applicationwindow.h | <reponame>imefGames/Poplin<gh_stars>0
#pragma once
#include <memory>
struct GLFWwindow;
namespace Poplin
{
namespace Input
{
class InputHandler;
}
struct ApplicationWindowEvents;
class ApplicationWindow
{
public:
ApplicationWindow();
~ApplicationWindow();
void BeginFrame();
void EndFrame();
void PollEvents(ApplicationWindowEvents& windowEvents);
private:
static void OnKeyStateChangedProc(GLFWwindow* window, int key, int scanCode, int action, int mods);
static void OnMouseStateChangedProc(GLFWwindow* window, int button, int action, int mods);
static void OnMouseScrollProc(GLFWwindow* window, double xOffset, double yOffset);
static void OnWindowSizeChanged(GLFWwindow* window, int width, int height);
std::unique_ptr<Input::InputHandler> m_InputHandler;
GLFWwindow* m_Window;
};
} |
imefGames/Poplin | Poplin/include/poplin/graphics/vertexbuffer.h | #pragma once
#include <poplin/core/types.hpp>
namespace Poplin
{
//Handle data layouts better
enum class EShaderDataType
{
Integer,
Float,
Float2,
Float3,
Float4,
Matrix3,
Matrix4
};
class VertexBuffer
{
public:
VertexBuffer(const void* data, u64 dataSize, EShaderDataType dataType);
~VertexBuffer();
void Bind();
inline EShaderDataType GetDataType() const { return m_DataType; }
private:
u32 m_BufferID;
EShaderDataType m_DataType;
};
} |
imefGames/Poplin | Poplin/include/poplin/core/profiling/profilerlogger.h | <reponame>imefGames/Poplin
#pragma once
#include <chrono>
#include <string>
namespace Poplin
{
class ProfilerLogger
{
using ProfileTimePoint = std::chrono::steady_clock::time_point;
public:
static void LogEntry(const std::string& logEntryName, const ProfileTimePoint& startTime, const ProfileTimePoint& endTime);
};
} |
imefGames/Poplin | Poplin/include/poplin/graphics/texture.h | #pragma once
#include <poplin/core/types.hpp>
namespace Poplin
{
class Texture
{
public:
Texture(const void* data, u32 dataWidth, u32 dataHeight);
~Texture();
void Bind();
private:
u32 m_TextureID;
};
} |
okoshi42/assignment11 | src/timing.h | <filename>src/timing.h
//
// timing.h
//
// Tests the speed of bst.contains() vs std::find()
// You should NOT modify this file.
//
// IMPORTANT NOTE: For this particular assignment you may not add
// any additional utility functions.
//
// Copyright 2019 <NAME>
//
// 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.
#ifndef timing_hpp
#define timing_hpp
#include <random>
#include <array>
#include <chrono> // for microseconds
#include <algorithm> // for find()
using namespace std;
using namespace std::chrono;
namespace csi281 {
// Finds the speed of contains() in BST vs std::find in array
static array<long long, 2> searchSpeed(const int length) {
// Generate Random Data Structures
int *testArray1 = new int[length];
int *testArray2 = new int[length];
// initialize random number generator in range min to max
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> uni(0,length);
// fill data structures with random data
for (int i = 0; i < length; i++) {
int num = uni(rng);
testArray1[i] = num;
testArray2[i] = num;
}
BST<int> bst = BST<int>();
for (int i = 0; i < length; i++) {
int num = testArray1[i];
bst.insert(num);
}
// test bst speed
using namespace std::chrono;
auto start = duration_cast< microseconds >(system_clock::now().time_since_epoch()).count();
for (int i = 0; i < length; i++) {
auto throwaway1 = bst.contains(testArray2[i]);
}
auto end = duration_cast< microseconds >(system_clock::now().time_since_epoch()).count();
long long bstTime = (end - start);
// test find speed
start = duration_cast< microseconds >(system_clock::now().time_since_epoch()).count();
for (int i = 0; i < length; i++) {
auto throwaway2 = find(testArray1, testArray1 + length, testArray2[i]);
}
end = duration_cast< microseconds >(system_clock::now().time_since_epoch()).count();
long long findTime = end - start;
// cout << stdSortTime << endl; // how long for std::sort
delete[] testArray1;
delete[] testArray2;
return {bstTime, findTime};
}
}
#endif /* timing_hpp */
|
okoshi42/assignment11 | src/bst.h | <gh_stars>0
//
// bst.h
//
// Defines a class for a binary search tree.
// You SHOULD modify this file.
//
// IMPORTANT NOTE: For this particular assignment you may not add
// any additional utility functions.
//
// Copyright 2019 <NAME>
//
// 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.
#ifndef bst_hpp
#define bst_hpp
#include <list>
#include <optional>
#include <random>
using namespace std;
namespace csi281 {
template <typename T>
class BST {
public:
// *Node* represents one node in the tree
struct Node {
Node (T k, Node *l, Node *r) : key(k), left(l), right(r) {}
T key;
Node *left;
Node *right;
};
// Delete a node and all of its children
void deleteHelper(Node *node) {
if (node == nullptr) { return; }
deleteHelper(node->left);
deleteHelper(node->right);
delete node;
}
// Delete all nodes
~BST() {
deleteHelper(root);
}
// Add a new node to the tree with *key*
// Make sure to insert it into the correct place
// NOTE: We are allowing duplicates, so, <= and >, or < and >=
// for traversing left and right should be used
// TIP: If the tree is empty, remember that you
// need to initialize root
void insert(T key) {
// YOUR CODE HERE
Node *newNode = new Node(key,nullptr,nullptr);
if (root == nullptr) {
root = newNode;
count++;
}
//TO BE FIXED L8TR
else {
Node* tempNode = root;
bool exitCondition = false;
while (!exitCondition) {
if (key <= tempNode->key) {
if (tempNode->left == nullptr) {
tempNode->left = newNode;
count++;
exitCondition = true;
}
else tempNode = tempNode->left;
}
else {
if (tempNode->right == nullptr) {
tempNode->right = newNode;
count++;
exitCondition = true;
}
else tempNode = tempNode->right;
}
}
}
//add where it go left right
}
// Do a search through the tree and return
// whether or not it contains *key*
bool contains(const T &key) {
// YOUR CODE HERE
Node* tempNode = root;
while (tempNode != nullptr) {
if (key == tempNode->key) return true;
else if (key < tempNode->key) tempNode = tempNode->left;
else tempNode = tempNode->right;
}
return false;
}
// Helper for inOrderWalk() to call for entire bst
void inOrderWalk(list<T> &accumulated) {
inOrderWalk(accumulated, root);
}
// Walk through the entire tree in ascending order, starting
// from *current*, and accumulate the values in the
// list *accumulated*
// TIP: See page 288 of Chapter 12 of Introduction to Algorithms
void inOrderWalk(list<T> &accumulated, Node *current) {
// YOUR CODE HERE
if (current->left != nullptr)inOrderWalk(accumulated, current->left);
accumulated.push_back(current->key);
if (current->right != nullptr)inOrderWalk(accumulated, current->right);
return;
}
// Find the minimum key in the tree
// If the tree is empty, return nullopt
optional<T> minimum() {
// YOUR CODE HERE
if (root == nullptr)return nullopt;
else {
Node* tempNode = root;
while (tempNode != nullptr) {
if (tempNode->left == nullptr)return tempNode->key;
else tempNode = tempNode->left;
}
}
return nullopt;
}
// Find the maximum key in the tree
// If the tree is empty, return nullopt
optional<T> maximum() {
// YOUR CODE HERE
if (root == nullptr)return nullopt;
else {
Node* tempNode = root;
T max = tempNode->key;
while (tempNode != nullptr) {
if (max < tempNode->key) max = tempNode->key;
if (tempNode->right == nullptr)return max;
else tempNode = tempNode->right;
}
return max;
}
}
// How many nodes are in the tree?
int getCount() { return count; }
private:
Node *root = nullptr;
int count = 0;
};
}
#endif /* bst_hpp */
|
mattgambill/MiscCppProjects | Array/Array/Header.h | #pragma once
#ifndef HEADER_H
#define HEADER_H
#include<iostream>
#include<vector>
using namespace std;
const int VECTOR_SIZE(20);
class functions {
public:
//read list
void read_list(vector<int>&, int& array_length);
//print vector
void print_array(vector<int>&, int array_length);
//find_max
int find_max(vector<int>&, int array_length);
//array_add
void array_add(int x, vector<int>&, int array_length);
private:
int max = 0;
int i; //index variable
int j = -1; //j is what the user inputs
};
#endif |
mattgambill/MiscCppProjects | EmpFormula/EmpFormula/Header.h | #pragma once
#ifndef HEADER_H
#define HEADER_H
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
//function prototypes
class ReadData {
public:
void data(const int, vector<double>&);
private:
const int NUM_ELEM = 93;
string userElement;
bool foundElement;
int i, j, k;
};
#endif
|
mattgambill/MiscCppProjects | Project3/Project3/exit.h | //#ifndef EXIT_H
//#define EXIT_H
//void exit(char & userChar);
//
//#endif |
mattgambill/MiscCppProjects | Project3/Project3/header.h | <reponame>mattgambill/MiscCppProjects
#ifndef HEADER_H
#define HEADER_H
void rootTable();
void exit(char & userChar);
#endif |
mattgambill/MiscCppProjects | vector_2D/Project5/Header.h | <reponame>mattgambill/MiscCppProjects<filename>vector_2D/Project5/Header.h
#pragma once
#ifndef HEADER_H
#define HEADER_H
using namespace std;
// function prototypes
// ENTER FUNCTION PROTOTYPE FOR read_vector HERE.
void read_vector(const string &a, double &u1, double &v1);
// ENTER FUNCTION PROTOTYPE FOR vector_length HERE.
double vector_length(double x, double y);
// ENTER FUNCTION PROTOTYPE FOR write_vector HERE.
void write_vector(const string &b, double x, double y);
// ENTER FUNCTION PROTOTYPE FOR vector_add HERE.
void vector_add(double x1, double y1, double x2, double y2, double &x3, double &y3);
// ENTER FUNCTION PROTOTYPE FOR vector_subtract HERE.
void vector_subtract(double x1, double y1, double x2, double y2, double &x3, double &y3);
// ENTER FUNCTION PROTOTYPE FOR scalar_mult HERE.
void scalar_mult(double x1, double y1, double scalar, double &x3, double &y3);
// ENTER FUNCTION PROTOTYPE FOR normalize HERE.
void normalize(double &x, double &y);
// ENTER FUNCTION PROTOTYPE FOR perpendicular HERE.
void perpendicular(double x1, double y1, double x2, double y2);
#endif
|
mattgambill/MiscCppProjects | hw6/hw6/Header.h | <gh_stars>0
#pragma once
#ifndef HEADER_H
#define HEADER_H
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
//function protypes/class definition
class Point
{
private:
double px;
double py;
public:
void setX(const double x);
void setY(const double y);
double getX() const;
double getY() const;
};
class Rectangle
{
private:
string name;
Point blPoint;
double length, height;
public:
// member functions
void setName(const string & inName);
void setBottomLeft(const double x, const double y);
void setDimensions(const double inLength, const double inHeight);
string getName() const;
Point getBottomLeft() const;
double getLength() const;
double getHeight() const;
double area() const;
double perimeter() const;
Point midPoint() const;
void scaleBy2();
void display() const;
};
// FUNCTION PROTOTYPES GO HERE:
void welcome();
bool isValidInput(const string & prompt, const string & errorInvalid, const string & errorUsed, string & validInput, vector<Rectangle>& recVector);
void blPoint(const string & prompt, double &x, double &y);
void heightAndLength(const string & prompt, double &length, double &height);
void addToVector(const string &recName, double x, double y, double length, double height, vector<Rectangle> & recVector);
void printVector(vector<Rectangle>& recVector);
#endif |
mattgambill/MiscCppProjects | freq/freq/Header.h | #pragma once
#ifndef HEADER_H
#define HEADER_H
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
//function protypes/calss definition
class numVowels {
public:
void init_vectors(vector<char> & vowels, vector<int> & frequencies);
string read_text(const string & prompt);
bool is_alphabetic(const char character);
void create_list(const string & str_text, vector<char> & vec_text);
bool is_member(const vector<char> & list, char character);
int find_index(const vector<char> & list, char character);
int compute_vowel_freqs(const vector<char> & text, const vector<char> & vowels, vector<int> & freqs);
void display_characters(const vector<char> & characters, const int colwidth);
void display_freqs(const vector<int> & freqs, const int colwidth);
};
#endif |
mattgambill/MiscCppProjects | Project4/Project4/Header.h | <filename>Project4/Project4/Header.h
#ifndef HEADER_H
#define HEADER_H
void magi();
#endif |
timpalpant/mprofile | src/spinlock.h | <reponame>timpalpant/mprofile
// Copyright 2019 <NAME>
#ifndef MPROFILE_SRC_SPINLOCK_H_
#define MPROFILE_SRC_SPINLOCK_H_
#include <atomic>
// SpinLock is a simple adapter to use an std::atomic<bool>
// with a std::lock_guard.
//
// Adapted from: https://rigtorp.se/spinlock/
class SpinLock {
public:
SpinLock() {}
// Not copyable or assignable.
SpinLock(const SpinLock &) = delete;
SpinLock &operator=(const SpinLock &) = delete;
void lock() {
while (true) {
// Optimistically assume the lock is free on the first try.
if (!flag_.exchange(true, std::memory_order_acquire)) {
break;
}
// Wait for lock to be released without generating cache misses.
while (flag_.load(std::memory_order_relaxed)) {
// Issue X86 PAUSE or ARM YIELD instruction to reduce contention
// between hyper-threads.
__builtin_ia32_pause();
}
}
}
void unlock() { flag_.store(false, std::memory_order_release); }
private:
std::atomic<bool> flag_ = {false};
};
#endif // MPROFILE_SRC_SPINLOCK_H
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.