OpenCores
URL https://opencores.org/ocsvn/neo430/neo430/trunk

Subversion Repositories neo430

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /neo430
    from Rev 160 to Rev 161
    Reverse comparison

Rev 160 → Rev 161

/trunk/rtl/core/neo430_bootloader_image.vhd
902,9 → 902,9
000891 => x"2072",
000892 => x"3256",
000893 => x"3130",
000894 => x"3138",
000894 => x"3039",
000895 => x"3131",
000896 => x"2037",
000896 => x"2038",
000897 => x"7962",
000898 => x"5320",
000899 => x"6574",
/trunk/sw/bootloader/bootloader.c
29,7 → 29,7
// # You should have received a copy of the GNU Lesser General Public License along with this #
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Stephan Nolting, Hannover, Germany 17.11.2018 #
// # Stephan Nolting, Hannover, Germany 18.01.2019 #
// #################################################################################################
 
// Libraries
127,8 → 127,7
 
// set SPI config:
// enable SPI, no IRQs, SPI clock mode 0, 1/1024 SPI speed, disable all 6 SPI CS lines (set high)
SPI_CT = 0; // reset SPI
SPI_CT = (1<<SPI_CT_EN) | (SPI_PRSC_1024<<SPI_CT_PRSC0);
neo430_spi_enable(SPI_PRSC_1024); // this also resets the SPI module
neo430_spi_trans(0); // clear SPI RTX buffer
 
// Timeout counter: init timer, irq tick @ ~1Hz (prescaler = 4096)
148,7 → 147,7
// ****************************************************************
// Show bootloader intro and system information
// ****************************************************************
neo430_uart_br_print("\n\nNEO430 Bootloader V20181117 by Stephan Nolting\n\n"
neo430_uart_br_print("\n\nNEO430 Bootloader V20190118 by Stephan Nolting\n\n"
"HWV: 0x");
neo430_uart_print_hex_word(HW_VERSION);
neo430_uart_br_print("\nCLK: 0x");
483,7 → 482,7
c1 = eeprom_read(a+1);
}
 
return __neo430_combine_bytes(c0, c1);
return neo430_combine_bytes(c0, c1);
}
 
 
/trunk/sw/example/game_of_life/main.c
61,14 → 61,14
clear_universe(0);
clear_universe(1);
 
_neo430_printf("\n\n### Conways's Game of Life ###\n\n");
_neo430_printf("This program requires a terminal resolution of at least %ux%u characters.\n", NUM_CELLS_X+2, NUM_CELLS_Y+3);
_neo430_printf("Press any key to start a random-initialized torus-style universe of %ux%u cells.\n", NUM_CELLS_X, NUM_CELLS_Y);
_neo430_printf("You can pause/restart the simulation by pressing any key.\n");
neo430_printf("\n\n### Conways's Game of Life ###\n\n");
neo430_printf("This program requires a terminal resolution of at least %ux%u characters.\n", NUM_CELLS_X+2, NUM_CELLS_Y+3);
neo430_printf("Press any key to start a random-initialized torus-style universe of %ux%u cells.\n", NUM_CELLS_X, NUM_CELLS_Y);
neo430_printf("You can pause/restart the simulation by pressing any key.\n");
 
// randomize until key pressed
while (neo430_uart_char_received() == 0) {
__neo430_xorshift32();
neo430_xorshift32();
}
 
 
75,7 → 75,7
// initialize universe using random data
for (x=0; x<NUM_CELLS_X/8; x++) {
for (y=0; y<NUM_CELLS_Y; y++) {
universe[0][x][y] = (uint8_t)__neo430_xorshift32();
universe[0][x][y] = (uint8_t)neo430_xorshift32();
}
}
 
83,7 → 83,7
 
// user abort?
if (neo430_uart_char_received()) {
_neo430_printf("\nRestart (y/n)?");
neo430_printf("\nRestart (y/n)?");
if (neo430_uart_getc() == 'y') {
neo430_soft_reset();
}
90,7 → 90,7
}
 
