/*
 * pow.c
 *
 *  Created on: 02-06-2016
 *      Author: Krzysztof Jakubczyk
 */

#include "tdefs.h"
#include "misc.h"

#include "pow.h"

int pow_initlog(void *arguments, void *logic)
{
	struct pow_args *args = (struct pow_args *)arguments;
	struct pow_logic *log = (struct pow_logic *)logic;

	log->out_ptr = (float *)(log_manager.nets_data + (args->io.out_float_out >> 3));

	if((u8 *)log->out_ptr > (log_manager.nets_data+sizeof(log_manager.nets_data)-sizeof(float)))
		return -1;

	log->in_ptr = (float *)(log_manager.nets_data + (args->io.in_float_in >> 3));
	if((u8*)log->in_ptr > (log_manager.nets_data+sizeof(log_manager.nets_data)-sizeof(float)))
		return -1;

	return 0;
}

void pow_1(void *arguments, void *logic)
{
	struct pow_args *args = (struct pow_args *)arguments;
	struct pow_logic *log = (struct pow_logic *)logic;

	if(args->io.out_float_out)
	{
			*log->out_ptr=*log->in_ptr * *log->in_ptr;
	}
}
