Skip to content

option to deselect other device on SPI (for example network chip) #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ F_CPU = 16000000 # CPU clock frequency [Hz] NOT critical: it just shoul
SD_CS_PORT = PORTB # Data Register of the SD CS pin
SD_CS_DDR = DDRB # Data Direction Register of the SD CS pin
SD_CS_BIT = 4 # Bit of the SD CS pin
#OTHER_CS_PORT = PORTD # Data Register of other SPI device CS pin
#OTHER_CS_DDR = DDRD # Data Direction Register of other SPI device CS pin
#OTHER_CS_BIT = 2 # Bit of other SPI device CS pin
USE_LED = 0 # Debug with two (defined in asmfunc.S)
USE_UART = 0 # Debug on Serial. 0 ... deactivate or divider of http://wormfood.net/avrbaudcalc.php for baud rate!
#------------------------------------------------------------------
Expand All @@ -21,7 +24,11 @@ endif
TARGET = avr_boot
ASRC = asmfunc.S
OPTIMIZE = -Os -mcall-prologues -ffunction-sections -fdata-sections
ifdef OTHER_CS_BIT
DEFS = -DBOOT_ADR=$(BOOT_ADR) -DF_CPU=$(F_CPU) -DUSE_LED=$(USE_LED) -DUSE_UART=$(USE_UART) -DSD_CS_PORT=$(SD_CS_PORT) -DSD_CS_DDR=$(SD_CS_DDR) -DSD_CS_BIT=$(SD_CS_BIT) -DOTHER_CS_PORT=$(OTHER_CS_PORT) -DOTHER_CS_DDR=$(OTHER_CS_DDR) -DOTHER_CS_BIT=$(OTHER_CS_BIT)
else
DEFS = -DBOOT_ADR=$(BOOT_ADR) -DF_CPU=$(F_CPU) -DUSE_LED=$(USE_LED) -DUSE_UART=$(USE_UART) -DSD_CS_PORT=$(SD_CS_PORT) -DSD_CS_DDR=$(SD_CS_DDR) -DSD_CS_BIT=$(SD_CS_BIT)
endif
LIBS =
DEBUG = dwarf-2

Expand Down
8 changes: 8 additions & 0 deletions asmfunc.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#define DDR_CS _SFR_IO_ADDR(SD_CS_DDR), SD_CS_BIT
#define PORT_CS _SFR_IO_ADDR(SD_CS_PORT), SD_CS_BIT

;OTHER DEVICE CS PIN
#ifdef OTHER_CS_BIT
#define DDR_CS1 _SFR_IO_ADDR(OTHER_CS_DDR), OTHER_CS_BIT
#define PORT_CS1 _SFR_IO_ADDR(OTHER_CS_PORT), OTHER_CS_BIT
#endif
;---------------------------------------------------------------------------;
.nolist
#include <avr/io.h>
Expand Down Expand Up @@ -87,6 +92,9 @@ init_spi:
sbi DDR_DI ; DI: output
sbi DDR_CK ; SCLK: output
sbi PORT_DO ; DO: pull-up
#ifdef PORT_CS1
sbi PORT_CS1 ; CS1: pull-up
#endif
ret
.endfunc

Expand Down