mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 09:36:13 +01:00
277431e84c
commit2bbb5c1119
Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit3aabb51888
Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit8e6fe6df21
Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit66e57b5ab2
Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit360c426675
Merge:dd16e0d
b026417
Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commitdd16e0da97
Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commite823db3d24
Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commitd3d6cc97fb
Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit03d8d5f93d
Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit235f3c82b5
Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit530b77bbab
Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit2a895fbbd5
Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commitc6f2db7909
Merge:a7df84b
7395aa4
Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commita7df84b01c
Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commitead6e5afa1
Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit0cb175544e
Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit2082051801
Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
103 lines
3.6 KiB
C
103 lines
3.6 KiB
C
/*
|
|
* © 2022 Paul M. Antoine
|
|
* © 2021 Neil McKechnie
|
|
* © 2021 Harald Barth
|
|
* © 2021 Fred Decker
|
|
* All rights reserved.
|
|
*
|
|
* This file is part of CommandStation-EX
|
|
*
|
|
* This is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* It is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef FSH_h
|
|
#define FSH_h
|
|
|
|
/* This is an architecture support file to manage the differences
|
|
* between the nano/uno.mega and the later nanoEvery, unoWifiRev2 etc
|
|
*
|
|
* IMPORTANT:
|
|
* To maintain portability the main code should NOT contain ANY references
|
|
* to the following:
|
|
*
|
|
* __FlashStringHelper Use FSH instead.
|
|
* PROGMEM use FLASH instead
|
|
* pgm_read_byte_near use GETFLASH instead.
|
|
* pgm_read_word_near use GETFLASHW instead.
|
|
*
|
|
* Also:
|
|
* HIGHFLASH - PROGMEM forced to end of link so needs far pointers.
|
|
* GETHIGHFLASH,GETHIGHFLASHW to access them
|
|
*
|
|
*/
|
|
#include <Arduino.h>
|
|
#ifdef ARDUINO_ARCH_AVR
|
|
// AVR devices have flash memory mapped differently
|
|
// progmem can be accessed by _near functions or _far
|
|
typedef __FlashStringHelper FSH;
|
|
#define FLASH PROGMEM
|
|
#define GETFLASH(addr) pgm_read_byte_near(addr)
|
|
#define STRCPY_P strcpy_P
|
|
#define STRCMP_P strcmp_P
|
|
#define STRNCPY_P strncpy_P
|
|
#define STRNCMP_P strncmp_P
|
|
#define STRLEN_P strlen_P
|
|
|
|
#if defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560)
|
|
// AVR_MEGA memory deliberately placed at end of link may need _far functions
|
|
#define HIGHFLASH __attribute__((section(".fini2")))
|
|
#define HIGHFLASH3 __attribute__((section(".fini3")))
|
|
#define GETFARPTR(data) pgm_get_far_address(data)
|
|
#define GETHIGHFLASH(data,offset) pgm_read_byte_far(GETFARPTR(data)+offset)
|
|
#define GETHIGHFLASHW(data,offset) pgm_read_word_far(GETFARPTR(data)+offset)
|
|
#define COPYHIGHFLASH(target,base,offset,length) \
|
|
memcpy_PF(target,GETFARPTR(base) + offset,length)
|
|
#else
|
|
// AVR_UNO/NANO runtime does not support _far functions so just use _near equivalent
|
|
// as there is no progmem above 32kb anyway.
|
|
#define HIGHFLASH PROGMEM
|
|
#define HIGHFLASH3 PROGMEM
|
|
#define GETFARPTR(data) ((uint32_t)(data))
|
|
#define GETHIGHFLASH(data,offset) pgm_read_byte_near(GETFARPTR(data)+(offset))
|
|
#define GETHIGHFLASHW(data,offset) pgm_read_word_near(GETFARPTR(data)+(offset))
|
|
#define COPYHIGHFLASH(target,base,offset,length) \
|
|
memcpy_P(target,(byte *)base + offset,length)
|
|
#endif
|
|
|
|
#else
|
|
// Non-AVR Flat-memory devices have no need of this support so can be remapped to normal memory access
|
|
#ifdef F
|
|
#undef F
|
|
#endif
|
|
#ifdef FLASH
|
|
#undef FLASH
|
|
#endif
|
|
#define F(str) (str)
|
|
typedef char FSH;
|
|
#define FLASH
|
|
#define HIGHFLASH
|
|
#define HIGHFLASH3
|
|
#define GETFARPTR(data) ((uint32_t)(data))
|
|
#define GETFLASH(addr) (*(const byte *)(addr))
|
|
#define GETHIGHFLASH(data,offset) (*(const byte *)(GETFARPTR(data)+offset))
|
|
#define GETHIGHFLASHW(data,offset) (*(const uint16_t *)(GETFARPTR(data)+offset))
|
|
#define COPYHIGHFLASH(target,base,offset,length) \
|
|
memcpy(target,(byte *)&base + offset,length)
|
|
#define STRCPY_P strcpy
|
|
#define STRCMP_P strcmp
|
|
#define STRNCPY_P strncpy
|
|
#define STRNCMP_P strncmp
|
|
#define STRLEN_P strlen
|
|
#endif
|
|
#endif
|