// print generation, population count and the current universe
_neo430_printf("\n\nGeneration %l, %u living cells\n", generation, pop_count(u));
neo430_printf("\n\nGeneration %l, %u living cells\n", generation, pop_count(u));
print_universe(u);
 
// compute next generation
/trunk/sw/example/hw_analysis/main.c
46,25 → 46,25
neo430_uart_setup(BAUD_RATE);
 
// intro text
_neo430_printf("\nNEO430 Hardware Analysis Tool\n\n");
neo430_printf("\nNEO430 Hardware Analysis Tool\n\n");
 
// General information
// --------------------------------------------
// HW version
_neo430_printf("Hardware version: 0x%x\n", HW_VERSION);
neo430_printf("Hardware version: 0x%x\n", HW_VERSION);
 
// HW user code
_neo430_printf("User code: 0x%x\n", USER_CODE);
neo430_printf("User code: 0x%x\n", USER_CODE);
// Clock speed
uint32_t clock = CLOCKSPEED_32bit;
_neo430_printf("Clock speed: %n Hz\n", clock);
neo430_printf("Clock speed: %n Hz\n", clock);
 
// ROM/IMEM
_neo430_printf("IMEM/ROM: %u bytes @ 0x0000\n", IMEM_SIZE);
neo430_printf("IMEM/ROM: %u bytes @ 0x0000\n", IMEM_SIZE);
 
// RAM/DMEM
_neo430_printf("DMEM/RAM: %u bytes @ 0x%x\n", DMEM_SIZE, DMEM_BASE);
neo430_printf("DMEM/RAM: %u bytes @ 0x%x\n", DMEM_SIZE, DMEM_BASE);
 
// UART baud rate
uint16_t baud = UART_CT & 0x00FF;
81,64 → 81,64
default: prsc = 0; break;
}
uint32_t baud_value = clock / (uint32_t)(prsc * baud);
_neo430_printf("UART Baud rate: %n\n", baud_value);
neo430_printf("UART Baud rate: %n\n", baud_value);
 
 
// System features
// --------------------------------------------
uint16_t ft = SYS_FEATURES;
_neo430_printf("\n\nSystem features\n");
neo430_printf("\n\nSystem features\n");
// CFU
_neo430_printf("- Multiplier/Divider: ");
neo430_printf("- Multiplier/Divider: ");
print_state(ft & (1<<SYS_MULDIV_EN));
// WB32
_neo430_printf("- Wishbone adapter: ");
neo430_printf("- Wishbone adapter: ");
print_state(ft & (1<<SYS_WB32_EN));
// WDT
_neo430_printf("- Watchdog timer: ");
neo430_printf("- Watchdog timer: ");
print_state(ft & (1<<SYS_WDT_EN));
// GPIO
_neo430_printf("- GPIO unit: ");
neo430_printf("- GPIO unit: ");
print_state(ft & (1<<SYS_GPIO_EN));
// TIMER
_neo430_printf("- High-precision timer: ");
neo430_printf("- High-precision timer: ");
print_state(ft & (1<<SYS_TIMER_EN));
// UART
_neo430_printf("- UART: ");
neo430_printf("- UART: ");
print_state(ft & (1<<SYS_UART_EN));
// SPI
_neo430_printf("- SPI: ");
neo430_printf("- SPI: ");
print_state(ft & (1<<SYS_SPI_EN));
// DADD
_neo430_printf("- DADD instruction: ");
neo430_printf("- DADD instruction: ");
print_state(ft & (1<<SYS_DADD_EN));
// Bootloader installed
_neo430_printf("- Internal bootloader: ");
neo430_printf("- Internal bootloader: ");
print_state(ft & (1<<SYS_BTLD_EN));
// is IMEM true ROM?
_neo430_printf("- IMEM as true ROM: ");
neo430_printf("- IMEM as true ROM: ");
print_state(ft & (1<<SYS_IROM_EN));
// CRC
_neo430_printf("- CRC16/CRC32: ");
neo430_printf("- CRC16/CRC32: ");
print_state(ft & (1<<SYS_CRC_EN));
// CFU
_neo430_printf("- Custom Functions Unit: ");
neo430_printf("- Custom Functions Unit: ");
print_state(ft & (1<<SYS_CFU_EN));
// PWM
_neo430_printf("- PWM Controller: ");
neo430_printf("- PWM Controller: ");
print_state(ft & (1<<SYS_PWM_EN));
// TWI
_neo430_printf("- Two Wire Interface: ");
neo430_printf("- Two Wire Interface: ");
print_state(ft & (1<<SYS_TWI_EN));
 
 
// Exit
// --------------------------------------------
_neo430_printf("\n\nPress any key to return to bootloader.\n");
neo430_printf("\n\nPress any key to return to bootloader.\n");
while(!neo430_uart_char_received());
 
