e54 i2c detect working

stable
Penguin 3 years ago
parent 0c6e7e3c0e
commit f2d3aa5fb2

@ -1,4 +1,6 @@
#include "p_i2c.h"
#include "hal_i2c_m_sync.h"
#include "p_usart.h"
void p_i2c_init(void)
@ -9,11 +11,38 @@ void p_i2c_init(void)
int p_i2c_write(const uint8_t* const data, uint16_t data_len)
{
io_write(&I2C_0.io, data, data_len);
return 0;
return io_write(&I2C_0.io, data, data_len);
}
int p_i2c_read(uint8_t* data, uint16_t len)
{
return 0;
return io_read(&I2C_0.io, data, len);
}
void p_i2c_scan(void)
{
PDEBUG(" ");
for(int ind = 0; ind < 16; ind++)
{
PDEBUG(" %02x", ind);
}
uint8_t data = 0x00;
for(int ind = 0; ind <= 119; ind++)
{
if (ind % 16 == 0)
{
PDEBUG("\r\n%02x:", ind & 0xF0);
}
i2c_m_sync_set_slaveaddr(&I2C_0, ind, I2C_M_SEVEN);
int ret = p_i2c_write(&data, 1);
if(ret != 1)
{
PDEBUG(" --");
}
else
{
PDEBUG(" %02x", ind);
}
}
PDEBUG("\r\n");
}

@ -11,4 +11,6 @@ void p_i2c_init(void);
int p_i2c_write(const uint8_t* const data, uint16_t data_len);
int p_i2c_read(uint8_t* data, uint16_t len);
void p_i2c_scan(void);
#endif

@ -12,7 +12,6 @@
void p_usart_init(void)
{
usart_sync_enable(&USART_0);
PDEBUG("Hello world\n");
}

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,7 +1,8 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
GDB=arm-none-eabi-gdb
SIZE=arm-none-eabi-size
ifdef SystemRoot
SHELL = cmd.exe
MK_DIR = mkdir
@ -262,3 +263,15 @@ clean:
rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \
$(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \
$(OUTPUT_FILE_NAME).srec
push:\
all
@echo $(QUOTE)$(QUOTE)
@echo $(QUOTE)Uploading $(OUTPUT_FILE_NAME).elf...$(QUOTE)
@$(GDB) $(OUTPUT_FILE_NAME).elf -x $(QUOTE)hw_interfacing_scripts/gdb/generic_push.gdb$(QUOTE) >/dev/null
@echo $(QUOTE)$(QUOTE)$(OUTPUT_FILE_NAME).elf $(QUOTE) uploaded!$(QUOTE)
@$(QUOTE)$(SIZE)$(QUOTE) $(QUOTE)$(OUTPUT_FILE_NAME).elf$(QUOTE)
debug:\
all
@$(GDB) $(OUTPUT_FILE_NAME).elf -x $(QUOTE)hw_interfacing_scripts/gdb/generic_debug.gdb$(QUOTE)

File diff suppressed because it is too large Load Diff

@ -86,7 +86,8 @@ drivers/p_i2c.d drivers/p_i2c.o: ../drivers/p_i2c.c ../drivers/p_i2c.h \
../hal/include/hal_io.h ../hal/include/hal_sleep.h \
../hal/include/hal_usart_sync.h ../hal/include/hal_io.h \
../hal/include/hpl_usart_sync.h ../hal/include/hpl_usart.h \
../hal/include/hal_i2c_m_sync.h ../hal/include/hpl_i2c_m_sync.h
../hal/include/hal_i2c_m_sync.h ../hal/include/hpl_i2c_m_sync.h \
../drivers/p_usart.h
../drivers/p_i2c.h:
../driver_init.h:
../atmel_start_pins.h:
@ -269,3 +270,4 @@ drivers/p_i2c.d drivers/p_i2c.o: ../drivers/p_i2c.c ../drivers/p_i2c.h \
../hal/include/hpl_usart.h:
../hal/include/hal_i2c_m_sync.h:
../hal/include/hpl_i2c_m_sync.h:
../drivers/p_usart.h:

Binary file not shown.

Binary file not shown.

@ -0,0 +1 @@
/home/penguin/Projects/hw_interfacing_scripts

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
/home/penguin/Projects/hw_interfacing_scripts

Binary file not shown.

@ -13,7 +13,14 @@ int main(void)
/* Initializes MCU, drivers and middleware */
atmel_start_init();
project_init();
PDEBUG("Hi there\n");
PDEBUG("--- I2C Detect ----\r\n\r\n");
// clear line
PDEBUG("%c[2K", 27);
// reset cursor pos
PDEBUG("%c[u", 27);
// moves cursor one down
PDEBUG("%c[1B", 27);
p_i2c_scan();
/* Replace with your application code */
while (1) {

Loading…
Cancel
Save