21#ifndef _CURRENT_SOURCE_AC_H_
22#define _CURRENT_SOURCE_AC_H_
38static bool current_source_ac_init(uint32_t n_ac_sources, uint32_t *next) {
39 ac_source = spin1_malloc(n_ac_sources *
sizeof(uint32_t*));
40 for (uint32_t n_ac=0; n_ac < n_ac_sources; n_ac++) {
41 ac_source[n_ac] = spin1_malloc(
sizeof(
ac_source_t));
42 if (ac_source[n_ac] == NULL) {
43 log_error(
"Unable to allocate DC source parameters - out of DTCM");
51static bool current_source_ac_load_parameters(
52 address_t cs_address, uint32_t n_ac_sources, uint32_t *next) {
53 for (uint32_t n_ac=0; n_ac < n_ac_sources; n_ac++) {
60static REAL current_source_ac_get_offset(uint32_t cs_index, uint32_t time) {
61 if ((time >= ac_source[cs_index]->start) && (time < ac_source[cs_index]->stop)) {
62 REAL time_value = kbits((time - ac_source[cs_index]->start) << 15);
63 REAL sin_value =
sink((time_value * ac_source[cs_index]->frequency) +
64 ac_source[cs_index]->phase);
65 REAL ac_current_offset = ac_source[cs_index]->offset + (
66 ac_source[cs_index]->amplitude * sin_value);
67 return ac_current_offset;
void log_error(const char *message,...)
accum REAL
Type used for "real" numbers.
void spin1_memcpy(void *dst, void const *src, uint len)