if (!(SYS_FEATURES & (1<<SYS_BTLD_EN)))
_neo430_printf("No bootloader installed!\n");
neo430_printf("No bootloader installed!\n");
else
asm volatile ("mov #0xF000, r0");
 
152,7 → 152,7
void print_state(uint16_t d) {
 
if (d)
_neo430_printf("enabled\n");
neo430_printf("enabled\n");
else
_neo430_printf("DISABLED\n");
neo430_printf("DISABLED\n");
}
/trunk/sw/example/muldiv_test/main.c
38,7 → 38,7
// setup UART
neo430_uart_setup(BAUD_RATE);
 
_neo430_printf("Multiplier/Divider Test\n\n");
neo430_printf("Multiplier/Divider Test\n\n");
 
// check if multiplier/divider unit was synthesized, exit if not
if (!(SYS_FEATURES & (1<<SYS_MULDIV_EN))) {
54,13 → 54,13
for (i=0; i<0xFFFF; i++) {
 
// get "random" operands
a = (uint16_t)__neo430_xorshift32();
b = (uint16_t)__neo430_xorshift32();
a = (uint16_t)neo430_xorshift32();
b = (uint16_t)neo430_xorshift32();
 
// multiply test
prod_ref = (uint32_t)a * (uint32_t)b;
prod = neo430_umul32(a, b);
_neo430_printf("UNSIGNED %u: %u * %u = %n vs ref. %n\n", i, a, b, prod, prod_ref);
neo430_printf("UNSIGNED %u: %u * %u = %n vs ref. %n\n", i, a, b, prod, prod_ref);
 
// division test
if (b == 0) // dont divide by zero
68,12 → 68,12
quot_ref = a / b;
rem_ref = a % b;
quot = neo430_umoddiv16(&rem, a, b);
_neo430_printf("UNSIGNED %u: %u / %u = %u & %u vs ref. %u & %u\n", i, a, b, quot, rem, quot_ref, rem_ref);
neo430_printf("UNSIGNED %u: %u / %u = %u & %u vs ref. %u & %u\n", i, a, b, quot, rem, quot_ref, rem_ref);
 
 
// get "random" operands
sa = (int16_t)__neo430_xorshift32();
sb = (int16_t)__neo430_xorshift32();
sa = (int16_t)neo430_xorshift32();
sb = (int16_t)neo430_xorshift32();
 
// division test - signed
if (sb == 0) // dont divide by zero
81,22 → 81,22
squot_ref = sa / sb;
srem_ref = sa % sb;
squot = neo430_moddiv16(&srem, sa, sb);
_neo430_printf("SIGNED %u: %i / %i = %i & %i vs ref. %i & %i\n", i, sa, sb, squot, srem, squot_ref, srem_ref);
neo430_printf("SIGNED %u: %i / %i = %i & %i vs ref. %i & %i\n", i, sa, sb, squot, srem, squot_ref, srem_ref);
 
// multiply test - signed
sprod_ref = (int32_t)sa * (int32_t)sb;
sprod = neo430_mul32(sa, sb);
_neo430_printf("SIGNED %u: %i * %i = %l vs ref. %l\n", i, sa, sb, sprod, sprod_ref);
neo430_printf("SIGNED %u: %i * %i = %l vs ref. %l\n", i, sa, sb, sprod, sprod_ref);
 
 
// all correct?
if ((rem != rem_ref) || (quot != quot_ref) || (prod != prod_ref) || (srem != srem_ref) || (squot != squot_ref) || (sprod != sprod_ref)) {
_neo430_printf("ERROR in one or more of the four previous operations!");
neo430_printf("ERROR in one or more of the four previous operations!");
while(1);
}
}
 
_neo430_printf("Tests passed!\n");
neo430_printf("Tests passed!\n");
while(1);
 
return 0;
/trunk/sw/example/prime_numbers/main.c
43,8 → 43,8
neo430_uart_setup(BAUD_RATE);
 
// intro text
_neo430_printf("\n\nGenerating prime numbers between 3 and %n", 0xFFFFFFFF);
_neo430_printf(".\n"
neo430_printf("\n\nGenerating prime numbers between 3 and %n", 0xFFFFFFFF);
neo430_printf(".\n"
"Press any key to start.\n"
"You can abort the program by pressing any key again.\n");
 
68,7 → 68,7
 
// output prime number in decimal representation
if (is_prime)
_neo430_printf("%n, ", n);
neo430_printf("%n, ", n);
 
// abort?
if (neo430_uart_char_received()) // any key input?
/trunk/sw/example/profiling_template/main.c
58,7 → 58,7
neo430_uart_setup(BAUD_RATE);
 
// intro text
_neo430_printf("\r\nProfiling template\r\n");
neo430_printf("\r\nProfiling template\r\n");
 
// check if TIMER unit was synthesized, exit if no TIMER is available
if (!(SYS_FEATURES & (1<<SYS_TIMER_EN))) {
66,7 → 66,7
return 1;
}
 
_neo430_printf("Starting profiling...\r\n");
neo430_printf("Starting profiling...\r\n");
 
// start runtime profiling
start_profiling(TIMER_PRSC);
87,13 → 87,13
// stop runtime profiling
uint32_t runtime = 0;
if (stop_profiling(&runtime, TIMER_PRSC) != 0) { // use SAME prescaler as in "start_time"
_neo430_printf("Timer overflow! Use a greater prescaler!\r\n\r\n");
neo430_printf("Timer overflow! Use a greater prescaler!\r\n\r\n");
}
 
 
// print results
_neo430_printf("Elapsed CPU cycles: %n\r\n", runtime);
_neo430_printf("Re-run the measurement with a smaller prescaler to increase precision.\r\n");
neo430_printf("Elapsed CPU cycles: %n\r\n", runtime);
neo430_printf("Re-run the measurement with a smaller prescaler to increase precision.\r\n");
 
return 0;
}
/trunk/sw/example/twi_test/main.c
19,7 → 19,7
// # You should have received a copy of the GNU Lesser General Public License along with this #
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Stephan Nolting, Hannover, Germany 17.11.2018 #
// # Stephan Nolting, Hannover, Germany 07.12.2018 #
// #################################################################################################
 
 
30,6 → 30,7
 
// Prototypes
void scan_twi(void);
void set_speed(void);
void send_twi(void);
 
// Configuration
81,6 → 82,7
" start - generate START condition\n"
" stop - generate STOP condition\n"
" send - write/read single byte to/from bus\n"
" speed - select bus clock\n"
" reset - perform soft-reset\n"
" exit - exit program and return to bootloader\n");
}
93,6 → 95,9
else if (!strcmp(buffer, "scan")) {
scan_twi();
}
else if (!strcmp(buffer, "speed")) {
set_speed();
}
else if (!strcmp(buffer, "send")) {
send_twi();
}
117,6 → 122,26
 
 
/* ------------------------------------------------------------
* INFO Set TWI speed
* ------------------------------------------------------------ */
void set_speed(void) {
 
char terminal_buffer[2];
 
neo430_uart_br_print("Select new clock prescaler (0..7): ");
neo430_uart_scan(terminal_buffer, 2, 1); // 1 hex char plus '\0'
uint8_t prsc = (uint8_t)neo430_hexstr_to_uint(terminal_buffer, strlen(terminal_buffer));
if ((prsc >= 0) && (prsc < 8)) { // valid?
TWI_CT = 0; // reset
TWI_CT = (1 << TWI_CT_ENABLE) | (prsc << TWI_CT_PRSC0);
neo430_uart_br_print("\nDone.\n");
}
else
neo430_uart_br_print("\nInvalid selection!\n");
}
 
 
/* ------------------------------------------------------------
* INFO Scan 7-bit TWI address space
* ------------------------------------------------------------ */
void scan_twi(void) {
128,7 → 153,7
neo430_twi_stop_trans();
 
if (twi_ack == 0) {
neo430_uart_br_print(" Found device at address (shifted left by 1 bit): 0x");
neo430_uart_br_print(" * Found device at address (shifted left by 1 bit): 0x");
neo430_uart_print_hex_byte(2*i);
neo430_uart_br_print("\n");
num_devices++;
149,7 → 174,7
char terminal_buffer[4];
 
// enter data
neo430_uart_br_print("Enterdata (2 hex chars): ");
neo430_uart_br_print("Enter TX data (2 hex chars): ");
neo430_uart_scan(terminal_buffer, 3, 1); // 2 hex chars for address plus '\0'
uint8_t tmp = (uint8_t)neo430_hexstr_to_uint(terminal_buffer, strlen(terminal_buffer));
uint8_t res = neo430_twi_trans(tmp);
/trunk/sw/lib/neo430/neo430_cpu.h
19,7 → 19,7
// # You should have received a copy of the GNU Lesser General Public License along with this #
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Stephan Nolting, Hannover, Germany 04.07.2018 #
// # Stephan Nolting, Hannover, Germany 18.01.2019 #
// #################################################################################################
 
#ifndef neo430_cpu_h
38,14 → 38,14
inline void neo430_soft_reset(void);
inline void neo430_jump_address(uint16_t addr);
inline void neo430_call_address(uint16_t addr);
inline uint16_t __neo430_bswap(uint16_t a);
inline uint16_t __neo430_combine_bytes(uint8_t hi, uint8_t lo);
inline uint16_t __neo430_dadd(uint16_t a, uint16_t b);
void __neo430_memset(uint8_t *dst, uint8_t data, uint16_t num);
uint8_t __neo430_memcmp(uint8_t *dst, uint8_t *src, uint16_t num);
void __neo430_memcpy(uint8_t *dst, uint8_t *src, uint16_t num);
uint16_t __neo430_bit_rev16(uint16_t x);
uint32_t __neo430_xorshift32(void);
inline uint16_t neo430_bswap(uint16_t a);
inline uint16_t neo430_combine_bytes(uint8_t hi, uint8_t lo);
inline uint16_t neo430_dadd(uint16_t a, uint16_t b);
void neo430_memset(uint8_t *dst, uint8_t data, uint16_t num);
uint8_t neo430_memcmp(uint8_t *dst, uint8_t *src, uint16_t num);
void neo430_memcpy(uint8_t *dst, uint8_t *src, uint16_t num);
uint16_t neo430_bit_rev16(uint16_t x);
uint32_t neo430_xorshift32(void);
 
 
/* ------------------------------------------------------------
189,7 → 189,7
* PARAM 16-bit input word
* RETURN 16-bit word with swapped bytes
* ------------------------------------------------------------ */
inline uint16_t __neo430_bswap(uint16_t a) {
inline uint16_t neo430_bswap(uint16_t a) {
 
register uint16_t r = a;
asm volatile ("swpb %0, %1" : "=r" (r) : "r" (r));
203,9 → 203,9
* PARAM lo will be put in result's low byte
* RETURN 16-bit combined word
* ------------------------------------------------------------ */
inline uint16_t __neo430_combine_bytes(uint8_t hi, uint8_t lo) {
inline uint16_t neo430_combine_bytes(uint8_t hi, uint8_t lo) {
 
register uint16_t r = __neo430_bswap((uint16_t)hi);
register uint16_t r = neo430_bswap((uint16_t)hi);
return r | (uint16_t)lo;
}
 
216,7 → 216,7
* PARAM 2x 16-bit BCD operands (4 digits)
* RETURN 16-bit BCD result (4 digits)
* ------------------------------------------------------------ */
inline uint16_t __neo430_dadd(uint16_t a, uint16_t b) {
inline uint16_t neo430_dadd(uint16_t a, uint16_t b) {
 
register uint16_t z = a;
asm volatile ("clrc");
231,7 → 231,7
* PARAM data: Init data
* PARAM num: Number of bytes to initialize
* ------------------------------------------------------------ */
void __neo430_memset(uint8_t *dst, uint8_t data, uint16_t num) {
void neo430_memset(uint8_t *dst, uint8_t data, uint16_t num) {
 
while (num--)
*dst++ = data;
245,7 → 245,7
* PARAM num: Number of bytes to compare
* RETURN 0 if src == dst
* ------------------------------------------------------------ */
uint8_t __neo430_memcmp(uint8_t *dst, uint8_t *src, uint16_t num) {
uint8_t neo430_memcmp(uint8_t *dst, uint8_t *src, uint16_t num) {
 
while (num--) {
if (*dst++ != *src++)
261,7 → 261,7
* PARAM src: Pointer to beginning source memory space
* PARAM num: Number of bytes to copy
* ------------------------------------------------------------ */
void __neo430_memcpy(uint8_t *dst, uint8_t *src, uint16_t num) {
void neo430_memcpy(uint8_t *dst, uint8_t *src, uint16_t num) {
 
while (num--)
*dst++ = *src++;
273,7 → 273,7
* PARAM input operand to be reversed
* RETURN reversed bit pattern
* ------------------------------------------------------------ */
uint16_t __neo430_bit_rev16(uint16_t x) {
uint16_t neo430_bit_rev16(uint16_t x) {
 
register uint16_t z = x;
register uint16_t y = 0;
294,7 → 294,7
* INFO Pseudo-random number generator
* RETURN 32-bit random data
* ------------------------------------------------------------ */
uint32_t __neo430_xorshift32(void) {
uint32_t neo430_xorshift32(void) {
 
static uint32_t x32 = 314159265;
 
/trunk/sw/lib/neo430/neo430_crc.h
19,7 → 19,7
// # You should have received a copy of the GNU Lesser General Public License along with this #
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Stephan Nolting, Hannover, Germany 04.07.2018 #
// # Stephan Nolting, Hannover, Germany 04.07.2018 #
// #################################################################################################
 
#ifndef neo430_crc_h
/trunk/sw/lib/neo430/neo430_pwm.h
19,7 → 19,7
// # You should have received a copy of the GNU Lesser General Public License along with this #
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Stephan Nolting, Hannover, Germany 04.07.2018 #
// # Stephan Nolting, Hannover, Germany 18.01.2019 #
// #################################################################################################
 
#ifndef neo430_pwm_h
26,28 → 26,30
#define neo430_pwm_h
 
// prototypes
inline void neo430_pwm_enable_slow_mode(void);
inline void neo430_pwm_enable_fast_mode(void);
inline void neo430_pwm_disable(void);
inline void neo430_pwm_set_ch0(uint8_t dc);
inline void neo430_pwm_set_ch1(uint8_t dc);
inline void neo430_pwm_set_ch2(uint8_t dc);
void neo430_pwm_enable_slow_mode(void);
void neo430_pwm_enable_fast_mode(void);
void neo430_pwm_disable(void);
void neo430_pwm_set_ch0(uint8_t dc);
void neo430_pwm_set_ch1(uint8_t dc);
void neo430_pwm_set_ch2(uint8_t dc);
 
 
/* ------------------------------------------------------------
* INFO Activate PWM controller in slow mode
* INFO Reset and activate PWM controller in slow mode
* ------------------------------------------------------------ */
inline void neo430_pwm_enable_slow_mode(void) {
void neo430_pwm_enable_slow_mode(void) {
 
PWM_CT = 0;
PWM_CT = (1<<PWM_CT_ENABLE) | (0<<PWM_CT_FMODE);
}
 
 
/* ------------------------------------------------------------
* INFO Activate PWM controller in fast mode
* INFO Reset and activate PWM controller in fast mode
* ------------------------------------------------------------ */
inline void neo430_pwm_enable_fast_mode(void) {
void neo430_pwm_enable_fast_mode(void) {
 
PWM_CT = 0;
PWM_CT = (1<<PWM_CT_ENABLE) | (1<<PWM_CT_FMODE);
}
 
55,7 → 57,7
/* ------------------------------------------------------------
* INFO Disable PWM controller
* ------------------------------------------------------------ */
inline void neo430_pwm_disable(void) {
void neo430_pwm_disable(void) {
 
PWM_CT = 0;
}
65,7 → 67,7
* INFO Set duty cycle of PWM channel 0
* PARAM 8-bit duty cycle
* ------------------------------------------------------------ */
inline void neo430_pwm_set_ch0(uint8_t dc) {
void neo430_pwm_set_ch0(uint8_t dc) {
 
PWM_CH0 = (uint16_t)dc;
}
75,7 → 77,7
* INFO Set duty cycle of PWM channel 1
* PARAM 8-bit duty cycle
* ------------------------------------------------------------ */
inline void neo430_pwm_set_ch1(uint8_t dc) {
void neo430_pwm_set_ch1(uint8_t dc) {
 
PWM_CH1 = (uint16_t)dc;
}
85,7 → 87,7
* INFO Set duty cycle of PWM channel 2
* PARAM 8-bit duty cycle
* ------------------------------------------------------------ */
inline void neo430_pwm_set_ch2(uint8_t dc) {
void neo430_pwm_set_ch2(uint8_t dc) {
 
PWM_CH2 = (uint16_t)dc;
}
/trunk/sw/lib/neo430/neo430_spi.h
19,7 → 19,7
// # You should have received a copy of the GNU Lesser General Public License along with this #
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Stephan Nolting, Hannover, Germany 19.11.2018 #
// # Stephan Nolting, Hannover, Germany 19.01.2019 #
// #################################################################################################
 
#ifndef neo430_spi_h
26,8 → 26,8
#define neo430_spi_h
 
// prototypes
void neo430_spi_enable(void); // configure and activate TWI module
void neo430_spi_disable(void); // deactivate TWI module
void neo430_spi_enable(uint8_t prsc); // configure and activate SPI module
void neo430_spi_disable(void); // deactivate SPI module
void neo430_spi_cs_en(uint8_t cs); // activate slave
void neo430_spi_cs_dis(uint8_t cs); // deactivate slave
uint8_t neo430_spi_trans(uint8_t d); // RTX transfer
34,16 → 34,27
 
 
/* ------------------------------------------------------------
* INFO Enable SPI CSx (set low)
* INFO Reset, activate, configure and enable SPI module
* INFO SPI SCK speed: f_main/(2*PRSC), prsc = see below (control reg)
* SPI clock prescaler select:
* 0: CLK/2
* 1: CLK/4
* 2: CLK/8
* 3: CLK/64
* 4: CLK/128
* 5: CLK/1024
* 6: CLK/2048
* 7: CLK/4096
* ------------------------------------------------------------ */
void neo430_spi_enable(void) {
void neo430_spi_enable(uint8_t prsc) {
 
SPI_CT = (1 << SPI_CT_EN);
SPI_CT = 0;
SPI_CT = (1 << SPI_CT_EN) | (prsc<<SPI_CT_PRSC0);;
}
 
 
/* ------------------------------------------------------------
* INFO Enable SPI CSx (set low)
* INFO Enable SPI module
* ------------------------------------------------------------ */
void neo430_spi_disable(void) {
 
76,16 → 87,6
 
/* ------------------------------------------------------------
* INFO SPI RTX byte transfer
* INFO SPI SCK speed: f_main/(2*PRSC), PRSC = see below (control reg)
* SPI clock prescaler select:
* 0: CLK/2
* 1: CLK/4
* 2: CLK/8
* 3: CLK/64
* 4: CLK/128
* 5: CLK/1024
* 6: CLK/2048
* 7: CLK/4096
* PARAM d byte to be send
* RETURN received byte
* ------------------------------------------------------------ */
/trunk/sw/lib/neo430/neo430_uart.h
19,7 → 19,7
// # You should have received a copy of the GNU Lesser General Public License along with this #
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Stephan Nolting, Hannover, Germany 17.11.2018 #
// # Stephan Nolting, Hannover, Germany 18.01.2019 #
// #################################################################################################
 
#ifndef neo430_uart_h
44,13 → 44,13
void neo430_uart_print_bin_byte(uint8_t b); // print byte in binary form
void neo430_uart_print_bin_word(uint16_t w); // print word in binary form
void neo430_uart_print_bin_dword(uint32_t dw); // print double word in binary form
void _neo430_itoa(uint32_t x); // convert double word to decimal number
void _neo430_printf(char *format, ...); // print format string
void neo430_itoa(uint32_t x); // convert double word to decimal number
void neo430_printf(char *format, ...); // print format string
uint32_t neo430_hexstr_to_uint(char *buffer, uint8_t length); // convert hex string to number
 
 
/* ------------------------------------------------------------
* INFO Set the Baud rate of UART transceiver
* INFO Reset UART, set the Baud rate of UART transceiver
* INFO UART_BAUD reg (8 bit) = f_main/(prsc*desired_BAUDRATE)
* INFO PRSC (Baud register bits 10..8):
* 0: CLK/2
297,7 → 297,7
* INFO Slow custom version of itoa
* PARAM 32-bit value to be printed as decimal number
* ------------------------------------------------------------ */
void _neo430_itoa(uint32_t x) {
void neo430_itoa(uint32_t x) {
 
static const char numbers[10] = "0123456789";
char buffer1[11], buffer2[11];
340,7 → 340,7
* INFO Original from http://forum.43oh.com/topic/1289-tiny-printf-c-version/
* PARAM Argument string
* ------------------------------------------------------------ */
void _neo430_printf(char *format, ...) {
void neo430_printf(char *format, ...) {
 
char c;
int16_t i;
365,10 → 365,10
i = -i;
neo430_uart_putc('-');
}
_neo430_itoa((uint32_t)i);
neo430_itoa((uint32_t)i);
break;
case 'u': // 16-bit unsigned
_neo430_itoa((uint32_t)va_arg(a, unsigned int));
neo430_itoa((uint32_t)va_arg(a, unsigned int));
break;
case 'l': // 32-bit long
n = va_arg(a, int32_t);
376,10 → 376,10
n = -n;
neo430_uart_putc('-');
}
_neo430_itoa((uint32_t)n);
neo430_itoa((uint32_t)n);
break;
case 'n': // 32-bit unsigned long
_neo430_itoa(va_arg(a, uint32_t));
neo430_itoa(va_arg(a, uint32_t));
break;
case 'x': // 16-bit hexadecimal
neo430_uart_print_hex_word(va_arg(a, unsigned int));
/trunk/sw/lib/neo430/neo430_wishbone.h
24,7 → 24,7
// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html #
// # ********************************************************************************************* #
// # Thanks to Edward Sherriff! #
// # Stephan Nolting, Hannover, Germany 29.09.2018 #
// # Stephan Nolting, Hannover, Germany 18.01.2019 #
// #################################################################################################
 
#ifndef neo430_wishbone_h
217,7 → 217,7
data = WB32_LD;
 
if (a & 1)
data = __neo430_bswap(data);
data = neo430_bswap(data);
 
return (uint8_t)data;
}
401,7 → 401,7
data = WB32_LD;
 
if (a & 1)
data = __neo430_bswap(data);
data = neo430_bswap(data);
 
return (uint8_t)data;
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.